Skip to content

Commit

Permalink
fix failing ApiCatalogEndpointIntegrationTest
Browse files Browse the repository at this point in the history
Signed-off-by: nx673747 <[email protected]>
  • Loading branch information
nx673747 committed Jan 28, 2025
1 parent 4145997 commit 3be3642
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@

import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;
import java.util.stream.Stream;

import static io.restassured.RestAssured.given;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
Expand All @@ -63,7 +67,7 @@ class ApiCatalogEndpointIntegrationTest implements TestWithStartedInstances {
private final static String USERNAME = ConfigReader.environmentConfiguration().getAuxiliaryUserList().getCredentials("servicesinfo-authorized").get(0).getUser();
private final static String PASSWORD = ConfigReader.environmentConfiguration().getAuxiliaryUserList().getCredentials("servicesinfo-authorized").get(0).getPassword();

private String baseHost;
private final List<String> baseHosts = new ArrayList<>();
private String validGatewayToken;
private String unauthorizedGatewayToken;

Expand All @@ -76,9 +80,9 @@ void init() {
@BeforeEach
void setUp() {
GatewayServiceConfiguration gatewayServiceConfiguration = ConfigReader.environmentConfiguration().getGatewayServiceConfiguration();
String host = gatewayServiceConfiguration.getHost();
int port = gatewayServiceConfiguration.getExternalPort();
baseHost = host + ":" + port;
Stream.of(gatewayServiceConfiguration.getHost().split(","))
.forEach(host -> baseHosts.add(host + ":" + port));
}

@Nested
Expand Down Expand Up @@ -149,7 +153,9 @@ void whenSpecificCatalogApiDoc() throws Exception {
// Then
assertFalse(paths.isEmpty(), apiCatalogSwagger);
assertFalse(componentSchemas.isEmpty(), apiCatalogSwagger);
assertEquals("https://" + baseHost + "/apicatalog/api/v1", swaggerServer, apiCatalogSwagger);
assertThat(apiCatalogSwagger, baseHosts.stream()
.map(host -> "https://" + host + "/apicatalog/api/v1")
.toList(), hasItem(equalTo(swaggerServer)));
assertNull(paths.get("/status/updates"), apiCatalogSwagger);
assertNotNull(paths.get("/containers/{id}"), apiCatalogSwagger);
assertNotNull(paths.get("/containers"), apiCatalogSwagger);
Expand Down Expand Up @@ -182,7 +188,9 @@ void whenDefaultCatalogApiDoc() throws Exception {
// Then
assertFalse(paths.isEmpty(), apiCatalogSwagger);
assertFalse(componentSchemas.isEmpty(), apiCatalogSwagger);
assertEquals("https://" + baseHost + "/apicatalog/api/v1", swaggerServer, apiCatalogSwagger);
assertThat(apiCatalogSwagger, baseHosts.stream()
.map(host -> "https://" + host + "/apicatalog/api/v1")
.toList(), hasItem(equalTo(swaggerServer)));
assertNull(paths.get("/status/updates"), apiCatalogSwagger);
assertNotNull(paths.get("/containers/{id}"), apiCatalogSwagger);
assertNotNull(paths.get("/containers"), apiCatalogSwagger);
Expand Down

0 comments on commit 3be3642

Please sign in to comment.