ความปลอดภัยTestCase

public class SecurityTestCase
extends StsExtraBusinessLogicHostTestBase

java.lang.Object
com.android.tradefed.testtype.junit4.BaseHostJUnit4Test
com.android.compatibility.common.tradefed.testtype.BusinessLogicHostTestBase
com.android.compatibility.common.tradefed.testtype.ExtraBusinessLogicHostTestBase
com.android.sts.common.tradefed.testtype.StsExtraBusinessLogicHostTestBase
com.android.sts.common.tradefed.testtype.SecurityTestCase


คลาสการทดสอบพื้นฐานสำหรับการทดสอบ STS ทั้งหมด

ใช้ RootSecurityTestCase หรือ NonRootSecurityTestCase แทน

สรุป

ค่าคงที่

int TIMEOUT_DEFAULT

int TIMEOUT_NONDETERMINISTIC

เขตข้อมูล

public PocPusher pocPusher

public TestName testName

ผู้รับเหมาก่อสร้างสาธารณะ

SecurityTestCase ()

วิธีการสาธารณะ

void assertMatches (String pattern, String input)
void assertMatchesMultiLine (String pattern, String input)
void assertNotKernelPointer (Callable<String> getPtrFunction, ITestDevice deviceToReboot)

รันฟังก์ชันที่จัดเตรียมไว้ซึ่งรวบรวมสตริงเพื่อทดสอบการรั่วไหลของเคอร์เนลพอยน์เตอร์

void assertNotMatches (String pattern, String input)
void assertNotMatchesMultiLine (String pattern, String input)
void assertWifiConnected (ITestDevice device)

ยืนยันว่าสถานะการเชื่อมต่อ wifi เชื่อมต่ออยู่

void assumeIsSupportedNfcDevice (ITestDevice device)
static MetricsReportLog buildMetricsReportLog (ITestDevice device)
WifiHelper createWifiHelper ()
static IAbi getAbi (ITestDevice device)
static IBuildInfo getBuildInfo (ITestDevice device)
static PocPusher getPocPusher (ITestDevice device)
static String getTestName (ITestDevice device)
boolean moduleIsPlayManaged (String modulePackageName)

คืนค่าเป็นจริงหากโมดูลได้รับการจัดการการเล่น

void safeReboot ()
void setUp ()

รอให้อุปกรณ์ออนไลน์ ทำเครื่องหมายเวลาบูตล่าสุดของอุปกรณ์

void tearDown ()

ตรวจสอบให้แน่ใจว่าโทรศัพท์ออนไลน์อยู่และตรวจสอบว่าอุปกรณ์ขัดข้องหรือไม่

void updateKernelStartTime ()

อนุญาตให้การทดสอบผ่านไปหากถูกเรียกหลังจากรีบูตตามแผน

วิธีการที่ได้รับการป้องกัน

boolean containsDriver (ITestDevice device, String driver, boolean checkReadable)

ตรวจสอบว่ามีไดรเวอร์อยู่บนเครื่องหรือไม่

boolean containsDriver (ITestDevice device, String driver)

ตรวจสอบว่ามีไดรเวอร์อยู่และสามารถอ่านได้หรือไม่

ค่าคงที่

TIMEOUT_DEFAULT

protected static final int TIMEOUT_DEFAULT

ค่าคงที่: 60 (0x0000003c)

TIMEOUT_NONDETERMINISTIC

public static final int TIMEOUT_NONDETERMINISTIC

ค่าคงที่: 315 (0x0000013b)

เขตข้อมูล

pocPusher

public PocPusher pocPusher

ชื่อทดสอบ

public TestName testName

ผู้รับเหมาก่อสร้างสาธารณะ

ความปลอดภัยTestCase

public SecurityTestCase ()

วิธีการสาธารณะ

ยืนยันการแข่งขัน

public void assertMatches (String pattern, 
                String input)

พารามิเตอร์
pattern String

input String

ขว้าง
Exception

assertMatchesMultiLine

public void assertMatchesMultiLine (String pattern, 
                String input)

พารามิเตอร์
pattern String

input String

ขว้าง
Exception

assertNotKernelPointer

public void assertNotKernelPointer (Callable<String> getPtrFunction, 
                ITestDevice deviceToReboot)

รันฟังก์ชันที่จัดเตรียมไว้ซึ่งรวบรวมสตริงเพื่อทดสอบการรั่วไหลของเคอร์เนลพอยน์เตอร์ การใช้งานฟังก์ชันgetPtrFunctionต้องส่งคืนสตริงที่ขึ้นต้นด้วยตัวชี้ เช่น "01234567" อนุญาตให้ใช้อักขระต่อท้ายได้ ยกเว้น [0-9a-fA-F] ในกรณีที่ตัวชี้ดูเหมือนจะมีช่องโหว่ การยืนยัน JUnit จะถูกส่งออกไป เนื่องจากตัวชี้เคอร์เนลสามารถแฮชได้ มีความเป็นไปได้ที่ตัวชี้แฮชจะทับซ้อนในพื้นที่เคอร์เนลปกติ การทดสอบซ้ำเพื่อให้ผลบวกลวงไม่มีนัยสำคัญทางสถิติ เมื่อเคอร์เนลพอยน์เตอร์ไม่เปลี่ยนแปลงโดยไม่ต้องรีบูต ให้จัดเตรียมอุปกรณ์เพื่อรีบูต

