6666import java .util .function .Function ;
6767import java .util .function .Supplier ;
6868import java .util .stream .Collectors ;
69- import org .junit .jupiter .api .AfterEach ;
7069import org .junit .jupiter .api .Test ;
7170import org .junit .jupiter .api .extension .ExtendWith ;
7271import org .junitpioneer .jupiter .ClearSystemProperty ;
8079import org .mockito .junit .jupiter .MockitoExtension ;
8180
8281@ ExtendWith (MockitoExtension .class )
83- @ ClearSystemProperty (key = "TRUSTIFY_DA_SNYK_TOKEN" )
8482@ ClearSystemProperty (key = "TRUSTIFY_DA_DEV_MODE" )
8583@ ClearSystemProperty (key = "TRUSTIFY_DA_PROXY_URL" )
8684@ ClearSystemProperty (key = "DEV_TRUSTIFY_DA_BACKEND_URL" )
@@ -95,13 +93,7 @@ class TRUSTIFY_DA_Api_Test extends ExhortTest {
9593
9694 @ InjectMocks ExhortApi exhortApiSut ;
9795
98- @ AfterEach
99- void cleanup () {
100- System .clearProperty ("TRUSTIFY_DA_SNYK_TOKEN" );
101- }
102-
10396 @ Test
104- @ SetSystemProperty (key = "TRUSTIFY_DA_SNYK_TOKEN" , value = "snyk-token-from-env-var" )
10597 @ SetSystemProperty (key = "TRUST_DA_TOKEN" , value = "trust-da-token-from-env-var" )
10698 @ SetSystemProperty (key = "TRUST_DA_SOURCE" , value = "trust-da-source-from-env-var" )
10799 void stackAnalysisHtml_with_pom_xml_should_return_html_report_from_the_backend ()
@@ -122,9 +114,6 @@ void stackAnalysisHtml_with_pom_xml_should_return_html_report_from_the_backend()
122114 r ->
123115 r .headers ().firstValue ("Content-Type" ).get ().equals ("fake-content-type" )
124116 && r .headers ().firstValue ("Accept" ).get ().equals ("text/html" )
125- &&
126- // snyk token is set using the environment variable (annotation)
127- r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token-from-env-var" )
128117 && r .headers ()
129118 .firstValue ("trust-da-token" )
130119 .get ()
@@ -168,7 +157,6 @@ void stackAnalysisHtml_with_pom_xml_should_return_html_report_from_the_backend()
168157 }
169158
170159 @ Test
171- @ SetSystemProperty (key = "TRUSTIFY_DA_SNYK_TOKEN" , value = "snyk-token" )
172160 @ SetSystemProperty (key = "TRUST_DA_TOKEN" , value = "trust-da-token" )
173161 @ SetSystemProperty (key = "TRUST_DA_SOURCE" , value = "trust-da-source" )
174162 void stackAnalysis_with_pom_xml_should_return_json_object_from_the_backend ()
@@ -189,7 +177,6 @@ void stackAnalysis_with_pom_xml_should_return_json_object_from_the_backend()
189177 r ->
190178 r .headers ().firstValue ("Content-Type" ).get ().equals ("fake-content-type" )
191179 && r .headers ().firstValue ("Accept" ).get ().equals ("application/json" )
192- && r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token" )
193180 && r .headers ().firstValue ("trust-da-token" ).get ().equals ("trust-da-token" )
194181 && r .headers ().firstValue ("trust-da-source" ).get ().equals ("trust-da-source" )
195182 && r .headers ().firstValue ("trust-da-operation-type" ).get ().equals ("Stack Analysis" )
@@ -244,7 +231,6 @@ void componentAnalysis_with_pom_xml_should_return_json_object_from_the_backend()
244231 .willReturn (new Provider .Content ("fake-body-content" .getBytes (), "fake-content-type" ));
245232
246233 // we expect this to picked up because no env var to take precedence
247- System .setProperty ("TRUSTIFY_DA_SNYK_TOKEN" , "snyk-token-from-property" );
248234 System .setProperty ("TRUST_DA_TOKEN" , "trust-da-token-from-property" );
249235 System .setProperty ("TRUST_DA_SOURCE" , "trust-da-source-from-property" );
250236
@@ -253,10 +239,6 @@ void componentAnalysis_with_pom_xml_should_return_json_object_from_the_backend()
253239 r ->
254240 r .headers ().firstValue ("Content-Type" ).get ().equals ("fake-content-type" )
255241 && r .headers ().firstValue ("Accept" ).get ().equals ("application/json" )
256- &&
257- // snyk token is set using properties which is picked up because no env var
258- // specified
259- r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token-from-property" )
260242 && r .headers ()
261243 .firstValue ("trust-da-token" )
262244 .get ()
@@ -388,17 +370,12 @@ void componentAnalysis_with_pom_xml_as_path_should_return_json_object_from_the_b
388370 .willReturn (new Provider .Content ("fake-body-content" .getBytes (), "fake-content-type" ));
389371
390372 // we expect this to picked up because no env var to take precedence
391- System .setProperty ("TRUSTIFY_DA_SNYK_TOKEN" , "snyk-token-from-property" );
392373
393374 // create an argument matcher to make sure we mock the response for the right request
394375 ArgumentMatcher <HttpRequest > matchesRequest =
395376 r ->
396377 r .headers ().firstValue ("Content-Type" ).get ().equals ("fake-content-type" )
397378 && r .headers ().firstValue ("Accept" ).get ().equals ("application/json" )
398- &&
399- // snyk token is set using properties which is picked up because no env var
400- // specified
401- r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token-from-property" )
402379 && r .method ().equals ("POST" );
403380
404381 // load dummy json and set as the expected analysis
@@ -472,7 +449,6 @@ void check_TRUSTIFY_DA_Url_When_Nothing_Set_Then_Default_TRUSTIFY_DA_URL_Selecte
472449 }
473450
474451 @ Test
475- @ SetSystemProperty (key = "TRUSTIFY_DA_SNYK_TOKEN" , value = "snyk-token-from-env-var" )
476452 @ SetSystemProperty (key = "TRUST_DA_TOKEN" , value = "trust-da-token-from-env-var" )
477453 @ SetSystemProperty (key = "TRUST_DA_SOURCE" , value = "trust-da-source-from-env-var" )
478454 @ SetSystemProperty (key = SKIP_VALIDATION_KEY , value = "true" )
@@ -536,7 +512,6 @@ void test_image_analysis()
536512 .firstValue ("Accept" )
537513 .get ()
538514 .equals (Api .MediaType .APPLICATION_JSON .toString ())
539- && r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token-from-env-var" )
540515 && r .headers ()
541516 .firstValue ("trust-da-token" )
542517 .get ()
@@ -581,7 +556,6 @@ void test_image_analysis()
581556 }
582557
583558 @ Test
584- @ SetSystemProperty (key = "TRUSTIFY_DA_SNYK_TOKEN" , value = "snyk-token-from-env-var" )
585559 @ SetSystemProperty (key = "TRUST_DA_TOKEN" , value = "trust-da-token-from-env-var" )
586560 @ SetSystemProperty (key = "TRUST_DA_SOURCE" , value = "trust-da-source-from-env-var" )
587561 @ SetSystemProperty (key = SKIP_VALIDATION_KEY , value = "true" )
@@ -644,7 +618,6 @@ void imageAnalysisHtml() throws IOException, ExecutionException, InterruptedExce
644618 .firstValue ("Accept" )
645619 .get ()
646620 .equals (Api .MediaType .TEXT_HTML .toString ())
647- && r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token-from-env-var" )
648621 && r .headers ()
649622 .firstValue ("trust-da-token" )
650623 .get ()
@@ -668,7 +641,6 @@ void imageAnalysisHtml() throws IOException, ExecutionException, InterruptedExce
668641 }
669642
670643 @ Test
671- @ SetSystemProperty (key = "TRUSTIFY_DA_SNYK_TOKEN" , value = "snyk-token-from-env-var" )
672644 @ SetSystemProperty (key = "TRUST_DA_TOKEN" , value = "trust-da-token-from-env-var" )
673645 @ SetSystemProperty (key = "TRUST_DA_SOURCE" , value = "trust-da-source-from-env-var" )
674646 void test_perform_batch_analysis ()
@@ -691,7 +663,6 @@ void test_perform_batch_analysis()
691663 .firstValue ("Accept" )
692664 .get ()
693665 .equals (Api .MediaType .APPLICATION_JSON .toString ())
694- && r .headers ().firstValue ("ex-snyk-token" ).get ().equals ("snyk-token-from-env-var" )
695666 && r .headers ()
696667 .firstValue ("trust-da-token" )
697668 .get ()
0 commit comments