diff --git a/src/main/java/framework/api/helpers/RequestHandler.java b/src/main/java/framework/api/helpers/RequestHandler.java index 1f33aec90101f1c3356935eb39db50a6bf7b9bc6..cd6769f7b124fa0e35f817a524714920b2203a23 100644 --- a/src/main/java/framework/api/helpers/RequestHandler.java +++ b/src/main/java/framework/api/helpers/RequestHandler.java @@ -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(); } diff --git a/src/test/java/features/api/simplOpen/Authority.feature b/src/test/java/features/api/simplOpen/Authority.feature index f5c3d2f85d4d6aa93a3f85e90a121317ef2c9608..82772be8316d9be2bdcd22a5fa5f3aaddb0e4651 100644 --- a/src/test/java/features/api/simplOpen/Authority.feature +++ b/src/test/java/features/api/simplOpen/Authority.feature @@ -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 | diff --git a/src/test/java/stepDefinitions/api/simplOpen/AuthoritySteps.java b/src/test/java/stepDefinitions/api/simplOpen/AuthoritySteps.java index a058af1f07afc17110259bd5c4cb3be74ecd9fef..738a666900d88d126128826c67e17057003e9a27 100644 --- a/src/test/java/stepDefinitions/api/simplOpen/AuthoritySteps.java +++ b/src/test/java/stepDefinitions/api/simplOpen/AuthoritySteps.java @@ -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();