Search in sources :

Example 1 with GitLabApiToken

use of com.dabsquared.gitlabjenkins.connection.GitLabApiToken in project configuration-as-code-plugin by jenkinsci.

the class GitLabConfigurationTest method configure_gitlab_api_token.

@Test
@ConfiguredWithReadme("gitlab/README.md")
public void configure_gitlab_api_token() {
    SystemCredentialsProvider systemCreds = SystemCredentialsProvider.getInstance();
    List<DomainCredentials> domainCredentials = systemCreds.getDomainCredentials();
    assertEquals(1, domainCredentials.size());
    final DomainCredentials gitLabCredential = domainCredentials.get(0);
    assertEquals(Domain.global(), gitLabCredential.getDomain());
    assertEquals(1, gitLabCredential.getCredentials().size());
    final GitLabApiToken apiToken = (GitLabApiToken) gitLabCredential.getCredentials().get(0);
    assertEquals("gitlab_token", apiToken.getId());
    assertEquals("qwertyuiopasdfghjklzxcvbnm", apiToken.getApiToken().getPlainText());
    assertEquals("Gitlab Token", apiToken.getDescription());
}
Also used : DomainCredentials(com.cloudbees.plugins.credentials.domains.DomainCredentials) SystemCredentialsProvider(com.cloudbees.plugins.credentials.SystemCredentialsProvider) GitLabApiToken(com.dabsquared.gitlabjenkins.connection.GitLabApiToken) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Aggregations

SystemCredentialsProvider (com.cloudbees.plugins.credentials.SystemCredentialsProvider)1 DomainCredentials (com.cloudbees.plugins.credentials.domains.DomainCredentials)1 GitLabApiToken (com.dabsquared.gitlabjenkins.connection.GitLabApiToken)1 ConfiguredWithReadme (io.jenkins.plugins.casc.misc.ConfiguredWithReadme)1 Test (org.junit.Test)1