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 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()));
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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()
        {
            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");
        }
Exemple #6
0
        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 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.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());
        }