Skip to content

Commit

Permalink
JCLOUDS-1519: Fix the authorization error with b2 application keys
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsenk committed Feb 19, 2024
1 parent 2a773c2 commit 41d842d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ public HttpRequest filter(HttpRequest request) throws HttpException {
endpoint.getPath() +
(endpoint.getQuery() == null ? "" : "?" + endpoint.getQuery()));

String updatedRequestBody = request.getPayload().getRawContent().toString().replaceAll("\"accountId\":.?\".*\"", "\"accountId\":\"" + auth.accountId() + "\"");
request = request.toBuilder()
.endpoint(endpoint)
.replaceHeader(HttpHeaders.AUTHORIZATION, auth.authorizationToken())
.payload(updatedRequestBody)
.build();
return request;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static void assertRequest(RecordedRequest request, String method, String path, S
* @see RecordedRequest
*/
private static void assertContentTypeIsJson(RecordedRequest request) {
assertThat(request.getHeaders().values("Content-Type")).contains("application/json");
assertThat(request.getHeaders().values("Content-Type")).contains("application/unknown");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion providers/b2/src/test/resources/create_bucket_request.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"accountId": "ACCOUNT_ID",
"accountId": "YOUR_ACCOUNT_ID",
"bucketName": "any_name_you_pick",
"bucketType": "allPrivate"
}
2 changes: 1 addition & 1 deletion providers/b2/src/test/resources/delete_bucket_request.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"accountId": "ACCOUNT_ID",
"accountId": "YOUR_ACCOUNT_ID",
"bucketId": "4a48fe8875c6214145260818"
}
2 changes: 1 addition & 1 deletion providers/b2/src/test/resources/list_buckets_request.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"accountId": "ACCOUNT_ID"
"accountId": "YOUR_ACCOUNT_ID"
}
2 changes: 1 addition & 1 deletion providers/b2/src/test/resources/update_bucket_request.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"accountId": "ACCOUNT_ID",
"accountId": "YOUR_ACCOUNT_ID",
"bucketId": "4a48fe8875c6214145260818",
"bucketType": "allPrivate"
}

0 comments on commit 41d842d

Please sign in to comment.