Skip to content

Commit 729b252

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 7019 b: refs/heads/tswast-patch-1 c: c486452 h: refs/heads/master i: 7017: 099fd14 7015: ba79eca
1 parent 3ebae44 commit 729b252

5 files changed

Lines changed: 49 additions & 7 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 7eb957d29adba95dc310d5854899baef4f7d0583
60+
refs/heads/tswast-patch-1: c486452b4c81da7f077e2573b1f29dee3994bd86
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,33 @@ public RestorableState<AuthCredentials> capture() {
243243
}
244244
}
245245

246+
public static class NoAuthCredentials extends AuthCredentials {
247+
248+
private static final AuthCredentials INSTANCE = new NoAuthCredentials();
249+
private static final NoAuthCredentialsState STATE = new NoAuthCredentialsState();
250+
251+
private static class NoAuthCredentialsState
252+
implements RestorableState<AuthCredentials>, Serializable {
253+
254+
private static final long serialVersionUID = -4022100563954640465L;
255+
256+
@Override
257+
public AuthCredentials restore() {
258+
return INSTANCE;
259+
}
260+
}
261+
262+
@Override
263+
public GoogleCredentials credentials() {
264+
return null;
265+
}
266+
267+
@Override
268+
public RestorableState<AuthCredentials> capture() {
269+
return STATE;
270+
}
271+
}
272+
246273
public abstract GoogleCredentials credentials();
247274

248275
public static AuthCredentials createForAppEngine() {
@@ -281,6 +308,13 @@ public static ServiceAccountAuthCredentials createFor(String account, PrivateKey
281308
return new ServiceAccountAuthCredentials(account, privateKey);
282309
}
283310

311+
/**
312+
* Creates a placeholder denoting that no credentials should be used.
313+
*/
314+
public static AuthCredentials noAuth() {
315+
return NoAuthCredentials.INSTANCE;
316+
}
317+
284318
/**
285319
* Creates Service Account Credentials given a stream for credentials in JSON format.
286320
*

branches/tswast-patch-1/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,10 @@ public RetryParams retryParams() {
523523
* options.
524524
*/
525525
public HttpRequestInitializer httpRequestInitializer() {
526-
final HttpRequestInitializer delegate = authCredentials() != null
527-
? new HttpCredentialsAdapter(authCredentials().credentials().createScoped(scopes()))
528-
: null;
526+
final HttpRequestInitializer delegate =
527+
authCredentials() != null && authCredentials.credentials() != null
528+
? new HttpCredentialsAdapter(authCredentials().credentials().createScoped(scopes()))
529+
: null;
529530
return new HttpRequestInitializer() {
530531
@Override
531532
public void initialize(HttpRequest httpRequest) throws IOException {

branches/tswast-patch-1/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.google.api.services.datastore.DatastoreV1.RunQueryResponse;
3333
import com.google.common.collect.Iterators;
3434
import com.google.common.collect.Lists;
35+
import com.google.gcloud.AuthCredentials;
3536
import com.google.gcloud.RetryParams;
3637
import com.google.gcloud.datastore.Query.ResultType;
3738
import com.google.gcloud.datastore.StructuredQuery.OrderBy;
@@ -128,6 +129,7 @@ public void setUp() {
128129
options = DatastoreOptions.builder()
129130
.projectId(PROJECT_ID)
130131
.host("http://localhost:" + PORT)
132+
.authCredentials(AuthCredentials.noAuth())
131133
.retryParams(RetryParams.noRetries())
132134
.build();
133135
datastore = options.service();

branches/tswast-patch-1/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.google.common.collect.ImmutableMap;
1313
import com.google.common.collect.ImmutableSet;
1414
import com.google.common.io.ByteStreams;
15+
import com.google.gcloud.AuthCredentials;
1516
import com.google.gcloud.resourcemanager.ResourceManagerOptions;
1617

1718
import com.sun.net.httpserver.Headers;
@@ -550,17 +551,21 @@ private LocalResourceManagerHelper() {
550551
}
551552

552553
/**
553-
* Creates a LocalResourceManagerHelper object that listens to requests on the local machine.
554+
* Creates a {@code LocalResourceManagerHelper} object that listens to requests on the local
555+
* machine.
554556
*/
555557
public static LocalResourceManagerHelper create() {
556558
return new LocalResourceManagerHelper();
557559
}
558560

559561
/**
560-
* Returns a ResourceManagerOptions instance that sets the host to use the mock server.
562+
* Returns a {@link ResourceManagerOptions} instance that sets the host to use the mock server.
561563
*/
562564
public ResourceManagerOptions options() {
563-
return ResourceManagerOptions.builder().host("http://localhost:" + port).build();
565+
return ResourceManagerOptions.builder()
566+
.host("http://localhost:" + port)
567+
.authCredentials(AuthCredentials.noAuth())
568+
.build();
564569
}
565570

566571
/**

0 commit comments

Comments
 (0)