@@ -151,7 +151,9 @@ mod tests {
151151 use htsget_config:: config:: Config ;
152152 use htsget_config:: storage:: file:: default_path;
153153 use htsget_config:: types:: JsonResponse ;
154- use htsget_test:: http:: auth:: { MockAuthServer , create_test_auth_config} ;
154+ use htsget_test:: http:: auth:: {
155+ MockAuthServer , create_test_auth_config, mock_id_test, mock_prefix_test, mock_regex_test,
156+ } ;
155157 use htsget_test:: http:: server:: expected_url_path;
156158 use htsget_test:: http:: {
157159 Header , Response as TestResponse , TestRequest , TestServer , auth, config_with_tls, cors,
@@ -161,6 +163,7 @@ mod tests {
161163 use http:: header:: HeaderName ;
162164 use http:: { Method , Request } ;
163165 use rustls:: crypto:: aws_lc_rs;
166+ use serde_json:: Value ;
164167 use tempfile:: TempDir ;
165168 use tower:: ServiceExt ;
166169
@@ -264,8 +267,8 @@ mod tests {
264267 }
265268 }
266269
267- async fn new_with_auth ( public_key : Vec < u8 > , suppressed : bool ) -> Self {
268- let mock_server = MockAuthServer :: new ( ) . await ;
270+ async fn new_with_auth ( public_key : Vec < u8 > , suppressed : bool , mock_location : Value ) -> Self {
271+ let mock_server = MockAuthServer :: new ( mock_location ) . await ;
269272 let auth_config = create_test_auth_config ( & mock_server, public_key, suppressed) ;
270273 let config = default_test_config ( Some ( auth_config) ) ;
271274
@@ -374,16 +377,38 @@ mod tests {
374377 async fn test_auth_insufficient_permissions ( ) {
375378 let ( private_key, public_key) = generate_key_pair ( ) ;
376379
377- let server = AxumTestServer :: new_with_auth ( public_key, false ) . await ;
380+ let server = AxumTestServer :: new_with_auth ( public_key, false , mock_id_test ( ) ) . await ;
378381 auth:: test_auth_insufficient_permissions :: < JsonResponse , _ > ( & server, private_key) . await ;
379382 }
380383
381384 #[ tokio:: test]
382- async fn test_auth_succeeds ( ) {
385+ async fn test_auth_succeeds_id ( ) {
386+ let ( private_key, public_key) = generate_key_pair ( ) ;
387+
388+ auth:: test_auth_succeeds :: < JsonResponse , _ > (
389+ & AxumTestServer :: new_with_auth ( public_key, false , mock_id_test ( ) ) . await ,
390+ private_key,
391+ )
392+ . await ;
393+ }
394+
395+ #[ tokio:: test]
396+ async fn test_auth_succeeds_prefix ( ) {
397+ let ( private_key, public_key) = generate_key_pair ( ) ;
398+
399+ auth:: test_auth_succeeds :: < JsonResponse , _ > (
400+ & AxumTestServer :: new_with_auth ( public_key, false , mock_prefix_test ( ) ) . await ,
401+ private_key,
402+ )
403+ . await ;
404+ }
405+
406+ #[ tokio:: test]
407+ async fn test_auth_succeeds_regex ( ) {
383408 let ( private_key, public_key) = generate_key_pair ( ) ;
384409
385410 auth:: test_auth_succeeds :: < JsonResponse , _ > (
386- & AxumTestServer :: new_with_auth ( public_key, false ) . await ,
411+ & AxumTestServer :: new_with_auth ( public_key, false , mock_regex_test ( ) ) . await ,
387412 private_key,
388413 )
389414 . await ;
@@ -394,7 +419,7 @@ mod tests {
394419 async fn test_auth_insufficient_permissions_suppressed ( ) {
395420 let ( private_key, public_key) = generate_key_pair ( ) ;
396421
397- let server = AxumTestServer :: new_with_auth ( public_key, true ) . await ;
422+ let server = AxumTestServer :: new_with_auth ( public_key, true , mock_id_test ( ) ) . await ;
398423 auth:: test_auth_insufficient_permissions :: < JsonResponse , _ > ( & server, private_key) . await ;
399424 }
400425
@@ -404,7 +429,7 @@ mod tests {
404429 let ( private_key, public_key) = generate_key_pair ( ) ;
405430
406431 auth:: test_auth_succeeds :: < JsonResponse , _ > (
407- & AxumTestServer :: new_with_auth ( public_key, true ) . await ,
432+ & AxumTestServer :: new_with_auth ( public_key, true , mock_id_test ( ) ) . await ,
408433 private_key,
409434 )
410435 . await ;
0 commit comments