กรณีทดสอบความปลอดภัย

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

ผู้สร้างสาธารณะ

กรณีทดสอบความปลอดภัย

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

ยืนยันว่าไม่ตรงกัน

public void assertNotMatches (String pattern, 
                String input)

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

input String

พ่น
Exception

ยืนยันไม่ตรงกันหลายบรรทัด

public void assertNotMatchesMultiLine (String pattern, 
                String input)

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

input String

พ่น
Exception

ยืนยันWifiConnected

public void assertWifiConnected (ITestDevice device)

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

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

พ่น
Exception

ถือว่าอุปกรณ์รองรับ NFC

public void assumeIsSupportedNfcDevice (ITestDevice device)

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

พ่น
Exception

buildMetricsReportLog

public static MetricsReportLog buildMetricsReportLog (ITestDevice device)

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

ส่งคืน
MetricsReportLog

สร้าง WifiHelper

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