Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
Minimal project to verify excluded protocols in SslContextFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
joschi committed Oct 29, 2020
0 parents commit 7d537e9
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
48 changes: 48 additions & 0 deletions pom.xml
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.joschi</groupId>
<artifactId>jetty-5531</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<url>https://github.com/eclipse/jetty.project/issues/5531</url>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>9.4.33.v20201020</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.7.0</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
26 changes: 26 additions & 0 deletions src/test/java/SslContextFactoryTest.java
@@ -0,0 +1,26 @@
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.junit.jupiter.api.Test;

import java.util.Arrays;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayContaining;
import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class SslContextFactoryTest {
@Test
public void testDumpExcludedProtocols() throws Exception {
SslContextFactory.Server cf = new SslContextFactory.Server();
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("keypwd");
cf.setExcludeProtocols("SSL.*", "TLSv1", "TLSv1\\.[01]");
cf.start();

// Confirm behavior in engine
String[] enabledProtocols = cf.newSSLEngine().getEnabledProtocols();
System.out.println(Arrays.toString(enabledProtocols));
assertThat(enabledProtocols, not(arrayContaining("TLSv1.1")));
assertTrue(Arrays.stream(enabledProtocols).noneMatch("TLSv1.1"::equals), "No item should match TLSv1.1");
}
}

0 comments on commit 7d537e9

Please sign in to comment.