Skip to content

Commit

Permalink
fix imports and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
shubha-rajan committed May 12, 2021
1 parent c4b430c commit 52f0106
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
14 changes: 10 additions & 4 deletions oauth2_http/java/com/google/auth/http/HttpCredentialsAdapter.java
Expand Up @@ -48,7 +48,9 @@
import java.util.logging.Logger;
import java.util.regex.Pattern;

/** A wrapper for using Credentials with the Google API Client Libraries for Java with Http. */
/**
* A wrapper for using Credentials with the Google API Client Libraries for Java with Http.
*/
public class HttpCredentialsAdapter
implements HttpRequestInitializer, HttpUnsuccessfulResponseHandler {

Expand All @@ -63,14 +65,18 @@ public class HttpCredentialsAdapter

private final Credentials credentials;

/** @param credentials Credentials instance to adapt for HTTP */
/**
* @param credentials Credentials instance to adapt for HTTP
*/
public HttpCredentialsAdapter(Credentials credentials) {
Preconditions.checkNotNull(credentials);
this.credentials = credentials;
}

/** A getter for the credentials instance being used */
public Credentials getCredentials(){
/**
* A getter for the credentials instance being used
*/
public Credentials getCredentials() {
return credentials;
}

Expand Down
Expand Up @@ -31,6 +31,7 @@

package com.google.auth.http;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

Expand All @@ -40,6 +41,7 @@
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.auth.Credentials;
import com.google.auth.oauth2.GoogleCredentialsTest.MockTokenServerTransportFactory;
import com.google.auth.oauth2.MockTokenCheckingTransport;
import com.google.auth.oauth2.OAuth2Credentials;
Expand Down Expand Up @@ -150,12 +152,10 @@ public void initialize_noURI() throws IOException {
String authorizationHeader = requestHeaders.getAuthorization();
assertEquals(authorizationHeader, expectedAuthorization);
}
}

@Test
public void getCredentials() throws IOException {
public void getCredentials() {
final String accessToken = "1/MkSJoj1xsli0AccessToken_NKPY2";
final String expectedAuthorization = InternalAuthHttpConstants.BEARER_PREFIX + accessToken;
MockTokenServerTransportFactory tokenServerTransportFactory =
new MockTokenServerTransportFactory();
tokenServerTransportFactory.transport.addClient(CLIENT_ID, CLIENT_SECRET);
Expand All @@ -170,7 +170,7 @@ public void getCredentials() throws IOException {
.build();

HttpCredentialsAdapter adapter = new HttpCredentialsAdapter(credentials);
OAuth2Credentials returnedCredentials = adapter.getCredentials();
assertThat(returnedCredentials, instanceOf(OAuth2Credentials.class));
Credentials returnedCredentials = adapter.getCredentials();
assertThat(returnedCredentials, instanceOf(Credentials.class));
}
}

0 comments on commit 52f0106

Please sign in to comment.