Commit f43065aa authored by lukas.burgey's avatar lukas.burgey

Add more tests for models.users

parent 2a663dcf
......@@ -103,6 +103,36 @@ def userinfo(idp, entitlement, group):
idp.userinfo_field_entitlements: [entitlement.name],
}
@pytest.fixture
def userinfo_without_lists(idp, entitlement, group):
return {
'iss': idp.issuer_uri,
'sub':'fb0fa558-cfa2-49f9-b847-5c651d1f6135',
'ssh_key': 'ssh-rsa AAAAB3NzaC1yhApzBpUulukg9Q== TEST_KEY',
'name': 'Gustav Holst',
'given_name': 'Gustav',
'family_name': 'Holst',
'preferred_username': 'gustav.holst',
'email': 'gustav@holst-feudal-test.co.uk',
idp.userinfo_field_groups: group.name,
idp.userinfo_field_entitlements: entitlement.name,
}
@pytest.fixture
def userinfo_invalid_vos(idp):
return {
'iss': idp.issuer_uri,
'sub':'fb0fa558-cfa2-49f9-b847-5c651d1f6135',
'ssh_key': 'ssh-rsa AAAAB3NzaC1yhApzBpUulukg9Q== TEST_KEY',
'name': 'Gustav Holst',
'given_name': 'Gustav',
'family_name': 'Holst',
'preferred_username': 'gustav.holst',
'email': 'gustav@holst-feudal-test.co.uk',
idp.userinfo_field_groups: 0, # invalid value
idp.userinfo_field_entitlements: 0, # invalid value
}
@pytest.fixture
def password():
return 'foobarbaz'
......
......@@ -21,12 +21,28 @@ def test_user_deactivation(deployed_deployment, user):
user.deactivate()
assert not user.is_active
user.deactivate() # redo the deactivation
assert not user.is_active
user.activate()
assert user.is_active
user.activate() # redo the activation
assert user.is_active
# TODO add assertions for the user and dep and state
def test_user_userinfo_without_lists(idp, userinfo_without_lists):
user = User.construct_from_userinfo(userinfo_without_lists, idp)
assert user.vos.count() == 2 # non list vos should still be applied
def test_user_userinfo_invalid_vos(idp, userinfo_invalid_vos):
user = User.construct_from_userinfo(userinfo_invalid_vos, idp)
assert user.vos.count() == 0 # no vos applied
def test_user_key_after_deployment(deployed_deployment, idp, userinfo, downstream_test_client):
user = User.construct_from_userinfo(userinfo, idp)
assert user is not None
......
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