@@ -10,7 +10,7 @@ use std::{
10
10
time:: Duration ,
11
11
} ;
12
12
13
- use common:: app;
13
+ use common:: { app, setup } ;
14
14
15
15
use axum:: {
16
16
body:: Body ,
@@ -43,6 +43,8 @@ use crate::common::default_test_config;
43
43
44
44
#[ tokio:: test]
45
45
async fn test_validate ( ) {
46
+ setup ( ) ;
47
+
46
48
let config = default_test_config ( ) ;
47
49
let app = app ( config) . await ;
48
50
@@ -86,6 +88,8 @@ async fn test_validate() {
86
88
true ,
87
89
) ]
88
90
async fn test_validate_policy_group ( #[ case] payload : & str , #[ case] expected_allowed : bool ) {
91
+ setup ( ) ;
92
+
89
93
let config = default_test_config ( ) ;
90
94
let app = app ( config) . await ;
91
95
@@ -147,6 +151,8 @@ async fn test_validate_policy_group(#[case] payload: &str, #[case] expected_allo
147
151
148
152
#[ tokio:: test]
149
153
async fn test_validate_policy_not_found ( ) {
154
+ setup ( ) ;
155
+
150
156
let config = default_test_config ( ) ;
151
157
let app = app ( config) . await ;
152
158
@@ -166,6 +172,8 @@ async fn test_validate_policy_not_found() {
166
172
167
173
#[ tokio:: test]
168
174
async fn test_validate_invalid_payload ( ) {
175
+ setup ( ) ;
176
+
169
177
let config = default_test_config ( ) ;
170
178
let app = app ( config) . await ;
171
179
@@ -183,6 +191,8 @@ async fn test_validate_invalid_payload() {
183
191
184
192
#[ tokio:: test]
185
193
async fn test_validate_raw ( ) {
194
+ setup ( ) ;
195
+
186
196
let config = default_test_config ( ) ;
187
197
let app = app ( config) . await ;
188
198
@@ -211,6 +221,8 @@ async fn test_validate_raw() {
211
221
212
222
#[ tokio:: test]
213
223
async fn test_validate_policy_group_does_not_do_mutation ( ) {
224
+ setup ( ) ;
225
+
214
226
let config = default_test_config ( ) ;
215
227
let app = app ( config) . await ;
216
228
@@ -264,6 +276,8 @@ async fn test_validate_policy_group_does_not_do_mutation() {
264
276
265
277
#[ tokio:: test]
266
278
async fn test_validate_raw_policy_not_found ( ) {
279
+ setup ( ) ;
280
+
267
281
let config = default_test_config ( ) ;
268
282
let app = app ( config) . await ;
269
283
@@ -283,6 +297,8 @@ async fn test_validate_raw_policy_not_found() {
283
297
284
298
#[ tokio:: test]
285
299
async fn test_validate_raw_invalid_payload ( ) {
300
+ setup ( ) ;
301
+
286
302
let config = default_test_config ( ) ;
287
303
let app = app ( config) . await ;
288
304
@@ -300,6 +316,8 @@ async fn test_validate_raw_invalid_payload() {
300
316
301
317
#[ tokio:: test]
302
318
async fn test_audit ( ) {
319
+ setup ( ) ;
320
+
303
321
let config = default_test_config ( ) ;
304
322
let app = app ( config) . await ;
305
323
@@ -332,6 +350,8 @@ async fn test_audit() {
332
350
333
351
#[ tokio:: test]
334
352
async fn test_audit_policy_not_found ( ) {
353
+ setup ( ) ;
354
+
335
355
let config = default_test_config ( ) ;
336
356
let app = app ( config) . await ;
337
357
@@ -351,6 +371,8 @@ async fn test_audit_policy_not_found() {
351
371
352
372
#[ tokio:: test]
353
373
async fn test_audit_invalid_payload ( ) {
374
+ setup ( ) ;
375
+
354
376
let config = default_test_config ( ) ;
355
377
let app = app ( config) . await ;
356
378
@@ -368,6 +390,8 @@ async fn test_audit_invalid_payload() {
368
390
369
391
#[ tokio:: test]
370
392
async fn test_timeout_protection_accept ( ) {
393
+ setup ( ) ;
394
+
371
395
let config = default_test_config ( ) ;
372
396
let app = app ( config) . await ;
373
397
@@ -390,6 +414,8 @@ async fn test_timeout_protection_accept() {
390
414
391
415
#[ tokio:: test]
392
416
async fn test_timeout_protection_reject ( ) {
417
+ setup ( ) ;
418
+
393
419
let config = default_test_config ( ) ;
394
420
let app = app ( config) . await ;
395
421
@@ -422,6 +448,8 @@ async fn test_timeout_protection_reject() {
422
448
423
449
#[ tokio:: test]
424
450
async fn test_verified_policy ( ) {
451
+ setup ( ) ;
452
+
425
453
let verification_cfg_yml = r#"---
426
454
allOf:
427
455
- kind: pubKey
@@ -477,6 +505,8 @@ async fn test_verified_policy() {
477
505
478
506
#[ tokio:: test]
479
507
async fn test_policy_with_invalid_settings ( ) {
508
+ setup ( ) ;
509
+
480
510
let mut config = default_test_config ( ) ;
481
511
config. policies . insert (
482
512
"invalid_settings" . to_owned ( ) ,
@@ -523,6 +553,8 @@ async fn test_policy_with_invalid_settings() {
523
553
524
554
#[ tokio:: test]
525
555
async fn test_policy_with_wrong_url ( ) {
556
+ setup ( ) ;
557
+
526
558
let mut config = default_test_config ( ) ;
527
559
config. policies . insert (
528
560
"wrong_url" . to_owned ( ) ,
@@ -653,14 +685,7 @@ mod certificate_reload_helpers {
653
685
async fn test_detect_certificate_rotation ( ) {
654
686
use certificate_reload_helpers:: * ;
655
687
656
- // Starting from rustls 0.22, each application must set its default crypto provider.
657
- // This setup is done inside of the `main` function of the policy server,
658
- // which is not called in this test.
659
- // Hence we have to setup the crypto provider here.
660
- let crypto_provider = rustls:: crypto:: ring:: default_provider ( ) ;
661
- crypto_provider
662
- . install_default ( )
663
- . expect ( "Failed to install crypto provider" ) ;
688
+ setup ( ) ;
664
689
665
690
let certs_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
666
691
let cert_file = certs_dir. path ( ) . join ( "policy-server.pem" ) ;
@@ -734,6 +759,8 @@ async fn test_detect_certificate_rotation() {
734
759
735
760
#[ tokio:: test]
736
761
async fn test_otel ( ) {
762
+ setup ( ) ;
763
+
737
764
let mut otelc_config_path = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
738
765
otelc_config_path. push ( "tests/data/otel-collector-config.yaml" ) ;
739
766
0 commit comments