SecurityTestCase
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)
斷言 Wi-Fi 連線狀態已連線。 |
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)
如果模組是 Play 管理的模組,則傳回 true。 |
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)
欄位
testName
public TestName testName
公用建構函式
SecurityTestCase
public SecurityTestCase ()
公用方法
assertMatches
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 |
assertWifiConnected
public void assertWifiConnected (ITestDevice device)
斷言 Wi-Fi 連線狀態已連線。由於 STS 可以在執行測試前立即重新啟動裝置,因此可能在測試執行前就已連上 Wi-Fi。我們會輪詢 Wi-Fi,直到逾時或 Wi-Fi 連線為止。
參數 | |
---|---|
device |
ITestDevice :要執行的裝置 |
擲回 | |
---|---|
Exception |
assumeIsSupportedNfcDevice
public void assumeIsSupportedNfcDevice (ITestDevice device)
參數 | |
---|---|
device |
ITestDevice |
擲回 | |
---|---|
Exception |
buildMetricsReportLog
public static MetricsReportLog buildMetricsReportLog (ITestDevice device)
參數 | |
---|---|
device |
ITestDevice |
傳回 | |
---|---|
MetricsReportLog |
createWifiHelper
public WifiHelper createWifiHelper ()
傳回 | |
---|---|
WifiHelper |
擲回 | |
---|---|
DeviceNotAvailableException |
getAbi
public static IAbi getAbi (ITestDevice device)
參數 | |
---|---|
device |
ITestDevice |
傳回 | |
---|---|
IAbi |
getBuildInfo
public static IBuildInfo getBuildInfo (ITestDevice device)
參數 | |
---|---|
device |
ITestDevice |
傳回 | |
---|---|
IBuildInfo |
getPocPusher
public static PocPusher getPocPusher (ITestDevice device)
參數 | |
---|---|
device |
ITestDevice |
傳回 | |
---|---|
PocPusher |
getTestName
public static String getTestName (ITestDevice device)
參數 | |
---|---|
device |
ITestDevice |
傳回 | |
---|---|
String |
moduleIsPlayManaged
public boolean moduleIsPlayManaged (String modulePackageName)
如果模組是 Play 管理的模組,則傳回 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 |
safeReboot
public void safeReboot ()
擲回 | |
---|---|
DeviceNotAvailableException |
setUp
public void setUp ()
等待裝置上線,並標記裝置最近的啟動時間
擲回 | |
---|---|
Exception |
tearDown
public void tearDown ()
確認手機已連上網路,並檢查裝置是否當機
擲回 | |
---|---|
Exception |
updateKernelStartTime
public void updateKernelStartTime ()
如果在預定重新啟動後呼叫,則允許測試通過。
擲回 | |
---|---|
DeviceNotAvailableException |
受保護的方法
containsDriver
protected boolean containsDriver (ITestDevice device, String driver, boolean checkReadable)
檢查機器上是否有驅動程式。
參數 | |
---|---|
device |
ITestDevice |
driver |
String |
checkReadable |
boolean |
傳回 | |
---|---|
boolean |
擲回 | |
---|---|
Exception |
containsDriver
protected boolean containsDriver (ITestDevice device, String driver)
檢查是否有驅動程式,且可供讀取。
參數 | |
---|---|
device |
ITestDevice |
driver |
String |
傳回 | |
---|---|
boolean |
擲回 | |
---|---|
Exception |