def test_userpass_fail(vo, rest_client): """AUTHENTICATION (REST): Username and password (wrong credentials).""" response = rest_client.get('/auth/userpass', headers=headers( loginhdr('wrong', 'wrong', 'wrong'), vohdr(vo))) assert response.status_code == 401
def test_delete_identity_of_account(vo, rest_client): """ ACCOUNT (REST): send a DELETE to remove an identity of an account.""" account = account_name_generator() identity = uuid() password = '******' add_account(account, 'USER', '*****@*****.**', 'root', vo=vo) add_identity(identity, IdentityType.USERPASS, '*****@*****.**', password) add_account_identity(identity, IdentityType.USERPASS, InternalAccount(account, vo=vo), '*****@*****.**') auth_response = rest_client.get('/auth/userpass', headers=headers( loginhdr(account, identity, password), vohdr(vo))) assert auth_response.status_code == 200 assert 'X-Rucio-Auth-Token' in auth_response.headers token = str(auth_response.headers.get('X-Rucio-Auth-Token')) assert len(token) != 0 # normal deletion data = {'authtype': 'USERPASS', 'identity': identity} response = rest_client.delete('/accounts/' + account + '/identities', headers=headers(auth(token)), json=data) assert response.status_code == 200 # unauthorized deletion other_account = account_name_generator() data = {'authtype': 'USERPASS', 'identity': identity} response = rest_client.delete('/accounts/' + other_account + '/identities', headers=headers(auth(token)), json=data) assert response.status_code == 401
def test_userpass_success(vo, rest_client): """AUTHENTICATION (REST): Username and password (correct credentials).""" response = rest_client.get('/auth/userpass', headers=headers( loginhdr('root', 'ddmlab', 'secret'), vohdr(vo))) assert response.status_code == 200 assert len(response.headers.get('X-Rucio-Auth-Token')) > 32
def auth_token(rest_client, vo): from rucio.tests.common import vohdr, headers, loginhdr auth_response = rest_client.get('/auth/userpass', headers=headers(loginhdr('root', 'ddmlab', 'secret'), vohdr(vo))) assert auth_response.status_code == 200 token = auth_response.headers.get('X-Rucio-Auth-Token') assert token return str(token)