@@ -55,7 +55,7 @@ public void givenEndpoint_whenQueryStockPrice_thenPriceCorrect() {
5555 public void givenKongAdminAPI_whenAddAPI_thenAPIAccessibleViaKong () throws Exception {
5656 restTemplate .delete ("http://localhost:8001/apis/stock-api" );
5757
58- APIObject stockAPI = new APIObject ("stock-api" , "stock.api" , "http://localhost:8080 " , "/" );
58+ APIObject stockAPI = new APIObject ("stock-api" , "stock.api" , "http://localhost:9090 " , "/" );
5959 HttpEntity <APIObject > apiEntity = new HttpEntity <>(stockAPI );
6060 ResponseEntity <String > addAPIResp = restTemplate .postForEntity ("http://localhost:8001/apis" , apiEntity , String .class );
6161
@@ -69,7 +69,7 @@ public void givenKongAdminAPI_whenAddAPI_thenAPIAccessibleViaKong() throws Excep
6969
7070 HttpHeaders headers = new HttpHeaders ();
7171 headers .set ("Host" , "stock.api" );
72- RequestEntity <String > requestEntity = new RequestEntity <>(headers , HttpMethod .GET , new URI ("http://localhost:8000/stock/btc" ));
72+ RequestEntity <String > requestEntity = new RequestEntity <>(headers , HttpMethod .GET , new URI ("http://localhost:8000/springbootapp/ stock/btc" ));
7373 ResponseEntity <String > stockPriceResp = restTemplate .exchange (requestEntity , String .class );
7474
7575 assertEquals ("10000" , stockPriceResp .getBody ());
@@ -126,22 +126,26 @@ public void givenAPIAuthEnabled_whenAddKey_thenAccessAllowed() throws Exception
126126 givenKongAdminAPI_whenAddAPIConsumer_thenAdded ();
127127 }
128128
129+ PluginObject authPlugin = new PluginObject ("key-auth" );
130+ ResponseEntity <String > enableAuthResp = restTemplate .postForEntity ("http://localhost:8001/apis/stock-api/plugins" , new HttpEntity <>(authPlugin ), String .class );
131+ assertTrue (HttpStatus .CREATED == enableAuthResp .getStatusCode () || HttpStatus .CONFLICT == enableAuthResp .getStatusCode ());
132+
129133 final String consumerKey = "eugenp.pass" ;
130134 KeyAuthObject keyAuth = new KeyAuthObject (consumerKey );
131135 ResponseEntity <String > keyAuthResp = restTemplate .postForEntity ("http://localhost:8001/consumers/eugenp/key-auth" , new HttpEntity <>(keyAuth ), String .class );
132-
136+
133137 assertTrue (HttpStatus .CREATED == keyAuthResp .getStatusCode () || HttpStatus .CONFLICT == keyAuthResp .getStatusCode ());
134138
135139 HttpHeaders headers = new HttpHeaders ();
136140 headers .set ("Host" , "stock.api" );
137141 headers .set ("apikey" , consumerKey );
138- RequestEntity <String > requestEntity = new RequestEntity <>(headers , HttpMethod .GET , new URI ("http://localhost:8000/stock/btc" ));
142+ RequestEntity <String > requestEntity = new RequestEntity <>(headers , HttpMethod .GET , new URI ("http://localhost:8000/springbootapp/ stock/btc" ));
139143 ResponseEntity <String > stockPriceResp = restTemplate .exchange (requestEntity , String .class );
140144
141145 assertEquals ("10000" , stockPriceResp .getBody ());
142146
143147 headers .set ("apikey" , "wrongpass" );
144- requestEntity = new RequestEntity <>(headers , HttpMethod .GET , new URI ("http://localhost:8000/stock/btc" ));
148+ requestEntity = new RequestEntity <>(headers , HttpMethod .GET , new URI ("http://localhost:8000/springbootapp/ stock/btc" ));
145149 stockPriceResp = restTemplate .exchange (requestEntity , String .class );
146150 assertEquals (HttpStatus .FORBIDDEN , stockPriceResp .getStatusCode ());
147151 }
0 commit comments