diff --git a/piu/cli.py b/piu/cli.py index b231454..4e734f4 100644 --- a/piu/cli.py +++ b/piu/cli.py @@ -146,12 +146,11 @@ def _request_access(even_url, cacert, username, hostname, reason, remote_host, if lifetime: data['lifetime_minutes'] = lifetime try: - token = zign.api.get_named_token(['uid'], 'employees', 'piu', user, password, prompt=True) + access_token = zign.api.get_token("piu", ['uid']) except zign.api.ServerError as e: click.secho('{}'.format(e), fg='red', bold=True) return 500 - access_token = token.get('access_token') click.secho('Requesting access to host {host_via} for {username}..'.format(host_via=host_via, username=username), bold=True) r = requests.post(even_url, headers={'Content-Type': 'application/json', @@ -398,5 +397,6 @@ def list_access_requests(obj, user, odd_host, status, limit, offset, output): def main(): handle_exceptions(cli)() + if __name__ == '__main__': main() diff --git a/requirements.txt b/requirements.txt index 5eb75b7..9f9d3a1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,6 @@ clickclick>=0.10 PyYAML requests pyperclip -stups-zign>=0.16 +stups-zign>=1.0.24 boto3>=1.3.0 botocore>=1.4.10 diff --git a/setup.py b/setup.py index c8209e1..9999cfc 100644 --- a/setup.py +++ b/setup.py @@ -22,6 +22,7 @@ def read_version(package): exec(fd.read(), data) return data['__version__'] + NAME = 'stups-piu' MAIN_PACKAGE = 'piu' VERSION = read_version(MAIN_PACKAGE) diff --git a/tests/test_cli.py b/tests/test_cli.py index a5fa99f..6a1bd0b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -16,7 +16,7 @@ def test_missing_reason(): def test_success(monkeypatch): response = MagicMock(status_code=200, text='**MAGIC-SUCCESS**') - monkeypatch.setattr('zign.api.get_named_token', MagicMock(return_value={'access_token': '123'})) + monkeypatch.setattr('zign.api.get_token', MagicMock(return_value='123')) monkeypatch.setattr('requests.post', MagicMock(return_value=response)) monkeypatch.setattr('keyring.set_password', MagicMock()) runner = CliRunner() @@ -36,7 +36,7 @@ def test_success(monkeypatch): def test_bad_request(monkeypatch): response = MagicMock(status_code=400, text='**MAGIC-BAD-REQUEST**') - monkeypatch.setattr('zign.api.get_named_token', MagicMock(return_value={'access_token': '123'})) + monkeypatch.setattr('zign.api.get_token', MagicMock(return_value='123')) monkeypatch.setattr('requests.post', MagicMock(return_value=response)) monkeypatch.setattr('keyring.set_password', MagicMock()) runner = CliRunner() @@ -57,7 +57,7 @@ def test_bad_request(monkeypatch): def test_auth_failure(monkeypatch): response = MagicMock(status_code=403, text='**MAGIC-AUTH-FAILED**') - monkeypatch.setattr('zign.api.get_named_token', MagicMock(return_value={'access_token': '123'})) + monkeypatch.setattr('zign.api.get_token', MagicMock(return_value='123')) monkeypatch.setattr('requests.post', MagicMock(return_value=response)) monkeypatch.setattr('keyring.set_password', MagicMock()) runner = CliRunner() @@ -77,7 +77,7 @@ def test_auth_failure(monkeypatch): def test_dialog(monkeypatch): response = MagicMock(status_code=200, text='**MAGIC-SUCCESS**') - monkeypatch.setattr('zign.api.get_named_token', MagicMock(return_value={'access_token': '123'})) + monkeypatch.setattr('zign.api.get_token', MagicMock(return_value='123')) monkeypatch.setattr('requests.post', MagicMock(return_value=response)) monkeypatch.setattr('requests.get', MagicMock(return_value=response)) monkeypatch.setattr('socket.getaddrinfo', MagicMock()) @@ -95,7 +95,7 @@ def test_dialog(monkeypatch): def test_oauth_failure(monkeypatch): response = MagicMock(status_code=200, text='**MAGIC-SUCCESS**') - monkeypatch.setattr('zign.api.get_named_token', MagicMock(side_effect=zign.api.ServerError('**MAGIC-FAIL**'))) + monkeypatch.setattr('zign.api.get_token', MagicMock(side_effect=zign.api.ServerError('**MAGIC-FAIL**'))) monkeypatch.setattr('requests.post', MagicMock(return_value=response)) monkeypatch.setattr('requests.get', MagicMock(return_value=response)) monkeypatch.setattr('socket.getaddrinfo', MagicMock()) @@ -305,7 +305,7 @@ def test_tunnel_success(monkeypatch): response = MagicMock(status_code=200, text='**MAGIC-SUCCESS**') - monkeypatch.setattr('zign.api.get_named_token', MagicMock(return_value={'access_token': '123'})) + monkeypatch.setattr('zign.api.get_token', MagicMock(return_value='123')) monkeypatch.setattr('requests.post', MagicMock(return_value=response)) monkeypatch.setattr('subprocess.call', MagicMock())