6565import java .util .function .Function ;
6666import java .util .function .Supplier ;
6767import java .util .stream .Collectors ;
68- import org .junit .jupiter .api .AfterEach ;
6968import org .junit .jupiter .api .Test ;
7069import org .junit .jupiter .api .extension .ExtendWith ;
7170import org .junitpioneer .jupiter .ClearSystemProperty ;
7978import org .mockito .junit .jupiter .MockitoExtension ;
8079
8180@ ExtendWith (MockitoExtension .class )
82- @ ClearSystemProperty (key = "TRUSTIFY_DA_SNYK_TOKEN" )
8381@ ClearSystemProperty (key = "TRUSTIFY_DA_DEV_MODE" )
8482@ ClearSystemProperty (key = "TRUSTIFY_DA_PROXY_URL" )
8583@ ClearSystemProperty (key = "DEV_TRUSTIFY_DA_BACKEND_URL" )
@@ -94,13 +92,7 @@ class TRUSTIFY_DA_Api_Test extends ExhortTest {
9492
9593 @ InjectMocks ExhortApi exhortApiSut ;
9694
97- @ AfterEach
98- void cleanup () {
99- System .clearProperty ("TRUSTIFY_DA_SNYK_TOKEN" );
100- }
101-
10295 @ Test
103- @ SetSystemProperty (key = "TRUSTIFY_DA_SNYK_TOKEN" , value = "snyk-token-from-env-var" )
10496 @ SetSystemProperty (key = "TRUST_DA_TOKEN" , value = "trust-da-token-from-env-var" )
10597 @ SetSystemProperty (key = "TRUST_DA_SOURCE" , value = "trust-da-source-from-env-var" )
10698 void stackAnalysisHtml_with_pom_xml_should_return_html_report_from_the_backend ()
@@ -121,9 +113,6 @@ void stackAnalysisHtml_with_pom_xml_should_return_html_report_from_the_backend()
121113 r ->
122114 r .headers ().firstValue ("Content-Type" ).get ().equals ("fake-content-type" )
123115 && r .headers ().firstValue ("Accept" ).get ().equals ("text/html" )
124- &&
125- // snyk token is set using the environment variable (annotation)
126- r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token-from-env-var" )
127116 && r .headers ()
128117 .firstValue ("trust-da-token" )
129118 .get ()
@@ -167,7 +156,6 @@ void stackAnalysisHtml_with_pom_xml_should_return_html_report_from_the_backend()
167156 }
168157
169158 @ Test
170- @ SetSystemProperty (key = "TRUSTIFY_DA_SNYK_TOKEN" , value = "snyk-token" )
171159 @ SetSystemProperty (key = "TRUST_DA_TOKEN" , value = "trust-da-token" )
172160 @ SetSystemProperty (key = "TRUST_DA_SOURCE" , value = "trust-da-source" )
173161 void stackAnalysis_with_pom_xml_should_return_json_object_from_the_backend ()
@@ -188,7 +176,6 @@ void stackAnalysis_with_pom_xml_should_return_json_object_from_the_backend()
188176 r ->
189177 r .headers ().firstValue ("Content-Type" ).get ().equals ("fake-content-type" )
190178 && r .headers ().firstValue ("Accept" ).get ().equals ("application/json" )
191- && r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token" )
192179 && r .headers ().firstValue ("trust-da-token" ).get ().equals ("trust-da-token" )
193180 && r .headers ().firstValue ("trust-da-source" ).get ().equals ("trust-da-source" )
194181 && r .headers ().firstValue ("trust-da-operation-type" ).get ().equals ("Stack Analysis" )
@@ -243,7 +230,6 @@ void componentAnalysis_with_pom_xml_should_return_json_object_from_the_backend()
243230 .willReturn (new Provider .Content ("fake-body-content" .getBytes (), "fake-content-type" ));
244231
245232 // we expect this to picked up because no env var to take precedence
246- System .setProperty ("TRUSTIFY_DA_SNYK_TOKEN" , "snyk-token-from-property" );
247233 System .setProperty ("TRUST_DA_TOKEN" , "trust-da-token-from-property" );
248234 System .setProperty ("TRUST_DA_SOURCE" , "trust-da-source-from-property" );
249235
@@ -252,10 +238,6 @@ void componentAnalysis_with_pom_xml_should_return_json_object_from_the_backend()
252238 r ->
253239 r .headers ().firstValue ("Content-Type" ).get ().equals ("fake-content-type" )
254240 && r .headers ().firstValue ("Accept" ).get ().equals ("application/json" )
255- &&
256- // snyk token is set using properties which is picked up because no env var
257- // specified
258- r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token-from-property" )
259241 && r .headers ()
260242 .firstValue ("trust-da-token" )
261243 .get ()
@@ -387,17 +369,12 @@ void componentAnalysis_with_pom_xml_as_path_should_return_json_object_from_the_b
387369 .willReturn (new Provider .Content ("fake-body-content" .getBytes (), "fake-content-type" ));
388370
389371 // we expect this to picked up because no env var to take precedence
390- System .setProperty ("TRUSTIFY_DA_SNYK_TOKEN" , "snyk-token-from-property" );
391372
392373 // create an argument matcher to make sure we mock the response for the right request
393374 ArgumentMatcher <HttpRequest > matchesRequest =
394375 r ->
395376 r .headers ().firstValue ("Content-Type" ).get ().equals ("fake-content-type" )
396377 && r .headers ().firstValue ("Accept" ).get ().equals ("application/json" )
397- &&
398- // snyk token is set using properties which is picked up because no env var
399- // specified
400- r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token-from-property" )
401378 && r .method ().equals ("POST" );
402379
403380 // load dummy json and set as the expected analysis
@@ -471,7 +448,6 @@ void check_TRUSTIFY_DA_Url_When_Nothing_Set_Then_Default_TRUSTIFY_DA_URL_Selecte
471448 }
472449
473450 @ Test
474- @ SetSystemProperty (key = "TRUSTIFY_DA_SNYK_TOKEN" , value = "snyk-token-from-env-var" )
475451 @ SetSystemProperty (key = "TRUST_DA_TOKEN" , value = "trust-da-token-from-env-var" )
476452 @ SetSystemProperty (key = "TRUST_DA_SOURCE" , value = "trust-da-source-from-env-var" )
477453 @ SetSystemProperty (key = SKIP_VALIDATION_KEY , value = "true" )
@@ -535,7 +511,6 @@ void test_image_analysis()
535511 .firstValue ("Accept" )
536512 .get ()
537513 .equals (Api .MediaType .APPLICATION_JSON .toString ())
538- && r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token-from-env-var" )
539514 && r .headers ()
540515 .firstValue ("trust-da-token" )
541516 .get ()
@@ -580,7 +555,6 @@ void test_image_analysis()
580555 }
581556
582557 @ Test
583- @ SetSystemProperty (key = "TRUSTIFY_DA_SNYK_TOKEN" , value = "snyk-token-from-env-var" )
584558 @ SetSystemProperty (key = "TRUST_DA_TOKEN" , value = "trust-da-token-from-env-var" )
585559 @ SetSystemProperty (key = "TRUST_DA_SOURCE" , value = "trust-da-source-from-env-var" )
586560 @ SetSystemProperty (key = SKIP_VALIDATION_KEY , value = "true" )
@@ -643,7 +617,6 @@ void imageAnalysisHtml() throws IOException, ExecutionException, InterruptedExce
643617 .firstValue ("Accept" )
644618 .get ()
645619 .equals (Api .MediaType .TEXT_HTML .toString ())
646- && r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token-from-env-var" )
647620 && r .headers ()
648621 .firstValue ("trust-da-token" )
649622 .get ()
@@ -667,7 +640,6 @@ void imageAnalysisHtml() throws IOException, ExecutionException, InterruptedExce
667640 }
668641
669642 @ Test
670- @ SetSystemProperty (key = "TRUSTIFY_DA_SNYK_TOKEN" , value = "snyk-token-from-env-var" )
671643 @ SetSystemProperty (key = "TRUST_DA_TOKEN" , value = "trust-da-token-from-env-var" )
672644 @ SetSystemProperty (key = "TRUST_DA_SOURCE" , value = "trust-da-source-from-env-var" )
673645 void test_perform_batch_analysis ()
@@ -690,7 +662,6 @@ void test_perform_batch_analysis()
690662 .firstValue ("Accept" )
691663 .get ()
692664 .equals (Api .MediaType .APPLICATION_JSON .toString ())
693- && r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token-from-env-var" )
694665 && r .headers ()
695666 .firstValue ("trust-da-token" )
696667 .get ()
0 commit comments