summaryrefslogtreecommitdiff
path: root/yarns/900.yarn
diff options
context:
space:
mode:
Diffstat (limited to 'yarns/900.yarn')
-rw-r--r--yarns/900.yarn36
1 files changed, 33 insertions, 3 deletions
diff --git a/yarns/900.yarn b/yarns/900.yarn
index c7e81a0..5d11865 100644
--- a/yarns/900.yarn
+++ b/yarns/900.yarn
@@ -1,8 +1,24 @@
# Scenario step implementations
+ IMPLEMENTS GIVEN a users.yaml with user (\S+), password (\S+), scopes (.+)
+ username = get_next_match()
+ password = get_next_match()
+ scopes_string = get_next_match()
+ scopes = [s.strip() for s in scopes_string.split(',')]
+ user = {
+ 'salt': 'nacl',
+ 'password': distixapi.encrypt_password('nacl', password),
+ 'cleartext': password,
+ 'scopes': scopes,
+ }
+ users = load_users()
+ users['users'][username] = user
+ save_users(users)
+
IMPLEMENTS GIVEN a running backend instance
backend = os.path.join(srcdir, 'distix-backend')
- cliapp.runcmd(['/usr/sbin/daemonize', '-c.', backend, 'pid', 'port'])
+ cliapp.runcmd(
+ ['/usr/sbin/daemonize', '-c.', backend, 'pid', 'port', 'users.yaml'])
vars['pid'] = cat('pid').strip()
vars['port'] = cat('port').strip()
@@ -11,8 +27,22 @@
print 'killing process', repr(vars['pid'])
os.kill(int(vars['pid']), signal.SIGTERM)
- IMPLEMENTS WHEN client makes request GET (\S+)
- path = os.environ['MATCH_1']
+ IMPLEMENTS WHEN user (\S+) makes request GET (\S+)
+ user = get_next_match()
+ path = get_next_match()
+ url = 'http://localhost:{}{}'.format(vars['port'], path)
+ print 'url:', repr(url)
+ users = load_users()
+ print repr(users)
+ password = users['users'][user]['cleartext']
+ import requests
+ r = requests.get(url, auth=(user, password))
+ vars['http-status'] = r.status_code
+ vars['http-body'] = r.text
+
+ IMPLEMENTS WHEN user (\S+) makes unauthenticated request GET (\S+)
+ user = get_next_match()
+ path = get_next_match()
url = 'http://localhost:{}{}'.format(vars['port'], path)
print 'url:', repr(url)
import requests