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


Base test class for all STS tests.

Use RootSecurityTestCase or NonRootSecurityTestCase instead.

Summary

Constants

int TIMEOUT_DEFAULT

int TIMEOUT_NONDETERMINISTIC

Fields

public PocPusher pocPusher

public TestName testName

Public constructors

SecurityTestCase()

Public methods

void assertMatches(String pattern, String input)
void assertMatchesMultiLine(String pattern, String input)
void assertNotKernelPointer(Callable<String> getPtrFunction, ITestDevice deviceToReboot)

Runs a provided function that collects a String to test against kernel pointer leaks.

void assertNotMatches(String pattern, String input)
void assertNotMatchesMultiLine(String pattern, String input)
void assertWifiConnected(ITestDevice device)

Asserts the wifi connection status is connected.

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)

Return true if a module is play managed.

void safeReboot()
void setUp()

Waits for device to be online, marks the most recent boottime of the device

void tearDown()

Makes sure the phone is online and checks if the device crashed

void updateKernelStartTime()

Allows a test to pass if called after a planned reboot.

Protected methods

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

Check if a driver is present on a machine.

boolean containsDriver(ITestDevice device, String driver)

Check if a driver is present and readable.

Constants

TIMEOUT_DEFAULT

protected static final int TIMEOUT_DEFAULT

Constant Value: 60 (0x0000003c)

TIMEOUT_NONDETERMINISTIC

public static final int TIMEOUT_NONDETERMINISTIC

Constant Value: 315 (0x0000013b)

Fields

pocPusher

public PocPusher pocPusher

testName

public TestName testName

Public constructors

SecurityTestCase

public SecurityTestCase ()

Public methods

assertMatches

public void assertMatches (String pattern, 
                String input)

Parameters
pattern String

input String

Throws
Exception

assertMatchesMultiLine

public void assertMatchesMultiLine (String pattern, 
                String input)

Parameters
pattern String

input String

Throws
Exception

assertNotKernelPointer

public void assertNotKernelPointer (Callable<String> getPtrFunction, 
                ITestDevice deviceToReboot)

Runs a provided function that collects a String to test against kernel pointer leaks. The getPtrFunction function implementation must return a String that starts with the pointer. i.e. "01234567". Trailing characters are allowed except for [0-9a-fA-F]. In the event that the pointer appears to be vulnerable, a JUnit assert is thrown. Since kernel pointers can be hashed, there is a possibility the hashed pointer overlaps into the normal kernel space. The test re-runs to make false positives statistically insignificant. When kernel pointers won't change without a reboot, provide a device to reboot.

Parameters
getPtrFunction Callable: a function that returns a string that starts with a pointer

deviceToReboot ITestDevice: device to reboot when kernel pointers won't change

Throws
Exception

assertNotMatches

public void assertNotMatches (String pattern, 
                String input)

Parameters
pattern String

input String

Throws
Exception

assertNotMatchesMultiLine

public void assertNotMatchesMultiLine (String pattern, 
                String input)

Parameters
pattern String

input String

Throws
Exception

assertWifiConnected

public void assertWifiConnected (ITestDevice device)

Asserts the wifi connection status is connected. Because STS can reboot a device immediately before running a test, wifi might not be connected before the test runs. We poll wifi until we hit a timeout or wifi is connected.

Parameters
device ITestDevice: device to be ran on

Throws
Exception

assumeIsSupportedNfcDevice

public void assumeIsSupportedNfcDevice (ITestDevice device)

Parameters
device ITestDevice

Throws
Exception

buildMetricsReportLog

public static MetricsReportLog buildMetricsReportLog (ITestDevice device)

Parameters
device ITestDevice

Returns
MetricsReportLog

createWifiHelper

public WifiHelper createWifiHelper ()

Returns
WifiHelper

Throws
DeviceNotAvailableException

getAbi

public static IAbi getAbi (ITestDevice device)

Parameters
device ITestDevice

Returns
IAbi

getBuildInfo

public static IBuildInfo getBuildInfo (ITestDevice device)

Parameters
device ITestDevice

Returns
IBuildInfo

getPocPusher

public static PocPusher getPocPusher (ITestDevice device)

Parameters
device ITestDevice

Returns
PocPusher

getTestName

public static String getTestName (ITestDevice device)

Parameters
device ITestDevice

Returns
String

moduleIsPlayManaged

public boolean moduleIsPlayManaged (String modulePackageName)

Return true if a module is play managed.

Example of skipping a test based on mainline modules:

  @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...
  }
 

Parameters
modulePackageName String

Returns
boolean

Throws
Exception

safeReboot

public void safeReboot ()

Throws
DeviceNotAvailableException

setUp

public void setUp ()

Waits for device to be online, marks the most recent boottime of the device

Throws
Exception

tearDown

public void tearDown ()

Makes sure the phone is online and checks if the device crashed

Throws
Exception

updateKernelStartTime

public void updateKernelStartTime ()

Allows a test to pass if called after a planned reboot.

Throws
DeviceNotAvailableException

Protected methods

containsDriver

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

Check if a driver is present on a machine.

Parameters
device ITestDevice

driver String

checkReadable boolean

Returns
boolean

Throws
Exception

containsDriver

protected boolean containsDriver (ITestDevice device, 
                String driver)

Check if a driver is present and readable.

Parameters
device ITestDevice

driver String

Returns
boolean

Throws
Exception