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

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

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

added test for 4096 - attempt to delete random Identity Attribute

See merge request simpl/pso/pso-test/pso-test-automation!147
parents 036f64db 9a0680b2
No related branches found
No related tags found
No related merge requests found
Pipeline #264233 passed with warnings
......@@ -51,7 +51,15 @@ Feature: Authority API scenarios
Given a user with role "IATTR_M" is logged in to governance authority
When the user searches for the identity attribute
And the user saves an ID of the first found identity attribute
And the user deletes the Identity Attribute he found
And the user deletes "the found" Identity Attribute
Then the system doesn't allow to do that
And the response body contains appropriate response message:
| error | The deletion of an assigned identity attribute is not allowed. |
@TCA05_API @SIMPL-4096
Scenario: Attempt to Delete random Identity Attribute
Given a user with role "IATTR_M" is logged in to governance authority
When the user deletes "a random" Identity Attribute
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 |
......@@ -19,6 +19,7 @@ import io.cucumber.java.en.When;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import static org.junit.Assert.*;
......@@ -29,6 +30,7 @@ public class AuthoritySteps {
private IdentityAttribute identityAttribute = new IdentityAttribute();
private String savedIdentityAttributeId;
private final List<String> createdIdentityAttributesIDs = new ArrayList<>();
private String randomIdentityAttributeId;
@Before("@AuthorityAPI")
public void setUp(Scenario scenario) {
......@@ -125,9 +127,28 @@ public class AuthoritySteps {
savedIdentityAttributeId = firstIdentityAttribute.getId();
}
@When("the user deletes the Identity Attribute he found")
public void theUserDeletesTheIdentityAttribute() {
requestHandler.sendRequest(HttpMethod.DELETE, ApiEndpoint.IDENTITY_ATTRIBUTE.getPath() + "/" + savedIdentityAttributeId);
@When("the user deletes {string} Identity Attribute")
public void theUserDeletesIdentityAttribute(String attributeType) {
String identityAttributeId;
if (attributeType.equalsIgnoreCase("the found")) {
identityAttributeId = savedIdentityAttributeId;
} else if (attributeType.equalsIgnoreCase("a random")) {
randomIdentityAttributeId = UUID.randomUUID().toString();
identityAttributeId = randomIdentityAttributeId;
} else {
throw new IllegalArgumentException("Unknown attribute type: " + attributeType);
}
requestHandler.sendRequest(HttpMethod.DELETE, ApiEndpoint.IDENTITY_ATTRIBUTE.getPath() + "/" + identityAttributeId);
}
@Then("the system indicates absence of such resource")
public void theSystemIndicatesAbsenceOfSuchResource() {
int actualStatusCode = requestHandler.getLastStatusCode();
int expectedStatusCode = HttpStatus.NOT_FOUND.getCode();
assertEquals("Mismatch in status code", expectedStatusCode, actualStatusCode);
}
@Then("the update is performed successfully")
......@@ -214,8 +235,14 @@ public class AuthoritySteps {
String expectedKey = entry.getKey();
String expectedValue = entry.getValue();
if (expectedValue.contains("random_id")) {
expectedValue = expectedValue.replace("random_id", randomIdentityAttributeId);
}
assertTrue("Response does not contain key: " + expectedKey, jsonResponse.has(expectedKey));
assertEquals("Mismatch in response value for key: " + expectedKey, expectedValue, jsonResponse.get(expectedKey).getAsString());
assertEquals("Mismatch in response value for key: " + expectedKey,
expectedValue,
jsonResponse.get(expectedKey).getAsString());
}
}
......
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