Skip to content

Commit

Permalink
Validate gitlab demo with the integrations framework (#1087)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored and timja committed Sep 29, 2019
1 parent 4a9102e commit 1fa36af
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
6 changes: 4 additions & 2 deletions demos/gitlab/README.md
@@ -1,4 +1,6 @@
# configure gitlab plugin
# Configure gitlab plugin

Basic configuration of the [Gitlab plugin](https://plugins.jenkins.io/gitlab-plugin)

## sample configuration

Expand All @@ -10,7 +12,7 @@ credentials:
- gitLabApiTokenImpl:
scope: SYSTEM
id: gitlab_token
apiToken: "qwertyuiopasdfghjklzxcvbnm"
apiToken: "${BIND_TOKEN}"
description: "Gitlab Token"
unclassified:
gitlabconnectionconfig:
Expand Down
Expand Up @@ -6,11 +6,14 @@
import com.dabsquared.gitlabjenkins.connection.GitLabApiToken;
import com.dabsquared.gitlabjenkins.connection.GitLabConnection;
import com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig;
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
import io.jenkins.plugins.casc.misc.ConfiguredWithReadme;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithReadmeRule;
import java.util.List;
import jenkins.model.Jenkins;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.rules.RuleChain;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
Expand All @@ -21,10 +24,12 @@
public class GitLabConfigurationTest {

@Rule
public JenkinsConfiguredWithCodeRule j = new JenkinsConfiguredWithCodeRule();
public RuleChain chain = RuleChain.outerRule(new EnvironmentVariables()
.set("BIND_TOKEN", "qwertyuiopasdfghjklzxcvbnm"))
.around(new JenkinsConfiguredWithReadmeRule());

@Test
@ConfiguredWithCode("GitLabTest.yml")
@ConfiguredWithReadme("gitlab/README.md")
public void configure_gitlab_api_token() throws Exception {
SystemCredentialsProvider systemCreds = SystemCredentialsProvider.getInstance();
List<DomainCredentials> domainCredentials = systemCreds.getDomainCredentials();
Expand All @@ -38,9 +43,10 @@ public void configure_gitlab_api_token() throws Exception {
assertEquals("Gitlab Token", apiToken.getDescription());
}
@Test
@ConfiguredWithCode("GitLabTest.yml")
@ConfiguredWithReadme("gitlab/README.md")
public void configure_gitlab_connection() throws Exception {
final GitLabConnectionConfig gitLabConnections = j.jenkins.getDescriptorByType(GitLabConnectionConfig.class);
final Jenkins jenkins = Jenkins.get();
final GitLabConnectionConfig gitLabConnections = jenkins.getDescriptorByType(GitLabConnectionConfig.class);
assertEquals(1, gitLabConnections.getConnections().size());
final GitLabConnection gitLabConnection = gitLabConnections.getConnections().get(0);
assertEquals("gitlab_token", gitLabConnection.getApiTokenId());
Expand Down

This file was deleted.

0 comments on commit 1fa36af

Please sign in to comment.