Skip to content

Commit 99fbf87

Browse files
authored
Merge pull request #298 from CodeForPhilly/297-tests
Update Admin tests for JWTs
2 parents 1dd57c3 + e21195a commit 99fbf87

File tree

1 file changed

+54
-11
lines changed

1 file changed

+54
-11
lines changed

src/server/test_api.py

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,6 @@ def test_client_dns():
7070
# Simple API tests ################################################
7171

7272

73-
def test_currentFiles():
74-
"""360 view Current Files list"""
75-
response = requests.get(SERVER_URL + "/api/listCurrentFiles")
76-
assert response.status_code == 200
77-
78-
79-
def test_statistics():
80-
"""360 view Statistics"""
81-
response = requests.get(SERVER_URL + "/api/statistics")
82-
assert response.status_code == 200
83-
8473

8574
def test_usertest():
8675
"""Verify liveness test works"""
@@ -181,6 +170,38 @@ def test_admingetusers(state: State):
181170
userlist = response.json()
182171
assert len(userlist) > 1
183172

173+
# Endpoints not implemented yet
174+
175+
# def test_check_usernames(state: State):
176+
# """Verify logged-in base_admin can test usernames, gets correct result - existing user """
177+
# # Build auth string value including token from state
178+
# b_string = 'Bearer ' + state.state['base_admin']
179+
180+
# assert len(b_string) > 24
181+
182+
# auth_hdr = {'Authorization' : b_string}
183+
184+
# data = {"username":"base_admin"}
185+
# response = requests.post(SERVER_URL + "/api/admin/user/check_name", headers=auth_hdr, json=data)
186+
# assert response.status_code == 200
187+
188+
# is_user = response.json()
189+
# assert is_user == 1
190+
191+
# def test_check_badusernames(state: State):
192+
# """Verify logged-in base_admin can test usernames, gets correct result - nonexistant user """
193+
# # Build auth string value including token from state
194+
# b_string = 'Bearer ' + state.state['base_admin']
195+
# assert len(b_string) > 24
196+
# auth_hdr = {'Authorization' : b_string}
197+
198+
# data = {"username":"got_no_username_like_this"}
199+
# response = requests.post(SERVER_URL + "/api/admin/user/check_name", headers=auth_hdr, json=data)
200+
# assert response.status_code == 200
201+
202+
# is_user = response.json()
203+
# assert is_user == 0
204+
184205

185206
def test_usergetusers(state: State):
186207
"""Verify logged-in base_user *cannot* use JWT to get user list """
@@ -192,3 +213,25 @@ def test_usergetusers(state: State):
192213
auth_hdr = {'Authorization' : b_string}
193214
response = requests.get(SERVER_URL + "/api/admin/user/get_users", headers=auth_hdr)
194215
assert response.status_code == 403
216+
217+
218+
def test_currentFiles(state: State):
219+
"""360 view Current Files list"""
220+
221+
b_string = 'Bearer ' + state.state['base_admin']
222+
assert len(b_string) > 24
223+
auth_hdr = {'Authorization' : b_string}
224+
225+
response = requests.get(SERVER_URL + "/api/listCurrentFiles", headers=auth_hdr)
226+
assert response.status_code == 200
227+
228+
229+
def test_statistics(state: State):
230+
"""360 view Statistics"""
231+
232+
b_string = 'Bearer ' + state.state['base_admin']
233+
assert len(b_string) > 24
234+
auth_hdr = {'Authorization' : b_string}
235+
236+
response = requests.get(SERVER_URL + "/api/statistics", headers=auth_hdr)
237+
assert response.status_code == 200

0 commit comments

Comments
 (0)