Search in sources :

Example 1 with DisabledForJreRange

use of org.junit.jupiter.api.condition.DisabledForJreRange in project dropwizard by dropwizard.

the class HttpsConnectorFactoryTest method testExcludedProtocolsWithWildcards.

@Test
@DisabledForJreRange(min = JRE.JAVA_16)
void testExcludedProtocolsWithWildcards() throws Exception {
    List<String> excludedProtocols = Arrays.asList("SSL.*", "TLSv1(\\.[01])?");
    HttpsConnectorFactory factory = new HttpsConnectorFactory();
    // necessary to avoid a prompt for a password
    factory.setKeyStorePassword("password");
    factory.setExcludedProtocols(excludedProtocols);
    SslContextFactory sslContextFactory = factory.configureSslContextFactory(new SslContextFactory.Server());
    assertThat(Arrays.asList(sslContextFactory.getExcludeProtocols())).isEqualTo(excludedProtocols);
    sslContextFactory.start();
    try {
        assertThat(sslContextFactory.newSSLEngine().getEnabledProtocols()).contains("TLSv1.2").allSatisfy(protocol -> assertThat(protocol).doesNotStartWith("SSL")).doesNotContain("TLSv1");
    } finally {
        sslContextFactory.stop();
    }
}
Also used : HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) InstanceOfAssertFactories(org.assertj.core.api.InstanceOfAssertFactories) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) KeyStoreException(java.security.KeyStoreException) InstrumentedConnectionFactory(com.codahale.metrics.jetty9.InstrumentedConnectionFactory) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) Assumptions.assumeFalse(org.junit.jupiter.api.Assumptions.assumeFalse) Map(java.util.Map) Assumptions.assumeTrue(org.junit.jupiter.api.Assumptions.assumeTrue) Jackson(io.dropwizard.jackson.Jackson) YamlConfigurationFactory(io.dropwizard.configuration.YamlConfigurationFactory) URI(java.net.URI) BaseValidator(io.dropwizard.validation.BaseValidator) Server(org.eclipse.jetty.server.Server) ConstraintViolation(javax.validation.ConstraintViolation) WINDOWS(org.junit.jupiter.api.condition.OS.WINDOWS) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) MetricRegistry(com.codahale.metrics.MetricRegistry) Collection(java.util.Collection) DiscoverableSubtypeResolver(io.dropwizard.jackson.DiscoverableSubtypeResolver) ScheduledExecutorScheduler(org.eclipse.jetty.util.thread.ScheduledExecutorScheduler) Validator(javax.validation.Validator) Set(java.util.Set) ResourceConfigurationSourceProvider(io.dropwizard.configuration.ResourceConfigurationSourceProvider) IOException(java.io.IOException) KeyStore(java.security.KeyStore) ConnectionFactory(org.eclipse.jetty.server.ConnectionFactory) Collectors(java.util.stream.Collectors) Assertions.entry(org.assertj.core.api.Assertions.entry) File(java.io.File) ThreadPool(org.eclipse.jetty.util.thread.ThreadPool) Test(org.junit.jupiter.api.Test) UncheckedIOException(java.io.UncheckedIOException) ServerConnector(org.eclipse.jetty.server.ServerConnector) List(java.util.List) Resource(org.eclipse.jetty.util.resource.Resource) Collections(java.util.Collections) JRE(org.junit.jupiter.api.condition.JRE) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) Test(org.junit.jupiter.api.Test) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange)

Example 2 with DisabledForJreRange

use of org.junit.jupiter.api.condition.DisabledForJreRange in project dropwizard by dropwizard.

the class HttpsConnectorFactoryTest method testExcludedProtocols.

@Test
@DisabledForJreRange(min = JRE.JAVA_16)
void testExcludedProtocols() throws Exception {
    List<String> excludedProtocols = Arrays.asList("SSLv3", "TLSv1");
    HttpsConnectorFactory factory = new HttpsConnectorFactory();
    // necessary to avoid a prompt for a password
    factory.setKeyStorePassword("password");
    factory.setExcludedProtocols(excludedProtocols);
    SslContextFactory sslContextFactory = factory.configureSslContextFactory(new SslContextFactory.Server());
    assertThat(Arrays.asList(sslContextFactory.getExcludeProtocols())).isEqualTo(excludedProtocols);
    sslContextFactory.start();
    try {
        assertThat(sslContextFactory.newSSLEngine().getEnabledProtocols()).contains("TLSv1.2").doesNotContain("SSLv3", "TLSv1");
    } finally {
        sslContextFactory.stop();
    }
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) Test(org.junit.jupiter.api.Test) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange)

Example 3 with DisabledForJreRange

use of org.junit.jupiter.api.condition.DisabledForJreRange in project dropwizard by dropwizard.

the class HttpsConnectorFactoryTest method testExcludedProtocolsWithWildcardsJava16.

