Skip to content

Commit c3c2b4b

Browse files
committed
STORAGE-2798 Allow overriding download urls
1 parent c197e20 commit c3c2b4b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

core/src/main/java/com/backblaze/b2/client/B2StorageClientWebifierImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ public void downloadById(B2AccountAuthorization accountAuth,
488488
B2DownloadByIdRequest request,
489489
B2ContentSink handler) throws B2Exception {
490490
downloadGuts(accountAuth,
491-
makeDownloadByIdUrl(accountAuth, request),
491+
getDownloadByIdUrl(accountAuth, request),
492492
request.getRange(),
493493
request.getServerSideEncryption(),
494494
handler);
@@ -505,7 +505,7 @@ public void downloadByName(B2AccountAuthorization accountAuth,
505505
B2DownloadByNameRequest request,
506506
B2ContentSink handler) throws B2Exception {
507507
downloadGuts(accountAuth,
508-
makeDownloadByNameUrl(accountAuth, request.getBucketName(), request.getFileName(), request),
508+
getDownloadByNameUrl(accountAuth, request),
509509
request.getRange(),
510510
request.getServerSideEncryption(),
511511
handler);

core/src/test/java/com/backblaze/b2/client/B2StorageClientWebifierImplTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
import static org.mockito.Matchers.eq;
104104
import static org.mockito.Mockito.mock;
105105
import static org.mockito.Mockito.reset;
106+
import static org.mockito.Mockito.spy;
106107
import static org.mockito.Mockito.times;
107108
import static org.mockito.Mockito.verify;
108109

@@ -1190,7 +1191,9 @@ public void testDownloadById() throws B2Exception {
11901191
final B2DownloadByIdRequest request = B2DownloadByIdRequest
11911192
.builder(fileId(1))
11921193
.build();
1193-
webifier.downloadById(ACCOUNT_AUTH, request, noopContentHandler);
1194+
final B2StorageClientWebifierImpl webifierSpy = spy(webifier);
1195+
webifierSpy.downloadById(ACCOUNT_AUTH, request, noopContentHandler);
1196+
verify(webifierSpy).getDownloadByIdUrl(ACCOUNT_AUTH, request);
11941197

11951198
webApiClient.check("getContent.\n" +
11961199
"url:\n" +
@@ -1201,7 +1204,7 @@ public void testDownloadById() throws B2Exception {
12011204
" X-Bz-Test-Mode: force_cap_exceeded\n"
12021205
);
12031206

1204-
assertEquals(expectedUrl, webifier.getDownloadByIdUrl(ACCOUNT_AUTH, request));
1207+
assertEquals(expectedUrl, webifierSpy.getDownloadByIdUrl(ACCOUNT_AUTH, request));
12051208

12061209
checkRequestCategory(OTHER, w -> w.downloadById(ACCOUNT_AUTH, request, noopContentHandler));
12071210
}
@@ -1303,7 +1306,9 @@ public void testDownloadByName() throws B2Exception {
13031306
final B2DownloadByNameRequest request = B2DownloadByNameRequest
13041307
.builder(bucketName(1), fileName(1))
13051308
.build();
1306-
webifier.downloadByName(ACCOUNT_AUTH, request, noopContentHandler);
1309+
final B2StorageClientWebifierImpl webifierSpy = spy(webifier);
1310+
webifierSpy.downloadByName(ACCOUNT_AUTH, request, noopContentHandler);
1311+
verify(webifierSpy).getDownloadByNameUrl(ACCOUNT_AUTH, request);
13071312

13081313
webApiClient.check("getContent.\n" +
13091314
"url:\n" +
@@ -1313,7 +1318,7 @@ public void testDownloadByName() throws B2Exception {
13131318
" User-Agent: SecretAgentMan/3.19.28\n" +
13141319
" X-Bz-Test-Mode: force_cap_exceeded\n"
13151320
);
1316-
assertEquals(expectedUrl, webifier.getDownloadByNameUrl(ACCOUNT_AUTH, request));
1321+
assertEquals(expectedUrl, webifierSpy.getDownloadByNameUrl(ACCOUNT_AUTH, request));
13171322

13181323
checkRequestCategory(OTHER, w -> w.downloadByName(ACCOUNT_AUTH, request, noopContentHandler));
13191324
}

0 commit comments

Comments
 (0)