Skip to content

Commit e67981a

Browse files
authored
Removing deprecated ServiceAccount creation in StorageImplTest. (#4490)
1 parent 3559aa7 commit e67981a

1 file changed

Lines changed: 48 additions & 12 deletions

File tree

  • google-cloud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage

google-cloud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageImplTest.java

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,10 @@ public void testSignUrl()
16621662
UnsupportedEncodingException {
16631663
EasyMock.replay(storageRpcMock);
16641664
ServiceAccountCredentials credentials =
1665-
new ServiceAccountCredentials(null, ACCOUNT, privateKey, null, null);
1665+
ServiceAccountCredentials.newBuilder()
1666+
.setClientEmail(ACCOUNT)
1667+
.setPrivateKey(privateKey)
1668+
.build();
16661669
storage = options.toBuilder().setCredentials(credentials).build().getService();
16671670
URL url = storage.signUrl(BLOB_INFO1, 14, TimeUnit.DAYS);
16681671
String stringUrl = url.toString();
@@ -1703,7 +1706,10 @@ public void testSignUrlWithHostName()
17031706
UnsupportedEncodingException {
17041707
EasyMock.replay(storageRpcMock);
17051708
ServiceAccountCredentials credentials =
1706-
new ServiceAccountCredentials(null, ACCOUNT, privateKey, null, null);
1709+
ServiceAccountCredentials.newBuilder()
1710+
.setClientEmail(ACCOUNT)
1711+
.setPrivateKey(privateKey)
1712+
.build();
17071713
storage = options.toBuilder().setCredentials(credentials).build().getService();
17081714
URL url =
17091715
storage.signUrl(
@@ -1750,7 +1756,10 @@ public void testSignUrlLeadingSlash()
17501756
String blobName = "/b1";
17511757
EasyMock.replay(storageRpcMock);
17521758
ServiceAccountCredentials credentials =
1753-
new ServiceAccountCredentials(null, ACCOUNT, privateKey, null, null);
1759+
ServiceAccountCredentials.newBuilder()
1760+
.setClientEmail(ACCOUNT)
1761+
.setPrivateKey(privateKey)
1762+
.build();
17541763
storage = options.toBuilder().setCredentials(credentials).build().getService();
17551764
URL url =
17561765
storage.signUrl(BlobInfo.newBuilder(BUCKET_NAME1, blobName).build(), 14, TimeUnit.DAYS);
@@ -1792,7 +1801,10 @@ public void testSignUrlLeadingSlashWithHostName()
17921801
String blobName = "/b1";
17931802
EasyMock.replay(storageRpcMock);
17941803
ServiceAccountCredentials credentials =
1795-
new ServiceAccountCredentials(null, ACCOUNT, privateKey, null, null);
1804+
ServiceAccountCredentials.newBuilder()
1805+
.setClientEmail(ACCOUNT)
1806+
.setPrivateKey(privateKey)
1807+
.build();
17961808
storage = options.toBuilder().setCredentials(credentials).build().getService();
17971809
URL url =
17981810
storage.signUrl(
@@ -1837,7 +1849,10 @@ public void testSignUrlWithOptions()
18371849
UnsupportedEncodingException {
18381850
EasyMock.replay(storageRpcMock);
18391851
ServiceAccountCredentials credentials =
1840-
new ServiceAccountCredentials(null, ACCOUNT, privateKey, null, null);
1852+
ServiceAccountCredentials.newBuilder()
1853+
.setClientEmail(ACCOUNT)
1854+
.setPrivateKey(privateKey)
1855+
.build();
18411856
storage = options.toBuilder().setCredentials(credentials).build().getService();
18421857
URL url =
18431858
storage.signUrl(
@@ -1889,7 +1904,10 @@ public void testSignUrlWithOptionsAndHostName()
18891904
UnsupportedEncodingException {
18901905
EasyMock.replay(storageRpcMock);
18911906
ServiceAccountCredentials credentials =
1892-
new ServiceAccountCredentials(null, ACCOUNT, privateKey, null, null);
1907+
ServiceAccountCredentials.newBuilder()
1908+
.setClientEmail(ACCOUNT)
1909+
.setPrivateKey(privateKey)
1910+
.build();
18931911
storage = options.toBuilder().setCredentials(credentials).build().getService();
18941912
URL url =
18951913
storage.signUrl(
@@ -1948,7 +1966,10 @@ public void testSignUrlForBlobWithSpecialChars()
19481966
};
19491967
EasyMock.replay(storageRpcMock);
19501968
ServiceAccountCredentials credentials =
1951-
new ServiceAccountCredentials(null, ACCOUNT, privateKey, null, null);
1969+
ServiceAccountCredentials.newBuilder()
1970+
.setClientEmail(ACCOUNT)
1971+
.setPrivateKey(privateKey)
1972+
.build();
19521973
storage = options.toBuilder().setCredentials(credentials).build().getService();
19531974

19541975
for (char specialChar : specialChars) {
@@ -2000,7 +2021,10 @@ public void testSignUrlForBlobWithSpecialCharsAndHostName()
20002021
};
20012022
EasyMock.replay(storageRpcMock);
20022023
ServiceAccountCredentials credentials =
2003-
new ServiceAccountCredentials(null, ACCOUNT, privateKey, null, null);
2024+
ServiceAccountCredentials.newBuilder()
2025+
.setClientEmail(ACCOUNT)
2026+
.setPrivateKey(privateKey)
2027+
.build();
20042028
storage = options.toBuilder().setCredentials(credentials).build().getService();
20052029

20062030
for (char specialChar : specialChars) {
@@ -2050,7 +2074,10 @@ public void testSignUrlWithExtHeaders()
20502074
UnsupportedEncodingException {
20512075
EasyMock.replay(storageRpcMock);
20522076
ServiceAccountCredentials credentials =
2053-
new ServiceAccountCredentials(null, ACCOUNT, privateKey, null, null);
2077+
ServiceAccountCredentials.newBuilder()
2078+
.setClientEmail(ACCOUNT)
2079+
.setPrivateKey(privateKey)
2080+
.build();
20542081
storage = options.toBuilder().setCredentials(credentials).build().getService();
20552082
Map<String, String> extHeaders = new HashMap<String, String>();
20562083
extHeaders.put("x-goog-acl", "public-read");
@@ -2107,7 +2134,10 @@ public void testSignUrlWithExtHeadersAndHostName()
21072134
UnsupportedEncodingException {
21082135
EasyMock.replay(storageRpcMock);
21092136
ServiceAccountCredentials credentials =
2110-
new ServiceAccountCredentials(null, ACCOUNT, privateKey, null, null);
2137+
ServiceAccountCredentials.newBuilder()
2138+
.setClientEmail(ACCOUNT)
2139+
.setPrivateKey(privateKey)
2140+
.build();
21112141
storage = options.toBuilder().setCredentials(credentials).build().getService();
21122142
Map<String, String> extHeaders = new HashMap<String, String>();
21132143
extHeaders.put("x-goog-acl", "public-read");
@@ -2165,7 +2195,10 @@ public void testSignUrlForBlobWithSlashes()
21652195
UnsupportedEncodingException {
21662196
EasyMock.replay(storageRpcMock);
21672197
ServiceAccountCredentials credentials =
2168-
new ServiceAccountCredentials(null, ACCOUNT, privateKey, null, null);
2198+
ServiceAccountCredentials.newBuilder()
2199+
.setClientEmail(ACCOUNT)
2200+
.setPrivateKey(privateKey)
2201+
.build();
21692202
storage = options.toBuilder().setCredentials(credentials).build().getService();
21702203

21712204
String blobName = "/foo/bar/baz #%20other cool stuff.txt";
@@ -2208,7 +2241,10 @@ public void testSignUrlForBlobWithSlashesAndHostName()
22082241
UnsupportedEncodingException {
22092242
EasyMock.replay(storageRpcMock);
22102243
ServiceAccountCredentials credentials =
2211-
new ServiceAccountCredentials(null, ACCOUNT, privateKey, null, null);
2244+
ServiceAccountCredentials.newBuilder()
2245+
.setClientEmail(ACCOUNT)
2246+
.setPrivateKey(privateKey)
2247+
.build();
22122248
storage = options.toBuilder().setCredentials(credentials).build().getService();
22132249

22142250
String blobName = "/foo/bar/baz #%20other cool stuff.txt";

0 commit comments

Comments
 (0)