Skip to content

Commit

Permalink
Add checks for response status code to IntegrationTestUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianhoelzl-sap committed May 8, 2024
1 parent ccf185b commit 884416d
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.util.RandomValueStringGenerator;
import org.cloudfoundry.identity.uaa.client.UaaClientDetails;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
Expand Down Expand Up @@ -503,6 +502,9 @@ public static ScimGroup createGroup(String token,
String zoneId,
String url,
ScimGroup group) {
assertNotNull(group.getDisplayName());
assertFalse(group.getDisplayName().isBlank());

RestTemplate template = new RestTemplate();
template.setErrorHandler(fiveHundredErrorHandler);
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
Expand All @@ -518,6 +520,7 @@ public static ScimGroup createGroup(String token,
new HttpEntity<>(JsonUtils.writeValueAsBytes(group), headers),
ScimGroup.class
);
assertTrue(createGroup.getStatusCode().is2xxSuccessful());
return createGroup.getBody();
}

Expand Down Expand Up @@ -621,6 +624,7 @@ private static IdentityZone createZoneOrUpdateSubdomain(RestTemplate client,
existing.setActive(active);
HttpEntity<IdentityZone> updateZoneRequest = new HttpEntity<>(existing);
ResponseEntity<String> getUpdatedZone = client.exchange(url + "/identity-zones/{id}", HttpMethod.PUT, updateZoneRequest, String.class, id);
assertTrue(getUpdatedZone.getStatusCode().is2xxSuccessful());
return JsonUtils.readValue(getUpdatedZone.getBody(), IdentityZone.class);
}

Expand All @@ -632,6 +636,7 @@ private static IdentityZone createZoneOrUpdateSubdomain(RestTemplate client,
identityZone.setConfig(config);
identityZone.setActive(active);
ResponseEntity<IdentityZone> zone = client.postForEntity(url + "/identity-zones", identityZone, IdentityZone.class);
assertTrue(zone.getStatusCode().is2xxSuccessful());
return zone.getBody();
}

Expand Down Expand Up @@ -1136,8 +1141,8 @@ public static HttpHeaders getHeaders(CookieStore cookies) {
headers.add("Cookie", cookie.getName() + "=" + cookie.getValue());
}
return headers;
}
}

public static String getAuthorizationResponse(ServerRunning serverRunning,
String clientId,
String username,
Expand Down Expand Up @@ -1228,7 +1233,7 @@ public static String getAuthorizationResponse(ServerRunning serverRunning,
}
return location;
}

public static ResponseEntity<Map> getTokens(ServerRunning serverRunning,
UaaTestAccounts testAccounts,
String clientId,
Expand Down

0 comments on commit 884416d

Please sign in to comment.