From 19a4617b9e4efe608c5fc678479eec847ea0baa1 Mon Sep 17 00:00:00 2001 From: Temirlan Dyussyumbayev Date: Thu, 14 Dec 2023 23:29:10 +0600 Subject: [PATCH 1/5] Bump version of google-oauth-plugin and fix the tests --- pom.xml | 7 +- .../storage/ClassicUploadStepTest.java | 11 +-- .../plugins/storage/DownloadStepTest.java | 11 +-- ...xpiringBucketLifecycleManagerStepTest.java | 4 +- .../plugins/storage/StdoutUploadStepTest.java | 11 +-- .../GoogleRobotCredentialsDescriptor.java | 79 +++++++++++++++++++ 6 files changed, 93 insertions(+), 30 deletions(-) create mode 100644 src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java diff --git a/pom.xml b/pom.xml index 3577dd5a..cb6f8e30 100644 --- a/pom.xml +++ b/pom.xml @@ -102,6 +102,11 @@ j2objc-annotations 2.8 + + org.jenkins-ci.plugins + oauth-credentials + 0.646.v02b_66dc03d2e + @@ -235,7 +240,7 @@ org.jenkins-ci.plugins google-oauth-plugin - 1.318.vb_39c5db_e3041 + 1.328.v6ea_0fb_df5f7b_ com.google.guava diff --git a/src/test/java/com/google/jenkins/plugins/storage/ClassicUploadStepTest.java b/src/test/java/com/google/jenkins/plugins/storage/ClassicUploadStepTest.java index c76684b1..e9626ed2 100644 --- a/src/test/java/com/google/jenkins/plugins/storage/ClassicUploadStepTest.java +++ b/src/test/java/com/google/jenkins/plugins/storage/ClassicUploadStepTest.java @@ -23,7 +23,6 @@ import com.cloudbees.plugins.credentials.SystemCredentialsProvider; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.services.storage.Storage; -import com.google.jenkins.plugins.credentials.oauth.AbstractGoogleRobotCredentialsDescriptor; import com.google.jenkins.plugins.credentials.oauth.GoogleOAuth2ScopeRequirement; import com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials; import com.google.jenkins.plugins.util.MockExecutor; @@ -50,10 +49,7 @@ public class ClassicUploadStepTest { private GoogleRobotCredentials credentials; private GoogleCredential credential; - - @Mock - private AbstractGoogleRobotCredentialsDescriptor descriptor; - + private final MockExecutor executor = new MockExecutor(); private NotFoundException notFoundException = new NotFoundException(); @@ -61,12 +57,9 @@ public class ClassicUploadStepTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - - when(descriptor.getDisplayName()).thenReturn("Credentials Name"); - + when(credentials.getId()).thenReturn(CREDENTIALS_ID); when(credentials.getProjectId()).thenReturn(PROJECT_ID); - when(credentials.getDescriptor()).thenReturn(descriptor); if (jenkins.jenkins != null) { SystemCredentialsProvider.getInstance().getCredentials().add(credentials); diff --git a/src/test/java/com/google/jenkins/plugins/storage/DownloadStepTest.java b/src/test/java/com/google/jenkins/plugins/storage/DownloadStepTest.java index 4b0ca2b5..353f2cb9 100644 --- a/src/test/java/com/google/jenkins/plugins/storage/DownloadStepTest.java +++ b/src/test/java/com/google/jenkins/plugins/storage/DownloadStepTest.java @@ -28,7 +28,6 @@ import com.google.api.services.storage.Storage; import com.google.api.services.storage.model.Objects; import com.google.api.services.storage.model.StorageObject; -import com.google.jenkins.plugins.credentials.oauth.AbstractGoogleRobotCredentialsDescriptor; import com.google.jenkins.plugins.credentials.oauth.GoogleOAuth2ScopeRequirement; import com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials; import com.google.jenkins.plugins.util.MockExecutor; @@ -66,19 +65,13 @@ public class DownloadStepTest { private GoogleCredential credential; private final MockExecutor executor = new MockExecutor(); - - @Mock - private AbstractGoogleRobotCredentialsDescriptor descriptor; - + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - - when(descriptor.getDisplayName()).thenReturn("Credentials Name"); - + when(credentials.getId()).thenReturn(CREDENTIALS_ID); when(credentials.getProjectId()).thenReturn(PROJECT_ID); - when(credentials.getDescriptor()).thenReturn(descriptor); if (jenkins.jenkins != null) { SystemCredentialsProvider.getInstance().getCredentials().add(credentials); diff --git a/src/test/java/com/google/jenkins/plugins/storage/ExpiringBucketLifecycleManagerStepTest.java b/src/test/java/com/google/jenkins/plugins/storage/ExpiringBucketLifecycleManagerStepTest.java index a8b150b9..a052287d 100644 --- a/src/test/java/com/google/jenkins/plugins/storage/ExpiringBucketLifecycleManagerStepTest.java +++ b/src/test/java/com/google/jenkins/plugins/storage/ExpiringBucketLifecycleManagerStepTest.java @@ -21,9 +21,9 @@ import com.cloudbees.plugins.credentials.SystemCredentialsProvider; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.services.storage.Storage; -import com.google.jenkins.plugins.credentials.oauth.AbstractGoogleRobotCredentialsDescriptor; import com.google.jenkins.plugins.credentials.oauth.GoogleOAuth2ScopeRequirement; import com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials; +import com.google.jenkins.plugins.storage.util.GoogleRobotCredentialsDescriptor; import com.google.jenkins.plugins.util.MockExecutor; import com.google.jenkins.plugins.util.NotFoundException; import hudson.model.FreeStyleBuild; @@ -47,7 +47,7 @@ public class ExpiringBucketLifecycleManagerStepTest { private GoogleCredential credential; @Mock - private AbstractGoogleRobotCredentialsDescriptor descriptor; + private GoogleRobotCredentialsDescriptor.AbstractGoogleRobotCredentialsTestDescriptor descriptor; private final MockExecutor executor = new MockExecutor(); private NotFoundException notFoundException = new NotFoundException(); diff --git a/src/test/java/com/google/jenkins/plugins/storage/StdoutUploadStepTest.java b/src/test/java/com/google/jenkins/plugins/storage/StdoutUploadStepTest.java index d05bda2b..4ac54e44 100644 --- a/src/test/java/com/google/jenkins/plugins/storage/StdoutUploadStepTest.java +++ b/src/test/java/com/google/jenkins/plugins/storage/StdoutUploadStepTest.java @@ -21,7 +21,6 @@ import com.cloudbees.plugins.credentials.SystemCredentialsProvider; import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.services.storage.Storage; -import com.google.jenkins.plugins.credentials.oauth.AbstractGoogleRobotCredentialsDescriptor; import com.google.jenkins.plugins.credentials.oauth.GoogleOAuth2ScopeRequirement; import com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials; import com.google.jenkins.plugins.util.MockExecutor; @@ -46,10 +45,7 @@ public class StdoutUploadStepTest { private GoogleRobotCredentials credentials; private GoogleCredential credential; - - @Mock - private AbstractGoogleRobotCredentialsDescriptor descriptor; - + private final MockExecutor executor = new MockExecutor(); private NotFoundException notFoundException = new NotFoundException(); private static final String PROJECT_ID = "foo.com:project-build"; @@ -61,12 +57,9 @@ public class StdoutUploadStepTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - - when(descriptor.getDisplayName()).thenReturn("Credentials Name"); - + when(credentials.getId()).thenReturn(CREDENTIALS_ID); when(credentials.getProjectId()).thenReturn(PROJECT_ID); - when(credentials.getDescriptor()).thenReturn(descriptor); if (jenkins.jenkins != null) { SystemCredentialsProvider.getInstance().getCredentials().add(credentials); diff --git a/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java b/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java new file mode 100644 index 00000000..1ce94086 --- /dev/null +++ b/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java @@ -0,0 +1,79 @@ +package com.google.jenkins.plugins.storage.util; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.cloudbees.plugins.credentials.CredentialsScope; +import com.google.api.client.auth.oauth2.Credential; +import com.google.common.base.Strings; +import com.google.jenkins.plugins.credentials.oauth.GoogleOAuth2ScopeRequirement; +import com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials; +import com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentialsModule; +import com.google.jenkins.plugins.credentials.oauth.Messages; +import edu.umd.cs.findbugs.annotations.NonNull; +import hudson.util.FormValidation; +import java.security.GeneralSecurityException; +import org.kohsuke.stapler.QueryParameter; + +/** + * Dev Memo: In earlier versions, {@code AbstractGoogleRobotCredentialsDescriptor} was a standalone + * abstract class responsible for handling descriptors for Google robot account credential + * extensions. Now, {@code AbstractGoogleRobotCredentialsDescriptor} has been restructured and + * integrated as a static inner class within {@code GoogleRobotCredentials}. + * + *

This change affects how the descriptor is accessed and used within the codebase. No major + * changes in the API usage are expected, but minor adjustments might be necessary in how the class + * is instantiated or accessed + */ +public class GoogleRobotCredentialsDescriptor extends GoogleRobotCredentials { + + protected GoogleRobotCredentialsDescriptor( + CredentialsScope scope, + String id, + String projectId, + String description, + GoogleRobotCredentialsModule module) { + super(scope, id, projectId, description, module); + } + + @Override + public Credential getGoogleCredential(GoogleOAuth2ScopeRequirement requirement) + throws GeneralSecurityException { + return null; + } + + @NonNull + @Override + public String getUsername() { + return null; + } + + /** + * Abstract class for testing Google Robot Credentials Descriptor. This class extends {@link + * GoogleRobotCredentials.AbstractGoogleRobotCredentialsDescriptor} and is used for creating test + * instances of Google Robot Credentials descriptors. + */ + public abstract static class AbstractGoogleRobotCredentialsTestDescriptor + extends GoogleRobotCredentials.AbstractGoogleRobotCredentialsDescriptor { + protected AbstractGoogleRobotCredentialsTestDescriptor( + Class clazz, GoogleRobotCredentialsModule module) { + super(clazz); + this.module = checkNotNull(module); + } + + /** The module to use for instantiating depended upon resources */ + public GoogleRobotCredentialsModule getModule() { + return module; + } + + private final GoogleRobotCredentialsModule module; + + /** Validate project-id entries */ + public FormValidation doCheckProjectId(@QueryParameter String projectId) { + if (!Strings.isNullOrEmpty(projectId)) { + return FormValidation.ok(); + } else { + return FormValidation.error(Messages.GoogleRobotMetadataCredentials_ProjectIDError()); + } + } + } +} \ No newline at end of file From 0af8200ae0bfd8918ccc344153d4a29eab6ec117 Mon Sep 17 00:00:00 2001 From: Temirlan Dyussyumbayev Date: Thu, 14 Dec 2023 23:48:18 +0600 Subject: [PATCH 2/5] apply mvn spotless:apply --- pom.xml | 2 +- .../jenkins/plugins/storage/ClassicUploadStepTest.java | 4 ++-- .../com/google/jenkins/plugins/storage/DownloadStepTest.java | 4 ++-- .../google/jenkins/plugins/storage/StdoutUploadStepTest.java | 4 ++-- .../storage/util/GoogleRobotCredentialsDescriptor.java | 5 ++--- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index cb6f8e30..944a503b 100644 --- a/pom.xml +++ b/pom.xml @@ -240,7 +240,7 @@ org.jenkins-ci.plugins google-oauth-plugin - 1.328.v6ea_0fb_df5f7b_ + 1.328.v6ea_0fb_df5f7b_ com.google.guava diff --git a/src/test/java/com/google/jenkins/plugins/storage/ClassicUploadStepTest.java b/src/test/java/com/google/jenkins/plugins/storage/ClassicUploadStepTest.java index e9626ed2..aa2a89d1 100644 --- a/src/test/java/com/google/jenkins/plugins/storage/ClassicUploadStepTest.java +++ b/src/test/java/com/google/jenkins/plugins/storage/ClassicUploadStepTest.java @@ -49,7 +49,7 @@ public class ClassicUploadStepTest { private GoogleRobotCredentials credentials; private GoogleCredential credential; - + private final MockExecutor executor = new MockExecutor(); private NotFoundException notFoundException = new NotFoundException(); @@ -57,7 +57,7 @@ public class ClassicUploadStepTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - + when(credentials.getId()).thenReturn(CREDENTIALS_ID); when(credentials.getProjectId()).thenReturn(PROJECT_ID); diff --git a/src/test/java/com/google/jenkins/plugins/storage/DownloadStepTest.java b/src/test/java/com/google/jenkins/plugins/storage/DownloadStepTest.java index 353f2cb9..8170f4b0 100644 --- a/src/test/java/com/google/jenkins/plugins/storage/DownloadStepTest.java +++ b/src/test/java/com/google/jenkins/plugins/storage/DownloadStepTest.java @@ -65,11 +65,11 @@ public class DownloadStepTest { private GoogleCredential credential; private final MockExecutor executor = new MockExecutor(); - + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - + when(credentials.getId()).thenReturn(CREDENTIALS_ID); when(credentials.getProjectId()).thenReturn(PROJECT_ID); diff --git a/src/test/java/com/google/jenkins/plugins/storage/StdoutUploadStepTest.java b/src/test/java/com/google/jenkins/plugins/storage/StdoutUploadStepTest.java index 4ac54e44..12ae7d25 100644 --- a/src/test/java/com/google/jenkins/plugins/storage/StdoutUploadStepTest.java +++ b/src/test/java/com/google/jenkins/plugins/storage/StdoutUploadStepTest.java @@ -45,7 +45,7 @@ public class StdoutUploadStepTest { private GoogleRobotCredentials credentials; private GoogleCredential credential; - + private final MockExecutor executor = new MockExecutor(); private NotFoundException notFoundException = new NotFoundException(); private static final String PROJECT_ID = "foo.com:project-build"; @@ -57,7 +57,7 @@ public class StdoutUploadStepTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - + when(credentials.getId()).thenReturn(CREDENTIALS_ID); when(credentials.getProjectId()).thenReturn(PROJECT_ID); diff --git a/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java b/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java index 1ce94086..f6445c1e 100644 --- a/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java +++ b/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java @@ -36,8 +36,7 @@ protected GoogleRobotCredentialsDescriptor( } @Override - public Credential getGoogleCredential(GoogleOAuth2ScopeRequirement requirement) - throws GeneralSecurityException { + public Credential getGoogleCredential(GoogleOAuth2ScopeRequirement requirement) throws GeneralSecurityException { return null; } @@ -76,4 +75,4 @@ public FormValidation doCheckProjectId(@QueryParameter String projectId) { } } } -} \ No newline at end of file +} From ea66f994ec8277ed877a6ffd768460093611ed88 Mon Sep 17 00:00:00 2001 From: Temirlan Dyussyumbayev Date: Fri, 15 Dec 2023 10:19:04 +0600 Subject: [PATCH 3/5] Minor fix in javadoc --- .../util/GoogleRobotCredentialsDescriptor.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java b/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java index f6445c1e..3739d0e4 100644 --- a/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java +++ b/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java @@ -15,12 +15,13 @@ import org.kohsuke.stapler.QueryParameter; /** - * Dev Memo: In earlier versions, {@code AbstractGoogleRobotCredentialsDescriptor} was a standalone - * abstract class responsible for handling descriptors for Google robot account credential - * extensions. Now, {@code AbstractGoogleRobotCredentialsDescriptor} has been restructured and + * Dev Memo: + * In earlier versions, {@code AbstractGoogleRobotCredentialsDescriptor} was a standalone + * abstract class responsible for handling descriptors for Google robot account credential extensions. + * Now, {@code AbstractGoogleRobotCredentialsDescriptor} has been restructured and * integrated as a static inner class within {@code GoogleRobotCredentials}. * - *

This change affects how the descriptor is accessed and used within the codebase. No major + * This change affects how the descriptor is accessed and used within the codebase. No major * changes in the API usage are expected, but minor adjustments might be necessary in how the class * is instantiated or accessed */ @@ -47,8 +48,8 @@ public String getUsername() { } /** - * Abstract class for testing Google Robot Credentials Descriptor. This class extends {@link - * GoogleRobotCredentials.AbstractGoogleRobotCredentialsDescriptor} and is used for creating test + * Abstract class for testing Google Robot Credentials Descriptor. This class extends + * {@link GoogleRobotCredentials.AbstractGoogleRobotCredentialsDescriptor} and is used for creating test * instances of Google Robot Credentials descriptors. */ public abstract static class AbstractGoogleRobotCredentialsTestDescriptor From 144b8617bf6b6ac745192ac516a566f626d02694 Mon Sep 17 00:00:00 2001 From: Temirlan Dyussyumbayev Date: Fri, 15 Dec 2023 10:30:35 +0600 Subject: [PATCH 4/5] apply mvn spotless:apply --- .../storage/util/GoogleRobotCredentialsDescriptor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java b/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java index 3739d0e4..e374f3c5 100644 --- a/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java +++ b/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java @@ -15,9 +15,9 @@ import org.kohsuke.stapler.QueryParameter; /** - * Dev Memo: + * Dev Memo: * In earlier versions, {@code AbstractGoogleRobotCredentialsDescriptor} was a standalone - * abstract class responsible for handling descriptors for Google robot account credential extensions. + * abstract class responsible for handling descriptors for Google robot account credential extensions. * Now, {@code AbstractGoogleRobotCredentialsDescriptor} has been restructured and * integrated as a static inner class within {@code GoogleRobotCredentials}. * @@ -48,7 +48,7 @@ public String getUsername() { } /** - * Abstract class for testing Google Robot Credentials Descriptor. This class extends + * Abstract class for testing Google Robot Credentials Descriptor. This class extends * {@link GoogleRobotCredentials.AbstractGoogleRobotCredentialsDescriptor} and is used for creating test * instances of Google Robot Credentials descriptors. */ From cb891b873eb5d9e622ad07b9f6dade4c471d3ead Mon Sep 17 00:00:00 2001 From: Temirlan Dyussyumbayev Date: Mon, 18 Dec 2023 14:03:30 +0600 Subject: [PATCH 5/5] remove descriptor test class --- ...xpiringBucketLifecycleManagerStepTest.java | 7 -- .../GoogleRobotCredentialsDescriptor.java | 79 ------------------- 2 files changed, 86 deletions(-) delete mode 100644 src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java diff --git a/src/test/java/com/google/jenkins/plugins/storage/ExpiringBucketLifecycleManagerStepTest.java b/src/test/java/com/google/jenkins/plugins/storage/ExpiringBucketLifecycleManagerStepTest.java index a052287d..d73114a4 100644 --- a/src/test/java/com/google/jenkins/plugins/storage/ExpiringBucketLifecycleManagerStepTest.java +++ b/src/test/java/com/google/jenkins/plugins/storage/ExpiringBucketLifecycleManagerStepTest.java @@ -23,7 +23,6 @@ import com.google.api.services.storage.Storage; import com.google.jenkins.plugins.credentials.oauth.GoogleOAuth2ScopeRequirement; import com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials; -import com.google.jenkins.plugins.storage.util.GoogleRobotCredentialsDescriptor; import com.google.jenkins.plugins.util.MockExecutor; import com.google.jenkins.plugins.util.NotFoundException; import hudson.model.FreeStyleBuild; @@ -46,9 +45,6 @@ public class ExpiringBucketLifecycleManagerStepTest { private GoogleCredential credential; - @Mock - private GoogleRobotCredentialsDescriptor.AbstractGoogleRobotCredentialsTestDescriptor descriptor; - private final MockExecutor executor = new MockExecutor(); private NotFoundException notFoundException = new NotFoundException(); private static final String PROJECT_ID = "foo.com:project-build"; @@ -61,11 +57,8 @@ public class ExpiringBucketLifecycleManagerStepTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - when(descriptor.getDisplayName()).thenReturn("Credentials Name"); - when(credentials.getId()).thenReturn(CREDENTIALS_ID); when(credentials.getProjectId()).thenReturn(PROJECT_ID); - when(credentials.getDescriptor()).thenReturn(descriptor); if (jenkins.jenkins != null) { SystemCredentialsProvider.getInstance().getCredentials().add(credentials); diff --git a/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java b/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java deleted file mode 100644 index e374f3c5..00000000 --- a/src/test/java/com/google/jenkins/plugins/storage/util/GoogleRobotCredentialsDescriptor.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.google.jenkins.plugins.storage.util; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.cloudbees.plugins.credentials.CredentialsScope; -import com.google.api.client.auth.oauth2.Credential; -import com.google.common.base.Strings; -import com.google.jenkins.plugins.credentials.oauth.GoogleOAuth2ScopeRequirement; -import com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials; -import com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentialsModule; -import com.google.jenkins.plugins.credentials.oauth.Messages; -import edu.umd.cs.findbugs.annotations.NonNull; -import hudson.util.FormValidation; -import java.security.GeneralSecurityException; -import org.kohsuke.stapler.QueryParameter; - -/** - * Dev Memo: - * In earlier versions, {@code AbstractGoogleRobotCredentialsDescriptor} was a standalone - * abstract class responsible for handling descriptors for Google robot account credential extensions. - * Now, {@code AbstractGoogleRobotCredentialsDescriptor} has been restructured and - * integrated as a static inner class within {@code GoogleRobotCredentials}. - * - * This change affects how the descriptor is accessed and used within the codebase. No major - * changes in the API usage are expected, but minor adjustments might be necessary in how the class - * is instantiated or accessed - */ -public class GoogleRobotCredentialsDescriptor extends GoogleRobotCredentials { - - protected GoogleRobotCredentialsDescriptor( - CredentialsScope scope, - String id, - String projectId, - String description, - GoogleRobotCredentialsModule module) { - super(scope, id, projectId, description, module); - } - - @Override - public Credential getGoogleCredential(GoogleOAuth2ScopeRequirement requirement) throws GeneralSecurityException { - return null; - } - - @NonNull - @Override - public String getUsername() { - return null; - } - - /** - * Abstract class for testing Google Robot Credentials Descriptor. This class extends - * {@link GoogleRobotCredentials.AbstractGoogleRobotCredentialsDescriptor} and is used for creating test - * instances of Google Robot Credentials descriptors. - */ - public abstract static class AbstractGoogleRobotCredentialsTestDescriptor - extends GoogleRobotCredentials.AbstractGoogleRobotCredentialsDescriptor { - protected AbstractGoogleRobotCredentialsTestDescriptor( - Class clazz, GoogleRobotCredentialsModule module) { - super(clazz); - this.module = checkNotNull(module); - } - - /** The module to use for instantiating depended upon resources */ - public GoogleRobotCredentialsModule getModule() { - return module; - } - - private final GoogleRobotCredentialsModule module; - - /** Validate project-id entries */ - public FormValidation doCheckProjectId(@QueryParameter String projectId) { - if (!Strings.isNullOrEmpty(projectId)) { - return FormValidation.ok(); - } else { - return FormValidation.error(Messages.GoogleRobotMetadataCredentials_ProjectIDError()); - } - } - } -}