From cd6661e1179265c88df90806431fa933d9553c65 Mon Sep 17 00:00:00 2001 From: timis1 <12120641+timis1@users.noreply.github.com> Date: Thu, 29 Jun 2023 11:26:08 +0300 Subject: [PATCH] JAVA-100003 Removed apis from Kong Co-authored-by: timis1 --- .../baeldung/kong/KongAdminAPILiveTest.java | 22 +++++++++---------- .../kong/KongLoadBalanceLiveTest.java | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java index 92d2286518..019d39f590 100644 --- a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java +++ b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/KongAdminAPILiveTest.java @@ -53,17 +53,17 @@ public class KongAdminAPILiveTest { @Test public void givenKongAdminAPI_whenAddAPI_thenAPIAccessibleViaKong() throws Exception { - restTemplate.delete("http://localhost:8001/apis/stock-api"); + restTemplate.delete("http://localhost:8001/stock-api"); APIObject stockAPI = new APIObject("stock-api", "stock.api", "http://localhost:9090", "/"); HttpEntity apiEntity = new HttpEntity<>(stockAPI); - ResponseEntity addAPIResp = restTemplate.postForEntity("http://localhost:8001/apis", apiEntity, String.class); + ResponseEntity addAPIResp = restTemplate.postForEntity("http://localhost:8001", apiEntity, String.class); assertEquals(HttpStatus.CREATED, addAPIResp.getStatusCode()); - addAPIResp = restTemplate.postForEntity("http://localhost:8001/apis", apiEntity, String.class); + addAPIResp = restTemplate.postForEntity("http://localhost:8001", apiEntity, String.class); assertEquals(HttpStatus.CONFLICT, addAPIResp.getStatusCode()); - String apiListResp = restTemplate.getForObject("http://localhost:8001/apis/", String.class); + String apiListResp = restTemplate.getForObject("http://localhost:8001/", String.class); assertTrue(apiListResp.contains("stock-api")); @@ -94,17 +94,17 @@ public class KongAdminAPILiveTest { @Test public void givenAPI_whenEnableAuth_thenAnonymousDenied() throws Exception { - String apiListResp = restTemplate.getForObject("http://localhost:8001/apis/", String.class); + String apiListResp = restTemplate.getForObject("http://localhost:8001/", String.class); if (!apiListResp.contains("stock-api")) { givenKongAdminAPI_whenAddAPI_thenAPIAccessibleViaKong(); } PluginObject authPlugin = new PluginObject("key-auth"); - ResponseEntity enableAuthResp = restTemplate.postForEntity("http://localhost:8001/apis/stock-api/plugins", new HttpEntity<>(authPlugin), String.class); + ResponseEntity enableAuthResp = restTemplate.postForEntity("http://localhost:8001/stock-api/plugins", new HttpEntity<>(authPlugin), String.class); assertTrue(HttpStatus.CREATED == enableAuthResp.getStatusCode() || HttpStatus.CONFLICT == enableAuthResp.getStatusCode()); - String pluginsResp = restTemplate.getForObject("http://localhost:8001/apis/stock-api/plugins", String.class); + String pluginsResp = restTemplate.getForObject("http://localhost:8001/stock-api/plugins", String.class); assertTrue(pluginsResp.contains("key-auth")); HttpHeaders headers = new HttpHeaders(); @@ -116,7 +116,7 @@ public class KongAdminAPILiveTest { @Test public void givenAPIAuthEnabled_whenAddKey_thenAccessAllowed() throws Exception { - String apiListResp = restTemplate.getForObject("http://localhost:8001/apis/", String.class); + String apiListResp = restTemplate.getForObject("http://localhost:8001/", String.class); if (!apiListResp.contains("stock-api")) { givenKongAdminAPI_whenAddAPI_thenAPIAccessibleViaKong(); } @@ -127,7 +127,7 @@ public class KongAdminAPILiveTest { } PluginObject authPlugin = new PluginObject("key-auth"); - ResponseEntity enableAuthResp = restTemplate.postForEntity("http://localhost:8001/apis/stock-api/plugins", new HttpEntity<>(authPlugin), String.class); + ResponseEntity enableAuthResp = restTemplate.postForEntity("http://localhost:8001/stock-api/plugins", new HttpEntity<>(authPlugin), String.class); assertTrue(HttpStatus.CREATED == enableAuthResp.getStatusCode() || HttpStatus.CONFLICT == enableAuthResp.getStatusCode()); final String consumerKey = "eugenp.pass"; @@ -154,14 +154,14 @@ public class KongAdminAPILiveTest { public void givenAdminAPIProxy_whenAddAPIViaProxy_thenAPIAdded() throws Exception { APIObject adminAPI = new APIObject("admin-api", "admin.api", "http://localhost:8001", "/admin-api"); HttpEntity apiEntity = new HttpEntity<>(adminAPI); - ResponseEntity addAPIResp = restTemplate.postForEntity("http://localhost:8001/apis", apiEntity, String.class); + ResponseEntity addAPIResp = restTemplate.postForEntity("http://localhost:8001", apiEntity, String.class); assertTrue(HttpStatus.CREATED == addAPIResp.getStatusCode() || HttpStatus.CONFLICT == addAPIResp.getStatusCode()); HttpHeaders headers = new HttpHeaders(); headers.set("Host", "admin.api"); APIObject baeldungAPI = new APIObject("baeldung-api", "baeldung.com", "http://ww.baeldung.com", "/"); - RequestEntity requestEntity = new RequestEntity<>(baeldungAPI, headers, HttpMethod.POST, new URI("http://localhost:8000/admin-api/apis")); + RequestEntity requestEntity = new RequestEntity<>(baeldungAPI, headers, HttpMethod.POST, new URI("http://localhost:8000/admin-api")); addAPIResp = restTemplate.exchange(requestEntity, String.class); assertTrue(HttpStatus.CREATED == addAPIResp.getStatusCode() || HttpStatus.CONFLICT == addAPIResp.getStatusCode()); diff --git a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java index 7cf67453a6..13e741eb46 100644 --- a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java +++ b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/kong/KongLoadBalanceLiveTest.java @@ -55,7 +55,7 @@ public class KongLoadBalanceLiveTest { APIObject stockAPI = new APIObject("balanced-stock-api", "balanced.stock.api", "http://stock.api.service", "/"); HttpEntity apiEntity = new HttpEntity<>(stockAPI); - ResponseEntity addAPIResp = restTemplate.postForEntity("http://localhost:8001/apis", apiEntity, String.class); + ResponseEntity addAPIResp = restTemplate.postForEntity("http://localhost:8001", apiEntity, String.class); assertTrue(HttpStatus.CREATED == addAPIResp.getStatusCode() || HttpStatus.CONFLICT == addAPIResp.getStatusCode()); HttpHeaders headers = new HttpHeaders();