Skip to content

Commit

Permalink
[SELC-5969] Fix cucumber test
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminiaScarciofolo committed Jan 10, 2025
1 parent 1f3e587 commit 1489166
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public void iHaveDataToUpdate(List<UserGroupEntity> userGroupEntityList) {
this.userGroupDetails = userGroupEntityList.get(0);
}

@When("I send a POST request to {string} with authentication {string}")
public void iSendAPOSTRequestTo(String url, String isAuthenticated) {
@When("I send a POST request to {string}")
public void iSendAPOSTRequestTo(String url) {
RequestSpecification requestSpecification = RestAssured.given()
.contentType("application/json");

if(Boolean.parseBoolean(isAuthenticated)){
if(StringUtils.isNotBlank(token)){
requestSpecification.header("Authorization", "Bearer " + token);
}

Expand All @@ -83,12 +83,12 @@ public void iSendAPOSTRequestTo(String url, String isAuthenticated) {
}
}

@When("I send a PUT request to {string} with authentication {string}")
public void iSendAPUTRequestTo(String url, String isAuthenticated) {
@When("I send a PUT request to {string} to update group")
public void iSendAPUTRequestTo(String url) {
RequestSpecification requestSpecification = RestAssured.given()
.contentType("application/json");

if(Boolean.parseBoolean(isAuthenticated)){
if(StringUtils.isNotBlank(token)){
requestSpecification.header("Authorization", "Bearer " + token);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected void login(String user, String pass) {
public String generateToken(JwtData jwtData) {
if (Objects.nonNull(jwtData)) {
try {
File file = new File("integration-test-config/key/private-key.pem");
File file = new File("src/test/resources/key/private-key.pem");
Algorithm alg = Algorithm.RSA256(KeyGenerator.getPrivateKey(new String(Files.readAllBytes(file.toPath()))));
String jwt = JWT.create()
.withHeader(jwtData.getJwtHeader())
Expand Down
45 changes: 44 additions & 1 deletion apps/user-group-ms/src/test/resources/dataPopulation/data.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
{
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Imp3dF9hMjo3YTo0NjozYjoyYTo2MDo1Njo0MDo4ODphMDo1ZDphNDpmODowMToxZTozZSJ9.eyJmYW1pbHlfbmFtZSI6IkJhbGJvYSIsImZpc2NhbF9udW1iZXIiOiJCTEJSS1k2N0MzMEg1MDFCIiwibmFtZSI6IlJvY2t5Iiwic3BpZF9sZXZlbCI6Imh0dHBzOi8vd3d3LnNwaWQuZ292Lml0L1NwaWRMMiIsImZyb21fYWEiOmZhbHNlLCJ1aWQiOiI0YmEyODMyZC05YzRjLTQwZjMtOTEyNi1lMWM3MjkwNWVmMTQiLCJsZXZlbCI6IkwyIiwiaWF0IjoxNzM0MDc4MzQ3LCJleHAiOjE3MzQxMTA3NDcsImF1ZCI6ImFwaS5kZXYuc2VsZmNhcmUucGFnb3BhLml0IiwiaXNzIjoiU1BJRCIsImp0aSI6Il8yZjYwM2E4YmMzNmIxMjMxYjFhNiJ9.MCSiqjxLAkdLiGE_1MAznFnKe0sfPS3V8nNL6PU07tUH6VStn2QwSENkGFcepeatQ7aNBsh9GFjQXdDfa00nSDmWJRaDeQ-aRwUWWcgf_3WxL6De6k9Ou4e8v8_jdOQ4bqkWMESCNLEgZiD-NuzbWemJnGSv6ysyU9iaL-38eQ3wrMn9xIVXmNkILpkuiAHLMnoPO82BMQ_ldTCfBRM9kfoo3JyAPf9bHqslOD_VRU6lGULV9gzJ_D6ZQVIyZNs_Wvx6KN0j3feDcfViURBQruE_UZ3SvsnYmqcTL7IOk4wLI_GdXOXjN49SmceLMM3tHYN9yfzyzA-yDaYJvg0QIA"
"jwtData": [
{
"username": "j.doe",
"password": "test",
"jwtHeader": {
"alg": "RS256",
"typ": "JWT",
"kid": "jwt_test_kid"
},
"jwtPayload": {
"family_name": "Doe",
"fiscal_number": "PRVTNT80A41H401T",
"name": "John",
"spid_level": "https://www.spid.gov.it/SpidL2",
"from_aa": false,
"uid": "97a511a7-2acc-47b9-afed-2f3c65753b4a",
"level": "L2",
"aud": "api.dev.selfcare.pagopa.it",
"iss": "SPID",
"jti": "_2f603a8bc36b1231b1a6"
}
},
{
"username": "r.balboa",
"password": "test",
"jwtHeader": {
"alg": "RS256",
"typ": "JWT",
"kid": "jwt_test_kid"
},
"jwtPayload": {
"family_name": "Balboa",
"fiscal_number": "BLBRKY67C30H501B",
"name": "Rocky",
"spid_level": "https://www.spid.gov.it/SpidL2",
"from_aa": false,
"uid": "35a78332-d038-4bfa-8e85-2cba7f6b7bf7",
"level": "L2",
"aud": "api.dev.selfcare.pagopa.it",
"iss": "SPID",
"jti": "_2f603a8bc36b1231b1a6"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Feature: Create User Group
And the response should contain the institutionId "inst123"
And the response should contain the status "ACTIVE"
And the response should contain 2 members
And the response should contain the createdBy "4ba2832d-9c4c-40f3-9126-e1c72905ef14"
And the response should contain the createdBy "97a511a7-2acc-47b9-afed-2f3c65753b4a"
And the response should contain the createdAt notNull
And the response should contain the modified data null

Expand Down Expand Up @@ -95,5 +95,5 @@ Feature: Create User Group
Given the following user group details:
| name | description | productId | institutionId | status | members |
| Group Name | Test Group | product123 | inst123 | ACTIVE | |
When I send a POST request to "/v1/user-groups" with the given details, with authentication "false"
When I send a POST request to "/v1/user-groups" with the given details
Then [CREATE] the response status should be 401
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Feature: Update User Group
And I have data to update:
| name | description | members |
| updated Name | updatedDescription | 525db33f-967f-4a82-8984-c606225e714a,a1b7c86b-d195-41d8-8291-7c3467abfd30 |
When I send a PUT request to "/v1/user-groups/{groupId}"
When I send a PUT request to "/v1/user-groups/{groupId}" to update group
Then [UPDATE] the response status should be 200
And the retrieved group should be updated

Expand All @@ -60,7 +60,7 @@ Feature: Update User Group
And I have data to update:
| name | description | members |
| Group Name | TestGroup | 525db33f-967f-4a82-8984-c606225e714a,a1b7c86b-d195-41d8-8291-7c3467abfd30 |
When I send a PUT request to "/v1/user-groups/{groupId}"
When I send a PUT request to "/v1/user-groups/{groupId}" to update group
Then [UPDATE] the response status should be 404
And [UPDATE] the response should contain an error message "Not Found"

Expand All @@ -71,7 +71,7 @@ Feature: Update User Group
And I have data to update:
| name | description | members |
| Group Name | TestGroup | 525db33f-967f-4a82-8984-c606225e714a,a1b7c86b-d195-41d8-8291-7c3467abfd30 |
When I send a PUT request to "/v1/user-groups/{groupId}"
When I send a PUT request to "/v1/user-groups/{groupId}" to update group
Then [UPDATE] the response status should be 400
And [UPDATE] the response should contain an error message "Trying to modify suspended group"

Expand Down

0 comments on commit 1489166

Please sign in to comment.