Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
roywilly committed May 8, 2024
1 parent 200a9b9 commit 7ce3e61
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions tests/test_access/tst_access_drogon_affiliate_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_get_userpermissions(explorer: Explorer):
print("/Userpermissions response: ", response.text)
userperms = json.loads(response.text)
assert "Drogon" in userperms
assert "read" in userperms.get("Drogon")
assert "affiliate" in userperms.get("Drogon")
assert 1 == len(userperms.get("Drogon"))
assert 1 == len(userperms)

Expand All @@ -58,33 +58,38 @@ def test_get_cases(explorer: Explorer):
print("Number of cases: ", len(cases))
for case in cases:
assert case.field.lower() == "drogon"
assert len(cases) > 0
# We have set up a KEEP case in Drogon DEV with one or more
# objects with affiliate-access
assert len(cases) == 1
# TODO dive into the case and find the child objects setup for
# this affiliate user to access
assert True == False # TODO


def test_write(explorer: Explorer):
"""Test a write method"""
print("Running test:", inspect.currentframe().f_code.co_name)
cases = explorer.cases
print("Number of cases: ", len(cases))
assert len(cases) > 0
case = cases[0]
print("case uuid:", case.metadata.get("fmu").get("case").get("uuid"))
with pytest.raises(Exception, match="403*"):
print("About to write a case which should raise exception")
explorer._sumo.post(f"/objects", json=case.metadata)
print("Execution should never reach this line")
# def test_write(explorer: Explorer): # TODO USE some hardcoded uuid
# """Test a write method"""
# print("Running test:", inspect.currentframe().f_code.co_name)
# cases = explorer.cases
# print("Number of cases: ", len(cases))
# assert len(cases) > 0
# case = cases[0]
# print("case uuid:", case.metadata.get("fmu").get("case").get("uuid"))
# with pytest.raises(Exception, match="403*"):
# print("About to write a case which should raise exception")
# explorer._sumo.post(f"/objects", json=case.metadata)
# print("Execution should never reach this line")


def test_read_restricted_classification_data(explorer: Explorer):
def test_read_restricted_classification_data(explorer: Explorer): # TODO use some hardcoded uuid
"""Test if can read restriced data aka 'access:classification: restricted'"""
print("Running test:", inspect.currentframe().f_code.co_name)
cases = explorer.cases
print("Number of cases: ", len(cases))
assert len(cases) > 0
assert len(cases) == 0

# A default Drogon iteration contains 2 restricted objects,
# so in normal situations there should be some restricted objects,
# but never for this DROGON-READ user
# but never for this DROGON-AFFILIATE user
response = explorer._sumo.get(
"/search?%24query=access.classification%3Arestricted"
)
Expand Down

0 comments on commit 7ce3e61

Please sign in to comment.