Search in sources :

Example 21 with PrivateRegistryImageSetting

use of com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting in project azure-tools-for-java by Microsoft.

the class ContainerRegistryMvpModelTest method testCreateImageSettingWithRegistry.

@Test
public void testCreateImageSettingWithRegistry() throws Exception {
    when(registryMock1.adminUserEnabled()).thenReturn(true);
    RegistryCredentials credentials = mock(RegistryCredentials.class);
    when(registryMock1.getCredentials()).thenReturn(credentials);
    when(registryMock1.loginServerUrl()).thenReturn("url");
    when(credentials.username()).thenReturn("Alice");
    Map<AccessKeyType, String> passwords = new HashMap<>();
    passwords.put(AccessKeyType.PRIMARY, "primaryKey");
    when(credentials.accessKeys()).thenReturn(passwords);
    PrivateRegistryImageSetting setting = containerRegistryMvpModel.createImageSettingWithRegistry(registryMock1);
    assertEquals(setting.getUsername(), "Alice");
    assertEquals(setting.getPassword(), "primaryKey");
    assertEquals(setting.getServerUrl(), "url");
    assertEquals(setting.getImageNameWithTag(), "image:tag");
}
Also used : AccessKeyType(com.microsoft.azure.management.containerregistry.AccessKeyType) PrivateRegistryImageSetting(com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting) HashMap(java.util.HashMap) Mockito.anyString(org.mockito.Mockito.anyString) RegistryCredentials(com.microsoft.azure.management.containerregistry.RegistryCredentials) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

PrivateRegistryImageSetting (com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting)21 DefaultDockerClient (com.spotify.docker.client.DefaultDockerClient)6 DockerClient (com.spotify.docker.client.DockerClient)6 Registry (com.microsoft.azure.management.containerregistry.Registry)5 ISecureStore (com.microsoft.azure.toolkit.ide.common.store.ISecureStore)4 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)4 InvalidFormDataException (com.microsoft.azuretools.azurecommons.exceptions.InvalidFormDataException)4 FileNotFoundException (java.io.FileNotFoundException)4 Path (java.nio.file.Path)4 PricingTier (com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)3 Gson (com.google.gson.Gson)2 ConfigurationException (com.intellij.openapi.options.ConfigurationException)2 AccessKeyType (com.microsoft.azure.management.containerregistry.AccessKeyType)2 RegistryCredentials (com.microsoft.azure.management.containerregistry.RegistryCredentials)2 DockerProgressHandler (com.microsoft.azure.toolkit.intellij.webapp.docker.utils.DockerProgressHandler)2 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)2 Region (com.microsoft.azure.toolkit.lib.common.model.Region)2 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)2 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)2 DockerProgressHandler (com.microsoft.azuretools.container.DockerProgressHandler)2