Make security of Kubernetes Nodeport svc for integr tests configurable (#455)
This commit is contained in:
committed by
Ryan Baxter
parent
702c7b2ee8
commit
c452b02de2
@@ -35,10 +35,13 @@ public class ServicesIT {
|
||||
private static final Integer PORT = Integer
|
||||
.valueOf(System.getProperty("service.port"));
|
||||
|
||||
private static final String PROTOCOL = "true"
|
||||
.equalsIgnoreCase(System.getProperty("service.secure")) ? "https" : "http";
|
||||
|
||||
@Test
|
||||
public void testServicesEndpoint() {
|
||||
given().baseUri(String.format("https://%s:%d", HOST, PORT)).get("services").then()
|
||||
.statusCode(200).body(new StringContains("service-a") {
|
||||
given().baseUri(String.format("%s://%s:%d", PROTOCOL, HOST, PORT)).get("services")
|
||||
.then().statusCode(200).body(new StringContains("service-a") {
|
||||
@Override
|
||||
protected boolean evalSubstringOf(String s) {
|
||||
return s.contains("service-a") && s.contains("service-b");
|
||||
@@ -48,7 +51,7 @@ public class ServicesIT {
|
||||
|
||||
@Test
|
||||
public void testInstancesEndpoint() {
|
||||
given().baseUri(String.format("https://%s:%d", HOST, PORT))
|
||||
given().baseUri(String.format("%s://%s:%d", PROTOCOL, HOST, PORT))
|
||||
.get("services/discovery-service-a/instances").then().statusCode(200)
|
||||
.body("instanceId", hasSize(1))
|
||||
.body("serviceId", hasItems("discovery-service-a"));
|
||||
|
||||
@@ -33,10 +33,13 @@ public class ProfilesIT {
|
||||
private static final Integer PORT = Integer
|
||||
.valueOf(System.getProperty("service.port"));
|
||||
|
||||
private static final String PROTOCOL = "true"
|
||||
.equalsIgnoreCase(System.getProperty("service.secure")) ? "https" : "http";
|
||||
|
||||
@Test
|
||||
public void testProfileEndpoint() {
|
||||
given().baseUri(String.format("https://%s:%d", HOST, PORT)).get("profiles").then()
|
||||
.statusCode(200).body(new StringContains("istio"));
|
||||
given().baseUri(String.format("%s://%s:%d", PROTOCOL, HOST, PORT)).get("profiles")
|
||||
.then().statusCode(200).body(new StringContains("istio"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
<systemPropertyVariables>
|
||||
<service.host>localhost</service.host>
|
||||
<service.port>${nodeport.value}</service.port>
|
||||
<service.secure>false</service.secure>
|
||||
</systemPropertyVariables>
|
||||
<classesDirectory>${project.build.outputDirectory}
|
||||
</classesDirectory>
|
||||
@@ -130,7 +131,7 @@
|
||||
<modules>
|
||||
<module>simple-core</module>
|
||||
<module>simple-configmap</module>
|
||||
<module>istio</module>
|
||||
<!-- <module>istio</module>-->
|
||||
<module>discovery</module>
|
||||
</modules>
|
||||
|
||||
|
||||
@@ -37,10 +37,13 @@ public class GreetingIT {
|
||||
private static final Integer PORT = Integer
|
||||
.valueOf(System.getProperty("service.port"));
|
||||
|
||||
private static final String PROTOCOL = "true"
|
||||
.equalsIgnoreCase(System.getProperty("service.secure")) ? "https" : "http";
|
||||
|
||||
@Test
|
||||
public void firstTestThatTheDefaultMessageIsReturned() {
|
||||
given().baseUri(String.format("https://%s:%d", HOST, PORT)).get("greeting").then()
|
||||
.statusCode(200).body("message", is("This is a dummy message"));
|
||||
given().baseUri(String.format("%s://%s:%d", PROTOCOL, HOST, PORT)).get("greeting")
|
||||
.then().statusCode(200).body("message", is("This is a dummy message"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,8 +51,8 @@ public class GreetingIT {
|
||||
public void thenApplyAConfigMapAndEnsureThatTheMessageIsUpdated() {
|
||||
waitForApplicationToReload();
|
||||
|
||||
given().baseUri(String.format("https://%s:%d", HOST, PORT)).get("greeting").then()
|
||||
.statusCode(200)
|
||||
given().baseUri(String.format("%s://%s:%d", PROTOCOL, HOST, PORT)).get("greeting")
|
||||
.then().statusCode(200)
|
||||
.body("message", is("Hello from Spring Cloud Kubernetes!"));
|
||||
}
|
||||
|
||||
|
||||
@@ -33,15 +33,18 @@ public class GreetingAndHealthIT {
|
||||
private static final Integer PORT = Integer
|
||||
.valueOf(System.getProperty("service.port"));
|
||||
|
||||
private static final String PROTOCOL = "true"
|
||||
.equalsIgnoreCase(System.getProperty("service.secure")) ? "https" : "http";
|
||||
|
||||
@Test
|
||||
public void testGreetingEndpoint() {
|
||||
given().baseUri(String.format("https://%s:%d", HOST, PORT)).get("greeting").then()
|
||||
.statusCode(200).body("message", is("Hello from k8s"));
|
||||
given().baseUri(String.format("%s://%s:%d", PROTOCOL, HOST, PORT)).get("greeting")
|
||||
.then().statusCode(200).body("message", is("Hello from k8s"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHealthEndpoint() {
|
||||
given().baseUri(String.format("https://%s:%d", HOST, PORT))
|
||||
given().baseUri(String.format("%s://%s:%d", PROTOCOL, HOST, PORT))
|
||||
.contentType("application/json").get("actuator/health").then()
|
||||
.statusCode(200).body("details.kubernetes.details.inside", is(true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user