Verified Commit 1a5c33a0 authored by p.jbowden's avatar p.jbowden
Browse files

update cpabe tests to account for access control

- when uploaded a new set of keys, create a new xnat subject with the correct keyid since xnat is used as an attribute source for access control
parent ec86a150
Pipeline #263227 passed with stages
in 1 minute and 7 seconds
......@@ -10,6 +10,7 @@ from .. import env
from ..lib.keycloak import get_keycloak_access_token
from ..lib.registration_authority import edit_user_and_regen_cpabe_key
from ..lib.cpabe_server import set_cpabe_policy, get_current_cpabe_policy, encrypt_and_upload_sse_keys, download_and_decrypt_sse_keys
from ..lib.xnat import create_xnat_subject
keycloak_env = [env.KEYCLOAK_AUTH_ENDPOINT, env.KEYCLOAK_REALM, env.KEYCLOAK_PUBLIC_CLIENT, env.TEST_KEYCLOAK_USER, env.TEST_KEYCLOAK_PASSWORD]
......@@ -38,6 +39,7 @@ class TestCPABEServer(unittest.TestCase):
"values":[env.TEST_PROJECT, "testing"],
"realmRoles":[],
}
edit_user_and_regen_cpabe_key(env.REGISTRATION_AUTHORITY_BASE_URL, env.TEST_KEYCLOAK_USER, payload, get_keycloak_access_token(*keycloak_env))
def test_000_set_cpabe_policy(self):
......@@ -76,6 +78,7 @@ class TestCPABEServer(unittest.TestCase):
Passes iff:
* CPABE Server returned an 'OK' status
* The output is a key_id (uuid) wrapped in quotes
* A new subject with that key_id can be added to XNAT
"""
res = encrypt_and_upload_sse_keys(env.CPABE_SERVER_BASE_URL, self.ver_key, self.enc_key, self.access_token)
......@@ -88,6 +91,21 @@ class TestCPABEServer(unittest.TestCase):
# save key_id for next test
state['key_id'] = data.decode('ascii').replace('"', '')
# add a new subject with that key_id on xnat
# this is needed because the next test uses xnat as attribute source for
# access control
res = create_xnat_subject(
env.XNAT_API_URL,
env.XNAT_ADMIN_USER,
env.XNAT_ADMIN_PASSWORD,
env.TEST_PROJECT,
uuid4(),
state['key_id']
)
assert (res.status == 201)
def test_003_download_and_decrypt_sse_keys(self):
"""
Test CPABE Server download an decrypt sse keys
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment