File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed
main/java/de/gdata/vaas/authentication
test/java/de/gdata/test/integration Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 22
33import com .google .gson .JsonObject ;
44import com .google .gson .JsonParser ;
5-
6- import de .gdata .vaas .CompletableFutureExceptionHandler ;
75import de .gdata .vaas .exceptions .VaasAuthenticationException ;
86import lombok .NonNull ;
97import org .jetbrains .annotations .NotNull ;
108
11- import java .io .IOException ;
129import java .net .URI ;
13- import java .net .URISyntaxException ;
1410import java .net .http .HttpClient ;
1511import java .net .http .HttpRequest ;
1612import java .net .http .HttpResponse ;
@@ -39,8 +35,8 @@ public TokenReceiver(@NotNull URI tokenUrl) {
3935 this (tokenUrl , HttpClient .newHttpClient ());
4036 }
4137
42- public TokenReceiver () throws URISyntaxException {
43- this (new URI ("https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" ),
38+ public TokenReceiver () {
39+ this (URI . create ("https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token" ),
4440 HttpClient .newHttpClient ());
4541 }
4642
Original file line number Diff line number Diff line change @@ -238,6 +238,8 @@ public void forSha256_IfBadRequest_ThrowsVaasClientException() throws Exception
238238 when (mockResponse .statusCode ()).thenReturn (400 );
239239 when (mockHttpClient .sendAsync (any (HttpRequest .class ), any (HttpResponse .BodyHandler .class )))
240240 .thenAnswer (invocation -> CompletableFuture .completedFuture (mockResponse ));
241+ when (mockResponse .body ()).thenReturn (
242+ new Gson ().toJson (new ProblemDetails ("VaasClientException" , "Bad Request" )));
241243
242244 vaas = getVaasWithCredentials (mockHttpClient );
243245
@@ -271,10 +273,10 @@ public void forSha256_IfUnauthorized_ThrowsVaasAuthenticationException() throws
271273 when (mockHttpClient .sendAsync (any (HttpRequest .class ), any (HttpResponse .BodyHandler .class )))
272274 .thenAnswer (invocation -> CompletableFuture .completedFuture (mockResponse ));
273275
274- vaas = getVaasWithCredentials (mockHttpClient );
276+ var authenticator = getAuthenticator (mockHttpClient );
277+ vaas = getVaasWithCredentials (authenticator );
275278
276- var exception = assertThrows (CompletionException .class , () -> vaas .forSha256Async (sha256 ).join ());
277- assertInstanceOf (VaasAuthenticationException .class , exception .getCause ());
279+ assertThrows (VaasAuthenticationException .class , () -> vaas .forSha256Async (sha256 ).join ());
278280 }
279281
280282 @ SuppressWarnings ("unchecked" )
You can’t perform that action at this time.
0 commit comments