Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrennan4 committed Aug 6, 2019
1 parent 0531c9b commit 42cdb80
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/unit/netapi/test_rest_tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,17 +527,17 @@ def test_login(self):
'''
Test valid logins
'''

# Test in form encoded
response = self.fetch('/login',
method='POST',
body=urlencode(self.auth_creds),
headers={'Content-Type': self.content_type_map['form']})

cookies = response.headers['Set-Cookie']
self.assertEqual(response.code, 200)
response_obj = salt.utils.json.loads(response.body)['return'][0]
token = response_obj['token']
self.assertEqual(response.cookies['session_id'], token)
self.assertIn('session_id={0}'.format(token), cookies)
self.assertEqual(sorted(response_obj['perms']), sorted(self.opts['external_auth']['auto'][self.auth_creds_dict['username']]))
self.assertIn('token', response_obj) # TODO: verify that its valid?
self.assertEqual(response_obj['user'], self.auth_creds_dict['username'])
Expand All @@ -549,10 +549,11 @@ def test_login(self):
body=salt.utils.json.dumps(self.auth_creds_dict),
headers={'Content-Type': self.content_type_map['json']})

cookies = response.headers['Set-Cookie']
self.assertEqual(response.code, 200)
response_obj = salt.utils.json.loads(response.body)['return'][0]
token = response_obj['token']
self.assertEqual(response.cookies['session_id'], token)
self.assertIn('session_id={0}'.format(token), cookies)
self.assertEqual(sorted(response_obj['perms']), sorted(self.opts['external_auth']['auto'][self.auth_creds_dict['username']]))
self.assertIn('token', response_obj) # TODO: verify that its valid?
self.assertEqual(response_obj['user'], self.auth_creds_dict['username'])
Expand All @@ -564,10 +565,11 @@ def test_login(self):
body=salt.utils.yaml.safe_dump(self.auth_creds_dict),
headers={'Content-Type': self.content_type_map['yaml']})

cookies = response.headers['Set-Cookie']
self.assertEqual(response.code, 200)
response_obj = salt.utils.json.loads(response.body)['return'][0]
token = response_obj['token']
self.assertEqual(response.cookies['session_id'], token)
self.assertIn('session_id={0}'.format(token), cookies)
self.assertEqual(sorted(response_obj['perms']), sorted(self.opts['external_auth']['auto'][self.auth_creds_dict['username']]))
self.assertIn('token', response_obj) # TODO: verify that its valid?
self.assertEqual(response_obj['user'], self.auth_creds_dict['username'])
Expand Down

0 comments on commit 42cdb80

Please sign in to comment.