Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
Merge 948e5ed into 3e38fb5
Browse files Browse the repository at this point in the history
  • Loading branch information
esc committed May 12, 2016
2 parents 3e38fb5 + 948e5ed commit 901526e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 138 deletions.
21 changes: 0 additions & 21 deletions src/cmdlinetest/test_cbas.t
Expand Up @@ -20,7 +20,6 @@
--help Show this message and exit.

Commands:
delete Delete user.
dry_run Dry run, sanitize all config only.
upload Upload ssh-key and create user.

Expand Down Expand Up @@ -76,26 +75,6 @@
403 Client Error: Forbidden for url: http://localhost:8080/create
[1]

# Test a positive case for user deletion

$ cbas -u user_ok -p testing -h $JUMP_MOCK -a $AUTH_MOCK delete
Will now attempt to obtain an JWT...
Authentication OK!
Access token was received.
Will now attempt to delete your user...
Delete OK!

# Test a negative case for user deletion

$ cbas -u delete_fail -p testing -h $JUMP_MOCK -a $AUTH_MOCK delete
Will now attempt to obtain an JWT...
Authentication OK!
Access token was received.
Will now attempt to delete your user...
Delete failed!
403 Client Error: Forbidden for url: http://localhost:8080/delete
[1]

# Test error message for an empty page

$ cbas -u empty_page -p testing -k pubkey.pub -h $JUMP_MOCK -a $AUTH_MOCK upload
Expand Down
97 changes: 0 additions & 97 deletions src/cmdlinetest/test_cbas_verbose.t
Expand Up @@ -20,7 +20,6 @@
--help Show this message and exit.

Commands:
delete Delete user.
dry_run Dry run, sanitize all config only.
upload Upload ssh-key and create user.

Expand Down Expand Up @@ -203,102 +202,6 @@
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://localhost:8080/create
[1]
# Test a positive case for user deletion
$ cbas -v -u user_ok -p testing -h $JUMP_MOCK -a $AUTH_MOCK delete
Default config is:
---
auth_host: null
jump_host: null
password_provider: prompt
ssh_key_file: ~/.ssh/id_rsa.pub
username: * (glob)
...
Values supplied on the command-line are:
{'auth_host': u?'http://localhost:8080', (re)
'jump_host': u?'http://localhost:8080', (re)
'password_provider': u?'testing', (re)
'ssh_key_file': None, (re)
'username': u?'user_ok'} (re)
Final aggregated config:
---
auth_host: http://localhost:8080
jump_host: http://localhost:8080
password_provider: testing
ssh_key_file: ~/.ssh/id_rsa.pub
username: user_ok
...
Password provider is: 'testing'
Will now attempt to obtain an JWT...
Authentication OK!
Access token was received.
Access token is:
'my-nifty-access-token'
Will now attempt to delete your user...
Delete OK!
# Test a negative case for user deletion
$ cbas -v -u delete_fail -p testing -h $JUMP_MOCK -a $AUTH_MOCK delete
Default config is:
---
auth_host: null
jump_host: null
password_provider: prompt
ssh_key_file: ~/.ssh/id_rsa.pub
username: * (glob)
...
Values supplied on the command-line are:
{'auth_host': u?'http://localhost:8080', (re)
'jump_host': u?'http://localhost:8080', (re)
'password_provider': u?'testing', (re)
'ssh_key_file': None, (re)
'username': u?'delete_fail'} (re)
Final aggregated config:
---
auth_host: http://localhost:8080
jump_host: http://localhost:8080
password_provider: testing
ssh_key_file: ~/.ssh/id_rsa.pub
username: delete_fail
...
Password provider is: 'testing'
Will now attempt to obtain an JWT...
Authentication OK!
Access token was received.
Access token is:
'the-token-with-which-delete-will-fail'
Will now attempt to delete your user...
Delete failed!
403 Client Error: Forbidden for url: http://localhost:8080/delete
Traceback (most recent call last):
File "*/scripts/cbas", line *, in <module> (glob)
main()
File "*/site-packages/click/core.py", line *, in __call__ (glob)
return self.main(*args, **kwargs)
File "*/site-packages/click/core.py", line *, in main (glob)
rv = self.invoke(ctx)
File "*/site-packages/click/core.py", line *, in invoke (glob)
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "*/site-packages/click/core.py", line *, in invoke (glob)
return ctx.invoke(self.callback, **ctx.params)
File "*/site-packages/click/core.py", line *, in invoke (glob)
return callback(*args, **kwargs)
File "*/site-packages/click/decorators.py", line *, in new_func (glob)
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "*/site-packages/click/core.py", line *, in invoke (glob)
return callback(*args, **kwargs)
File "*/scripts/cbas", line *, in delete (glob)
jump_response.raise_for_status()
File "*/site-packages/requests/models.py", line *, in raise_for_status (glob)
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://localhost:8080/delete
[1]
# Shut down the mocked cbastion/auth server
$ rm pubkey.pub
Expand Down
20 changes: 0 additions & 20 deletions src/main/scripts/cbas
Expand Up @@ -113,26 +113,6 @@ def upload(config):
log.info("Upload OK!")


@main.command(help="Delete user.")
@pass_config
def delete(config):
password = get_password(config.password_provider, config.username)
access_token = obtain_access_token(config, password)

jump_request_header = {'Authorization': 'Bearer ' + access_token,
'Content-Type': 'application/json',
'Cache-Control': 'no-cache'}
jump_url = get_jump_url(config) + '/delete'

info("Will now attempt to delete your user...")
jump_response = requests.post(jump_url, headers=jump_request_header)
if jump_response.status_code != 200:
log.info("Delete failed!")
jump_response.raise_for_status()
else:
log.info("Delete OK!")


@main.command(help="Dry run, sanitize all config only.")
@pass_config
def dry_run(config):
Expand Down

0 comments on commit 901526e

Please sign in to comment.