Skip to content

Commit

Permalink
Add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
madurangasiriwardena committed Jan 18, 2025
1 parent 881ad9f commit ab98f10
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import io.restassured.http.ContentType;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.Header;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.message.BasicHeader;
Expand All @@ -41,6 +43,7 @@

public class SCIM2RestClient extends RestBaseClient {

private final Log log = LogFactory.getLog(SCIM2RestClient.class);
private static final String SCIM2_USERS_ENDPOINT = "scim2/Users";
private static final String SCIM2_ROLES_ENDPOINT = "scim2/Roles";
private static final String SCIM2_GROUPS_ENDPOINT = "scim2/Groups";
Expand Down Expand Up @@ -82,6 +85,10 @@ public String createUser(UserObject userInfo) throws Exception {
try (CloseableHttpResponse response = getResponseOfHttpPost(getUsersPath(), jsonRequest, getHeaders())) {
Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_CREATED,
"User creation failed");
//if the response code is 400 log the response
if (response.getStatusLine().getStatusCode() >= HttpServletResponse.SC_BAD_REQUEST) {
log.error("======= Response: " + EntityUtils.toString(response.getEntity()));
}
JSONObject jsonResponse = getJSONObject(EntityUtils.toString(response.getEntity()));
return jsonResponse.get("id").toString();
}
Expand Down

0 comments on commit ab98f10

Please sign in to comment.