Skip to content

Commit

Permalink
Postpone SpringBoot tests until CQ is approved.
Browse files Browse the repository at this point in the history
Signed-off-by: jansupol <jan.supol@oracle.com>
  • Loading branch information
jansupol committed May 10, 2022
1 parent a370f22 commit a21b621
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 149 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/glassfish/tyrus/core/Handshake.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2017 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -631,16 +631,16 @@
<artifactId>jakarta.annotation-api</artifactId>
<version>${javax.annotation.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-websocket</artifactId>-->
<!-- <version>${spring.boot.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-test</artifactId>-->
<!-- <version>${spring.boot.version}</version>-->
<!-- </dependency>-->
</dependencies>
</dependencyManagement>
</project>
22 changes: 11 additions & 11 deletions tests/e2e/standard-config/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -57,16 +57,16 @@
<groupId>org.glassfish.tyrus.tests</groupId>
<artifactId>tyrus-test-tools</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-websocket</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-test</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

package org.glassfish.tyrus.test.standard_config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;

/**
* @author Roman Puchkovskiy
*/
@SpringBootApplication
@EnableWebSocketMessageBroker
public class WssApplication {
public static void main(String[] args) {
SpringApplication.run(WssApplication.class, args);
}
}
//import org.springframework.boot.SpringApplication;
//import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
//
///**
// * @author Roman Puchkovskiy
// */
//@SpringBootApplication
//@EnableWebSocketMessageBroker
//public class WssApplication {
// public static void main(String[] args) {
// SpringApplication.run(WssApplication.class, args);
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -16,99 +16,99 @@

package org.glassfish.tyrus.test.standard_config;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.websocket.ClientEndpointConfig;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.Session;
import java.net.URI;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.test.standard_config.springboot.WebSocketConfig;
import org.glassfish.tyrus.test.tools.TestContainer;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.junit4.SpringRunner;

import static org.glassfish.tyrus.client.ClientProperties.SSL_ENGINE_CONFIGURATOR;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;

/**
* This tests that a correct Origin is sent when working with a wss:// connection.
* A Spring Boot application is started to easily start a TLS-protected Websocket server that
* verifies Origin header.
*
* @author Roman Puchkovskiy
*/
@SpringBootTest(classes = {WssApplication.class, WebSocketConfig.class}, webEnvironment = RANDOM_PORT)
@RunWith(SpringRunner.class)
public class WssOriginTest extends TestContainer {
@LocalServerPort
private int serverPort;

@Test
public void wssConnectionToServerValidatingOriginShouldWork() throws Exception {
final ClientEndpointConfig cec = ClientEndpointConfig.Builder.create()
.build();

ClientManager client = createClient();
client.getProperties().put(SSL_ENGINE_CONFIGURATOR, createSslEngineConfigurator());

client.connectToServer(new Endpoint() {
@Override
public void onOpen(final Session session, EndpointConfig EndpointConfig) {
}
}, cec, new URI("wss://localhost:" + serverPort + "/hello"));
}

private SslEngineConfigurator createSslEngineConfigurator() {
return createTrustAllSslEngineConfigurator();
}

private SslEngineConfigurator createTrustAllSslEngineConfigurator() {
try {
SSLContext ctx = SSLContext.getInstance("TLS");

ctx.init(null, new TrustManager[]{new DisabledX509TrustManager()}, null);

SslEngineConfigurator sslEngineConfigurator = new SslEngineConfigurator(ctx, true, false, false);

sslEngineConfigurator.setHostVerificationEnabled(false);

return sslEngineConfigurator;
} catch (NoSuchAlgorithmException | KeyManagementException e) {
throw new IllegalStateException(e);
}
}

private static class DisabledX509TrustManager implements X509TrustManager {
private static final X509Certificate[] CERTS = new X509Certificate[0];

@Override
public void checkClientTrusted(X509Certificate[] x509Certificates, String s)
throws CertificateException {
// No-op, all clients are trusted.
}

@Override
public void checkServerTrusted(X509Certificate[] x509Certificates, String s)
throws CertificateException {
// No-op, all servers are trusted.
}

@Override
public X509Certificate[] getAcceptedIssuers() {
return CERTS;
}
}
}
//import javax.net.ssl.SSLContext;
//import javax.net.ssl.TrustManager;
//import javax.net.ssl.X509TrustManager;
//import javax.websocket.ClientEndpointConfig;
//import javax.websocket.Endpoint;
//import javax.websocket.EndpointConfig;
//import javax.websocket.Session;
//import java.net.URI;
//import java.security.KeyManagementException;
//import java.security.NoSuchAlgorithmException;
//import java.security.cert.CertificateException;
//import java.security.cert.X509Certificate;
//
//import org.glassfish.tyrus.client.ClientManager;
//import org.glassfish.tyrus.client.SslEngineConfigurator;
//import org.glassfish.tyrus.test.standard_config.springboot.WebSocketConfig;
//import org.glassfish.tyrus.test.tools.TestContainer;
//
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.boot.web.server.LocalServerPort;
//import org.springframework.test.context.junit4.SpringRunner;
//
//import static org.glassfish.tyrus.client.ClientProperties.SSL_ENGINE_CONFIGURATOR;
//import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
//
///**
// * This tests that a correct Origin is sent when working with a wss:// connection.
// * A Spring Boot application is started to easily start a TLS-protected Websocket server that
// * verifies Origin header.
// *
// * @author Roman Puchkovskiy
// */
//@SpringBootTest(classes = {WssApplication.class, WebSocketConfig.class}, webEnvironment = RANDOM_PORT)
//@RunWith(SpringRunner.class)
//public class WssOriginTest extends TestContainer {
// @LocalServerPort
// private int serverPort;
//
// @Test
// public void wssConnectionToServerValidatingOriginShouldWork() throws Exception {
// final ClientEndpointConfig cec = ClientEndpointConfig.Builder.create()
// .build();
//
// ClientManager client = createClient();
// client.getProperties().put(SSL_ENGINE_CONFIGURATOR, createSslEngineConfigurator());
//
// client.connectToServer(new Endpoint() {
// @Override
// public void onOpen(final Session session, EndpointConfig EndpointConfig) {
// }
// }, cec, new URI("wss://localhost:" + serverPort + "/hello"));
// }
//
// private SslEngineConfigurator createSslEngineConfigurator() {
// return createTrustAllSslEngineConfigurator();
// }
//
// private SslEngineConfigurator createTrustAllSslEngineConfigurator() {
// try {
// SSLContext ctx = SSLContext.getInstance("TLS");
//
// ctx.init(null, new TrustManager[]{new DisabledX509TrustManager()}, null);
//
// SslEngineConfigurator sslEngineConfigurator = new SslEngineConfigurator(ctx, true, false, false);
//
// sslEngineConfigurator.setHostVerificationEnabled(false);
//
// return sslEngineConfigurator;
// } catch (NoSuchAlgorithmException | KeyManagementException e) {
// throw new IllegalStateException(e);
// }
// }
//
// private static class DisabledX509TrustManager implements X509TrustManager {
// private static final X509Certificate[] CERTS = new X509Certificate[0];
//
// @Override
// public void checkClientTrusted(X509Certificate[] x509Certificates, String s)
// throws CertificateException {
// // No-op, all clients are trusted.
// }
//
// @Override
// public void checkServerTrusted(X509Certificate[] x509Certificates, String s)
// throws CertificateException {
// // No-op, all servers are trusted.
// }
//
// @Override
// public X509Certificate[] getAcceptedIssuers() {
// return CERTS;
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@

package org.glassfish.tyrus.test.standard_config.springboot;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

/**
* Spring Config for {@link org.glassfish.tyrus.test.standard_config.WssOriginTest}.
*
* @author Roman Puchkovskiy
*/
@Configuration
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/hello");
}
}
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
//import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
//
///**
// * Spring Config for {@link org.glassfish.tyrus.test.standard_config.WssOriginTest}.
// *
// * @author Roman Puchkovskiy
// */
//@Configuration
//public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
// @Override
// public void registerStompEndpoints(StompEndpointRegistry registry) {
// registry.addEndpoint("/hello");
// }
//}

0 comments on commit a21b621

Please sign in to comment.