-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DMS-444] Allow validating empty request bodies, add E2E tests for re…
…gistration (#376) * Allow validating empty request bodies, add E2E tests for registration * More E2E * Add unique run id per scenario * Improve E2E state management * Rename feature
- Loading branch information
1 parent
769826a
commit 8c55963
Showing
6 changed files
with
262 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
src/config/tests/EdFi.DmsConfigurationService.Tests.E2E/Features/Connect.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
Feature: Connect endpoints | ||
|
||
Scenario: 00 Verify register new client | ||
When a Form URL Encoded POST request is made to "/connect/register" with | ||
| Key | Value | | ||
| ClientId | _scenarioRunId | | ||
| ClientSecret | Secr3t:) | | ||
| DisplayName | E2E | | ||
Then it should respond with 200 | ||
And the response body is | ||
""" | ||
{ | ||
"title": "Registered client {scenarioRunId} successfully.", | ||
"status": 200 | ||
} | ||
""" | ||
|
||
Scenario: 01 Verify already registered clients return 400 | ||
When a Form URL Encoded POST request is made to "/connect/register" with | ||
| Key | Value | | ||
| ClientId | _scenarioRunId | | ||
| ClientSecret | Secr3t:) | | ||
| DisplayName | E2E | | ||
Then it should respond with 200 | ||
And the response body is | ||
""" | ||
{ | ||
"title": "Registered client {scenarioRunId} successfully.", | ||
"status": 200 | ||
} | ||
""" | ||
When a Form URL Encoded POST request is made to "/connect/register" with | ||
| Key | Value | | ||
| ClientId | _scenarioRunId | | ||
| ClientSecret | Secr3t:) | | ||
| DisplayName | E2E | | ||
Then it should respond with 400 | ||
And the response body is | ||
""" | ||
{ | ||
"detail": "Data validation failed. See 'validationErrors' for details.", | ||
"type": "urn:ed-fi:api:bad-request:data-validation-failed", | ||
"title": "Data Validation Failed", | ||
"status": 400, | ||
"validationErrors": { | ||
"ClientId": [ | ||
"Client with the same Client Id already exists. Please provide different Client Id." | ||
] | ||
}, | ||
"errors": [] | ||
} | ||
""" | ||
|
||
Scenario: 02 Verify password requirements | ||
When a Form URL Encoded POST request is made to "/connect/register" with | ||
| Key | Value | | ||
| ClientId | _scenarioRunId | | ||
| ClientSecret | weak | | ||
| DisplayName | _scenarioRunId | | ||
Then it should respond with 400 | ||
And the response body is | ||
""" | ||
{ | ||
"detail": "Data validation failed. See 'validationErrors' for details.", | ||
"type": "urn:ed-fi:api:bad-request:data-validation-failed", | ||
"title": "Data Validation Failed", | ||
"status": 400, | ||
"validationErrors": { | ||
"ClientSecret": [ | ||
"Client secret must contain at least one lowercase letter, one uppercase letter, one number, and one special character, and must be 8 to 12 characters long." | ||
] | ||
}, | ||
"errors": [] | ||
} | ||
""" | ||
|
||
Scenario: 03 Verify empty post failure | ||
When a Form URL Encoded POST request is made to "/connect/register" with | ||
| Key | Value | | ||
Then it should respond with 400 | ||
And the response body is | ||
""" | ||
{ | ||
"detail": "Data validation failed. See 'validationErrors' for details.", | ||
"type": "urn:ed-fi:api:bad-request:data-validation-failed", | ||
"title": "Data Validation Failed", | ||
"status": 400, | ||
"validationErrors": { | ||
"ClientId": [ | ||
"'Client Id' must not be empty." | ||
], | ||
"ClientSecret": [ | ||
"'Client Secret' must not be empty." | ||
], | ||
"DisplayName": [ | ||
"'Display Name' must not be empty." | ||
] | ||
}, | ||
"errors": [] | ||
} | ||
""" | ||
Scenario: 04 Verify token creation with registered client | ||
When a Form URL Encoded POST request is made to "/connect/register" with | ||
| Key | Value | | ||
| ClientId | _scenarioRunId | | ||
| ClientSecret | Secr3t:) | | ||
| DisplayName | _scenarioRunId | | ||
Then it should respond with 200 | ||
And the response body is | ||
""" | ||
{ | ||
"title": "Registered client {scenarioRunId} successfully.", | ||
"status": 200 | ||
} | ||
""" | ||
When a Form URL Encoded POST request is made to "/connect/token" with | ||
| Key | Value | | ||
| client_id | _scenarioRunId | | ||
| client_secret | Secr3t:) | | ||
| grant_type | client_credentials | | ||
| scope | edfi_admin_api/full_access | | ||
Then it should respond with 200 | ||
And the response body is | ||
""" | ||
{ | ||
"access_token": "{access_token}", | ||
"expires_in": 1800, | ||
"token_type": "Bearer" | ||
} | ||
""" | ||
When a Form URL Encoded POST request is made to "/connect/token" with | ||
| Key | Value | | ||
| client_id | _scenarioRunId | | ||
| client_secret | wrong | | ||
| grant_type | client_credentials | | ||
| scope | edfi_admin_api/full_access | | ||
Then it should respond with 401 | ||
And the response body is | ||
""" | ||
{ | ||
"detail":"{\"error\":\"unauthorized_client\",\"error_description\":\"Invalid client or Invalid client credentials\"}", | ||
"type":"urn:ed-fi:api:security:authentication", | ||
"title":"Authentication Failed", | ||
"status":401, | ||
"validationErrors":{}, | ||
"errors":[] | ||
} | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ Feature: Vendors endpoints | |
And the response headers include | ||
""" | ||
{ | ||
"location": "/v2/vendors/{id}" | ||
"location": "/v2/vendors/{vendorId}" | ||
} | ||
""" | ||
And the record can be retrieved with a GET request | ||
|
@@ -71,7 +71,7 @@ Feature: Vendors endpoints | |
} | ||
""" | ||
Then it should respond with 201 | ||
When a GET request is made to "/v2/vendors/{id}" | ||
When a GET request is made to "/v2/vendors/{vendorId}" | ||
Then it should respond with 200 | ||
And the response body is | ||
""" | ||
|
@@ -95,10 +95,10 @@ Feature: Vendors endpoints | |
} | ||
""" | ||
Then it should respond with 201 | ||
When a PUT request is made to "/v2/vendors/{id}" with | ||
When a PUT request is made to "/v2/vendors/{vendorId}" with | ||
""" | ||
{ | ||
"id": {id}, | ||
"id": {vendorId}, | ||
"company": "Test 18 updated", | ||
"contactName": "Test", | ||
"contactEmailAddress": "[email protected]", | ||
|
@@ -128,7 +128,7 @@ Feature: Vendors endpoints | |
} | ||
""" | ||
Then it should respond with 201 | ||
When a DELETE request is made to "/v2/vendors/{id}" | ||
When a DELETE request is made to "/v2/vendors/{vendorId}" | ||
Then it should respond with 204 | ||
|
||
Scenario: 06 Verify error handling when trying to get an item that has already been deleted | ||
|
@@ -142,9 +142,9 @@ Feature: Vendors endpoints | |
} | ||
""" | ||
Then it should respond with 201 | ||
When a DELETE request is made to "/v2/vendors/{id}" | ||
When a DELETE request is made to "/v2/vendors/{vendorId}" | ||
Then it should respond with 204 | ||
When a GET request is made to "/v2/vendors/{id}" | ||
When a GET request is made to "/v2/vendors/{vendorId}" | ||
Then it should respond with 404 | ||
|
||
Scenario: 07 Verify error handling when trying to update an item that has already been deleted | ||
|
@@ -158,12 +158,12 @@ Feature: Vendors endpoints | |
} | ||
""" | ||
Then it should respond with 201 | ||
When a DELETE request is made to "/v2/vendors/{id}" | ||
When a DELETE request is made to "/v2/vendors/{vendorId}" | ||
Then it should respond with 204 | ||
When a PUT request is made to "/v2/vendors/{id}" with | ||
When a PUT request is made to "/v2/vendors/{vendorId}" with | ||
""" | ||
{ | ||
"id": {id}, | ||
"id": {vendorId}, | ||
"company": "Test 21 updated", | ||
"contactName": "Test", | ||
"contactEmailAddress": "[email protected]", | ||
|
@@ -183,9 +183,9 @@ Feature: Vendors endpoints | |
} | ||
""" | ||
Then it should respond with 201 | ||
When a DELETE request is made to "/v2/vendors/{id}" | ||
When a DELETE request is made to "/v2/vendors/{vendorId}" | ||
Then it should respond with 204 | ||
When a DELETE request is made to "/v2/vendors/{id}" | ||
When a DELETE request is made to "/v2/vendors/{vendorId}" | ||
Then it should respond with 404 | ||
|
||
Scenario: 09 Verify error handling when trying to get a vendor using a invalid id | ||
|
@@ -303,7 +303,7 @@ Feature: Vendors endpoints | |
""" | ||
|
||
Scenario: 16 Verify vendor applications endpoint | ||
Given vendor created | ||
Given a POST request is made to "/v2/vendors" with | ||
""" | ||
{ | ||
"company": "Scenario 16", | ||
|
Oops, something went wrong.