Skip to content

Commit

Permalink
Fix #11 Update gherkin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
albinpa authored and georgepadayatti committed Dec 19, 2023
1 parent 87f4da9 commit d93729c
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Feature: Audit Logging

Scenario: View consents for audit
When the admin clicks on the view icon
And views the data agreement
And views the consent records
Then the admin should be able to view the consent records

Scenario: Revision list
Expand Down
20 changes: 10 additions & 10 deletions steps/create_data_agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def create_draft_data_agreement(context):
"description": "Age of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down Expand Up @@ -126,8 +126,8 @@ def step_impl(context):
"description": "Age of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down Expand Up @@ -194,8 +194,8 @@ def create_data_agreement(context):
"description": "Age of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down Expand Up @@ -247,8 +247,8 @@ def step_impl(context):
"description": "Age of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down Expand Up @@ -325,8 +325,8 @@ def create_data_agreement(context):
"description": "Age of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down
37 changes: 30 additions & 7 deletions steps/data_processing_auditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,34 @@ def step_impl(context):
response = requests.get(url + "/", verify=False, headers=headers)
context.response = response

@when('views the consent records')
def step_impl(context):
base_url = context.config.userdata.get("base_url")
headers = {"Authorization": f"Bearer {context.access_token}"}
url = base_url + "/audit/consent-records"
response = requests.get(url + "/", verify=False, headers=headers)
context.response = response


@then('the admin should be able to view the consent records')
def step_impl(context):
raise NotImplementedError(u'STEP: Then the admin should be able to view the consent records')
assert context.response.status_code == 200


@when('views the revision of data agreement')
def step_impl(context):
raise NotImplementedError(u'STEP: When views the revision of data agreement')
add_data_agreements(context)
base_url = context.config.userdata.get("base_url")
headers = {"Authorization": f"Bearer {context.access_token}"}
url = base_url + "/config/data-agreement/" + context.config.userdata.published_data_agreement_id + "/revisions"
response = requests.get(url + "/", verify=False, headers=headers)
context.response = response


@then('the admin should be able to view the revision of the data agreement')
def step_impl(context):
raise NotImplementedError(u'STEP: Then the admin should be able to view the revision of the data agreement')
cleanup_data_agreement(context)
assert context.response.status_code == 200

def add_data_agreements(context):
data = {
Expand Down Expand Up @@ -108,8 +122,8 @@ def add_data_agreements(context):
"description": "Age of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down Expand Up @@ -152,8 +166,8 @@ def add_data_agreements(context):
"description": "Name of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
url = base_url + "/config/data-agreement"
Expand All @@ -162,3 +176,12 @@ def add_data_agreements(context):
data_agreement_id = response_json["dataAgreement"]["id"]
context.config.userdata.draft_data_agreement_id = data_agreement_id

def cleanup_data_agreement(context):
base_url = context.config.userdata.get("base_url")
headers = {"Authorization": f"Bearer {context.access_token}"}
url = base_url + "/config/data-agreement/" + context.config.userdata.published_data_agreement_id
response = requests.delete(url + "/", verify=False, headers=headers)

url = base_url + "/config/data-agreement/" + context.config.userdata.draft_data_agreement_id
response = requests.delete(url + "/", verify=False, headers=headers)

4 changes: 2 additions & 2 deletions steps/delete_data_agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def add_data_agreement(context,active):
"description": "Age of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down
8 changes: 4 additions & 4 deletions steps/filter_data_agreements.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def add_data_agreements(context):
"description": "Age of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down Expand Up @@ -119,8 +119,8 @@ def add_data_agreements(context):
"description": "Name of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
url = base_url + "/config/data-agreement"
Expand Down
25 changes: 18 additions & 7 deletions steps/individual_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ def step_impl(context):
individual_id = response_json["individuals"][0]["id"]
context.individual_id = individual_id

if len(individual_id) < 1:
data = {"individual": {"name": "John"}}
url = base_url + "/service/individual"
response = requests.post(url + "/", json=data, verify=False, headers=headers)
response_json = json.loads(response.content)
individual_id = response_json["individual"]["id"]
context.individual_id = individual_id

if not hasattr(context.config.userdata, 'apikey'):
base_url = context.config.userdata.get("base_url")
data = {"apiKey": {"name": "Service", "scopes": ["service"], "expiryInDays": 30}}
Expand Down Expand Up @@ -60,7 +68,6 @@ def step_impl(context):
def step_impl(context):
base_url = context.config.userdata.get("base_url")
individual_id = context.individual_id
context.config.userdata.individual_id = individual_id
headers = {"Authorization": f"ApiKey {context.config.userdata.apikey}","X-ConsentBB-IndividualId": individual_id}
data_agreement_id = context.config.userdata.data_agreement_id
url = base_url + "/service/individual/record/data-agreement/" + data_agreement_id
Expand Down Expand Up @@ -96,9 +103,12 @@ def step_impl(context):
headers = {"Authorization": f"ApiKey {context.config.userdata.apikey}","X-ConsentBB-IndividualId": individual_id}
data_agreement_id = context.config.userdata.data_agreement_id
consent_record_id = context.config.userdata.consent_record_id
data = {
"optIn": False
}
params = {"individualId": individual_id,"dataAgreementId":data_agreement_id}
url = base_url + "/service/individual/record/consent-record/" + consent_record_id
response = requests.put(url + "/", verify=False, headers=headers,params=params)
response = requests.put(url + "/",json=data, verify=False, headers=headers,params=params)
context.response = response


Expand All @@ -119,8 +129,9 @@ def step_impl(context):

@then("the user can view all their actions")
def step_impl(context):
assert context.response.status_code == 200
cleanup_data_agreement(context)
assert context.response.status_code == 200



@when("the user modifies their consent")
Expand Down Expand Up @@ -194,8 +205,8 @@ def add_data_agreements(context):
"description": "Age of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down Expand Up @@ -238,8 +249,8 @@ def add_data_agreements(context):
"description": "Name of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
url = base_url + "/config/data-agreement"
Expand Down
16 changes: 8 additions & 8 deletions steps/update_data_agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def step_impl(context):
"description": "Age of customer",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down Expand Up @@ -134,8 +134,8 @@ def step_impl(context):
"description": "Age of customer",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down Expand Up @@ -182,8 +182,8 @@ def step_impl(context):
"description": "Name of customer",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down Expand Up @@ -233,8 +233,8 @@ def add_data_agreement(context):
"description": "Age of person",
"sensitivity": False,
"category": "",
},
],
}
]
}
}
base_url = context.config.userdata.get("base_url")
Expand Down
Loading

0 comments on commit d93729c

Please sign in to comment.