Skip to content

Commit

Permalink
Merge pull request #293 from sap-contributions/fix/sts-token-api
Browse files Browse the repository at this point in the history
Fix STS Token API Response
  • Loading branch information
borisrizov-zf authored May 2, 2024
2 parents b242a3d + 8eda499 commit 6b1b541
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private ResponseEntity<StsTokenResponse> 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 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,6 +34,9 @@
@NoArgsConstructor
@AllArgsConstructor
public class StsTokenResponse {

@JsonProperty("access_token")
private String token;

private long expiresAt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand All @@ -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));
}
}

0 comments on commit 6b1b541

Please sign in to comment.