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;
}
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));
}
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
}
Aggregations