From 09729552e3574ca13530dd744434295d2e4cfa5c Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Sun, 28 May 2023 22:27:39 -0700 Subject: [PATCH] Added GDPR report test for events.SpaceCreated (#6397) --- .../features/apiGraph/userGDPRExport.feature | 61 ++++++++++++++++++- .../features/bootstrap/GraphContext.php | 13 +++- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/features/apiGraph/userGDPRExport.feature b/tests/acceptance/features/apiGraph/userGDPRExport.feature index 3e7bea6fb9..cd9bcbabbb 100644 --- a/tests/acceptance/features/apiGraph/userGDPRExport.feature +++ b/tests/acceptance/features/apiGraph/userGDPRExport.feature @@ -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"] + } + } + } + } + } + """ diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index 11480fbd5e..fb58da2daf 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -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; }