Added GDPR report test for events.SpaceCreated (#6397)

This commit is contained in:
Prarup Gurung
2023-05-28 22:27:39 -07:00
committed by GitHub
parent 1ad0637254
commit 09729552e3
2 changed files with 71 additions and 3 deletions

View File

@@ -122,7 +122,7 @@ Feature: user GDPR (General Data Protection Regulation) report
}
}
"""
And the downloaded JSON content should contain event type "events.SpaceCreated" in item 'events' and should match
And the downloaded JSON content should contain event type "events.SpaceCreated" for "personal" space and should match
"""
{
"type": "object",
@@ -955,3 +955,62 @@ Feature: user GDPR (General Data Protection Regulation) report
}
}
"""
Scenario: generate a GDPR report and check events when a space is created
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "GDPR Space" with the default quota using the GraphApi
When user "Alice" exports her GDPR report to "/.personal_data_export.json" using the Graph API
And user "Alice" downloads the content of GDPR report ".personal_data_export.json"
Then the HTTP status code of responses on each endpoint should be "201, 200" respectively
And the downloaded JSON content should contain event type "events.SpaceCreated" for "project" space and should match
"""
{
"type": "object",
"required": [
"event"
],
"properties": {
"event" : {
"type": "object",
"required": [
"Executant",
"Name",
"Type"
],
"properties": {
"Executant": {
"type": "object",
"required": [
"idp",
"opaque_id",
"type"
],
"properties": {
"idp": {
"type": "string",
"pattern": "^%base_url%$"
},
"opaque_id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"type": {
"type": "number",
"enum": [1]
}
}
},
"Name": {
"type": "string",
"enum": ["GDPR Space"]
},
"Type": {
"type": "string",
"enum": ["project"]
}
}
}
}
}
"""

View File

@@ -2340,19 +2340,28 @@ class GraphContext implements Context {
/**
* @Then the downloaded JSON content should contain event type :eventType in item 'events' and should match
* @Then the downloaded JSON content should contain event type :eventType for :spaceType space and should match
*
* @param string $eventType
* @param PyStringNode $schemaString
* @param string|null $spaceType
* @param PyStringNode|null $schemaString
*
* @return void
* @throws GuzzleException
*
*/
public function downloadedJsonContentShouldContainEventTypeInItemAndShouldMatch(string $eventType, PyStringNode $schemaString): void {
public function downloadedJsonContentShouldContainEventTypeInItemAndShouldMatch(string $eventType, ?string $spaceType=null, PyStringNode $schemaString=null): void {
$actualResponseToAssert = null;
$events = $this->featureContext->getJsonDecodedResponseBodyContent()->events;
foreach ($events as $event) {
if ($event->type === $eventType) {
if ($spaceType !== null) {
if ($event->event->Type === $spaceType) {
$actualResponseToAssert = $event;
break;
}
continue;
}
$actualResponseToAssert = $event;
break;
}