public void AddsEnvironmentWithStorageEndpoint() { var profile = new AzureSMProfile(); Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); PSAzureEnvironment actual = null; commandRuntimeMock.Setup(f => f.WriteObject(It.IsAny <object>())) .Callback((object output) => actual = (PSAzureEnvironment)output); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", StorageEndpoint = "core.windows.net", Profile = profile }; cmdlet.InvokeBeginProcessing(); cmdlet.ExecuteCmdlet(); cmdlet.InvokeEndProcessing(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny <PSAzureEnvironment>()), Times.Once()); ProfileClient client = new ProfileClient(profile); AzureEnvironment env = client.Profile.Environments["KaTaL"]; Assert.Equal(env.Name, cmdlet.Name); Assert.Equal(env.Endpoints[AzureEnvironment.Endpoint.PublishSettingsFileUrl], actual.PublishSettingsFileUrl); }
public void AddsAzureEnvironment() { Mock<ICommandRuntime> commandRuntimeMock = new Mock<ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", ServiceEndpoint = "endpoint.net", ManagementPortalUrl = "management portal url", StorageEndpoint = "endpoint.net", GalleryEndpoint = "http://galleryendpoint.com" }; cmdlet.ExecuteCmdlet(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny<WindowsAzureEnvironment>()), Times.Once()); WindowsAzureEnvironment env = WindowsAzureProfile.Instance.Environments["KaTaL"]; Assert.AreEqual(env.Name, cmdlet.Name); Assert.AreEqual(env.PublishSettingsFileUrl, cmdlet.PublishSettingsFileUrl); Assert.AreEqual(env.ServiceEndpoint, cmdlet.ServiceEndpoint); Assert.AreEqual(env.ManagementPortalUrl, cmdlet.ManagementPortalUrl); Assert.AreEqual(env.StorageBlobEndpointFormat, "{0}://{1}.blob.endpoint.net/"); Assert.AreEqual(env.StorageQueueEndpointFormat, "{0}://{1}.queue.endpoint.net/"); Assert.AreEqual(env.StorageTableEndpointFormat, "{0}://{1}.table.endpoint.net/"); Assert.AreEqual(env.GalleryEndpoint, "http://galleryendpoint.com"); }
public void AddsAzureEnvironment() { Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", ServiceEndpoint = "endpoint.net", ManagementPortalUrl = "management portal url", StorageEndpoint = "endpoint.net", GalleryEndpoint = "http://galleryendpoint.com" }; cmdlet.InvokeBeginProcessing(); cmdlet.ExecuteCmdlet(); cmdlet.InvokeEndProcessing(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny <PSObject>()), Times.Once()); ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile))); AzureEnvironment env = client.GetEnvironmentOrDefault("KaTaL"); Assert.Equal(env.Name, cmdlet.Name); Assert.Equal(env.Endpoints[AzureEnvironment.Endpoint.PublishSettingsFileUrl], cmdlet.PublishSettingsFileUrl); Assert.Equal(env.Endpoints[AzureEnvironment.Endpoint.ServiceManagement], cmdlet.ServiceEndpoint); Assert.Equal(env.Endpoints[AzureEnvironment.Endpoint.ManagementPortalUrl], cmdlet.ManagementPortalUrl); Assert.Equal(env.Endpoints[AzureEnvironment.Endpoint.Gallery], "http://galleryendpoint.com"); }
public void AddsAzureEnvironment() { Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", ServiceEndpoint = "endpoint.net", ManagementPortalUrl = "management portal url", StorageEndpoint = "endpoint.net" }; cmdlet.ExecuteCmdlet(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny <WindowsAzureEnvironment>()), Times.Once()); WindowsAzureEnvironment env = WindowsAzureProfile.Instance.Environments["KaTaL"]; Assert.AreEqual(env.Name, cmdlet.Name); Assert.AreEqual(env.PublishSettingsFileUrl, cmdlet.PublishSettingsFileUrl); Assert.AreEqual(env.ServiceEndpoint, cmdlet.ServiceEndpoint); Assert.AreEqual(env.ManagementPortalUrl, cmdlet.ManagementPortalUrl); Assert.AreEqual(env.StorageBlobEndpointFormat, "{0}://{1}.blob.endpoint.net/"); Assert.AreEqual(env.StorageQueueEndpointFormat, "{0}://{1}.queue.endpoint.net/"); Assert.AreEqual(env.StorageTableEndpointFormat, "{0}://{1}.table.endpoint.net/"); }
public void AddsEnvironmentWithEmptyStorageEndpoint() { Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); WindowsAzureEnvironment actual = null; commandRuntimeMock.Setup(f => f.WriteObject(It.IsAny <object>())) .Callback((object output) => actual = (WindowsAzureEnvironment)output); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", StorageEndpoint = null }; cmdlet.ExecuteCmdlet(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny <WindowsAzureEnvironment>()), Times.Once()); WindowsAzureEnvironment env = WindowsAzureProfile.Instance.Environments["KaTaL"]; Assert.AreEqual(env.Name, cmdlet.Name); Assert.AreEqual(env.PublishSettingsFileUrl, actual.PublishSettingsFileUrl); Assert.IsTrue(string.IsNullOrEmpty(actual.StorageBlobEndpointFormat)); Assert.IsTrue(string.IsNullOrEmpty(actual.StorageQueueEndpointFormat)); Assert.IsTrue(string.IsNullOrEmpty(actual.StorageTableEndpointFormat)); }
public void AddsEnvironmentWithStorageEndpoint() { Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); WindowsAzureEnvironment actual = null; commandRuntimeMock.Setup(f => f.WriteObject(It.IsAny <object>())) .Callback((object output) => actual = (WindowsAzureEnvironment)output); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", StorageEndpoint = "core.windows.net" }; cmdlet.ExecuteCmdlet(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny <WindowsAzureEnvironment>()), Times.Once()); WindowsAzureEnvironment env = GlobalSettingsManager.Instance.GetEnvironment("KaTaL"); Assert.AreEqual(env.Name, cmdlet.Name); Assert.AreEqual(env.PublishSettingsFileUrl, actual.PublishSettingsFileUrl); Assert.AreEqual( WindowsAzureEnvironmentConstants.AzureStorageBlobEndpointFormat, actual.StorageBlobEndpointFormat); Assert.AreEqual( WindowsAzureEnvironmentConstants.AzureStorageQueueEndpointFormat, actual.StorageQueueEndpointFormat); Assert.AreEqual( WindowsAzureEnvironmentConstants.AzureStorageTableEndpointFormat, actual.StorageTableEndpointFormat); }
public void AddsEnvironmentWithMinimumInformation() { var profile = new AzureSMProfile(); Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", EnableAdfsAuthentication = true, Profile = profile }; cmdlet.InvokeBeginProcessing(); cmdlet.ExecuteCmdlet(); cmdlet.InvokeEndProcessing(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny <PSAzureEnvironment>()), Times.Once()); ProfileClient client = new ProfileClient(profile); AzureEnvironment env = client.Profile.Environments["KaTaL"]; Assert.Equal(env.Name, cmdlet.Name); Assert.True(env.OnPremise); Assert.Equal(env.Endpoints[AzureEnvironment.Endpoint.PublishSettingsFileUrl], cmdlet.PublishSettingsFileUrl); }
public void AddsEnvironmentWithStorageEndpoint() { Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); PSObject actual = null; commandRuntimeMock.Setup(f => f.WriteObject(It.IsAny <object>())) .Callback((object output) => actual = (PSObject)output); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", StorageEndpoint = "core.windows.net" }; cmdlet.InvokeBeginProcessing(); cmdlet.ExecuteCmdlet(); cmdlet.InvokeEndProcessing(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny <PSObject>()), Times.Once()); ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile))); AzureEnvironment env = client.Profile.Environments["KaTaL"]; Assert.Equal(env.Name, cmdlet.Name); Assert.Equal(env.Endpoints[AzureEnvironment.Endpoint.PublishSettingsFileUrl], actual.GetVariableValue <string>(AzureEnvironment.Endpoint.PublishSettingsFileUrl.ToString())); }
public void AddsAzureEnvironment() { var profile = new AzureSMProfile(); Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", ServiceEndpoint = "endpoint.net", ManagementPortalUrl = "management portal url", StorageEndpoint = "endpoint.net", GalleryEndpoint = "http://galleryendpoint.com", Profile = profile }; cmdlet.InvokeBeginProcessing(); cmdlet.ExecuteCmdlet(); cmdlet.InvokeEndProcessing(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny <PSAzureEnvironment>()), Times.Once()); ProfileClient client = new ProfileClient(profile); IAzureEnvironment env = client.GetEnvironmentOrDefault("KaTaL"); Assert.Equal(env.Name, cmdlet.Name); Assert.Equal(env.PublishSettingsFileUrl, cmdlet.PublishSettingsFileUrl); Assert.Equal(env.ServiceManagementUrl, cmdlet.ServiceEndpoint); Assert.Equal(env.ManagementPortalUrl, cmdlet.ManagementPortalUrl); Assert.Equal(env.GalleryUrl, "http://galleryendpoint.com"); }
public void CanCreateEnvironmentWithAllProperties() { var profile = new AzureSMProfile(); Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); PSAzureEnvironment actual = null; commandRuntimeMock.Setup(f => f.WriteObject(It.IsAny <PSAzureEnvironment>())) .Callback((object output) => actual = (PSAzureEnvironment)output); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", Profile = profile, ActiveDirectoryEndpoint = "ActiveDirectoryEndpoint", AdTenant = "AdTenant", AzureKeyVaultDnsSuffix = "AzureKeyVaultDnsSuffix", ActiveDirectoryServiceEndpointResourceId = "ActiveDirectoryServiceEndpointResourceId", AzureKeyVaultServiceEndpointResourceId = "AzureKeyVaultServiceEndpointResourceId", EnableAdfsAuthentication = true, GalleryEndpoint = "GalleryEndpoint", GraphEndpoint = "GraphEndpoint", ManagementPortalUrl = "ManagementPortalUrl", PublishSettingsFileUrl = "PublishSettingsFileUrl", ResourceManagerEndpoint = "ResourceManagerEndpoint", ServiceEndpoint = "ServiceEndpoint", StorageEndpoint = "StorageEndpoint", SqlDatabaseDnsSuffix = "SqlDatabaseDnsSuffix", TrafficManagerDnsSuffix = "TrafficManagerDnsSuffix" }; cmdlet.InvokeBeginProcessing(); cmdlet.ExecuteCmdlet(); cmdlet.InvokeEndProcessing(); Assert.Equal(cmdlet.Name, actual.Name); Assert.Equal(cmdlet.EnableAdfsAuthentication.ToBool(), actual.EnableAdfsAuthentication); Assert.Equal(cmdlet.ActiveDirectoryEndpoint, actual.ActiveDirectoryAuthority); Assert.Equal(cmdlet.ActiveDirectoryServiceEndpointResourceId, actual.ActiveDirectoryServiceEndpointResourceId); Assert.Equal(cmdlet.AdTenant, actual.AdTenant); Assert.Equal(cmdlet.AzureKeyVaultDnsSuffix, actual.AzureKeyVaultDnsSuffix); Assert.Equal(cmdlet.AzureKeyVaultServiceEndpointResourceId, actual.AzureKeyVaultServiceEndpointResourceId); Assert.Equal(cmdlet.GalleryEndpoint, actual.GalleryUrl); Assert.Equal(cmdlet.GraphEndpoint, actual.GraphUrl); Assert.Equal(cmdlet.ManagementPortalUrl, actual.ManagementPortalUrl); Assert.Equal(cmdlet.PublishSettingsFileUrl, actual.PublishSettingsFileUrl); Assert.Equal(cmdlet.ResourceManagerEndpoint, actual.ResourceManagerUrl); Assert.Equal(cmdlet.ServiceEndpoint, actual.ServiceManagementUrl); Assert.Equal(cmdlet.StorageEndpoint, actual.StorageEndpointSuffix); Assert.Equal(cmdlet.SqlDatabaseDnsSuffix, actual.SqlDatabaseDnsSuffix); Assert.Equal(cmdlet.TrafficManagerDnsSuffix, actual.TrafficManagerDnsSuffix); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny <PSAzureEnvironment>()), Times.Once()); ProfileClient client = new ProfileClient(profile); AzureEnvironment env = client.Profile.Environments["KaTaL"]; Assert.Equal(env.Name, cmdlet.Name); }
public void IgnoresAddingDuplicatedEnvironment() { Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", ServiceEndpoint = "endpoint.net", ManagementPortalUrl = "management portal url", StorageEndpoint = "endpoint.net" }; cmdlet.ExecuteCmdlet(); int count = WindowsAzureProfile.Instance.Environments.Count; // Add again cmdlet.Name = "kAtAl"; Testing.AssertThrows <Exception>(() => cmdlet.ExecuteCmdlet()); }
public void IgnoresAddingPublicEnvironment() { Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = EnvironmentName.AzureCloud, PublishSettingsFileUrl = "http://microsoft.com" }; Testing.AssertThrows <Exception>(() => cmdlet.ExecuteCmdlet()); }
public void IgnoresAddingDuplicatedEnvironment() { Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", ServiceEndpoint = "endpoint.net", ManagementPortalUrl = "management portal url", StorageEndpoint = "endpoint.net" }; cmdlet.InvokeBeginProcessing(); cmdlet.ExecuteCmdlet(); cmdlet.InvokeEndProcessing(); ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile))); int count = client.Profile.Environments.Count; // Add again cmdlet.Name = "kAtAl"; Testing.AssertThrows <Exception>(() => cmdlet.ExecuteCmdlet()); }
public void AddsEnvironmentWithMinimumInformation() { Mock<ICommandRuntime> commandRuntimeMock = new Mock<ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com" }; cmdlet.ExecuteCmdlet(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny<WindowsAzureEnvironment>()), Times.Once()); WindowsAzureEnvironment env = WindowsAzureProfile.Instance.Environments["KaTaL"]; Assert.AreEqual(env.Name, cmdlet.Name); Assert.AreEqual(env.PublishSettingsFileUrl, cmdlet.PublishSettingsFileUrl); }
public void AddsEnvironmentWithMinimumInformation() { Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com" }; cmdlet.ExecuteCmdlet(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny <WindowsAzureEnvironment>()), Times.Once()); WindowsAzureEnvironment env = WindowsAzureProfile.Instance.Environments["KaTaL"]; Assert.AreEqual(env.Name, cmdlet.Name); Assert.AreEqual(env.PublishSettingsFileUrl, cmdlet.PublishSettingsFileUrl); }
public void AddsEnvironmentWithMinimumInformation() { Mock <ICommandRuntime> commandRuntimeMock = new Mock <ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com" }; cmdlet.InvokeBeginProcessing(); cmdlet.ExecuteCmdlet(); cmdlet.InvokeEndProcessing(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny <PSObject>()), Times.Once()); ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile))); AzureEnvironment env = client.Profile.Environments["KaTaL"]; Assert.Equal(env.Name, cmdlet.Name); Assert.Equal(env.Endpoints[AzureEnvironment.Endpoint.PublishSettingsFileUrl], cmdlet.PublishSettingsFileUrl); }
public void IgnoresAddingDuplicatedEnvironment() { Mock<ICommandRuntime> commandRuntimeMock = new Mock<ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", ServiceEndpoint = "endpoint.net", ManagementPortalUrl = "management portal url", StorageEndpoint = "endpoint.net" }; cmdlet.ExecuteCmdlet(); int count = WindowsAzureProfile.Instance.Environments.Count; // Add again cmdlet.Name = "kAtAl"; Testing.AssertThrows<Exception>(() => cmdlet.ExecuteCmdlet()); }
public void IgnoresAddingPublicEnvironment() { Mock<ICommandRuntime> commandRuntimeMock = new Mock<ICommandRuntime>(); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = EnvironmentName.AzureCloud, PublishSettingsFileUrl = "http://microsoft.com" }; Testing.AssertThrows<Exception>(() => cmdlet.ExecuteCmdlet()); }
public void AddsEnvironmentWithEmptyStorageEndpoint() { Mock<ICommandRuntime> commandRuntimeMock = new Mock<ICommandRuntime>(); WindowsAzureEnvironment actual = null; commandRuntimeMock.Setup(f => f.WriteObject(It.IsAny<object>())) .Callback((object output) => actual = (WindowsAzureEnvironment)output); AddAzureEnvironmentCommand cmdlet = new AddAzureEnvironmentCommand() { CommandRuntime = commandRuntimeMock.Object, Name = "Katal", PublishSettingsFileUrl = "http://microsoft.com", StorageEndpoint = null }; cmdlet.ExecuteCmdlet(); commandRuntimeMock.Verify(f => f.WriteObject(It.IsAny<WindowsAzureEnvironment>()), Times.Once()); WindowsAzureEnvironment env = WindowsAzureProfile.Instance.Environments["KaTaL"]; Assert.AreEqual(env.Name, cmdlet.Name); Assert.AreEqual(env.PublishSettingsFileUrl, actual.PublishSettingsFileUrl); Assert.IsTrue(string.IsNullOrEmpty(actual.StorageBlobEndpointFormat)); Assert.IsTrue(string.IsNullOrEmpty(actual.StorageQueueEndpointFormat)); Assert.IsTrue(string.IsNullOrEmpty(actual.StorageTableEndpointFormat)); }