def test_renew(dev_server): client = Vault(dev_server.addr, token=dev_server.root_token) response = yield from client.write('/secret/foo', json={ 'data': 'bar', 'lease': '1h' }) assert response.status == 204 response = yield from client.read('/secret/foo') result = yield from response.json() renewed = yield from client.lease.renew(result['lease_id']) assert renewed
def test_appid_raw(dev_server): client = Vault(dev_server.addr, token=dev_server.root_token) # enable app-id response = yield from client.write('/sys/auth/app-id', json={'type': 'app-id'}) assert response.status == 204 response = yield from client.write('/auth/app-id/map/app-id/foo', json={'value': 'dummy'}) response = yield from client.write('/auth/app-id/map/user-id/bar', json={'value': 'foo'}) assert response.status == 204 # do login client = Vault(dev_server.addr) # login response = yield from client.write('/auth/app-id/login', json={'app_id': 'foo', 'user_id': 'bar'}) result = yield from response.json() assert result['auth']['policies'] == ['dummy']
def test_userpass(dev_server): client = Vault(dev_server.addr, token=dev_server.root_token) # enable userpass backend = yield from client.auth.enable('userpass') response = yield from backend.create('mitchellh', 'foo') assert response # raw login response = yield from client.write('/auth/userpass/login/mitchellh', json={"password": "******"}) result = yield from response.json() assert result['auth']['metadata'] == {'username': '******'} # nicer login token = yield from client.login('userpass', username='******', password='******') assert token['metadata'] == {'username': '******'}
def test_github_raw_loading(dev_server): client = Vault(dev_server.addr, token=dev_server.root_token) response = yield from client.read('/sys/auth/github/login', params={"help": 1}) data = yield from response.json() print(data['help']) # low level create/delete response = yield from client.write('/sys/auth/github', json={"type": "github"}) assert response.status == 204, 'Must add github auth backend' response = yield from client.delete('/sys/auth/github') assert response.status == 204, 'Must delete github auth backend' # high level create/delete response = yield from client.auth.enable('github') assert response.type == 'github', 'Must add github auth backend' response = yield from client.auth.disable('github') assert response is True, 'Must delete github auth backend'