กรณีทดสอบความปลอดภัย
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
แทน
สรุป
วิธีการป้องกัน |
---|
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)
เขตข้อมูล
ชื่อการทดสอบ
public TestName testName
ผู้สร้างสาธารณะ
กรณีทดสอบความปลอดภัย
public SecurityTestCase ()
วิธีการสาธารณะ
ยืนยันตรงกัน
public void assertMatches (String pattern,
String input)
พารามิเตอร์ |
---|
pattern | String |
input | String |
assertMatchesMultiLine
public void assertMatchesMultiLine (String pattern,
String input)
พารามิเตอร์ |
---|
pattern | String |
input | String |
assertNotKernelPointer
public void assertNotKernelPointer (Callable<String> getPtrFunction,
ITestDevice deviceToReboot)
เรียกใช้ฟังก์ชันที่มีให้ซึ่งรวบรวมสตริงเพื่อทดสอบการรั่วไหลของตัวชี้เคอร์เนล การใช้งานฟังก์ชัน getPtrFunction ต้องส่งคืนสตริงที่ขึ้นต้นด้วยตัวชี้ คือ "01234567" อนุญาตให้ใช้อักขระต่อท้าย ยกเว้น [0-9a-fA-F] ในกรณีที่ตัวชี้ดูเหมือนจะมีช่องโหว่ การยืนยัน JUnit จะถูกส่งออกไป เนื่องจากเคอร์เนลพอยน์เตอร์สามารถแฮชได้ จึงมีความเป็นไปได้ที่พอยน์เตอร์ที่แฮชจะทับซ้อนกันในพื้นที่เคอร์เนลปกติ การทดสอบซ้ำเพื่อให้ผลบวกปลอมไม่มีนัยสำคัญทางสถิติ เมื่อพอยน์เตอร์เคอร์เนลไม่เปลี่ยนแปลงโดยไม่รีบูต ให้เตรียมอุปกรณ์ที่จะรีบูต
พารามิเตอร์ |
---|
getPtrFunction | Callable : ฟังก์ชันที่ส่งคืนสตริงที่ขึ้นต้นด้วยตัวชี้ |
deviceToReboot | ITestDevice : อุปกรณ์ที่จะรีบูตเมื่อตัวชี้เคอร์เนลไม่เปลี่ยนแปลง |
ยืนยันว่าไม่ตรงกัน
public void assertNotMatches (String pattern,
String input)
พารามิเตอร์ |
---|
pattern | String |
input | String |
ยืนยันไม่ตรงกันหลายบรรทัด
public void assertNotMatchesMultiLine (String pattern,
String input)
พารามิเตอร์ |
---|
pattern | String |
input | String |
ยืนยันWifiConnected
public void assertWifiConnected (ITestDevice device)
ยืนยันสถานะการเชื่อมต่อ wifi ว่าเชื่อมต่อแล้ว เนื่องจาก STS สามารถรีบูตอุปกรณ์ได้ทันทีก่อนที่จะเรียกใช้การทดสอบ จึงอาจไม่ได้เชื่อมต่อ wifi ก่อนการทดสอบจะทำงาน เราสำรวจ wifi จนกว่าเราจะหมดเวลาหรือมีการเชื่อมต่อ wifi
พารามิเตอร์ |
---|
device | ITestDevice : อุปกรณ์ที่จะรัน |
ถือว่าอุปกรณ์รองรับ NFC
public void assumeIsSupportedNfcDevice (ITestDevice device)
พารามิเตอร์ |
---|
device | ITestDevice |
buildMetricsReportLog
public static MetricsReportLog buildMetricsReportLog (ITestDevice device)
พารามิเตอร์ |
---|
device | ITestDevice |
สร้าง WifiHelper
public WifiHelper createWifiHelper ()
พ่น |
---|
DeviceNotAvailableException | |
รับเอบี
public static IAbi getAbi (ITestDevice device)
พารามิเตอร์ |
---|
device | ITestDevice |
รับ BuildInfo
public static IBuildInfo getBuildInfo (ITestDevice device)
พารามิเตอร์ |
---|
device | ITestDevice |
รับPocPusher
public static PocPusher getPocPusher (ITestDevice device)
พารามิเตอร์ |
---|
device | ITestDevice |
รับชื่อทดสอบ
public static String getTestName (ITestDevice device)
พารามิเตอร์ |
---|
device | ITestDevice |
โมดูล 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 |
ปลอดภัยรีบูต
public void safeReboot ()
พ่น |
---|
DeviceNotAvailableException | |
ติดตั้ง
public void setUp ()
รอให้อุปกรณ์ออนไลน์ ทำเครื่องหมายเวลาบูตล่าสุดของอุปกรณ์
การถอดออก
public void tearDown ()
ตรวจสอบให้แน่ใจว่าโทรศัพท์ออนไลน์อยู่และตรวจสอบว่าอุปกรณ์ขัดข้องหรือไม่
อัปเดต KernelStartTime
public void updateKernelStartTime ()
อนุญาตให้ผ่านการทดสอบหากเรียกหลังจากการรีบูตตามแผน
พ่น |
---|
DeviceNotAvailableException | |
วิธีการป้องกัน
ประกอบด้วยไดรเวอร์
protected boolean containsDriver (ITestDevice device,
String driver,
boolean checkReadable)
ตรวจสอบว่ามีไดรเวอร์อยู่ในเครื่องหรือไม่
พารามิเตอร์ |
---|
device | ITestDevice |
driver | String |
checkReadable | boolean |
ประกอบด้วยไดรเวอร์
protected boolean containsDriver (ITestDevice device,
String driver)
ตรวจสอบว่ามีไดรเวอร์อยู่และสามารถอ่านได้หรือไม่
พารามิเตอร์ |
---|
device | ITestDevice |
driver | String |