38
38
import com .google .api .core .ApiClock ;
39
39
import com .google .api .core .CurrentMillisClock ;
40
40
import com .google .auth .oauth2 .GoogleCredentials ;
41
+ import com .google .auth .oauth2 .ServiceAccountCredentials ;
41
42
import com .google .cloud .spi .ServiceRpcFactory ;
42
43
import com .google .common .collect .ArrayListMultimap ;
43
44
import com .google .common .collect .Multimap ;
@@ -58,7 +59,7 @@ class ServiceOptionsTest {
58
59
private static GoogleCredentials credentialsWithQuotaProject ;
59
60
private static GoogleCredentials credentialsNotInGDU ;
60
61
61
- private static final String JSON_KEY =
62
+ private static final String SA_JSON_KEY =
62
63
"{\n "
63
64
+ " \" private_key_id\" : \" somekeyid\" ,\n "
64
65
+ " \" private_key\" : \" -----BEGIN PRIVATE KEY-----\\ nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS"
@@ -87,7 +88,7 @@ class ServiceOptionsTest {
87
88
+ " \" universe_domain\" : \" googleapis.com\" \n "
88
89
+ "}" ;
89
90
90
- private static final String JSON_KEY_PROJECT_ID =
91
+ private static final String SA_JSON_KEY_PROJECT_ID =
91
92
"{\n "
92
93
+ " \" private_key_id\" : \" somekeyid\" ,\n "
93
94
+ " \" private_key\" : \" -----BEGIN PRIVATE KEY-----\\ nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS"
@@ -117,7 +118,7 @@ class ServiceOptionsTest {
117
118
+ " \" universe_domain\" : \" googleapis.com\" \n "
118
119
+ "}" ;
119
120
120
- private static final String JSON_KEY_QUOTA_PROJECT_ID =
121
+ private static final String SA_JSON_KEY_QUOTA_PROJECT_ID =
121
122
"{\n "
122
123
+ " \" private_key_id\" : \" somekeyid\" ,\n "
123
124
+ " \" private_key\" : \" -----BEGIN PRIVATE KEY-----\\ nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS"
@@ -149,7 +150,7 @@ class ServiceOptionsTest {
149
150
+ "}" ;
150
151
151
152
// Key added by copying the keys above and adding in the universe domain field
152
- private static final String JSON_KEY_NON_GDU =
153
+ private static final String SA_JSON_KEY_NON_GDU =
153
154
"{\n "
154
155
+ " \" private_key_id\" : \" somekeyid\" ,\n "
155
156
+ " \" private_key\" : \" -----BEGIN PRIVATE KEY-----\\ nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS"
@@ -179,16 +180,16 @@ class ServiceOptionsTest {
179
180
+ "}" ;
180
181
181
182
static {
182
- credentials = loadCredentials ( JSON_KEY );
183
- credentialsWithProjectId = loadCredentials ( JSON_KEY_PROJECT_ID );
184
- credentialsWithQuotaProject = loadCredentials ( JSON_KEY_QUOTA_PROJECT_ID );
185
- credentialsNotInGDU = loadCredentials ( JSON_KEY_NON_GDU );
183
+ credentials = loadServiceAccountCredentials ( SA_JSON_KEY );
184
+ credentialsWithProjectId = loadServiceAccountCredentials ( SA_JSON_KEY_PROJECT_ID );
185
+ credentialsWithQuotaProject = loadServiceAccountCredentials ( SA_JSON_KEY_QUOTA_PROJECT_ID );
186
+ credentialsNotInGDU = loadServiceAccountCredentials ( SA_JSON_KEY_NON_GDU );
186
187
}
187
188
188
- static GoogleCredentials loadCredentials (String credentialFile ) {
189
+ static GoogleCredentials loadServiceAccountCredentials (String credentialFile ) {
189
190
try {
190
191
InputStream keyStream = new ByteArrayInputStream (credentialFile .getBytes ());
191
- return GoogleCredentials .fromStream (keyStream );
192
+ return ServiceAccountCredentials .fromStream (keyStream );
192
193
} catch (IOException e ) {
193
194
fail ("Couldn't create fake JSON credentials." );
194
195
}
0 commit comments