Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove deprecated methods #537

Merged
merged 5 commits into from Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 0 additions & 30 deletions appengine/java/com/google/auth/appengine/AppEngineCredentials.java
Expand Up @@ -35,7 +35,6 @@
import com.google.appengine.api.appidentity.AppIdentityService.GetAccessTokenResult;
import com.google.appengine.api.appidentity.AppIdentityServiceFactory;
import com.google.auth.ServiceAccountSigner;
import com.google.auth.http.HttpTransportFactory;
import com.google.auth.oauth2.AccessToken;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.common.base.MoreObjects;
Expand All @@ -46,7 +45,6 @@
import java.util.Collection;
import java.util.Date;
import java.util.Objects;
import java.util.logging.Logger;

/**
* OAuth2 credentials representing the built-in service account for Google App Engine. You should
Expand All @@ -56,7 +54,6 @@
*/
public class AppEngineCredentials extends GoogleCredentials implements ServiceAccountSigner {

private static final Logger logger = Logger.getLogger(AppEngineCredentials.class.getName());
private static final long serialVersionUID = -2627708355455064660L;

private final String appIdentityServiceClassName;
Expand All @@ -65,33 +62,6 @@ public class AppEngineCredentials extends GoogleCredentials implements ServiceAc

private transient AppIdentityService appIdentityService;

/**
* @deprecated AppEngineCredentials should be instantiated via its Builder. See
* https://github.com/googleapis/google-auth-library-java#google-auth-library-appengine
*/
@Deprecated
public static GoogleCredentials getApplicationDefault() throws IOException {
logger.warning(
"You are attempting to "
+ "fetch Application Default Credentials from com.google.auth.appengine.AppEngineCredentials."
+ " This method will not return a com.google.auth.appengine.AppEngineCredentials instance.");
return GoogleCredentials.getApplicationDefault();
}

/**
* @deprecated AppEngineCredentials should be instantiated via its Builder. See
* https://github.com/googleapis/google-auth-library-java#google-auth-library-appengine
*/
@Deprecated
public static GoogleCredentials getApplicationDefault(HttpTransportFactory transportFactory)
throws IOException {
logger.warning(
"You are attempting to fetch "
+ "Application Default Credentials from com.google.auth.appengine.AppEngineCredentials. "
+ "This method does not return a com.google.auth.appengine.AppEngineCredentials instance.");
return GoogleCredentials.getApplicationDefault(transportFactory);
}

private AppEngineCredentials(Collection<String> scopes, AppIdentityService appIdentityService) {
this.scopes = scopes == null ? ImmutableSet.<String>of() : ImmutableList.copyOf(scopes);
this.appIdentityService =
Expand Down
Expand Up @@ -39,9 +39,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import com.google.api.client.http.HttpTransport;
import com.google.auth.Credentials;
import com.google.auth.http.HttpTransportFactory;
import com.google.auth.oauth2.AccessToken;
import com.google.auth.oauth2.BaseSerializationTest;
import com.google.auth.oauth2.GoogleCredentials;
Expand All @@ -53,9 +51,6 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -264,61 +259,4 @@ private static void assertContainsBearerToken(Map<String, List<String>> metadata
}
assertTrue("Bearer token not found", found);
}

@Test
@SuppressWarnings("deprecation")
public void warnsDefaultCredentials() {
Logger logger = Logger.getLogger(AppEngineCredentials.class.getName());
LogHandler handler = new LogHandler();
logger.addHandler(handler);

try {
Credentials unused = AppEngineCredentials.getApplicationDefault();
} catch (IOException ex) {
// ignore - this may just fail for not being in a supported environment
}

LogRecord message = handler.getRecord();
assertTrue(message.getMessage().contains("You are attempting to"));
}

@Test
@SuppressWarnings("deprecation")
public void warnsDefaultCredentialsWithTransport() {
Logger logger = Logger.getLogger(AppEngineCredentials.class.getName());
LogHandler handler = new LogHandler();
logger.addHandler(handler);

try {
Credentials unused =
AppEngineCredentials.getApplicationDefault(
new HttpTransportFactory() {
@Override
public HttpTransport create() {
return null;
}
});
} catch (IOException ex) {
// ignore - this may just fail for not being in a supported environment
}

LogRecord message = handler.getRecord();
assertTrue(message.getMessage().contains("You are attempting to"));
}

private class LogHandler extends Handler {
LogRecord lastRecord;

public void publish(LogRecord record) {
lastRecord = record;
}

public LogRecord getRecord() {
return lastRecord;
}

public void close() {}

public void flush() {}
}
}
4 changes: 0 additions & 4 deletions appengine/pom.xml
Expand Up @@ -58,10 +58,6 @@
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
Expand Down