安全測試用例

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