พารามิเตอร์
getPtrFunction Callable : ฟังก์ชันที่ส่งคืนสตริงที่ขึ้นต้นด้วยตัวชี้

deviceToReboot ITestDevice : อุปกรณ์ที่จะรีบูตเมื่อเคอร์เนลพอยน์เตอร์ไม่เปลี่ยนแปลง

ขว้าง
Exception

assertNotMatches

public void assertNotMatches (String pattern, 
                String input)

พารามิเตอร์
pattern String

input String

ขว้าง
Exception

assertNotMatchesMultiLine

public void assertNotMatchesMultiLine (String pattern, 
                String input)

พารามิเตอร์
pattern String

input String

ขว้าง
Exception

assertWifiเชื่อมต่อแล้ว

public void assertWifiConnected (ITestDevice device)

ยืนยันว่าสถานะการเชื่อมต่อ wifi เชื่อมต่ออยู่ เนื่องจาก STS สามารถรีบูทอุปกรณ์ได้ทันทีก่อนทำการทดสอบ จึงอาจไม่ได้เชื่อมต่อ wifi ก่อนทำการทดสอบ เราสำรวจ wifi จนกว่าเราจะหมดเวลาหรือมีการเชื่อมต่อ wifi

พารามิเตอร์
device ITestDevice : อุปกรณ์ที่จะรัน

ขว้าง
Exception

ถือว่าIsSupportedNfcDevice

public void assumeIsSupportedNfcDevice (ITestDevice device)

พารามิเตอร์
device ITestDevice

ขว้าง
Exception

buildMetricsReportLog

public static MetricsReportLog buildMetricsReportLog (ITestDevice device)

พารามิเตอร์
device ITestDevice

การส่งคืน
MetricsReportLog

createWifiHelper

public WifiHelper createWifiHelper ()

การส่งคืน
WifiHelper

ขว้าง
DeviceNotAvailableException

รับอาบี

public static IAbi getAbi (ITestDevice device)

พารามิเตอร์
device ITestDevice

การส่งคืน
IAbi

รับ BuildInfo

public static IBuildInfo getBuildInfo (ITestDevice device)

พารามิเตอร์
device ITestDevice

การส่งคืน
IBuildInfo

รับPocPusher

public static PocPusher getPocPusher (ITestDevice device)

พารามิเตอร์
device ITestDevice

การส่งคืน
PocPusher

รับชื่อการทดสอบ

public static String getTestName (ITestDevice device)

พารามิเตอร์
device ITestDevice

การส่งคืน
String

โมดูล IsPlayManaged

public boolean moduleIsPlayManaged (String modulePackageName)

คืนค่าเป็นจริงหากโมดูลได้รับการจัดการการเล่น

ตัวอย่างของการข้ามการทดสอบตามโมดูลเมนไลน์:

  @Test
  public void testPocCVE_1234_5678() throws Exception {
      // This will skip the test if MODULE_METADATA mainline module is play managed.
      assumeFalse(moduleIsPlayManaged("com.google.android.captiveportallogin"));
      // Do testing...
  }
 

พารามิเตอร์
modulePackageName String

การส่งคืน
boolean

ขว้าง
Exception

ปลอดภัยรีบูต

public void safeReboot ()

ขว้าง
DeviceNotAvailableException

ติดตั้ง

public void setUp ()

รอให้อุปกรณ์ออนไลน์ ทำเครื่องหมายเวลาบูตล่าสุดของอุปกรณ์

ขว้าง
Exception

การถอดออก

public void tearDown ()

ตรวจสอบให้แน่ใจว่าโทรศัพท์ออนไลน์อยู่และตรวจสอบว่าอุปกรณ์ขัดข้องหรือไม่

ขว้าง
Exception

อัพเดต KernelStartTime

public void updateKernelStartTime ()

อนุญาตให้การทดสอบผ่านไปหากถูกเรียกหลังจากรีบูตตามแผน

ขว้าง
DeviceNotAvailableException

วิธีการที่ได้รับการป้องกัน

มีไดร์เวอร์

protected boolean containsDriver (ITestDevice device, 
                String driver, 
                boolean checkReadable)

ตรวจสอบว่ามีไดรเวอร์อยู่บนเครื่องหรือไม่

พารามิเตอร์
device ITestDevice

driver String

checkReadable boolean

การส่งคืน
boolean

ขว้าง
Exception

มีไดร์เวอร์

protected boolean containsDriver (ITestDevice device, 
                String driver)

ตรวจสอบว่ามีไดรเวอร์อยู่และสามารถอ่านได้หรือไม่

พารามิเตอร์
device ITestDevice

driver String

การส่งคืน
boolean

ขว้าง
Exception