From 40df285f583cf9d119855d11898e90c861db06ce Mon Sep 17 00:00:00 2001 From: Antoine Neveux Date: Wed, 25 Oct 2023 15:32:51 +0200 Subject: [PATCH] Using updated google-oauth-plugin dependency and calling non deprecated constructor for credentials creation --- pom.xml | 3 ++- .../plugins/computeengine/ComputeEngineCloudTest.java | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index b3efecfe..c32cc30d 100644 --- a/pom.xml +++ b/pom.xml @@ -92,7 +92,8 @@ pom import - + + org.jenkins-ci.plugins google-oauth-plugin 1.1.1 diff --git a/src/test/java/com/google/jenkins/plugins/computeengine/ComputeEngineCloudTest.java b/src/test/java/com/google/jenkins/plugins/computeengine/ComputeEngineCloudTest.java index 6c0788f9..a8ea5d17 100644 --- a/src/test/java/com/google/jenkins/plugins/computeengine/ComputeEngineCloudTest.java +++ b/src/test/java/com/google/jenkins/plugins/computeengine/ComputeEngineCloudTest.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertThrows; import com.cloudbees.plugins.credentials.Credentials; +import com.cloudbees.plugins.credentials.CredentialsScope; import com.cloudbees.plugins.credentials.CredentialsStore; import com.cloudbees.plugins.credentials.SecretBytes; import com.cloudbees.plugins.credentials.SystemCredentialsProvider; @@ -61,18 +62,18 @@ public void construction() throws Exception { serviceAccountConfig.setSecretJsonKey(bytes); assertNotNull(serviceAccountConfig.getAccountId()); // Create a credential - GoogleRobotPrivateKeyCredentials c = - new GoogleRobotPrivateKeyCredentials(ACCOUNT_ID, serviceAccountConfig, null); - String credentialsId = c.getId(); + final String credentialId = "test-credential-id"; + GoogleRobotPrivateKeyCredentials c = new GoogleRobotPrivateKeyCredentials(CredentialsScope.GLOBAL, credentialId, ACCOUNT_ID, + serviceAccountConfig, null); CredentialsStore store = new SystemCredentialsProvider.ProviderImpl().getStore(r.jenkins); + assertNotNull(store); store.addCredentials(Domain.global(), c); // Add a few InstanceConfigurations List ics = new ArrayList<>(); ics.add(instanceConfigurationBuilder().build()); ics.add(instanceConfigurationBuilder().build()); - ComputeEngineCloud cloud = - new ComputeEngineCloud(CLOUD_NAME, PROJECT_ID, credentialsId, INSTANCE_CAP_STR); + ComputeEngineCloud cloud = new ComputeEngineCloud(CLOUD_NAME, PROJECT_ID, credentialId, INSTANCE_CAP_STR); cloud.setInstanceId(INSTANCE_ID); cloud.setConfigurations(ics);