Skip to content

Commit

Permalink
adding test for deprovisioning notification using date format
Browse files Browse the repository at this point in the history
  • Loading branch information
nirajacharya2 committed Aug 18, 2023
1 parent f9b69af commit 219aa2d
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,71 @@ Feature: Deprovisioning notification
| Space Admin |
| User |
| User Light |


Scenario Outline: administrator creates a deprovisioning notification with different date formats
When the administrator creates a deprovisioning notification on "<deprovision_date>" using date format "<deprovision_date_format>"
Then the HTTP status code should be "200"
When user "Alice" lists all notifications
Then the HTTP status code should be "200"
And the JSON response should contain a notification message with the subject "Instance will be shut down and deprovisioned" and the message-details should match
"""
{
"type": "object",
"required": [
"message"
],
"properties": {
"message": {
"type": "string",
"enum": [
"Attention! The instance will be shut down and deprovisioned on <deprovision_date>. Download all your data before that date as no access past that date is possible."
]
}
}
}
"""
Examples:
| deprovision_date | deprovision_date_format |
| 2006-01-02T15:04:05.999999999+07:00 | 2006-01-02T15:04:05.999999999Z07:00 |
| 3:04PM | 3:04PM |
| Jan 2 15:04:05 | Jan _2 15:04:05 |
| Jan 2 15:04:05.000000000 | Jan _2 15:04:05.000000000 |
# when we make an api request using date format like Jan `_2 15:04:05` the server removes the `_` with a space so added a space to make assertions.
| 2023-01-02 15:04:05 | 2006-01-02 15:04:05 |
| 2023-01-02 | 2006-01-02 |
| 15:04:05 | 15:04:05 |


Scenario Outline: administrator change a deprovisioning notification with different date formats
Given the administrator has created a deprovisioning notification
When the administrator creates a deprovisioning notification on "<deprovision_date>" using date format "<deprovision_date_format>"
Then the HTTP status code should be "200"
When user "Alice" lists all notifications
Then the HTTP status code should be "200"
And the JSON response should contain a notification message with the subject "Instance will be shut down and deprovisioned" and the message-details should match
"""
{
"type": "object",
"required": [
"message"
],
"properties": {
"message": {
"type": "string",
"enum": [
"Attention! The instance will be shut down and deprovisioned on <deprovision_date>. Download all your data before that date as no access past that date is possible."
]
}
}
}
"""
Examples:
| deprovision_date | deprovision_date_format |
| 01/02 03:04:05PM '23 -0700 | 01/02 03:04:05PM '06 -0700 |
| Mon Jan 2 15:04:05 UTC 2023 | Mon Jan _2 15:04:05 UTC 2006 |
| Mon Jan 02 15:04:05 -0700 2023 | Mon Jan 02 15:04:05 -0700 2006 |
| 02 Jan 23 15:04 -0700 | 02 Jan 06 15:04 -0700 |
| Monday, 02-Jan-23 15:04:05 UTC | Monday, 02-Jan-06 15:04:05 UTC |
| Mon, 02 Jan 2023 15:04:05 -0700 | Mon, 02 Jan 2006 15:04:05 -0700 |
| 2006-01-02T15:04:05+07:00 | 2006-01-02T15:04:05Z07:00 |
30 changes: 27 additions & 3 deletions tests/acceptance/features/bootstrap/NotificationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,22 @@ public function clearInbucketMessages():void {
* @When user :user tries to create a deprovisioning notification
*
* @param string|null $user
* @param string|null $deprovision_date
* @param string|null $deprovision_date_format
*
* @return void
*
* @throws GuzzleException
*
* @throws JsonException
*/
public function userCreatesDeprovisioningNotification(?string $user = null):void {
public function userCreatesDeprovisioningNotification(
?string $user = null,
?string $deprovision_date = "2043-07-04T11:23:12Z",
?string $deprovision_date_format= "2006-01-02T15:04:05Z07:00"
):void {
$payload["type"] = "deprovision";
$payload["data"] = ["deprovision_date" => "2043-07-04T11:23:12Z"];

$payload["data"] = ["deprovision_date" => $deprovision_date, "deprovision_date_format" => $deprovision_date_format];
$response = OcsApiHelper::sendRequest(
$this->featureContext->getBaseUrl(),
$user ? $this->featureContext->getActualUsername($user) : $this->featureContext->getAdminUsername(),
Expand All @@ -540,6 +549,21 @@ public function userCreatesDeprovisioningNotification(?string $user = null):void
$this->featureContext->setResponse($response);
}

/**
* @When the administrator creates a deprovisioning notification on :arg1 using date format :arg2
*
* @param $deprovision_date
* @param $deprovision_date_format
*
* @return void
*
* @throws GuzzleException
* @throws JsonException
*/
public function theAdministratorCreatesADeprovisioningNotificationUsingDateFormat($deprovision_date, $deprovision_date_format) {
$this->userCreatesDeprovisioningNotification(null, $deprovision_date, $deprovision_date_format);
}

/**
* @Given the administrator has created a deprovisioning notification
*
Expand Down

0 comments on commit 219aa2d

Please sign in to comment.