Skip to content

Commit

Permalink
reset ssl context in test
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Hernán Carle <[email protected]>
  • Loading branch information
Pablo Hernán Carle committed Sep 26, 2024
1 parent 6fda9e5 commit cc8ba1b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ public class SslContext {
private static AtomicBoolean isInitialized = new AtomicBoolean(false);
private static AtomicReference<SslContextConfigurer> configurer = new AtomicReference<>();

public synchronized static void reset() {
clientCertValid = null;
clientCertApiml = null;
clientCertUser = null;
clientCertUnknownUser = null;
apimlRootCert = null;
selfSignedUntrusted = null;
tlsWithoutCert = null;
configurer.set(null);
isInitialized.set(false);
}

public synchronized static void prepareSslAuthentication(SslContextConfigurer providedConfigurer) throws Exception {

if (configurer.get() != null && !configurer.get().equals(providedConfigurer)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
package org.zowe.apiml.discovery.eureka;

import io.restassured.http.ContentType;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ActiveProfiles;
Expand All @@ -24,6 +28,7 @@
import static org.hamcrest.core.IsEqual.equalTo;

@ActiveProfiles("https")
@TestInstance(Lifecycle.PER_CLASS)
public class EurekaEndpointTest extends DiscoveryFunctionalTest {

@Value("${server.ssl.keyPassword}")
Expand All @@ -39,6 +44,16 @@ void setup() throws Exception {
SslContext.prepareSslAuthentication(configurer);
}

@BeforeAll
void init() {
SslContext.reset();
}

@AfterAll
void tearDown() {
SslContext.reset();
}

@Override
protected String getProtocol() {
return "https";
Expand Down

0 comments on commit cc8ba1b

Please sign in to comment.