From 78b7dc33d6ddf9fbe5d0aeccf6e540fc3110e1d5 Mon Sep 17 00:00:00 2001 From: hemantxpatel Date: Mon, 29 Apr 2024 12:57:42 +0530 Subject: [PATCH 1/2] fix: STS Token API Response --- .../controller/SecureTokenController.java | 2 +- .../managedidentitywallets/domain/StsTokenResponse.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/eclipse/tractusx/managedidentitywallets/controller/SecureTokenController.java b/src/main/java/org/eclipse/tractusx/managedidentitywallets/controller/SecureTokenController.java index 82e74e1e9..1027d6f48 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/controller/SecureTokenController.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/controller/SecureTokenController.java @@ -139,7 +139,7 @@ private ResponseEntity processTokenRequest(SecureTokenRequest .token(responseJwt.serialize()) .expiresAt(responseJwt.getJWTClaimsSet().getExpirationTime().getTime()) .build(); - return ResponseEntity.status(HttpStatus.CREATED).body(response); + return ResponseEntity.status(HttpStatus.OK).body(response); } @ExceptionHandler({ UnsupportedGrantTypeException.class, InvalidSecureTokenRequestException.class, UnknownBusinessPartnerNumberException.class, InvalidIdpTokenResponseException.class }) diff --git a/src/main/java/org/eclipse/tractusx/managedidentitywallets/domain/StsTokenResponse.java b/src/main/java/org/eclipse/tractusx/managedidentitywallets/domain/StsTokenResponse.java index 2e78cfff0..50161b118 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/domain/StsTokenResponse.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/domain/StsTokenResponse.java @@ -21,6 +21,7 @@ package org.eclipse.tractusx.managedidentitywallets.domain; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -33,6 +34,9 @@ @NoArgsConstructor @AllArgsConstructor public class StsTokenResponse { + + @JsonProperty("access_token") private String token; + private long expiresAt; } From 8eda499476604ee14001811df3c01297bd3e7f7a Mon Sep 17 00:00:00 2001 From: hemantxpatel Date: Mon, 29 Apr 2024 13:14:53 +0530 Subject: [PATCH 2/2] fix: Test Cases --- .../controller/SecureTokenControllerTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/controller/SecureTokenControllerTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/controller/SecureTokenControllerTest.java index 768b4db2a..58dc11653 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/controller/SecureTokenControllerTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/controller/SecureTokenControllerTest.java @@ -104,10 +104,10 @@ void tokenJSON() { new ParameterizedTypeReference<>() { } ); - Assertions.assertEquals(response.getStatusCode(), HttpStatus.CREATED); + Assertions.assertEquals(response.getStatusCode(), HttpStatus.OK); Assertions.assertEquals(response.getHeaders().getContentType(), MediaType.APPLICATION_JSON); Assertions.assertNotNull(response.getBody()); - Assertions.assertNotNull(response.getBody().getOrDefault("token", null)); + Assertions.assertNotNull(response.getBody().getOrDefault("access_token", null)); Assertions.assertNotNull(response.getBody().getOrDefault("expiresAt", null)); } @@ -127,10 +127,10 @@ void tokenFormUrlencoded() { new ParameterizedTypeReference<>() { } ); - Assertions.assertEquals(response.getStatusCode(), HttpStatus.CREATED); + Assertions.assertEquals(response.getStatusCode(), HttpStatus.OK); Assertions.assertEquals(response.getHeaders().getContentType(), MediaType.APPLICATION_JSON); Assertions.assertNotNull(response.getBody()); - Assertions.assertNotNull(response.getBody().getOrDefault("token", null)); + Assertions.assertNotNull(response.getBody().getOrDefault("access_token", null)); Assertions.assertNotNull(response.getBody().getOrDefault("expiresAt", null)); } }