use of org.eclipse.che.plugin.docker.client.dto.AuthConfigs in project che by eclipse.
the class UserSpecificDockerRegistryCredentialsProviderTest method shouldReturnConfigsWithEmptyMapIfNoCredentialsDataInUserPreferences.
@Test
public void shouldReturnConfigsWithEmptyMapIfNoCredentialsDataInUserPreferences() throws ServerException {
String base64encodedCredentials = "e30=";
setCredentialsIntoPreferences(base64encodedCredentials);
AuthConfigs parsedAuthConfigs = dockerCredentials.getCredentials();
assertEquals(parsedAuthConfigs.getConfigs().size(), 0);
}
use of org.eclipse.che.plugin.docker.client.dto.AuthConfigs in project che by eclipse.
the class DockerConnectorTest method shouldBeAbleToBuildImage.
@Test
public void shouldBeAbleToBuildImage() throws IOException, InterruptedException {
AuthConfigs authConfigs = DtoFactory.newDto(AuthConfigs.class);
AuthConfig authConfig = DtoFactory.newDto(AuthConfig.class);
Map<String, AuthConfig> auth = new HashMap<>();
auth.put("auth", authConfig);
authConfigs.setConfigs(auth);
final String imageId = "37a7da3b7edc";
BuildImageParams buildImageParams = BuildImageParams.create(dockerfile).withAuthConfigs(authConfigs);
doReturn(new ByteArrayInputStream(("{\"stream\":\"Successfully built " + imageId + "\"}").getBytes())).when(dockerResponse).getInputStream();
String returnedImageId = dockerConnector.buildImage(buildImageParams, progressMonitor);
verify(dockerConnectionFactory).openConnection(any(URI.class));
verify(dockerConnection).method(REQUEST_METHOD_POST);
verify(dockerConnection).path("/build");
verify(dockerConnection).header("Content-Type", "application/x-compressed-tar");
verify(dockerConnection).header(eq("Content-Length"), anyInt());
verify(dockerConnection).entity(any(InputStream.class));
verify(dockerConnection, never()).header(eq("remote"), anyString());
verify(dockerConnection).header(eq("X-Registry-Config"), any(byte[].class));
verify(dockerConnection).request();
verify(dockerResponse).getStatus();
verify(dockerResponse).getInputStream();
assertEquals(returnedImageId, imageId);
}
use of org.eclipse.che.plugin.docker.client.dto.AuthConfigs in project che by eclipse.
the class DockerConnectorTest method shouldBeAbleToBuildImageWithRemoteContext.
@Test
public void shouldBeAbleToBuildImageWithRemoteContext() throws IOException, InterruptedException {
AuthConfigs authConfigs = DtoFactory.newDto(AuthConfigs.class);
AuthConfig authConfig = DtoFactory.newDto(AuthConfig.class);
Map<String, AuthConfig> auth = new HashMap<>();
auth.put("auth", authConfig);
authConfigs.setConfigs(auth);
final String imageId = "37a7da3b7edc";
final String remote = "https://some.host.com/path/tarball.tar";
BuildImageParams buildImageParams = BuildImageParams.create(remote).withAuthConfigs(authConfigs);
doReturn(new ByteArrayInputStream(("{\"stream\":\"Successfully built " + imageId + "\"}").getBytes())).when(dockerResponse).getInputStream();
String returnedImageId = dockerConnector.buildImage(buildImageParams, progressMonitor);
verify(dockerConnectionFactory).openConnection(any(URI.class));
verify(dockerConnection).method(REQUEST_METHOD_POST);
verify(dockerConnection).path("/build");
verify(dockerConnection).query(eq("remote"), eq(remote));
verify(dockerConnection, never()).header("Content-Type", "application/x-compressed-tar");
verify(dockerConnection, never()).header(eq("Content-Length"), anyInt());
verify(dockerConnection, never()).entity(any(InputStream.class));
verify(dockerConnection).header(eq("X-Registry-Config"), any(byte[].class));
verify(dockerConnection).request();
verify(dockerResponse).getStatus();
verify(dockerResponse).getInputStream();
assertEquals(returnedImageId, imageId);
}
use of org.eclipse.che.plugin.docker.client.dto.AuthConfigs in project che by eclipse.
the class DockerConnectorTest method shouldThrowDockerExceptionWhileBuildingImageIfResponseCodeIsNotSuccess.
@Test(expectedExceptions = DockerException.class, expectedExceptionsMessageRegExp = EXCEPTION_ERROR_MESSAGE)
public void shouldThrowDockerExceptionWhileBuildingImageIfResponseCodeIsNotSuccess() throws IOException, InterruptedException {
AuthConfigs authConfigs = DtoFactory.newDto(AuthConfigs.class);
AuthConfig authConfig = DtoFactory.newDto(AuthConfig.class);
Map<String, AuthConfig> auth = new HashMap<>();
auth.put("auth", authConfig);
authConfigs.setConfigs(auth);
BuildImageParams getExecInfoParams = BuildImageParams.create(dockerfile).withAuthConfigs(authConfigs);
when(dockerResponse.getStatus()).thenReturn(RESPONSE_ERROR_CODE);
dockerConnector.buildImage(getExecInfoParams, progressMonitor);
verify(dockerResponse).getStatus();
}
Aggregations