Skip to content

Commit

Permalink
Merge pull request #585 from colbyprior/json_test_fix
Browse files Browse the repository at this point in the history
Fix Flaky Black Box Test for test_get_all_users
  • Loading branch information
jdaigneau5 authored Mar 18, 2022
2 parents 99f1401 + 539e6b2 commit 81aaec4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions datadump/pre-population/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@
}
},
{
"username": "cps@mitre.org",
"username": "cps2@mitre.org",
"cna_short_name": "mitre",
"active": true,
"name": {
Expand Down Expand Up @@ -1014,4 +1014,4 @@
"created": "2021-05-11T15:07:20.674347Z"
}
}
]
]
11 changes: 8 additions & 3 deletions test-http/src/test/user_tests/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ def test_get_all_users():
f'{env.AWG_BASE_URL}/api/users',
headers=utils.BASE_HEADERS
)
assert json.loads(res.content.decode())['users'][0]['username'] == '[email protected]'
assert json.loads(res.content.decode())['users'][0]['name']['first'] == 'Jeremy'
test_user={}
for user in json.loads(res.content.decode())['users']:
if user['username'] == '[email protected]':
test_user = user
break
assert test_user['username'] == '[email protected]'
assert test_user['name']['first'] == 'Jeremy'
assert '"secret"' not in res.content.decode() # check that no secrets are included
assert res.status_code == 200

Expand All @@ -37,4 +42,4 @@ def test_org_admins_cannot_get_all_users(org_admin_headers):
headers=org_admin_headers
)
assert res.status_code == 403
response_contains_json(res, 'error', 'SECRETARIAT_ONLY')
response_contains_json(res, 'error', 'SECRETARIAT_ONLY')

0 comments on commit 81aaec4

Please sign in to comment.