use of io.fabric8.maven.docker.service.RegistryService.RegistryConfig in project docker-maven-plugin by fabric8io.
the class JibBuildServiceTest method mockAuthConfigFactory.
private void mockAuthConfigFactory(boolean isPush, RegistryService.RegistryConfig registryConfig) throws MojoExecutionException {
new Expectations() {
{
authConfigFactory.createAuthConfig(anyBoolean, registryConfig.isSkipExtendedAuth(), registryConfig.getAuthConfig(), registryConfig.getSettings(), null, anyString);
result = new AuthConfig("testuser" + (isPush ? "push" : "pull"), "testpass", "foo@example.com", null, null);
}
};
}
use of io.fabric8.maven.docker.service.RegistryService.RegistryConfig in project docker-maven-plugin by fabric8io.
the class JibBuildServiceTest method testGetRegistryCredentialsForPull.
@Test
@java.lang.SuppressWarnings("squid:S00112")
public void testGetRegistryCredentialsForPull() throws MojoExecutionException {
// Given
ImageConfiguration imageConfiguration = getImageConfiguration();
RegistryService.RegistryConfig registryConfig = new RegistryService.RegistryConfig.Builder().authConfig(Collections.emptyMap()).authConfigFactory(authConfigFactory).settings(settings).build();
mockAuthConfigFactory(false, registryConfig);
// When
Credential credential = JibBuildService.getRegistryCredentials(registryConfig, false, imageConfiguration, logger);
// Then
assertNotNull(credential);
assertEquals("testuserpull", credential.getUsername());
assertEquals("testpass", credential.getPassword());
}
use of io.fabric8.maven.docker.service.RegistryService.RegistryConfig in project docker-maven-plugin by fabric8io.
the class JibBuildServiceTest method testPushWithConfiguration.
@Test
public void testPushWithConfiguration(@Mocked JibServiceUtil jibServiceUtil) throws Exception {
// Given
File projectBaseDir = Files.createTempDirectory("test").toFile();
setupServiceHubExpectations(projectBaseDir);
final ImageConfiguration imageConfiguration = getImageConfiguration();
final RegistryService.RegistryConfig registryConfig = new RegistryService.RegistryConfig.Builder().authConfigFactory(authConfigFactory).build();
mockAuthConfigFactory(true, registryConfig);
// When
new JibBuildService(serviceHub, params, logger).push(Collections.singletonList(imageConfiguration), 1, registryConfig, false);
// Then
// @formatter:off
new Verifications() {
{
JibServiceUtil.jibPush(imageConfiguration, Credential.from("testuserpush", "testpass"), (File) any, logger);
times = 1;
}
};
// @formatter:on
}
Aggregations