@@ -70,17 +70,6 @@ def test_client_dns():
70
70
# Simple API tests ################################################
71
71
72
72
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
-
84
73
85
74
def test_usertest ():
86
75
"""Verify liveness test works"""
@@ -181,6 +170,36 @@ def test_admingetusers(state: State):
181
170
userlist = response .json ()
182
171
assert len (userlist ) > 1
183
172
173
+ def test_check_usernames (state : State ):
174
+ """Verify logged-in base_admin can test usernames, gets correct result - existing user """
175
+ # Build auth string value including token from state
176
+ b_string = 'Bearer ' + state .state ['base_admin' ]
177
+
178
+ assert len (b_string ) > 24
179
+
180
+ auth_hdr = {'Authorization' : b_string }
181
+
182
+ data = {"username" :"base_admin" }
183
+ response = requests .post (SERVER_URL + "/api/admin/user/check_name" , headers = auth_hdr , json = data )
184
+ assert response .status_code == 200
185
+
186
+ is_user = response .json ()
187
+ assert is_user == 1
188
+
189
+ def test_check_badusernames (state : State ):
190
+ """Verify logged-in base_admin can test usernames, gets correct result - nonexistant user """
191
+ # Build auth string value including token from state
192
+ b_string = 'Bearer ' + state .state ['base_admin' ]
193
+ assert len (b_string ) > 24
194
+ auth_hdr = {'Authorization' : b_string }
195
+
196
+ data = {"username" :"got_no_username_like_this" }
197
+ response = requests .post (SERVER_URL + "/api/admin/user/check_name" , headers = auth_hdr , json = data )
198
+ assert response .status_code == 200
199
+
200
+ is_user = response .json ()
201
+ assert is_user == 0
202
+
184
203
185
204
def test_usergetusers (state : State ):
186
205
"""Verify logged-in base_user *cannot* use JWT to get user list """
@@ -192,3 +211,25 @@ def test_usergetusers(state: State):
192
211
auth_hdr = {'Authorization' : b_string }
193
212
response = requests .get (SERVER_URL + "/api/admin/user/get_users" , headers = auth_hdr )
194
213
assert response .status_code == 403
214
+
215
+
216
+ def test_currentFiles (state : State ):
217
+ """360 view Current Files list"""
218
+
219
+ b_string = 'Bearer ' + state .state ['base_admin' ]
220
+ assert len (b_string ) > 24
221
+ auth_hdr = {'Authorization' : b_string }
222
+
223
+ response = requests .get (SERVER_URL + "/api/listCurrentFiles" , headers = auth_hdr )
224
+ assert response .status_code == 200
225
+
226
+
227
+ def test_statistics (state : State ):
228
+ """360 view Statistics"""
229
+
230
+ b_string = 'Bearer ' + state .state ['base_admin' ]
231
+ assert len (b_string ) > 24
232
+ auth_hdr = {'Authorization' : b_string }
233
+
234
+ response = requests .get (SERVER_URL + "/api/statistics" , headers = auth_hdr )
235
+ assert response .status_code == 200
0 commit comments