use of com.spotify.docker.client.messages.RegistryConfigs in project docker-client by spotify.
the class DockerConfigReaderTest method testFromDockerConfig_CredsStore.
@Test
public void testFromDockerConfig_CredsStore() throws Exception {
assumeTrue("Need to have a credential store.", getAuthCredentialsExist());
String domain1 = "https://test.fakedomain.com";
String domain2 = "https://test.fakedomain2.com";
String testAuth1 = "{\n" + "\t\"ServerURL\": \"" + domain1 + "\",\n" + "\t\"Username\": \"david\",\n" + "\t\"Secret\": \"passw0rd1\"\n" + "}";
String testAuth2 = "{\n" + "\t\"ServerURL\": \"" + domain2 + "\",\n" + "\t\"Username\": \"carl\",\n" + "\t\"Secret\": \"myPassword\"\n" + "}";
storeAuthCredential(testAuth1);
storeAuthCredential(testAuth2);
final Path path = getTestFilePath("dockerConfig/" + getCredsStoreFileName());
final RegistryConfigs configs = reader.fromConfig(path);
for (RegistryAuth authConfigs : configs.configs().values()) {
if (domain1.equals(authConfigs.serverAddress())) {
assertThat(authConfigs.username(), equalTo("david"));
assertThat(authConfigs.password(), equalTo("passw0rd1"));
} else if (domain2.equals(authConfigs.serverAddress())) {
assertThat(authConfigs.username(), equalTo("carl"));
assertThat(authConfigs.password(), equalTo("myPassword"));
}
}
eraseAuthCredential(domain1);
eraseAuthCredential(domain2);
}
use of com.spotify.docker.client.messages.RegistryConfigs in project docker-client by spotify.
the class DockerConfigReaderTest method testParseRegistryConfigs.
@Test
public void testParseRegistryConfigs() throws Exception {
final Path path = getTestFilePath("dockerConfig/multiConfig.json");
final RegistryConfigs configs = reader.fromConfig(path);
assertThat(configs.configs(), allOf(hasEntry("https://index.docker.io/v1/", DOCKER_AUTH_CONFIG), hasEntry("https://narnia.mydock.io/v1/", MY_AUTH_CONFIG)));
}
use of com.spotify.docker.client.messages.RegistryConfigs in project docker-client by spotify.
the class ConfigFileRegistryAuthSupplierTest method testAuthForBuild_Success.
@Test
public void testAuthForBuild_Success() throws Exception {
final RegistryConfigs configs = RegistryConfigs.create(ImmutableMap.of("server1", RegistryAuth.builder().serverAddress("server1").username("user1").password("pass1").build()));
when(reader.fromConfig(configFile.toPath())).thenReturn(configs);
assertThat(supplier.authForBuild(), is(equalTo(configs)));
}
use of com.spotify.docker.client.messages.RegistryConfigs in project docker-client by spotify.
the class ContainerRegistryAuthSupplierTest method testAuthForBuild_TokenWithoutExpirationDoesNotCauseRefresh.
@Test
public void testAuthForBuild_TokenWithoutExpirationDoesNotCauseRefresh() throws Exception {
final AccessToken accessToken = new AccessToken(tokenValue, null);
final GoogleCredentials credentials = new GoogleCredentials(accessToken);
final ContainerRegistryAuthSupplier supplier = new ContainerRegistryAuthSupplier(credentials, clock, TimeUnit.SECONDS.toMillis(minimumExpirationSecs), refresher);
final RegistryConfigs configs = supplier.authForBuild();
assertThat(configs.configs().values(), is(not(empty())));
assertThat(configs.configs().values(), everyItem(matchesAccessToken(accessToken)));
verify(refresher, never()).refresh(credentials);
}
use of com.spotify.docker.client.messages.RegistryConfigs in project docker-client by spotify.
the class ContainerRegistryAuthSupplierTest method testAuthForBuild_NoRefresh.
@Test
public void testAuthForBuild_NoRefresh() throws Exception {
when(clock.currentTimeMillis()).thenReturn(expiration.minusSeconds(minimumExpirationSecs + 1).getMillis());
final RegistryConfigs configs = supplier.authForBuild();
assertThat(configs.configs().values(), is(not(empty())));
assertThat(configs.configs().values(), everyItem(matchesAccessToken(accessToken)));
verify(refresher, never()).refresh(credentials);
}
Aggregations