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)

מפעיל פונקציה מסופקת שאוספת String כדי לבדוק נגד דליפות מצביע ליבה.

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)

בדוק אם מנהל התקן קיים וניתן לקריאה.

קבועים

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

בנאים ציבוריים

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)

מפעיל פונקציה מסופקת שאוספת String כדי לבדוק נגד דליפות מצביע ליבה. יישום הפונקציה 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)

טוען שמצב חיבור ה-WiFi מחובר. מכיוון ש-STS יכול לאתחל מכשיר מיד לפני הפעלת בדיקה, ייתכן שה- wifi לא יהיה מחובר לפני שהבדיקה רצה. אנו מסקרים את ה-wifi עד שנגיע לפסק זמן או שה-wifi מחובר.

פרמטרים
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)

החזר 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

updateKernelStartTime

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
,

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)

מפעיל פונקציה מסופקת שאוספת String כדי לבדוק נגד דליפות מצביע ליבה.

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)

בדוק אם מנהל התקן קיים וניתן לקריאה.

קבועים

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

בנאים ציבוריים

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)

מפעיל פונקציה מסופקת שאוספת String כדי לבדוק נגד דליפות מצביע ליבה. יישום הפונקציה 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)

טוען שמצב חיבור ה-WiFi מחובר. מכיוון ש-STS יכול לאתחל מכשיר מיד לפני הפעלת בדיקה, ייתכן שה- wifi לא יהיה מחובר לפני שהבדיקה רצה. אנו מסקרים את ה-wifi עד שנגיע לפסק זמן או שה-wifi מחובר.

פרמטרים
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)

החזר אמת אם מודול מנוהל משחק.

דוגמה לדילוג על מבחן המבוסס על מודולים מרכזיים:

  @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

updateKernelStartTime

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