Skip to content

Commit

Permalink
fix: RDCC-2820 Fixed failing test due to changes in UP email removal (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SujeethKumarAri authored Jul 29, 2021
1 parent ba71c87 commit e4b0c18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ public List getUserProfilesFromCw(

public UserProfileResponse getUserProfileFromUp(String email) {
return funcTestRequestHandler.sendGet(OK,
"/v1/userprofile/roles?email=" + email, UserProfileResponse.class, baseUrlUserProfile);
"/v1/userprofile/roles", UserProfileResponse.class, baseUrlUserProfile,
Map.of("UserEmail", email));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import lombok.extern.slf4j.Slf4j;
import net.serenitybdd.rest.SerenityRest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;

import java.util.Map;

import static uk.gov.hmcts.reform.cwrdapi.AuthorizationFunctionalTest.getS2sToken;
import static uk.gov.hmcts.reform.cwrdapi.idam.IdamOpenIdClient.crdAdminToken;

Expand All @@ -30,19 +33,25 @@ public void sendPut(Object data, HttpStatus expectedStatus, String path) throws
path);
}

public <T> T sendGet(HttpStatus httpStatus, String urlPath, Class<T> clazz, String baseUrl) {
return sendGet(httpStatus, urlPath, baseUrl).as(clazz);
public <T> T sendGet(HttpStatus httpStatus, String urlPath, Class<T> clazz, String baseUrl,
Map<String, String> additionalHeaders) {
return sendGet(httpStatus, urlPath, baseUrl, additionalHeaders).as(clazz);
}

public Response sendGet(HttpStatus httpStatus, String urlPath, String baseUrl) {
public Response sendGet(HttpStatus httpStatus, String urlPath, String baseUrl,
Map<String, String> additionalHeaders) {

Response response = SerenityRest
RequestSpecification requestSpecification = SerenityRest
.given()
.contentType(MediaType.APPLICATION_JSON_VALUE)
.baseUri(baseUrl)
.header("ServiceAuthorization", getS2sToken())
.header("Authorization", BEARER + crdAdminToken)
.when()
.header("Authorization", BEARER + crdAdminToken);
if (!additionalHeaders.isEmpty()) {
additionalHeaders
.forEach(requestSpecification::header);
}
Response response = requestSpecification.when()
.get(urlPath);
log.info("UP get user response status code: {}", response.getStatusCode());
return response.then()
Expand Down

0 comments on commit e4b0c18

Please sign in to comment.