Skip to content

Commit ed55b29

Browse files
committed
chore: update http headers
1 parent 10275b0 commit ed55b29

5 files changed

Lines changed: 97 additions & 55 deletions

File tree

catalog-info.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ apiVersion: backstage.io/v1alpha1
22
kind: Component
33
metadata:
44
annotations:
5-
backstage.io/kubernetes-id: trustify-da-java-client
5+
backstage.io/kuberqnetes-id: trustify-da-java-client
66
github.com/project-slug: guacsec/trustify-da-java-client
77
github.com/project-readme-path: README.md
88
backstage.io/view-url: https://github.com/guacsec/trustify-da-java-client/blob/main/catalog-info.yaml
99
backstage.io/edit-url: https://github.com/guacsec/trustify-da-java-client/blob/main/catalog-info.yaml
1010
backstage.io/source-location: url:https://github.com/guacsec/trustify-da-java-client
11-
rhda/manifest-file-path: package.json
11+
trust-da/manifest-file-path: package.json
1212
backstage.io/techdocs-ref: url:https://github.com/guacsec/trustify-da-java-client
1313
name: trustify-da-java-client
1414
tags:
15-
- rhda
15+
- trust-da
1616
spec:
1717
lifecycle: production
1818
owner: ecosystem-appeng

src/main/java/com/redhat/exhort/impl/ExhortApi.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ public final class ExhortApi implements Api {
7777

7878
public static final String DEFAULT_ENDPOINT = "https://rhda.rhcloud.com";
7979
public static final String DEFAULT_ENDPOINT_DEV = "https://exhort.stage.devshift.net";
80-
public static final String RHDA_TOKEN_HEADER = "rhda-token";
81-
public static final String RHDA_SOURCE_HEADER = "rhda-source";
82-
public static final String RHDA_OPERATION_TYPE_HEADER = "rhda-operation-type";
80+
public static final String TRUST_DA_TOKEN_HEADER = "trust-da-token";
81+
public static final String TRUST_DA_SOURCE_HEADER = "trust-da-source";
82+
public static final String TRUST_DA_OPERATION_TYPE_HEADER = "trust-da-operation-type";
8383
public static final String TRUSTIFY_DA_REQUEST_ID_HEADER_NAME = "ex-request-id";
8484

8585
private final String endpoint;
@@ -671,19 +671,19 @@ private HttpRequest buildRequest(
671671
}
672672
}
673673
});
674-
// set rhda-token
675-
// Environment variable/property name = RHDA_TOKEN
676-
String rhdaToken = calculateHeaderValue(RHDA_TOKEN_HEADER);
677-
if (rhdaToken != null) {
678-
request.setHeader(RHDA_TOKEN_HEADER, rhdaToken);
674+
// set trust-da-token
675+
// Environment variable/property name = TRUST_DA_TOKEN
676+
String trustDaToken = calculateHeaderValue(TRUST_DA_TOKEN_HEADER);
677+
if (trustDaToken != null) {
678+
request.setHeader(TRUST_DA_TOKEN_HEADER, trustDaToken);
679679
}
680-
// set rhda-source ( extension/plugin id/name)
681-
// Environment variable/property name = RHDA_SOURCE
682-
String rhdaSource = calculateHeaderValue(RHDA_SOURCE_HEADER);
683-
if (rhdaSource != null) {
684-
request.setHeader(RHDA_SOURCE_HEADER, rhdaSource);
680+
// set trust-da-source ( extension/plugin id/name)
681+
// Environment variable/property name = TRUST_DA_SOURCE
682+
String trustDaSource = calculateHeaderValue(TRUST_DA_SOURCE_HEADER);
683+
if (trustDaSource != null) {
684+
request.setHeader(TRUST_DA_SOURCE_HEADER, trustDaSource);
685685
}
686-
request.setHeader(RHDA_OPERATION_TYPE_HEADER, analysisType);
686+
request.setHeader(TRUST_DA_OPERATION_TYPE_HEADER, analysisType);
687687

688688
return request.build();
689689
}

src/main/resources/exhort/openapi.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ paths:
1919
operationId: analysis
2020
summary: Takes a client-resolved dependency graph to perform a full stack analysis from all the available Vulnerability sources
2121
security:
22-
- RhdaTokenAuth: []
22+
- TrustDaTokenAuth: []
2323
- SnykTokenAuth: []
2424
- OssIndexUserAuth: []
2525
OssIndexTokenAuth: []
@@ -74,7 +74,7 @@ paths:
7474
operationId: batchAnalysis
7575
summary: Takes an array of client-resolved dependency graphs to perform a full stack analysis from all the available Vulnerability sources
7676
security:
77-
- RhdaTokenAuth: [ ]
77+
- TrustDaTokenAuth: [ ]
7878
- SnykTokenAuth: [ ]
7979
- OssIndexUserAuth: [ ]
8080
OssIndexTokenAuth: [ ]
@@ -137,7 +137,7 @@ paths:
137137
operationId: validateToken
138138
summary: Validates a vulnerability provider token
139139
security:
140-
- RhdaTokenAuth: []
140+
- TrustDaTokenAuth: []
141141
- SnykTokenAuth: []
142142
- OssIndexUserAuth: []
143143
OssIndexTokenAuth: []
@@ -180,10 +180,10 @@ paths:
180180

181181
components:
182182
securitySchemes:
183-
RhdaTokenAuth:
183+
TrustDaTokenAuth:
184184
type: apiKey
185185
in: header
186-
name: rhda-token
186+
name: trust-da-token
187187
SnykTokenAuth:
188188
type: apiKey
189189
in: header

src/test/java/com/redhat/exhort/impl/ExhortApiIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
@Tag("IntegrationTest")
7979
@ExtendWith(HelperExtension.class)
8080
@ExtendWith(MockitoExtension.class)
81-
@SetSystemProperty(key = "RHDA_SOURCE", value = "trustify-da-java-client-it")
81+
@SetSystemProperty(key = "TRUST_DA_SOURCE", value = "trustify-da-java-client-it")
8282
@SetSystemProperty(key = "TRUSTIFY_DA_DEV_MODE", value = "false")
8383
@RestoreSystemProperties
8484
class ExhortApiIT extends ExhortTest {

src/test/java/com/redhat/exhort/impl/Exhort_Api_Test.java

Lines changed: 74 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@
8484
@ClearSystemProperty(key = "TRUSTIFY_DA_DEV_MODE")
8585
@ClearSystemProperty(key = "TRUSTIFY_DA_PROXY_URL")
8686
@ClearSystemProperty(key = "DEV_TRUSTIFY_DA_BACKEND_URL")
87-
@ClearSystemProperty(key = "RHDA_TOKEN")
88-
@ClearSystemProperty(key = "RHDA_SOURCE")
87+
@ClearSystemProperty(key = "TRUST_DA_TOKEN")
88+
@ClearSystemProperty(key = "TRUST_DA_SOURCE")
8989
@SuppressWarnings("unchecked")
9090
class TRUSTIFY_DA_Api_Test extends ExhortTest {
9191

@@ -102,8 +102,8 @@ void cleanup() {
102102

103103
@Test
104104
@SetSystemProperty(key = "TRUSTIFY_DA_SNYK_TOKEN", value = "snyk-token-from-env-var")
105-
@SetSystemProperty(key = "RHDA_TOKEN", value = "rhda-token-from-env-var")
106-
@SetSystemProperty(key = "RHDA_SOURCE", value = "rhda-source-from-env-var")
105+
@SetSystemProperty(key = "TRUST_DA_TOKEN", value = "trust-da-token-from-env-var")
106+
@SetSystemProperty(key = "TRUST_DA_SOURCE", value = "trust-da-source-from-env-var")
107107
void stackAnalysisHtml_with_pom_xml_should_return_html_report_from_the_backend()
108108
throws IOException, ExecutionException, InterruptedException {
109109
// create a temporary pom.xml file
@@ -125,9 +125,15 @@ void stackAnalysisHtml_with_pom_xml_should_return_html_report_from_the_backend()
125125
&&
126126
// snyk token is set using the environment variable (annotation)
127127
r.headers().firstValue("ex-snyk-token").get().equals("snyk-token-from-env-var")
128-
&& r.headers().firstValue("rhda-token").get().equals("rhda-token-from-env-var")
129-
&& r.headers().firstValue("rhda-source").get().equals("rhda-source-from-env-var")
130-
&& r.headers().firstValue("rhda-operation-type").get().equals("Stack Analysis")
128+
&& r.headers()
129+
.firstValue("trust-da-token")
130+
.get()
131+
.equals("trust-da-token-from-env-var")
132+
&& r.headers()
133+
.firstValue("trust-da-source")
134+
.get()
135+
.equals("trust-da-source-from-env-var")
136+
&& r.headers().firstValue("trust-da-operation-type").get().equals("Stack Analysis")
131137
&& r.method().equals("POST");
132138

133139
// load dummy html and set as the expected analysis
@@ -163,8 +169,8 @@ void stackAnalysisHtml_with_pom_xml_should_return_html_report_from_the_backend()
163169

164170
@Test
165171
@SetSystemProperty(key = "TRUSTIFY_DA_SNYK_TOKEN", value = "snyk-token")
166-
@SetSystemProperty(key = "RHDA_TOKEN", value = "rhda-token")
167-
@SetSystemProperty(key = "RHDA_SOURCE", value = "rhda-source")
172+
@SetSystemProperty(key = "TRUST_DA_TOKEN", value = "trust-da-token")
173+
@SetSystemProperty(key = "TRUST_DA_SOURCE", value = "trust-da-source")
168174
void stackAnalysis_with_pom_xml_should_return_json_object_from_the_backend()
169175
throws IOException, ExecutionException, InterruptedException {
170176
// create a temporary pom.xml file
@@ -184,9 +190,9 @@ void stackAnalysis_with_pom_xml_should_return_json_object_from_the_backend()
184190
r.headers().firstValue("Content-Type").get().equals("fake-content-type")
185191
&& r.headers().firstValue("Accept").get().equals("application/json")
186192
&& r.headers().firstValue("ex-snyk-token").get().equals("snyk-token")
187-
&& r.headers().firstValue("rhda-token").get().equals("rhda-token")
188-
&& r.headers().firstValue("rhda-source").get().equals("rhda-source")
189-
&& r.headers().firstValue("rhda-operation-type").get().equals("Stack Analysis")
193+
&& r.headers().firstValue("trust-da-token").get().equals("trust-da-token")
194+
&& r.headers().firstValue("trust-da-source").get().equals("trust-da-source")
195+
&& r.headers().firstValue("trust-da-operation-type").get().equals("Stack Analysis")
190196
&& r.method().equals("POST");
191197

192198
// load dummy json and set as the expected analysis
@@ -239,8 +245,8 @@ void componentAnalysis_with_pom_xml_should_return_json_object_from_the_backend()
239245

240246
// we expect this to picked up because no env var to take precedence
241247
System.setProperty("TRUSTIFY_DA_SNYK_TOKEN", "snyk-token-from-property");
242-
System.setProperty("RHDA_TOKEN", "rhda-token-from-property");
243-
System.setProperty("RHDA_SOURCE", "rhda-source-from-property");
248+
System.setProperty("TRUST_DA_TOKEN", "trust-da-token-from-property");
249+
System.setProperty("TRUST_DA_SOURCE", "trust-da-source-from-property");
244250

245251
// create an argument matcher to make sure we mock the response for the right request
246252
ArgumentMatcher<HttpRequest> matchesRequest =
@@ -251,9 +257,18 @@ void componentAnalysis_with_pom_xml_should_return_json_object_from_the_backend()
251257
// snyk token is set using properties which is picked up because no env var
252258
// specified
253259
r.headers().firstValue("ex-snyk-token").get().equals("snyk-token-from-property")
254-
&& r.headers().firstValue("rhda-token").get().equals("rhda-token-from-property")
255-
&& r.headers().firstValue("rhda-source").get().equals("rhda-source-from-property")
256-
&& r.headers().firstValue("rhda-operation-type").get().equals("Component Analysis")
260+
&& r.headers()
261+
.firstValue("trust-da-token")
262+
.get()
263+
.equals("trust-da-token-from-property")
264+
&& r.headers()
265+
.firstValue("trust-da-source")
266+
.get()
267+
.equals("trust-da-source-from-property")
268+
&& r.headers()
269+
.firstValue("trust-da-operation-type")
270+
.get()
271+
.equals("Component Analysis")
257272
&& r.method().equals("POST");
258273

259274
// load dummy json and set as the expected analysis
@@ -458,8 +473,8 @@ void check_TRUSTIFY_DA_Url_When_Nothing_Set_Then_Default_TRUSTIFY_DA_URL_Selecte
458473

459474
@Test
460475
@SetSystemProperty(key = "TRUSTIFY_DA_SNYK_TOKEN", value = "snyk-token-from-env-var")
461-
@SetSystemProperty(key = "RHDA_TOKEN", value = "rhda-token-from-env-var")
462-
@SetSystemProperty(key = "RHDA_SOURCE", value = "rhda-source-from-env-var")
476+
@SetSystemProperty(key = "TRUST_DA_TOKEN", value = "trust-da-token-from-env-var")
477+
@SetSystemProperty(key = "TRUST_DA_SOURCE", value = "trust-da-source-from-env-var")
463478
@SetSystemProperty(key = SKIP_VALIDATION_KEY, value = "true")
464479
void test_image_analysis()
465480
throws IOException, ExecutionException, InterruptedException, MalformedPackageURLException {
@@ -522,9 +537,18 @@ void test_image_analysis()
522537
.get()
523538
.equals(Api.MediaType.APPLICATION_JSON.toString())
524539
&& r.headers().firstValue("ex-snyk-token").get().equals("snyk-token-from-env-var")
525-
&& r.headers().firstValue("rhda-token").get().equals("rhda-token-from-env-var")
526-
&& r.headers().firstValue("rhda-source").get().equals("rhda-source-from-env-var")
527-
&& r.headers().firstValue("rhda-operation-type").get().equals("Image Analysis")
540+
&& r.headers()
541+
.firstValue("trust-da-token")
542+
.get()
543+
.equals("trust-da-token-from-env-var")
544+
&& r.headers()
545+
.firstValue("trust-da-source")
546+
.get()
547+
.equals("trust-da-source-from-env-var")
548+
&& r.headers()
549+
.firstValue("trust-da-operation-type")
550+
.get()
551+
.equals("Image Analysis")
528552
&& r.method().equals("POST");
529553

530554
when(mockHttpClient.sendAsync(argThat(matchesRequest), any()))
@@ -558,8 +582,8 @@ void test_image_analysis()
558582

559583
@Test
560584
@SetSystemProperty(key = "TRUSTIFY_DA_SNYK_TOKEN", value = "snyk-token-from-env-var")
561-
@SetSystemProperty(key = "RHDA_TOKEN", value = "rhda-token-from-env-var")
562-
@SetSystemProperty(key = "RHDA_SOURCE", value = "rhda-source-from-env-var")
585+
@SetSystemProperty(key = "TRUST_DA_TOKEN", value = "trust-da-token-from-env-var")
586+
@SetSystemProperty(key = "TRUST_DA_SOURCE", value = "trust-da-source-from-env-var")
563587
@SetSystemProperty(key = SKIP_VALIDATION_KEY, value = "true")
564588
void imageAnalysisHtml() throws IOException, ExecutionException, InterruptedException {
565589
try (MockedStatic<Operations> mock = Mockito.mockStatic(Operations.class);
@@ -621,9 +645,18 @@ void imageAnalysisHtml() throws IOException, ExecutionException, InterruptedExce
621645
.get()
622646
.equals(Api.MediaType.TEXT_HTML.toString())
623647
&& r.headers().firstValue("ex-snyk-token").get().equals("snyk-token-from-env-var")
624-
&& r.headers().firstValue("rhda-token").get().equals("rhda-token-from-env-var")
625-
&& r.headers().firstValue("rhda-source").get().equals("rhda-source-from-env-var")
626-
&& r.headers().firstValue("rhda-operation-type").get().equals("Image Analysis")
648+
&& r.headers()
649+
.firstValue("trust-da-token")
650+
.get()
651+
.equals("trust-da-token-from-env-var")
652+
&& r.headers()
653+
.firstValue("trust-da-source")
654+
.get()
655+
.equals("trust-da-source-from-env-var")
656+
&& r.headers()
657+
.firstValue("trust-da-operation-type")
658+
.get()
659+
.equals("Image Analysis")
627660
&& r.method().equals("POST");
628661

629662
when(mockHttpClient.sendAsync(argThat(matchesRequest), any()))
@@ -636,8 +669,8 @@ void imageAnalysisHtml() throws IOException, ExecutionException, InterruptedExce
636669

637670
@Test
638671
@SetSystemProperty(key = "TRUSTIFY_DA_SNYK_TOKEN", value = "snyk-token-from-env-var")
639-
@SetSystemProperty(key = "RHDA_TOKEN", value = "rhda-token-from-env-var")
640-
@SetSystemProperty(key = "RHDA_SOURCE", value = "rhda-source-from-env-var")
672+
@SetSystemProperty(key = "TRUST_DA_TOKEN", value = "trust-da-token-from-env-var")
673+
@SetSystemProperty(key = "TRUST_DA_SOURCE", value = "trust-da-source-from-env-var")
641674
void test_perform_batch_analysis()
642675
throws IOException, MalformedPackageURLException, ExecutionException, InterruptedException {
643676
try (var is = getResourceAsStreamDecision(this.getClass(), "msc/image/image_sbom.json")) {
@@ -659,9 +692,18 @@ void test_perform_batch_analysis()
659692
.get()
660693
.equals(Api.MediaType.APPLICATION_JSON.toString())
661694
&& r.headers().firstValue("ex-snyk-token").get().equals("snyk-token-from-env-var")
662-
&& r.headers().firstValue("rhda-token").get().equals("rhda-token-from-env-var")
663-
&& r.headers().firstValue("rhda-source").get().equals("rhda-source-from-env-var")
664-
&& r.headers().firstValue("rhda-operation-type").get().equals("Image Analysis")
695+
&& r.headers()
696+
.firstValue("trust-da-token")
697+
.get()
698+
.equals("trust-da-token-from-env-var")
699+
&& r.headers()
700+
.firstValue("trust-da-source")
701+
.get()
702+
.equals("trust-da-source-from-env-var")
703+
&& r.headers()
704+
.firstValue("trust-da-operation-type")
705+
.get()
706+
.equals("Image Analysis")
665707
&& r.method().equals("POST");
666708

667709
var imageRef =

0 commit comments

Comments
 (0)