Skip to content

Commit

Permalink
Using updated google-oauth-plugin dependency and calling non deprecat…
Browse files Browse the repository at this point in the history
…ed constructor for credentials creation
  • Loading branch information
aneveux committed Oct 25, 2023
1 parent 9172ced commit 40df285
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency> <!-- until it is back in the parent -->
<!-- TODO: Remove the version here when it is integrated in the BOM -->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>google-oauth-plugin</artifactId>
<version>1.1.1</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<InstanceConfiguration> 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);

Expand Down

0 comments on commit 40df285

Please sign in to comment.