From cea4d5a250632d39b4050686d7cc46ad92a4a15c Mon Sep 17 00:00:00 2001 From: Albin Antony Date: Wed, 10 Jan 2024 15:00:23 +0530 Subject: [PATCH] Add #19 Update bdd test to support issue feature/612 revisions --- features/issue_fix_610/issue_fix_610.feature | 22 ++++---- fixtures/main.py | 4 +- steps/issue_fix_610.py | 27 +++++++--- test/test-data.json | 56 +++++++++++++++++--- 4 files changed, 80 insertions(+), 29 deletions(-) diff --git a/features/issue_fix_610/issue_fix_610.feature b/features/issue_fix_610/issue_fix_610.feature index 2cb595e..3186c96 100644 --- a/features/issue_fix_610/issue_fix_610.feature +++ b/features/issue_fix_610/issue_fix_610.feature @@ -23,6 +23,17 @@ Feature: Issue fix 610 | dataAgreementId | | 1 | | 659c12ea3140212807b80000 | + + @positive @delete_data_agreement + Scenario Outline: CONFIG - DELETE - Delete data agreement + Given a data agreement ID "" + When I make a DELETE request to /config/data-agreement/"" + Then The response should have a status code of 200 + And The response should only contain the data agreement revision details for "" + + Examples: Valid data + | dataAgreementId | + | 659e5aafa35cad660a9021f5 | @positive @list_data_agreement_revisions Scenario Outline: CONFIG - LIST - List data agreement revisions @@ -197,15 +208,4 @@ Feature: Issue fix 610 | dataAgreementId | consentRecordId | individualId | | 1 | 1 | 1 | - @positive @delete_data_agreement - Scenario Outline: CONFIG - DELETE - Delete data agreement - Given a data agreement ID "" - When I make a DELETE request to /config/data-agreement/"" - Then The response should have a status code of 200 - And The response should only contain the data agreement revision details for "" - - Examples: Valid data - | dataAgreementId | - | 659c12ea3140212807b80000 | - diff --git a/fixtures/main.py b/fixtures/main.py index 6ce121e..19d4e1a 100644 --- a/fixtures/main.py +++ b/fixtures/main.py @@ -411,7 +411,7 @@ def populate_revisions(db): "_id": revision.get( "id", generate_object_id(seed_year + index, 1, 1) ), - "schemaname": revision.get("schemaName", "dataAgreement"), + "schemaname": revision.get("schemaName", "DataAgreement"), "objectid": revision.get("objectId", "1"), "signedwithoutobjectid": revision.get( "signedWithoutObjectId", False @@ -420,7 +420,7 @@ def populate_revisions(db): "authorizedbyindividualid": revision.get( "authorizedByIndividualId", "" ), - "authorizedbyotherid": revision.get("authorizedByOtherId", ""), + "authorizedbyother": revision.get("authorizedByOther", ""), "predecessorhash": revision.get("predecessorHash", ""), "predecessorsignature": revision.get("predecessorSignature", ""), "objectdata": revision.get("objectData", ""), diff --git a/steps/issue_fix_610.py b/steps/issue_fix_610.py index 61a95af..adc29d1 100644 --- a/steps/issue_fix_610.py +++ b/steps/issue_fix_610.py @@ -25,7 +25,8 @@ def step_impl(context, dataAgreementId): response_data = json.loads(context.response.content) assert response_data["dataAgreement"]["id"] == dataAgreementId, "Data agreement ID does not match" assert response_data["revision"]["objectId"] == dataAgreementId, "Revision object ID does not match data agreement ID" - assert response_data["revision"]["schemaName"] == "dataAgreement", "Revision schema name does not match data agreement" + assert response_data["revision"]["schemaName"] == "DataAgreement", "Revision schema name does not match data agreement" + assert len(response_data["revision"]["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther" @when('I make a GET request to /config/data-agreements') def step_impl(context): @@ -64,9 +65,11 @@ def step_impl(context, dataAgreementId): response_data = json.loads(context.response.content) revisions = response_data["revisions"] assert response_data["dataAgreement"]["id"] == dataAgreementId, "Data agreement ID does not match" + assert len(revisions) > 0, "Revisions is empty" for revision in revisions: assert revision["objectId"] == dataAgreementId, "Revision object ID does not match data agreement ID" - assert revision["schemaName"] == "dataAgreement", "Revision schema name does not match data agreement" + assert revision["schemaName"] == "DataAgreement", "Revision schema name does not match data agreement" + assert len(revision["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther" @given("a policy ID \"{policyId}\"") def step_impl(context, policyId): @@ -87,7 +90,8 @@ def step_impl(context, policyId): response_data = json.loads(context.response.content) assert response_data["policy"]["id"] == policyId, "Policy ID does not match" assert response_data["revision"]["objectId"] == policyId, "Revision object ID does not match policy ID" - assert response_data["revision"]["schemaName"] == "policy", "Revision schema name does not match policy" + assert response_data["revision"]["schemaName"] == "Policy", "Revision schema name does not match policy" + assert len(response_data["revision"]["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther" @when('I make a GET request to /config/policies') def step_impl(context): @@ -127,9 +131,11 @@ def step_impl(context, policyId): response_data = json.loads(context.response.content) revisions = response_data["revisions"] assert response_data["policy"]["id"] == policyId, "Policy ID does not match" + assert len(revisions) > 0, "Revisions is empty" for revision in revisions: assert revision["objectId"] == policyId, "Revision object ID does not match policy ID" - assert revision["schemaName"] == "policy", "Revision schema name does not match policy" + assert revision["schemaName"] == "Policy", "Revision schema name does not match policy" + assert len(revision["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther" @when("I make a DELETE request to /config/policy/\"{policyId}\"") def step_impl(context, policyId): @@ -144,7 +150,8 @@ def step_impl(context, policyId): # Parse the response content and assert the data agreement details response_data = json.loads(context.response.content) assert response_data["objectId"] == policyId, "Revision object ID does not match policy ID" - assert response_data["schemaName"] == "policy", "Revision schema name does not match policy" + assert response_data["schemaName"] == "Policy", "Revision schema name does not match policy" + assert len(response_data["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther" @when('I make a GET request to /service/data-agreement/\"{dataAgreementId}\"') def step_impl(context, dataAgreementId): @@ -207,7 +214,8 @@ def step_impl(context): response_data = json.loads(context.response.content) assert response_data["consentRecord"]["dataAgreementId"] == context.data_agreement_id, "Data agreement Id does not match for consent record" assert response_data["consentRecord"]["individualId"] == context.individual_id, "Individual Id does not match for consent record" - assert response_data["revision"]["schemaName"] == "consentRecord", "Revision schema name does not match consentRecord" + assert response_data["revision"]["schemaName"] == "ConsentRecord", "Revision schema name does not match consentRecord" + assert len(response_data["revision"]["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther" @when('I make a GET request to /service/individual/record/data-agreement/\"{dataAgreementId}\"') def step_impl(context,dataAgreementId): @@ -246,7 +254,8 @@ def step_impl(context, consentRecordId): assert response_data["consentRecord"]["dataAgreementId"] == context.data_agreement_id, "Data agreement Id does not match for consent record" assert response_data["consentRecord"]["individualId"] == context.individual_id, "Individual Id does not match for consent record" assert response_data["revision"]["objectId"] == consentRecordId, "Revision object ID does not match consent record ID" - assert response_data["revision"]["schemaName"] == "consentRecord", "Revision schema name does not match consentRecord" + assert response_data["revision"]["schemaName"] == "ConsentRecord", "Revision schema name does not match consentRecord" + assert len(response_data["revision"]["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther" @when('I make a PUT request to /service/individual/record/consent-record/\"{consentRecordId}\"') def step_impl(context,consentRecordId,): @@ -276,6 +285,7 @@ def step_impl(context, consentRecordId): response_data = json.loads(context.response.content) consent_records = response_data["consentRecords"] consent_record_id_found = False + assert len(consent_records) > 0, "Consent records is empty" for consent_record in consent_records: if consent_record.get("id") == consentRecordId: consent_record_id_found = True @@ -308,7 +318,8 @@ def step_impl(context, dataAgreementId): # Parse the response content and assert the data agreement details response_data = json.loads(context.response.content) assert response_data["objectId"] == dataAgreementId, "Revision object ID does not match data agreement ID" - assert response_data["schemaName"] == "dataAgreement", "Revision schema name does not match data agreement" + assert response_data["schemaName"] == "DataAgreement", "Revision schema name does not match data agreement" + assert len(response_data["authorizedByOther"]) > 0, "Revision does not contain authorizedByOther" diff --git a/test/test-data.json b/test/test-data.json index c1ca67a..a6dadb5 100644 --- a/test/test-data.json +++ b/test/test-data.json @@ -65,17 +65,42 @@ "dpia": "", "compatibleWithVersion": "", "timestamp": "2024-01-03T09:23:31Z" + }, + { + "id": "659e5aafa35cad660a9021f5", + "purpose": "Issue License", + "purposeDescription": "Issue License", + "lawfulBasis": "consent", + "active": true, + "forgettable": false, + "lifecycle": "complete", + "dpiaDate": "2023-10-31T14:24", + "dpiaSummaryUrl": "https://privacyant.se/dpia_results.html", + "dataAttributes": [ + { + "id": "659e5aafa35cad660a9021f8", + "name": "Age", + "description": "Age of person", + "sensitivity": false, + "category": "" + } + ], + "methodOfUse": "data_source", + "datause": "data_source", + "dpia": "", + "compatibleWithVersion": "", + "timestamp": "2024-01-10T08:51:59Z" } ], "revisions": [ { "id": "6595279313c370b9a5569c23", - "schemaName": "dataAgreement", + "schemaName": "DataAgreement", "objectId": "1", "signedWithoutObjectId": false, "timestamp": "2024-01-03T09:23:31Z", "authorizedByIndividualId": "", - "authorizedByOtherId": "", + "authorizedByOther": "6595276613c370b9a5569c0c", "predecessorHash": "", "predecessorSignature": "", "objectData": "{\"id\":\"1\",\"version\":\"1.0.0\",\"controllerId\":\"1\",\"controllerUrl\":\"https://abc.com/eula.html\",\"controllerName\":\"Retail company\",\"policy\":{\"id\":\"1\",\"name\":\"Updated Policy\",\"version\":\"\",\"url\":\"https://igrant.io/policy.html\",\"jurisdiction\":\"London,GB\",\"industrySector\":\"Retail\",\"dataRetentionPeriodDays\":350,\"geographicRestriction\":\"Not restricted\",\"storageLocation\":\"London\",\"thirdPartyDataSharing\":true},\"purpose\":\"Issue Licensess\",\"purposeDescription\":\"Issue Passports\",\"lawfulBasis\":\"consent\",\"methodOfUse\":\"data_source\",\"dpiaDate\":\"2023-10-31T14:24\",\"dpiaSummaryUrl\":\"https://privacyant.se/dpia_results.html\",\"signature\":{\"id\":\"6595279313c370b9a5569c20\",\"payload\":\"\",\"signature\":\"\",\"verificationMethod\":\"\",\"verificationPayload\":\"\",\"verificationPayloadHash\":\"\",\"verificationArtifact\":\"\",\"verificationSignedBy\":\"\",\"verificationSignedAs\":\"\",\"verificationJwsHeader\":\"\",\"timestamp\":\"\",\"signedWithoutObjectReference\":false,\"objectType\":\"\",\"objectReference\":\"\"},\"active\":true,\"forgettable\":false,\"compatibleWithVersionId\":\"\",\"lifecycle\":\"complete\",\"dataAttributes\":[{\"id\":\"6595279313c370b9a5569c21\",\"name\":\"Name\",\"description\":\"Name of person\",\"sensitivity\":false,\"category\":\"\"},{\"id\":\"6595279313c370b9a5569c22\",\"name\":\"Age\",\"description\":\"Age of person\",\"sensitivity\":false,\"category\":\"\"}],\"dataUse\":\"data_source\",\"dpia\":\"\",\"compatibleWithVersion\":\"\",\"controller\":{\"id\":\"1\",\"name\":\"Retail company\",\"url\":\"https://abc.com/eula.html\"}}", @@ -85,12 +110,12 @@ }, { "id": "659c12ea3140212807b80004", - "schemaName": "dataAgreement", + "schemaName": "DataAgreement", "objectId": "659c12ea3140212807b80000", "signedWithoutObjectId": false, "timestamp": "2024-01-08T15:21:14Z", "authorizedByIndividualId": "", - "authorizedByOtherId": "659c121f3140212807b7ffee", + "authorizedByOther": "659c121f3140212807b7ffee", "predecessorHash": "", "predecessorSignature": "", "objectData": "{\"id\":\"659c12ea3140212807b80000\",\"version\":\"1.0.0\",\"controllerId\":\"1\",\"controllerUrl\":\"https://www.skatteverket.se\",\"controllerName\":\"Skatteverket\",\"policy\":{\"id\":\"659c12ea3140212807b80001\",\"name\":\"Policy 1\",\"version\":\"1.0.0\",\"url\":\"https://www.skatteverket.se\",\"jurisdiction\":\"Sweden\",\"industrySector\":\"Public\",\"dataRetentionPeriodDays\":1095,\"geographicRestriction\":\"Sweden\",\"storageLocation\":\"Sweden\",\"thirdPartyDataSharing\":true},\"purpose\":\"Marketing and campaign\",\"purposeDescription\":\"Marketing and campaign\",\"lawfulBasis\":\"consent\",\"methodOfUse\":\"data_source\",\"dpiaDate\":\"\",\"dpiaSummaryUrl\":\"\",\"signature\":{\"id\":\"659c12ea3140212807b80002\",\"payload\":\"\",\"signature\":\"\",\"verificationMethod\":\"\",\"verificationPayload\":\"\",\"verificationPayloadHash\":\"\",\"verificationArtifact\":\"\",\"verificationSignedBy\":\"\",\"verificationSignedAs\":\"\",\"verificationJwsHeader\":\"\",\"timestamp\":\"\",\"signedWithoutObjectReference\":false,\"objectType\":\"\",\"objectReference\":\"\"},\"active\":true,\"forgettable\":false,\"compatibleWithVersionId\":\"\",\"lifecycle\":\"complete\",\"dataAttributes\":[{\"id\":\"659c12ea3140212807b80003\",\"name\":\"Name\",\"description\":\"Name of person\",\"sensitivity\":false,\"category\":\"\"}],\"dataUse\":\"data_source\",\"dpia\":\"\",\"compatibleWithVersion\":\"\",\"controller\":{\"id\":\"1\",\"name\":\"Skatteverket\",\"url\":\"https://www.skatteverket.se\"}}", @@ -100,12 +125,12 @@ }, { "id": "659ba2f439e82e51b4885d77", - "schemaName": "consentRecord", + "schemaName": "ConsentRecord", "objectId": "1", "signedWithoutObjectId": false, "timestamp": "2024-01-08T07:23:32Z", "authorizedByIndividualId": "", - "authorizedByOtherId": "659b9d1539e82e51b4885ca7", + "authorizedByOther": "659b9d1539e82e51b4885ca7", "predecessorHash": "", "predecessorSignature": "", "objectData": "{\"id\":\"1\",\"dataAgreementId\":\"1\",\"dataAgreementRevisionId\":\"6595279313c370b9a5569c23\",\"dataAgreementRevisionHash\":\"83a7cc40a2de1b07e8b7971f0a44ac110bc37b24\",\"individualId\":\"1\",\"optIn\":true,\"state\":\"unsigned\",\"signatureId\":\"\"}", @@ -115,18 +140,33 @@ }, { "id": "659c16be3140212807b80009", - "schemaName": "policy", + "schemaName": "Policy", "objectId": "2", "signedWithoutObjectId": false, "timestamp": "2024-01-08T15:37:34Z", "authorizedByIndividualId": "", - "authorizedByOtherId": "659c121f3140212807b7ffee", + "authorizedByOther": "659c121f3140212807b7ffee", "predecessorHash": "", "predecessorSignature": "", "objectData": "{\"id\":\"2\",\"name\":\"Policy 2\",\"version\":\"1.0.0\",\"url\":\"https://www.skatteverket.se\",\"jurisdiction\":\"Sweden\",\"industrySector\":\"Public\",\"dataRetentionPeriodDays\":1095,\"geographicRestriction\":\"Sweden\",\"storageLocation\":\"Sweden\"}", "successorId": "", "serializedHash": "2712c137158bd8ef2549f7c5fb84dfcbab5c0a9f", "serializedSnapshot": "{\"id\":\"659c16be3140212807b80009\",\"schemaName\":\"policy\",\"objectId\":\"2\",\"signedWithoutObjectId\":false,\"timestamp\":\"2024-01-08T15:37:34Z\",\"authorizedByIndividualId\":\"\",\"authorizedByOtherId\":\"659c121f3140212807b7ffee\",\"predecessorHash\":\"\",\"predecessorSignature\":\"\",\"objectData\":\"{\\\"id\\\":\\\"2\\\",\\\"name\\\":\\\"Policy 2\\\",\\\"version\\\":\\\"1.0.0\\\",\\\"url\\\":\\\"https://www.skatteverket.se\\\",\\\"jurisdiction\\\":\\\"Sweden\\\",\\\"industrySector\\\":\\\"Public\\\",\\\"dataRetentionPeriodDays\\\":1095,\\\"geographicRestriction\\\":\\\"Sweden\\\",\\\"storageLocation\\\":\\\"Sweden\\\"}\"}" + }, + { + "id": "659e5aafa35cad660a9021f9", + "schemaName": "DataAgreement", + "objectId": "659e5aafa35cad660a9021f5", + "signedWithoutObjectId": false, + "timestamp": "2024-01-10T08:51:59Z", + "authorizedByIndividualId": "", + "authorizedByOther": "659e5aa4a35cad660a9021e4", + "predecessorHash": "", + "predecessorSignature": "", + "objectData": "{\"id\":\"659e5aafa35cad660a9021f5\",\"version\":\"1.0.0\",\"controllerId\":\"1\",\"controllerUrl\":\"https://www.skatteverket.se\",\"controllerName\":\"Skatteverket\",\"policy\":{\"id\":\"659e5aafa35cad660a9021f6\",\"name\":\"Policy 2\",\"version\":\"1.0.0\",\"url\":\"https://www.skatteverket.se\",\"jurisdiction\":\"Sweden\",\"industrySector\":\"Public\",\"dataRetentionPeriodDays\":1095,\"geographicRestriction\":\"Sweden\",\"storageLocation\":\"Sweden\",\"thirdPartyDataSharing\":true},\"purpose\":\"Issue License\",\"purposeDescription\":\"Issue License\",\"lawfulBasis\":\"consent\",\"methodOfUse\":\"data_source\",\"dpiaDate\":\"2023-10-31T14:24\",\"dpiaSummaryUrl\":\"https://privacyant.se/dpia_results.html\",\"signature\":{\"id\":\"659e5aafa35cad660a9021f7\",\"payload\":\"\",\"signature\":\"\",\"verificationMethod\":\"\",\"verificationPayload\":\"\",\"verificationPayloadHash\":\"\",\"verificationArtifact\":\"\",\"verificationSignedBy\":\"\",\"verificationSignedAs\":\"\",\"verificationJwsHeader\":\"\",\"timestamp\":\"\",\"signedWithoutObjectReference\":false,\"objectType\":\"\",\"objectReference\":\"\"},\"active\":true,\"forgettable\":false,\"compatibleWithVersionId\":\"\",\"lifecycle\":\"complete\",\"dataAttributes\":[{\"id\":\"659e5aafa35cad660a9021f8\",\"name\":\"Age\",\"description\":\"Age of person\",\"sensitivity\":false,\"category\":\"\"}],\"dataUse\":\"data_source\",\"dpia\":\"\",\"compatibleWithVersion\":\"\",\"controller\":{\"id\":\"1\",\"name\":\"Skatteverket\",\"url\":\"https://www.skatteverket.se\"}}", + "SuccessorId": "", + "SerializedHash": "f88bda218177f3ee1296d5897c145de96a2f59d0", + "SerializedSnapshot": "{\"schemaName\":\"DataAgreement\",\"objectId\":\"659e5aafa35cad660a9021f5\",\"signedWithoutObjectId\":false,\"timestamp\":\"2024-01-10T08:51:59Z\",\"authorizedByIndividualId\":\"\",\"authorizedByOther\":\"659e5aa4a35cad660a9021e4\",\"objectData\":\"{\\\"id\\\":\\\"659e5aafa35cad660a9021f5\\\",\\\"version\\\":\\\"1.0.0\\\",\\\"controllerId\\\":\\\"1\\\",\\\"controllerUrl\\\":\\\"https://www.skatteverket.se\\\",\\\"controllerName\\\":\\\"Skatteverket\\\",\\\"policy\\\":{\\\"id\\\":\\\"659e5aafa35cad660a9021f6\\\",\\\"name\\\":\\\"Policy 2\\\",\\\"version\\\":\\\"1.0.0\\\",\\\"url\\\":\\\"https://www.skatteverket.se\\\",\\\"jurisdiction\\\":\\\"Sweden\\\",\\\"industrySector\\\":\\\"Public\\\",\\\"dataRetentionPeriodDays\\\":1095,\\\"geographicRestriction\\\":\\\"Sweden\\\",\\\"storageLocation\\\":\\\"Sweden\\\",\\\"thirdPartyDataSharing\\\":true},\\\"purpose\\\":\\\"Issue License\\\",\\\"purposeDescription\\\":\\\"Issue License\\\",\\\"lawfulBasis\\\":\\\"consent\\\",\\\"methodOfUse\\\":\\\"data_source\\\",\\\"dpiaDate\\\":\\\"2023-10-31T14:24\\\",\\\"dpiaSummaryUrl\\\":\\\"https://privacyant.se/dpia_results.html\\\",\\\"signature\\\":{\\\"id\\\":\\\"659e5aafa35cad660a9021f7\\\",\\\"payload\\\":\\\"\\\",\\\"signature\\\":\\\"\\\",\\\"verificationMethod\\\":\\\"\\\",\\\"verificationPayload\\\":\\\"\\\",\\\"verificationPayloadHash\\\":\\\"\\\",\\\"verificationArtifact\\\":\\\"\\\",\\\"verificationSignedBy\\\":\\\"\\\",\\\"verificationSignedAs\\\":\\\"\\\",\\\"verificationJwsHeader\\\":\\\"\\\",\\\"timestamp\\\":\\\"\\\",\\\"signedWithoutObjectReference\\\":false,\\\"objectType\\\":\\\"\\\",\\\"objectReference\\\":\\\"\\\"},\\\"active\\\":true,\\\"forgettable\\\":false,\\\"compatibleWithVersionId\\\":\\\"\\\",\\\"lifecycle\\\":\\\"complete\\\",\\\"dataAttributes\\\":[{\\\"id\\\":\\\"659e5aafa35cad660a9021f8\\\",\\\"name\\\":\\\"Age\\\",\\\"description\\\":\\\"Age of person\\\",\\\"sensitivity\\\":false,\\\"category\\\":\\\"\\\"}],\\\"dataUse\\\":\\\"data_source\\\",\\\"dpia\\\":\\\"\\\",\\\"compatibleWithVersion\\\":\\\"\\\",\\\"controller\\\":{\\\"id\\\":\\\"1\\\",\\\"name\\\":\\\"Skatteverket\\\",\\\"url\\\":\\\"https://www.skatteverket.se\\\"}}\"}" } ], "consentRecords": [