Search in sources :

Example 1 with Credentials

use of io.jenkins.tools.pluginmanager.config.Credentials in project plugin-installation-manager-tool by jenkinsci.

the class CredentialsOptionHandler method parse.

@Override
protected Credentials parse(String argument) throws CmdLineException {
    final Credentials option;
    // extract the 4 pieces: username, password, host, port
    final String[] parts = argument.split(":", 4);
    if (parts.length < 3) {
        throw new CmdLineException(owner, Messages.INVALID_CREDENTIALS_VALUE, argument);
    }
    if (parts.length == 3) {
        option = new Credentials(parts[1], parts[2], parts[0]);
    } else {
        int port = Integer.parseInt(parts[1]);
        option = new Credentials(parts[2], parts[3], parts[0], port);
    }
    return option;
}
Also used : Credentials(io.jenkins.tools.pluginmanager.config.Credentials) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 2 with Credentials

use of io.jenkins.tools.pluginmanager.config.Credentials in project plugin-installation-manager-tool by jenkinsci.

the class CliOptionsTest method credentialsTest.

@Test
public void credentialsTest() throws CmdLineException {
    parser.parseArgument("--credentials", "myhost:myuser:mypass,myhost2:1234:myuser2:mypass2");
    Config cfg = options.setup();
    assertThat(cfg.getCredentials()).containsExactly(new Credentials("myuser", "mypass", "myhost"), new Credentials("myuser2", "mypass2", "myhost2", 1234));
}
Also used : Config(io.jenkins.tools.pluginmanager.config.Config) Credentials(io.jenkins.tools.pluginmanager.config.Credentials) Test(org.junit.Test)

Example 3 with Credentials

use of io.jenkins.tools.pluginmanager.config.Credentials in project plugin-installation-manager-tool by jenkinsci.

the class PluginManagerWiremockTest method proxyToWireMock.

@Before
public void proxyToWireMock() {
    archives = new WireMockServer(WireMockConfiguration.options().dynamicPort().notifier(new ConsoleNotifier(true)));
    archives.start();
    protectedArchives = new WireMockServer(WireMockConfiguration.options().dynamicPort().notifier(new ConsoleNotifier(true)));
    protectedArchives.start();
    cfg = Config.builder().withJenkinsWar(Settings.DEFAULT_WAR).withPluginDir(new File(folder.getRoot(), "plugins")).withCredentials(Collections.singletonList(new Credentials("myuser", "mypassword", "localhost", protectedArchives.port()))).build();
    pm = new PluginManager(cfg);
    if (record) {
        archives.stubFor(proxyAllTo("http://archives.jenkins-ci.org").atPriority(1));
    }
// the mappings from src/test/resources/mappings are used otherwise
}
Also used : ConsoleNotifier(com.github.tomakehurst.wiremock.common.ConsoleNotifier) File(java.io.File) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) Credentials(io.jenkins.tools.pluginmanager.config.Credentials) Before(org.junit.Before)

Aggregations

Credentials (io.jenkins.tools.pluginmanager.config.Credentials)3 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)1 ConsoleNotifier (com.github.tomakehurst.wiremock.common.ConsoleNotifier)1 Config (io.jenkins.tools.pluginmanager.config.Config)1 File (java.io.File)1 Before (org.junit.Before)1 Test (org.junit.Test)1 CmdLineException (org.kohsuke.args4j.CmdLineException)1