Search in sources :

Example 11 with CredentialsStore

use of com.cloudbees.plugins.credentials.CredentialsStore in project blueocean-plugin by jenkinsci.

the class CredentialApiTest method createSshCredentialUsingSshFileOnMaster.

@Test
public void createSshCredentialUsingSshFileOnMaster() throws IOException {
    SystemCredentialsProvider.ProviderImpl system = ExtensionList.lookup(CredentialsProvider.class).get(SystemCredentialsProvider.ProviderImpl.class);
    CredentialsStore systemStore = system.getStore(j.getInstance());
    systemStore.addDomain(new Domain("domain1", null, null));
    Map<String, Object> resp = post("/organizations/jenkins/credentials/system/domains/domain1/credentials/", ImmutableMap.of("credentials", new ImmutableMap.Builder<String, Object>().put("privateKeySource", ImmutableMap.of("privateKeyFile", "~/.ssh/blah", "stapler-class", "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$FileOnMasterPrivateKeySource")).put("passphrase", "ssh2").put("scope", "GLOBAL").put("description", "ssh2 desc").put("$class", "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey").put("username", "ssh2").build()), 201);
    Assert.assertEquals("SSH Username with private key", resp.get("typeName"));
    Assert.assertEquals("domain1", resp.get("domain"));
}
Also used : SystemCredentialsProvider(com.cloudbees.plugins.credentials.SystemCredentialsProvider) CredentialsStore(com.cloudbees.plugins.credentials.CredentialsStore) SystemCredentialsProvider(com.cloudbees.plugins.credentials.SystemCredentialsProvider) CredentialsProvider(com.cloudbees.plugins.credentials.CredentialsProvider) Domain(com.cloudbees.plugins.credentials.domains.Domain) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 12 with CredentialsStore

use of com.cloudbees.plugins.credentials.CredentialsStore in project blueocean-plugin by jenkinsci.

the class CredentialApiTest method createSshCredentialUsingDefaultSshOnMaster.

@Test
public void createSshCredentialUsingDefaultSshOnMaster() throws IOException {
    SystemCredentialsProvider.ProviderImpl system = ExtensionList.lookup(CredentialsProvider.class).get(SystemCredentialsProvider.ProviderImpl.class);
    CredentialsStore systemStore = system.getStore(j.getInstance());
    systemStore.addDomain(new Domain("domain1", null, null));
    Map<String, Object> resp = post("/organizations/jenkins/credentials/system/domains/domain1/credentials/", ImmutableMap.of("credentials", new ImmutableMap.Builder<String, Object>().put("privateKeySource", ImmutableMap.of("stapler-class", "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$UsersPrivateKeySource")).put("passphrase", "ssh2").put("scope", "GLOBAL").put("description", "ssh2 desc").put("$class", "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey").put("username", "ssh2").build()), 201);
    Assert.assertEquals("SSH Username with private key", resp.get("typeName"));
    Assert.assertEquals("domain1", resp.get("domain"));
}
Also used : SystemCredentialsProvider(com.cloudbees.plugins.credentials.SystemCredentialsProvider) CredentialsStore(com.cloudbees.plugins.credentials.CredentialsStore) SystemCredentialsProvider(com.cloudbees.plugins.credentials.SystemCredentialsProvider) CredentialsProvider(com.cloudbees.plugins.credentials.CredentialsProvider) Domain(com.cloudbees.plugins.credentials.domains.Domain) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 13 with CredentialsStore

use of com.cloudbees.plugins.credentials.CredentialsStore in project blueocean-plugin by jenkinsci.

the class CredentialApiTest method createUsingUsernamePassword.

@Test
public void createUsingUsernamePassword() throws IOException {
    SystemCredentialsProvider.ProviderImpl system = ExtensionList.lookup(CredentialsProvider.class).get(SystemCredentialsProvider.ProviderImpl.class);
    CredentialsStore systemStore = system.getStore(j.getInstance());
    systemStore.addDomain(new Domain("domain1", null, null));
    Map<String, Object> resp = post("/organizations/jenkins/credentials/system/domains/domain1/credentials/", ImmutableMap.of("credentials", new ImmutableMap.Builder<String, Object>().put("password", "abcd").put("stapler-class", "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl").put("scope", "GLOBAL").put("description", "joe desc").put("$class", "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl").put("username", "joe").build()), 201);
    Assert.assertEquals("Username with password", resp.get("typeName"));
    Assert.assertEquals("domain1", resp.get("domain"));
}
Also used : SystemCredentialsProvider(com.cloudbees.plugins.credentials.SystemCredentialsProvider) CredentialsStore(com.cloudbees.plugins.credentials.CredentialsStore) SystemCredentialsProvider(com.cloudbees.plugins.credentials.SystemCredentialsProvider) CredentialsProvider(com.cloudbees.plugins.credentials.CredentialsProvider) Domain(com.cloudbees.plugins.credentials.domains.Domain) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

CredentialsStore (com.cloudbees.plugins.credentials.CredentialsStore)13 Domain (com.cloudbees.plugins.credentials.domains.Domain)12 Test (org.junit.Test)9 CredentialsProvider (com.cloudbees.plugins.credentials.CredentialsProvider)8 SystemCredentialsProvider (com.cloudbees.plugins.credentials.SystemCredentialsProvider)8 ImmutableMap (com.google.common.collect.ImmutableMap)7 User (hudson.model.User)5 UsernamePasswordCredentialsImpl (com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl)3 PipelineBaseTest (io.jenkins.blueocean.rest.impl.pipeline.PipelineBaseTest)3 Map (java.util.Map)3 CredentialsStoreAction (com.cloudbees.plugins.credentials.CredentialsStoreAction)2 ArrayList (java.util.ArrayList)2 AbstractFolderProperty (com.cloudbees.hudson.plugins.folder.AbstractFolderProperty)1 Credentials (com.cloudbees.plugins.credentials.Credentials)1 IdCredentials (com.cloudbees.plugins.credentials.common.IdCredentials)1 StandardCredentials (com.cloudbees.plugins.credentials.common.StandardCredentials)1 StandardUsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials)1 DomainSpecification (com.cloudbees.plugins.credentials.domains.DomainSpecification)1 ExtensionList (hudson.ExtensionList)1 BlueOceanDomainRequirement (io.jenkins.blueocean.rest.impl.pipeline.credential.BlueOceanDomainRequirement)1