Skip to content

Commit

Permalink
fix zosmf mock service support for ltpa tokens in auth header
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Salac <[email protected]>
  • Loading branch information
richard-salac committed Feb 21, 2025
1 parent bd70161 commit f831f7a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static Stream<Arguments> schemas() {
var schemasTest = new ArrayList<Arguments>();
schemasTest.add(Arguments.of("zowejwt", HttpRequestUtils.getUriFromGateway(ZOWE_JWT_REQUEST), (Consumer<Response>) r -> {
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
assertNull(r.getBody().path("headers.authorization"));
assertNotNull(r.getBody().path("headers.authorization"));
assertThat(r.getBody().path("headers.cookie"), containsString(COOKIE_NAME));
String jwt = r.getBody().path("headers.cookie").toString();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ static Stream<Arguments> validToBeTransformed() {
List<Arguments> arguments = new ArrayList<>(Arrays.asList(
Arguments.of("Zowe auth scheme", ZOWE_JWT_REQUEST, (Consumer<Response>) response -> {
assertNotNull(response.jsonPath().getString("cookies.apimlAuthenticationToken"), "Expected not null apimlAuthenticationToken. Response was: " + response.asPrettyString());
assertNull(response.jsonPath().getString("headers.authorization"), "Expected null Authorization header. Response was: " + response.asPrettyString());
assertNotNull(response.jsonPath().getString("headers.authorization"), "Expected not null Authorization header. Response was: " + response.asPrettyString());
assertTrue(CollectionUtils.isEmpty(response.jsonPath().getList("certs")), "Expected empty certs list. Response was: " + response.asPrettyString());
}),
Arguments.of("z/OSMF auth scheme", ZOSMF_REQUEST, (Consumer<Response>) response -> {
assertNotNull(response.jsonPath().getString("cookies.jwtToken"), "Expected not null jwtToken cookie. Response was: " + response.asPrettyString());
assertNull(response.jsonPath().getString("headers.authorization"), "Expected null Authorization header. Response was: " + response.asPrettyString());
assertNotNull(response.jsonPath().getString("headers.authorization"), "Expected not null Authorization header. Response was: " + response.asPrettyString());
assertTrue(CollectionUtils.isEmpty(response.jsonPath().getList("certs")), "Expected empty certs list. Response was: " + response.asPrettyString());
}),
Arguments.of("PassTicket auth scheme", REQUEST_INFO_ENDPOINT, (Consumer<Response>) response -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected ResponseEntity<?> handleFiles(Map<String, String> headers) {
String authorization = headers.get(AUTHORIZATION_HEADER);

if (authorization != null) {
if (!isValidAuthHeader(authorization)) {
if (!isValidAuthHeader(authorization) && !ltpaIsPresent(headers)) {
return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
}
} else {
Expand Down

0 comments on commit f831f7a

Please sign in to comment.