Skip to content

Commit

Permalink
Merge pull request #192 from RedHatInsights/fix_send_bearer_auth_corr…
Browse files Browse the repository at this point in the history
…ectly

fix: send bearer auth correctly
  • Loading branch information
jponge authored Jan 26, 2024
2 parents da98e0a + 26d683f commit f715ecf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ The original work is also licensed under the Apache 2 License.
Here's a command-line guide to uploading some payload:

```
export BASIC_AUTH='the-token'
export AUTH='the-token'
export HOST='the-host'
curl -F "[email protected];type=application/vnd.redhat.runtimes-java-general.analytics+tgz" \
-H "Authorization: Basic ${BASIC_AUTH}" \
-H "Authorization: Bearer ${AUTH}" \
"https://${HOST}/api/ingress/v1/upload" -v --insecure
```

Expand All @@ -62,7 +62,7 @@ Or if you prefer HTTPie:
http --verbose --multipart $HOST/api/ingress/v1/upload \
'[email protected];type=application/vnd.redhat.runtimes-java-general.analytics+tgz' \
type='application/vnd.redhat.runtimes-java-general.analytics+tgz' \
"Authorization":"Basic ${BASIC_AUTH}"
"Authorization":"Bearer ${AUTH}"
```

## Environment variables and system properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) Red Hat 2023 */
/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.core.httpclient;

import static com.redhat.insights.InsightsErrorCode.*;
Expand Down Expand Up @@ -126,7 +126,7 @@ protected void sendInsightsReportWithClient(

if (!configuration.useMTLS()) {
final var authToken = configuration.getMaybeAuthToken().get();
requestBuilder = requestBuilder.setHeader("Authorization", "Basic " + authToken);
requestBuilder = requestBuilder.setHeader("Authorization", "Bearer " + authToken);
}
requestBuilder =
requestBuilder.uri(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) Red Hat 2023 */
/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.core.httpclient;

import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -207,7 +207,7 @@ public void testSendReportWithoutMtls() throws IOException, InterruptedException

// if using token, there should be authorization header
assertEquals(1, request.get().headers().allValues("Authorization").size());
assertEquals("Basic randomToken", request.get().headers().allValues("Authorization").get(0));
assertEquals("Bearer randomToken", request.get().headers().allValues("Authorization").get(0));
}

@Test
Expand Down

0 comments on commit f715ecf

Please sign in to comment.