Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 38c9c01c authored by Jaime Pérez-Lozana's avatar Jaime Pérez-Lozana
Browse files

Merge branch 'feature/SOAPI-SIMPL-4532' into 'develop'

added test for 4532 - Disable an Identity Attribute

See merge request simpl/pso/pso-test/pso-test-automation!148
parents e3edb72c d46de13b
No related branches found
No related tags found
No related merge requests found
Pipeline #264784 passed with warnings
......@@ -70,6 +70,10 @@ public class RequestHandler {
return sendRequest(method, endpoint, bodyRequest, MediaType.JSON);
}
public JsonObject sendRequest(HttpMethod method, String endpoint, String bodyRequest) {
return sendRequest(method, endpoint, bodyRequest, MediaType.JSON);
}
public JsonObject sendUrlEncodedRequest(HttpMethod method, String endpoint, Map<String, String> data) {
String encodedData = encodeFormData(data);
return sendRequest(method, endpoint, encodedData, MediaType.X_WWW_FORM_URLENCODED);
......@@ -85,6 +89,7 @@ public class RequestHandler {
JsonObject jsonResponse = null;
if (responseBody != null && !responseBody.isEmpty()) {
logger.logToScenario("Request Body", responseBody);
jsonResponse = JsonParser.parseString(responseBody).getAsJsonObject();
}
......
......@@ -63,3 +63,13 @@ Feature: Authority API scenarios
Then the system indicates absence of such resource
And the response body contains appropriate response message:
| error | Identity attribute with id [ random_id ] not found |
@TCA06_API @SIMPL-4532
Scenario: Disable an Identity Attribute
Given a user with role "IATTR_M" is logged in to governance authority
And an "Identity Attribute" is already created
When the user sets the Identity Attribute as assignable to "false"
And the operation is completed successfully
And the user searches for the identity attribute by ID
Then the response body contains updated Identity Attribute data:
| assignable to roles | false |
......@@ -151,6 +151,52 @@ public class AuthoritySteps {
assertEquals("Mismatch in status code", expectedStatusCode, actualStatusCode);
}
@When("the user sets the Identity Attribute as assignable to \"false\"")
public void theUserChangesTheIdentityAttributeAssignableToFalse() {
JsonArray idArray = new JsonArray();
idArray.add(identityAttribute.getId());
requestHandler.sendRequest(HttpMethod.PUT, ApiEndpoint.IDENTITY_ATTRIBUTE.getPath() + "/" + "assignable/false", idArray.toString());
}
@When("the operation is completed successfully")
public void theOperationIsCompletedSuccessfully() {
int actualStatusCode = requestHandler.getLastStatusCode();
int expectedStatusCode = HttpStatus.OK.getCode();
assertEquals("Mismatch in status code", expectedStatusCode, actualStatusCode);
}
@Then("the response body contains updated Identity Attribute data:")
public void theResponseBodyContainsUpdatedIdentityAttributeData(DataTable dataTable) {
Gson gson = new Gson();
IdentityAttribute identityAttributeRetrieved = gson.fromJson(requestHandler.getLastResponseBody(), IdentityAttribute.class);
assertNotNull("Retrieved identity attribute is null", identityAttributeRetrieved);
Map<String, String> expectedValues = dataTable.asMap(String.class, String.class);
for (Map.Entry<String, String> entry : expectedValues.entrySet()) {
String fieldName = entry.getKey();
String expectedValue = entry.getValue();
switch (fieldName.toLowerCase()) {
case "assignable to roles":
boolean expectedAssignableToRoles = Boolean.parseBoolean(expectedValue);
assertEquals("Mismatch in 'assignableToRoles'", expectedAssignableToRoles, identityAttributeRetrieved.isAssignableToRoles());
break;
case "enabled":
boolean expectedEnabled = Boolean.parseBoolean(expectedValue);
assertEquals("Mismatch in 'enabled'", expectedEnabled, identityAttributeRetrieved.isEnabled());
break;
default:
throw new IllegalArgumentException("Unknown field in DataTable: " + fieldName);
}
}
}
@Then("the update is performed successfully")
public void theUpdateIsPerformedSuccessfully() {
int actualStatusCode = requestHandler.getLastStatusCode();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment