Skip to content

Commit

Permalink
Revert^4 "Add support for enabling/disabling TLS v1.0 and 1.1 in Cons…
Browse files Browse the repository at this point in the history
…crypt."

This reverts commit 5ae7b5c2f272365d13c9ff3ba0c7a682375dc1d8.

Reason for revert: fixed the failures by checking that API levels are not higher than a 100, and bumped API level check to 36 because I noticed that this version of using reflection is more resilient than the previous one.

Change-Id: I42fcb922e046072eea0fa5aee07c513233d2b1e9
  • Loading branch information
miguelaranda0 committed Dec 10, 2024
1 parent 8f4e2be commit 7a1f5e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1837,22 +1837,6 @@ public void test_SSLSocket_TLSv1Supported() throws Exception {
}
}

// @TargetSdkVersion(35)
@Test
public void test_SSLSocket_SSLv3Unsupported_35() throws Exception {
assumeFalse(isTlsV1Filtered());
TestSSLContext context = new TestSSLContext.Builder()
.clientProtocol(clientVersion)
.serverProtocol(serverVersion)
.build();
final SSLSocket client =
(SSLSocket) context.clientContext.getSocketFactory().createSocket();
assertThrows(IllegalArgumentException.class,
() -> client.setEnabledProtocols(new String[] {"SSLv3"}));
assertThrows(IllegalArgumentException.class,
() -> client.setEnabledProtocols(new String[] {"SSL"}));
}

// @TargetSdkVersion(34)
@Test
@Ignore("For platform CTS only")
Expand Down Expand Up @@ -1889,20 +1873,6 @@ public void test_TLSv1Filtered_34() throws Exception {
assertEquals("TLSv1.2", client.getEnabledProtocols()[0]);
}

// @TargetSdkVersion(35)
@Test
public void test_TLSv1Filtered_35() throws Exception {
assumeTrue(isTlsV1Filtered());
TestSSLContext context = new TestSSLContext.Builder()
.clientProtocol(clientVersion)
.serverProtocol(serverVersion)
.build();
final SSLSocket client =
(SSLSocket) context.clientContext.getSocketFactory().createSocket();
assertThrows(IllegalArgumentException.class, () ->
client.setEnabledProtocols(new String[] {"TLSv1", "TLSv1.1", "TLSv1.2"}));
}

@Test
public void test_TLSv1Unsupported_notEnabled() {
assumeTrue(!isTlsV1Supported());
Expand Down
30 changes: 14 additions & 16 deletions platform/src/test/java/org/conscrypt/TlsDeprecationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@

@RunWith(JUnit4.class)
public class TlsDeprecationTest {
@Rule
public final TestRule switchTargetSdkVersionRule = SwitchTargetSdkVersionRule.getInstance();

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(36)
@TargetSdkVersion(36)
public void test_SSLSocket_SSLv3Unsupported_36() throws Exception {
assertFalse(TestUtils.isTlsV1Filtered());
TestSSLContext context = TestSSLContext.create();
Expand All @@ -52,7 +50,7 @@ public void test_SSLSocket_SSLv3Unsupported_36() throws Exception {
}

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(34)
@TargetSdkVersion(34)
public void test_SSLSocket_SSLv3Unsupported_34() throws Exception {
assertTrue(TestUtils.isTlsV1Filtered());
TestSSLContext context = TestSSLContext.create();
Expand All @@ -65,7 +63,7 @@ public void test_SSLSocket_SSLv3Unsupported_34() throws Exception {
}

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(34)
@TargetSdkVersion(34)
public void test_TLSv1Filtered_34() throws Exception {
assertTrue(TestUtils.isTlsV1Filtered());
TestSSLContext context = TestSSLContext.create();
Expand All @@ -77,7 +75,7 @@ public void test_TLSv1Filtered_34() throws Exception {
}

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(34)
@TargetSdkVersion(34)
public void test_TLSv1FilteredEmpty_34() throws Exception {
assertTrue(TestUtils.isTlsV1Filtered());
TestSSLContext context = TestSSLContext.create();
Expand All @@ -88,7 +86,7 @@ public void test_TLSv1FilteredEmpty_34() throws Exception {
}

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(36)
@TargetSdkVersion(36)
public void test_TLSv1Filtered_36() throws Exception {
assertFalse(TestUtils.isTlsV1Filtered());
TestSSLContext context = TestSSLContext.create();
Expand All @@ -99,7 +97,7 @@ public void test_TLSv1Filtered_36() throws Exception {
}

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(34)
@TargetSdkVersion(34)
public void testInitializeDeprecatedEnabled_34() {
Provider conscryptProvider = TestUtils.getConscryptProvider(true, true);
assertTrue(TestUtils.isTlsV1Deprecated());
Expand All @@ -108,7 +106,7 @@ public void testInitializeDeprecatedEnabled_34() {
}

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(36)
@TargetSdkVersion(36)
public void testInitializeDeprecatedEnabled_36() {
Provider conscryptProvider = TestUtils.getConscryptProvider(true, true);
assertTrue(TestUtils.isTlsV1Deprecated());
Expand All @@ -117,7 +115,7 @@ public void testInitializeDeprecatedEnabled_36() {
}

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(34)
@TargetSdkVersion(34)
public void testInitializeDeprecatedDisabled_34() {
Provider conscryptProvider = TestUtils.getConscryptProvider(true, false);
assertTrue(TestUtils.isTlsV1Deprecated());
Expand All @@ -126,7 +124,7 @@ public void testInitializeDeprecatedDisabled_34() {
}

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(36)
@TargetSdkVersion(36)
public void testInitializeDeprecatedDisabled_36() {
Provider conscryptProvider = TestUtils.getConscryptProvider(true, false);
assertTrue(TestUtils.isTlsV1Deprecated());
Expand All @@ -135,7 +133,7 @@ public void testInitializeDeprecatedDisabled_36() {
}

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(34)
@TargetSdkVersion(34)
public void testInitializeUndeprecatedEnabled_34() {
Provider conscryptProvider = TestUtils.getConscryptProvider(false, true);
assertFalse(TestUtils.isTlsV1Deprecated());
Expand All @@ -144,7 +142,7 @@ public void testInitializeUndeprecatedEnabled_34() {
}

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(36)
@TargetSdkVersion(36)
public void testInitializeUndeprecatedEnabled_36() {
Provider conscryptProvider = TestUtils.getConscryptProvider(false, true);
assertFalse(TestUtils.isTlsV1Deprecated());
Expand All @@ -153,14 +151,14 @@ public void testInitializeUndeprecatedEnabled_36() {
}

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(34)
@TargetSdkVersion(34)
public void testInitializeUndeprecatedDisabled_34() {
assertThrows(RuntimeException.class, () -> TestUtils.getConscryptProvider(false, false));
}

@Test
@SwitchTargetSdkVersionRule.TargetSdkVersion(36)
@TargetSdkVersion(36)
public void testInitializeUndeprecatedDisabled_36() {
assertThrows(RuntimeException.class, () -> TestUtils.getConscryptProvider(false, false));
}
}
}

0 comments on commit 7a1f5e5

Please sign in to comment.