Search in sources :

Example 11 with RegistryConfig

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);
        }
    };
}
Also used : Expectations(mockit.Expectations) AuthConfig(io.fabric8.maven.docker.access.AuthConfig)

Example 12 with RegistryConfig

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());
}
Also used : Credential(com.google.cloud.tools.jib.api.Credential) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) Test(org.junit.Test)

Example 13 with RegistryConfig

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
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) Verifications(mockit.Verifications) File(java.io.File) Test(org.junit.Test)

Aggregations

ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)7 ImageName (io.fabric8.maven.docker.util.ImageName)6 AuthConfig (io.fabric8.maven.docker.access.AuthConfig)5 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)5 Credential (com.google.cloud.tools.jib.api.Credential)4 Test (org.junit.Test)3 RegistryConfig (io.fabric8.maven.docker.service.RegistryService.RegistryConfig)2 AuthConfigFactory (io.fabric8.maven.docker.util.AuthConfigFactory)2 JibServiceUtil.containerFromImageConfiguration (io.fabric8.maven.docker.util.JibServiceUtil.containerFromImageConfiguration)2 File (java.io.File)2 Verifications (mockit.Verifications)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 JibContainerBuilder (com.google.cloud.tools.jib.api.JibContainerBuilder)1 TarImage (com.google.cloud.tools.jib.api.TarImage)1 CreateImageOptions (io.fabric8.maven.docker.access.CreateImageOptions)1 AssemblyFiles (io.fabric8.maven.docker.assembly.AssemblyFiles)1 BuildDirs (io.fabric8.maven.docker.assembly.BuildDirs)1 ArchiveCompression (io.fabric8.maven.docker.config.ArchiveCompression)1 AssemblyConfiguration (io.fabric8.maven.docker.config.AssemblyConfiguration)1 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)1