Skip to content

Commit

Permalink
OPA ingest tests (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
daisieh committed Oct 4, 2024
1 parent 18f2a60 commit 797cf8f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions etc/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,34 @@ def test_opa_datasets(user, dataset):
assert dataset in response.json()["result"]


## Can we add a dataset to one of the users?
def test_add_opa_dataset():
token = get_token(
username=ENV["CANDIG_SITE_ADMIN_USER"],
password=ENV["CANDIG_SITE_ADMIN_PASSWORD"],
)
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json; charset=utf-8",
}

test_data = {
"email": ENV["CANDIG_SITE_ADMIN_USER"] + "@test.ca",
"program": "OPA-TEST"
}

response = requests.post(f"{ENV['CANDIG_URL']}/ingest/program/{test_data['program']}/email/{test_data['email']}", headers=headers)
# when the user has admin access, they should be allowed
print(response.json())
assert response.status_code == 200

test_opa_datasets("CANDIG_SITE_ADMIN", test_data["program"])

response = requests.delete(f"{ENV['CANDIG_URL']}/ingest/program/{test_data['program']}/email/{test_data['email']}", headers=headers)
assert response.status_code == 200
assert test_data['program'] not in response.json()["access"]["controlled_access_list"][test_data["email"]]


## Is the user a site admin?
def user_admin():
return [
Expand Down

0 comments on commit 797cf8f

Please sign in to comment.