安全测试用例

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 测试的基本测试类。

请改用RootSecurityTestCaseNonRootSecurityTestCase

概括

常数

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)

如果模块是播放管理的,则返回 true。

void safeReboot ()
void setUp ()

等待设备上线,标记设备最近一次开机时间

void tearDown ()

确保手机在线并检查设备是否崩溃

void updateKernelStartTime ()

如果在计划的重新启动后调用,则允许测试通过。

受保护的方法

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

检查机器上是否存在驱动程序。

boolean containsDriver (ITestDevice device, String driver)

检查驱动程序是否存在且可读。

常数

超时_默认值

protected static final int TIMEOUT_DEFAULT

常量值:60 (0x0000003c)

超时_非确定性

public static final int TIMEOUT_NONDETERMINISTIC

常量值:315 (0x0000013b)

领域

波克推手

public PocPusher pocPusher

测试名称

public TestName testName

公共构造函数

安全测试用例

public SecurityTestCase ()

公共方法

断言匹配

public void assertMatches (String pattern, 
                String input)

参数
pattern String

input String

投掷
Exception

断言匹配多行

public void assertMatchesMultiLine (String pattern, 
                String input)

参数
pattern String

input String

投掷
Exception

断言非内核指针

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

断言Wifi已连接

public void assertWifiConnected (ITestDevice device)

断言 wifi 连接状态已连接。由于 STS 可以在运行测试之前立即重新启动设备,因此在测试运行之前可能无法连接 wifi。我们轮询 wifi,直到超时或 wifi 连接为止。

参数
device ITestDevice :要运行的设备

投掷
Exception

假设IsSupportedNfcDevice

public void assumeIsSupportedNfcDevice (ITestDevice device)

参数
device ITestDevice

投掷
Exception

构建指标报告日志

public static MetricsReportLog buildMetricsReportLog (ITestDevice device)

参数
device ITestDevice

退货
MetricsReportLog

创建Wifi助手

public WifiHelper createWifiHelper ()

退货
WifiHelper

投掷
DeviceNotAvailableException

获取阿比

public static IAbi getAbi (ITestDevice device)

参数
device ITestDevice

退货
IAbi

获取构建信息

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

moduleIsPlayManaged

public boolean moduleIsPlayManaged (String modulePackageName)

如果模块是播放管理的,则返回 true。

跳过基于主线模块的测试的示例:

  @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

更新内核开始时间

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