Search in sources :

Example 6 with RegistryCredentials

use of com.microsoft.azure.management.containerregistry.RegistryCredentials 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

RegistryCredentials (com.microsoft.azure.management.containerregistry.RegistryCredentials)6 AccessKeyType (com.microsoft.azure.management.containerregistry.AccessKeyType)4 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 PrivateRegistryImageSetting (com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting)2 HashMap (java.util.HashMap)2 Mockito.anyString (org.mockito.Mockito.anyString)2 ContainerRegistryProperty (com.microsoft.azuretools.core.mvp.ui.containerregistry.ContainerRegistryProperty)1