JCLOUDS-1519: Fix the authorization error with b2 application keys

This commit is contained in:
davidsenk 2024-02-18 21:05:35 -05:00 committed by GitHub
parent 2a773c2a72
commit 41d842d449
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 7 additions and 5 deletions

View File

@ -50,9 +50,11 @@ public final class RequestAuthorization implements HttpRequestFilter {
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;
}

View File

@ -120,7 +120,7 @@ final class B2TestUtils {
* @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");
}
/**

View File

@ -1,5 +1,5 @@
{
"accountId": "ACCOUNT_ID",
"accountId": "YOUR_ACCOUNT_ID",
"bucketName": "any_name_you_pick",
"bucketType": "allPrivate"
}

View File

@ -1,4 +1,4 @@
{
"accountId": "ACCOUNT_ID",
"accountId": "YOUR_ACCOUNT_ID",
"bucketId": "4a48fe8875c6214145260818"
}

View File

@ -1,3 +1,3 @@
{
"accountId": "ACCOUNT_ID"
"accountId": "YOUR_ACCOUNT_ID"
}

View File

@ -1,5 +1,5 @@
{
"accountId": "ACCOUNT_ID",
"accountId": "YOUR_ACCOUNT_ID",
"bucketId": "4a48fe8875c6214145260818",
"bucketType": "allPrivate"
}