@Test
@DisabledForJreRange(max = JRE.JAVA_15)
void testExcludedProtocolsWithWildcardsJava16() throws Exception {
    List<String> excludedProtocols = Arrays.asList("SSL.*", "TLSv1(\\.[01])?");
    HttpsConnectorFactory factory = new HttpsConnectorFactory();
    // necessary to avoid a prompt for a password
    factory.setKeyStorePassword("password");
    factory.setExcludedProtocols(excludedProtocols);
    SslContextFactory sslContextFactory = factory.configureSslContextFactory(new SslContextFactory.Server());
    assertThat(Arrays.asList(sslContextFactory.getExcludeProtocols())).isEqualTo(excludedProtocols);
    sslContextFactory.start();
    try {
        assertThat(sslContextFactory.newSSLEngine().getEnabledProtocols()).contains("TLSv1.2", "TLSv1.3").allSatisfy(protocol -> assertThat(protocol).doesNotStartWith("SSL")).doesNotContain("TLSv1");
    } finally {
        sslContextFactory.stop();
    }
}
Also used : HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) InstanceOfAssertFactories(org.assertj.core.api.InstanceOfAssertFactories) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) KeyStoreException(java.security.KeyStoreException) InstrumentedConnectionFactory(com.codahale.metrics.jetty9.InstrumentedConnectionFactory) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) Assumptions.assumeFalse(org.junit.jupiter.api.Assumptions.assumeFalse) Map(java.util.Map) Assumptions.assumeTrue(org.junit.jupiter.api.Assumptions.assumeTrue) Jackson(io.dropwizard.jackson.Jackson) YamlConfigurationFactory(io.dropwizard.configuration.YamlConfigurationFactory) URI(java.net.URI) BaseValidator(io.dropwizard.validation.BaseValidator) Server(org.eclipse.jetty.server.Server) ConstraintViolation(javax.validation.ConstraintViolation) WINDOWS(org.junit.jupiter.api.condition.OS.WINDOWS) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) MetricRegistry(com.codahale.metrics.MetricRegistry) Collection(java.util.Collection) DiscoverableSubtypeResolver(io.dropwizard.jackson.DiscoverableSubtypeResolver) ScheduledExecutorScheduler(org.eclipse.jetty.util.thread.ScheduledExecutorScheduler) Validator(javax.validation.Validator) Set(java.util.Set) ResourceConfigurationSourceProvider(io.dropwizard.configuration.ResourceConfigurationSourceProvider) IOException(java.io.IOException) KeyStore(java.security.KeyStore) ConnectionFactory(org.eclipse.jetty.server.ConnectionFactory) Collectors(java.util.stream.Collectors) Assertions.entry(org.assertj.core.api.Assertions.entry) File(java.io.File) ThreadPool(org.eclipse.jetty.util.thread.ThreadPool) Test(org.junit.jupiter.api.Test) UncheckedIOException(java.io.UncheckedIOException) ServerConnector(org.eclipse.jetty.server.ServerConnector) List(java.util.List) Resource(org.eclipse.jetty.util.resource.Resource) Collections(java.util.Collections) JRE(org.junit.jupiter.api.condition.JRE) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) Test(org.junit.jupiter.api.Test) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange)

Example 4 with DisabledForJreRange

use of org.junit.jupiter.api.condition.DisabledForJreRange in project spring-data-mongodb by spring-projects.

the class DbRefMappingMongoConverterUnitTests method shouldFallbackToOneByOneFetchingWhenElementsInListOfReferencesPointToDifferentCollections.

// DATAMONGO-1194
@Test
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.")
void shouldFallbackToOneByOneFetchingWhenElementsInListOfReferencesPointToDifferentCollections() {
    String id1 = "1";
    String id2 = "2";
    String value = "val";
    MappingMongoConverter converterSpy = spy(converter);
    doReturn(new Document("_id", id1).append("value", value)).doReturn(new Document("_id", id2).append("value", value)).when(converterSpy).readRef(Mockito.any(DBRef.class));
    Document document = new Document();
    ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs();
    lazyDbRefs.dbRefToConcreteCollection = new ArrayList<>(Arrays.asList(new LazyDbRefTarget(id1, value), new SerializableLazyDbRefTarget(id2, value)));
    converterSpy.write(lazyDbRefs, document);
    ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, document);
    assertProxyIsResolved(result.dbRefToConcreteCollection, false);
    assertThat(result.dbRefToConcreteCollection.get(0).getId()).isEqualTo(id1);
    assertProxyIsResolved(result.dbRefToConcreteCollection, true);
    assertThat(result.dbRefToConcreteCollection.get(1).getId()).isEqualTo(id2);
    verify(converterSpy, times(2)).readRef(Mockito.any(DBRef.class));
    verify(converterSpy, never()).bulkReadRefs(anyList());
}
Also used : DBRef(com.mongodb.DBRef) Document(org.bson.Document) Test(org.junit.jupiter.api.Test) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange)

Example 5 with DisabledForJreRange

use of org.junit.jupiter.api.condition.DisabledForJreRange in project spring-boot by spring-projects.

the class SpringBootPluginIntegrationTests method failFastWithVersionOfGradle7LowerThanRequired.

@DisabledForJreRange(min = JRE.JAVA_14)
@Test
void failFastWithVersionOfGradle7LowerThanRequired() {
    BuildResult result = this.gradleBuild.gradleVersion("7.3.3").buildAndFail();
    assertThat(result.getOutput()).contains("Spring Boot plugin requires Gradle 7.x (7.4 or later). The current version is Gradle 7.3.3");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) Test(org.junit.jupiter.api.Test) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange)

Aggregations

Test (org.junit.jupiter.api.Test)12 DisabledForJreRange (org.junit.jupiter.api.condition.DisabledForJreRange)12 Document (org.bson.Document)4 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)4 MetricRegistry (com.codahale.metrics.MetricRegistry)2 InstrumentedConnectionFactory (com.codahale.metrics.jetty9.InstrumentedConnectionFactory)2 DBRef (com.mongodb.DBRef)2 ResourceConfigurationSourceProvider (io.dropwizard.configuration.ResourceConfigurationSourceProvider)2 YamlConfigurationFactory (io.dropwizard.configuration.YamlConfigurationFactory)2 DiscoverableSubtypeResolver (io.dropwizard.jackson.DiscoverableSubtypeResolver)2 Jackson (io.dropwizard.jackson.Jackson)2 BaseValidator (io.dropwizard.validation.BaseValidator)2 File (java.io.File)2 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 URI (java.net.URI)2 KeyStore (java.security.KeyStore)2 KeyStoreException (java.security.KeyStoreException)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2