Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb1de097 authored by Thiébaud Weksteen's avatar Thiébaud Weksteen
Browse files

Fix NetworkSecurityConfigTest tests

Update the intermediate certificate pin reference (WR2).

Other tests were failing because HttpsURLConnection was trying to follow
the HTTP 301 returned by android.com to www.android.com. Update
TestUtils to not follow any HTTP redirection.

Test: atest NetworkSecurityConfigTest
Bug: 259406200
Change-Id: I570b12b1d665270aeddb38379f4bc10abbe674e6
parent 4fff241a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
    </domain>
    <domain>   developer.android.com    </domain>
    <pin-set>
      <pin digest="SHA-256">  zCTnfLwLKbS9S2sbp+uFz4KZOocFvXxkV06Ce9O5M2w=  </pin>
      <pin digest="SHA-256"> YPtHaftLw6/0vnc2BnNKGF54xiCA28WFcccjkA4ypCM=  </pin>
    </pin-set>
  </domain-config>
</network-security-config>
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
      <domain-config>
          <domain>developer.android.com</domain>
          <pin-set>
              <pin digest="SHA-256">zCTnfLwLKbS9S2sbp+uFz4KZOocFvXxkV06Ce9O5M2w=</pin>
              <pin digest="SHA-256">YPtHaftLw6/0vnc2BnNKGF54xiCA28WFcccjkA4ypCM=</pin>
          </pin-set>
      </domain-config>
    </domain-config>
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
  <domain-config>
    <domain>android.com</domain>
    <pin-set>
      <pin digest="SHA-256">zCTnfLwLKbS9S2sbp+uFz4KZOocFvXxkV06Ce9O5M2w=</pin>
      <pin digest="SHA-256">YPtHaftLw6/0vnc2BnNKGF54xiCA28WFcccjkA4ypCM=</pin>
    </pin-set>
  </domain-config>
</network-security-config>
+2 −2
Original line number Diff line number Diff line
@@ -40,9 +40,9 @@ public class NetworkSecurityConfigTests extends ActivityUnitTestCase<Activity> {
        super(Activity.class);
    }

    // SHA-256 of the GTS intermediate CA (CN = GTS CA 1C3) for android.com (as of 09/2023).
    // SHA-256 of the GTS intermediate CA (CN = WR2) for android.com (as of 01/2025).
    private static final byte[] GTS_INTERMEDIATE_SPKI_SHA256 =
        hexToBytes("cc24e77cbc0b29b4bd4b6b1ba7eb85cf82993a8705bd7c64574e827bd3b9336c");
        hexToBytes("60fb4769fb4bc3aff4be773606734a185e78c62080dbc58571c723900e32a423");

    private static final byte[] TEST_CA_BYTES
            = hexToBytes(
+2 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ public final class TestUtils {
            throws Exception {
        URL url = new URL("https://" + host + ":" + port);
        HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
        connection.setInstanceFollowRedirects(false);
        connection.setSSLSocketFactory(context.getSocketFactory());
        try {
            connection.getInputStream();
@@ -68,6 +69,7 @@ public final class TestUtils {
            throws Exception {
        URL url = new URL("https://" + host + ":" + port);
        HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
        connection.setInstanceFollowRedirects(false);
        connection.setSSLSocketFactory(context.getSocketFactory());
        connection.getInputStream();
    }