diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-03-23 14:23:05 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-03-23 14:23:05 +0200 |
commit | 1a8367b5cf4432a3dadbb49f01e4de45c5ff4667 (patch) | |
tree | 0976924a6e41dc79e860cad61620e060fbc71586 | |
parent | ce861a21c9021e0f467e862a1bae7525a7fd5012 (diff) | |
download | effitool-1a8367b5cf4432a3dadbb49f01e4de45c5ff4667.tar.gz |
Refactor: add Session.allow_scopes
-rwxr-xr-x | effitool | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -222,6 +222,12 @@ class Session: def get_client(self, client_id): return self._api.get_json(self._token, '/clients/{}'.format(client_id)) + def allow_scopes(self, client_id, scopes): + path = '/clients/{}'.format(client_id) + client = self._api.get_json(self._token, path) + client['allowed_scopes'] = uniq(client.get('allowed_scopes', []) + scopes) + self._api.put_json(self._token, path, client) + def fetch_member(self, rid): headers = { 'Muck-Id': rid, @@ -323,15 +329,8 @@ class Tool: print(scope) def allow_scope(self, args): - name = args['client-name'] - scopes = args['scope'] - server = self.get_chosen_server(args) - token = self.get_admin_token(server) - api = HTTPAPI(server['url']) - path = '/clients/{}'.format(name) - client = api.get_json(token, path) - client['allowed_scopes'] = uniq(client.get('allowed_scopes', []) + scopes) - api.put_json(token, path, client) + session = self.get_session(args) + session.allow_scopes(args['client-name'], args['scope']) def deny_scope(self, args): name = args['client-name'] |