Revert "Updates CTS tests for MAC address restrictions."
Revert submission 1518603-soft-restrict-mac
Reason for revert: Missing type check
Reverted Changes:
I0488932de:Soft-enable MAC address restrictions with allowlis...
Idb9d940e4:Updates CTS tests for MAC address restrictions.
I9461f287e:Return anonymized MAC for apps targeting SDK < 30
Change-Id: If55cd2a857f5d73ea2e0c0d566ee6e2360b8dba8
(cherry picked from commit 75e5ec51077cb16adbc3d99eebfb3148e5ea5a89)
diff --git a/tests/tests/selinux/common/src/android/security/SELinuxTargetSdkTestBase.java b/tests/tests/selinux/common/src/android/security/SELinuxTargetSdkTestBase.java
index 496270f..6ec352c 100644
--- a/tests/tests/selinux/common/src/android/security/SELinuxTargetSdkTestBase.java
+++ b/tests/tests/selinux/common/src/android/security/SELinuxTargetSdkTestBase.java
@@ -12,7 +12,6 @@
import java.util.Collections;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
-import org.junit.Assert;
abstract class SELinuxTargetSdkTestBase extends AndroidTestCase
{
@@ -20,8 +19,6 @@
System.loadLibrary("ctsselinux_jni");
}
- static final byte[] ANONYMIZED_HARDWARE_ADDRESS = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
protected static String getFile(String filename) throws IOException {
BufferedReader in = null;
try {
@@ -79,11 +76,19 @@
}
}
- protected static void noNetlinkRouteBind() throws IOException {
- assertEquals(
- "bind() is not allowed on netlink route sockets",
- 13,
- checkNetlinkRouteBind());
+ protected static void checkNetlinkRouteBind(boolean expectAllowed) throws IOException {
+ if (!expectAllowed) {
+ assertEquals(
+ "Bind() is not allowed on a netlink route sockets",
+ 13,
+ checkNetlinkRouteBind());
+ } else {
+ assertEquals(
+ "Bind() should succeed for netlink route sockets for apps with "
+ + "targetSdkVersion <= Q",
+ -1,
+ checkNetlinkRouteBind());
+ }
}
/**
@@ -164,17 +169,16 @@
}
/**
- * Verify that apps having targetSdkVersion <= 29 get an anonymized MAC
- * address (02:00:00:00:00:00) instead of a null MAC for ethernet interfaces.
+ * Verify that apps having targetSdkVersion <= 29 are able to see MAC
+ * addresses of ethernet devices.
* The counterpart of this test (testing for targetSdkVersion > 29) is
* {@link libcore.java.net.NetworkInterfaceTest#testGetHardwareAddress_returnsNull()}.
*/
- protected static void checkNetworkInterface_returnsAnonymizedHardwareAddresses()
- throws Exception {
+ protected static void checkNetworkInterface_returnsHardwareAddresses() throws Exception {
assertNotNull(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface nif : Collections.list(NetworkInterface.getNetworkInterfaces())) {
if (isEthernet(nif.getName())) {
- Assert.assertArrayEquals(ANONYMIZED_HARDWARE_ADDRESS, nif.getHardwareAddress());
+ assertEquals(6, nif.getHardwareAddress().length);
}
}
}
diff --git a/tests/tests/selinux/selinuxEphemeral/src/android/security/SELinuxTargetSdkTest.java b/tests/tests/selinux/selinuxEphemeral/src/android/security/SELinuxTargetSdkTest.java
index 1098a6f..1ed366e 100644
--- a/tests/tests/selinux/selinuxEphemeral/src/android/security/SELinuxTargetSdkTest.java
+++ b/tests/tests/selinux/selinuxEphemeral/src/android/security/SELinuxTargetSdkTest.java
@@ -83,6 +83,6 @@
}
public void testNoNetlinkRouteBind() throws IOException {
- noNetlinkRouteBind();
+ checkNetlinkRouteBind(false);
}
}
diff --git a/tests/tests/selinux/selinuxTargetSdk27/src/android/security/SELinuxTargetSdkTest.java b/tests/tests/selinux/selinuxTargetSdk27/src/android/security/SELinuxTargetSdkTest.java
index 5e2f75d..a784464 100644
--- a/tests/tests/selinux/selinuxTargetSdk27/src/android/security/SELinuxTargetSdkTest.java
+++ b/tests/tests/selinux/selinuxTargetSdk27/src/android/security/SELinuxTargetSdkTest.java
@@ -66,6 +66,6 @@
}
public void testNetworkInterface() throws Exception {
- checkNetworkInterface_returnsAnonymizedHardwareAddresses();
+ checkNetworkInterface_returnsHardwareAddresses();
}
}
diff --git a/tests/tests/selinux/selinuxTargetSdk28/src/android/security/SELinuxTargetSdkTest.java b/tests/tests/selinux/selinuxTargetSdk28/src/android/security/SELinuxTargetSdkTest.java
index 29b68db..880ae1a 100644
--- a/tests/tests/selinux/selinuxTargetSdk28/src/android/security/SELinuxTargetSdkTest.java
+++ b/tests/tests/selinux/selinuxTargetSdk28/src/android/security/SELinuxTargetSdkTest.java
@@ -66,6 +66,6 @@
}
public void testNetworkInterface() throws Exception {
- checkNetworkInterface_returnsAnonymizedHardwareAddresses();
+ checkNetworkInterface_returnsHardwareAddresses();
}
}
diff --git a/tests/tests/selinux/selinuxTargetSdk29/src/android/security/SELinuxTargetSdkTest.java b/tests/tests/selinux/selinuxTargetSdk29/src/android/security/SELinuxTargetSdkTest.java
index c1d93dc..1f1eaaa 100644
--- a/tests/tests/selinux/selinuxTargetSdk29/src/android/security/SELinuxTargetSdkTest.java
+++ b/tests/tests/selinux/selinuxTargetSdk29/src/android/security/SELinuxTargetSdkTest.java
@@ -47,8 +47,8 @@
checkNetlinkRouteGetlink(true);
}
- public void testNoNetlinkRouteBind() throws IOException {
- noNetlinkRouteBind();
+ public void testNetlinkRouteBindSucceeds() throws IOException {
+ checkNetlinkRouteBind(true);
}
public void testCanNotExecuteFromHomeDir() throws Exception {
@@ -86,6 +86,6 @@
}
public void testNetworkInterface() throws Exception {
- checkNetworkInterface_returnsAnonymizedHardwareAddresses();
+ checkNetworkInterface_returnsHardwareAddresses();
}
}
diff --git a/tests/tests/selinux/selinuxTargetSdkCurrent/src/android/security/SELinuxTargetSdkTest.java b/tests/tests/selinux/selinuxTargetSdkCurrent/src/android/security/SELinuxTargetSdkTest.java
index 4de03b0..05fad31 100644
--- a/tests/tests/selinux/selinuxTargetSdkCurrent/src/android/security/SELinuxTargetSdkTest.java
+++ b/tests/tests/selinux/selinuxTargetSdkCurrent/src/android/security/SELinuxTargetSdkTest.java
@@ -38,7 +38,7 @@
}
public void testNoNetlinkRouteBind() throws IOException {
- noNetlinkRouteBind();
+ checkNetlinkRouteBind(false);
}
public void testCanNotExecuteFromHomeDir() throws Exception {