Merge "Decouple security exception check test from ConnectivityServiceTest"
This commit is contained in:
commit
bb2e871cce
2 changed files with 14 additions and 13 deletions
|
|
@ -10632,19 +10632,6 @@ public class ConnectivityServiceTest {
|
||||||
assertContainsExactly(uidCaptor.getValue(), APP1_UID, APP2_UID);
|
assertContainsExactly(uidCaptor.getValue(), APP1_UID, APP2_UID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStartVpnProfileFromDiffPackage() throws Exception {
|
|
||||||
final String notMyVpnPkg = "com.not.my.vpn";
|
|
||||||
assertThrows(
|
|
||||||
SecurityException.class, () -> mVpnManagerService.startVpnProfile(notMyVpnPkg));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStopVpnProfileFromDiffPackage() throws Exception {
|
|
||||||
final String notMyVpnPkg = "com.not.my.vpn";
|
|
||||||
assertThrows(SecurityException.class, () -> mVpnManagerService.stopVpnProfile(notMyVpnPkg));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUidUpdateChangesInterfaceFilteringRule() throws Exception {
|
public void testUidUpdateChangesInterfaceFilteringRule() throws Exception {
|
||||||
LinkProperties lp = new LinkProperties();
|
LinkProperties lp = new LinkProperties();
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import static android.os.Build.VERSION_CODES.R;
|
||||||
|
|
||||||
import static com.android.testutils.ContextUtils.mockService;
|
import static com.android.testutils.ContextUtils.mockService;
|
||||||
import static com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
|
import static com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
|
||||||
|
import static com.android.testutils.MiscAsserts.assertThrows;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
|
@ -75,6 +76,8 @@ public class VpnManagerServiceTest extends VpnTestBase {
|
||||||
private VpnManagerServiceDependencies mDeps;
|
private VpnManagerServiceDependencies mDeps;
|
||||||
private VpnManagerService mService;
|
private VpnManagerService mService;
|
||||||
|
|
||||||
|
private final String mNotMyVpnPkg = "com.not.my.vpn";
|
||||||
|
|
||||||
class VpnManagerServiceDependencies extends VpnManagerService.Dependencies {
|
class VpnManagerServiceDependencies extends VpnManagerService.Dependencies {
|
||||||
@Override
|
@Override
|
||||||
public HandlerThread makeHandlerThread() {
|
public HandlerThread makeHandlerThread() {
|
||||||
|
|
@ -146,4 +149,15 @@ public class VpnManagerServiceTest extends VpnTestBase {
|
||||||
mService.onPackageAdded(PKGS[0], PKG_UIDS[0], false /* isReplacing */);
|
mService.onPackageAdded(PKGS[0], PKG_UIDS[0], false /* isReplacing */);
|
||||||
verify(mVpn, times(2)).refreshPlatformVpnAppExclusionList();
|
verify(mVpn, times(2)).refreshPlatformVpnAppExclusionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStartVpnProfileFromDiffPackage() {
|
||||||
|
assertThrows(
|
||||||
|
SecurityException.class, () -> mService.startVpnProfile(mNotMyVpnPkg));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStopVpnProfileFromDiffPackage() {
|
||||||
|
assertThrows(SecurityException.class, () -> mService.stopVpnProfile(mNotMyVpnPkg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue