public void EnableRemoteDesktopBasicParameterValidation()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                files.CreateAzureSdkDirectoryAndImportPublishSettings();
                files.CreateNewService("NEW_SERVICE");

                Testing.AssertThrows <ArgumentException>(
                    () => EnableRemoteDesktop(null, null));
                Testing.AssertThrows <ArgumentException>(
                    () => EnableRemoteDesktop(string.Empty, string.Empty));
                Testing.AssertThrows <ArgumentException>(
                    () => EnableRemoteDesktop("user", null));
                Testing.AssertThrows <ArgumentException>(
                    () => EnableRemoteDesktop("user", string.Empty));
                Testing.AssertThrows <ArgumentException>(
                    () => EnableRemoteDesktop("user", "short"));
                Testing.AssertThrows <ArgumentException>(
                    () => EnableRemoteDesktop("user", "onlylower"));
                Testing.AssertThrows <ArgumentException>(
                    () => EnableRemoteDesktop("user", "ONLYUPPER"));
                Testing.AssertThrows <ArgumentException>(
                    () => EnableRemoteDesktop("user", "1234567890"));
            }
        }
        public void RemoveTrafficManagerEndpointNonExistingFails()
        {
            // Setup
            ProfileWithDefinition original = GetProfileWithDefinition();

            var existingEndpoint = new TrafficManagerEndpoint
            {
                DomainName = DomainName,
                Type       = EndpointType.Any,
                Status     = EndpointStatus.Enabled
            };

            original.Endpoints.Add(existingEndpoint);

            // Assert the endpoint exists
            Assert.IsTrue(original.Endpoints.Any(e => e.DomainName == DomainName));

            cmdlet = new RemoveAzureTrafficManagerEndpoint
            {
                DomainName            = DomainName,
                TrafficManagerProfile = original,
                CommandRuntime        = mockCommandRuntime
            };

            // Action + Assert
            Testing.AssertThrows <Exception>(() => cmdlet.ExecuteCmdlet());
        }
Esempio n. 3
0
        public void NewAzureSBNamespaceWithInternalServerError()
        {
            // Setup
            SimpleServiceBusManagement channel            = new SimpleServiceBusManagement();
            MockCommandRuntime         mockCommandRuntime = new MockCommandRuntime();
            string name     = "test";
            string location = "West US";
            NewAzureSBNamespaceCommand cmdlet = new NewAzureSBNamespaceCommand(channel)
            {
                Name = name, Location = location, CommandRuntime = mockCommandRuntime
            };

            channel.CreateServiceBusNamespaceThunk = csbns => { throw new Exception(Resources.InternalServerErrorMessage); };
            channel.ListServiceBusRegionsThunk     = lsbr =>
            {
                List <ServiceBusRegion> list = new List <ServiceBusRegion>();
                list.Add(new ServiceBusRegion {
                    Code = location
                });
                return(list);
            };
            string expected = Resources.NewNamespaceErrorMessage;

            Testing.AssertThrows <Exception>(() => cmdlet.ExecuteCmdlet(), expected);
        }
        public void AddTrafficManagerEndpointAlreadyExistsFails()
        {
            // Setup
            ProfileWithDefinition original = GetProfileWithDefinition();

            var existingEndpoint = new TrafficManagerEndpoint
            {
                DomainName = DomainName,
                Type       = EndpointType.Any,
                Status     = EndpointStatus.Enabled
            };

            original.Endpoints.Add(existingEndpoint);

            cmdlet = new AddAzureTrafficManagerEndpoint
            {
                DomainName            = DomainName,
                Type                  = AnyType,
                TrafficManagerProfile = original,
                CommandRuntime        = mockCommandRuntime
            };

            // Action + Assert
            Testing.AssertThrows <Exception>(() => cmdlet.ExecuteCmdlet());
        }
 public void AzureServiceCreateNewEmptyServiceNameFail()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         Testing.AssertThrows <ArgumentException>(() => new AzureService(files.RootPath, string.Empty, null), string.Format(Resources.InvalidOrEmptyArgumentMessage, "Name"));
     }
 }
 public void AzureServiceAddNewPHPWorkerRoleWithWhiteCharFail()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         Testing.AssertThrows <ArgumentException>(() => new AzureService(files.RootPath, serviceName, null).AddWebRole(Resources.PHPScaffolding, "\tRole"), string.Format(Resources.InvalidRoleNameMessage, "\tRole"));
     }
 }
Esempio n. 7
0
 public void AzureServiceAddNewNodeWorkerRoleWithWhiteCharFail()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         Testing.AssertThrows <ArgumentException>(() => new CloudServiceProject(files.RootPath, serviceName, null).AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath, "\tRole"), string.Format(Resources.InvalidRoleNameMessage, "\tRole"));
     }
 }
Esempio n. 8
0
        public void EnableAzureMemcacheWithNoCacheWorkerRolesFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string serviceName     = "AzureService";
                string rootPath        = files.CreateNewService(serviceName);
                string webRoleName     = "WebRole";
                string expectedMessage = string.Format(Resources.NoCacheWorkerRoles);

                addNodeWebCmdlet = new AddAzureNodeWebRoleCommand()
                {
                    RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = webRoleName
                };
                addNodeWebCmdlet.ExecuteCmdlet();
                addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand()
                {
                    RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole"
                };
                addNodeWorkerCmdlet.ExecuteCmdlet();
                mockCommandRuntime.ResetPipelines();
                enableCacheCmdlet.PassThru            = true;
                enableCacheCmdlet.CacheRuntimeVersion = "2.5.0";

                Testing.AssertThrows <Exception>(() => enableCacheCmdlet.EnableAzureMemcacheRoleProcess(webRoleName, null, rootPath), expectedMessage);
            }
        }
        public void ThrowsErrorForInvalidCacheVersion()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                files.CreateAzureSdkDirectoryAndImportPublishSettings();
                files.CreateNewService("NEW_SERVICE");
                string rootPath      = Path.Combine(files.RootPath, "NEW_SERVICE");
                string packagePath   = Path.Combine(rootPath, Resources.CloudPackageFileName);
                string cacheRoleName = "WorkerRole1";
                AddAzureCacheWorkerRoleCommand addCacheWorkerCmdlet = new AddAzureCacheWorkerRoleCommand()
                {
                    CommandRuntime = mockCommandRuntime
                };
                EnableAzureMemcacheRoleCommand enableCacheCmdlet = new EnableAzureMemcacheRoleCommand()
                {
                    CacheRuntimeVersion = "1.8.0",
                    CommandRuntime      = mockCommandRuntime
                };

                CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services"));
                service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath);
                addCacheWorkerCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath);
                enableCacheCmdlet.EnableAzureMemcacheRoleProcess("WebRole1", cacheRoleName, rootPath);

                Testing.AssertThrows <Exception>(
                    () => cmdlet.ExecuteCmdlet(),
                    string.Format(Resources.CacheMismatchMessage, "WebRole1", "2.5.0"));
            }
        }
Esempio n. 10
0
 public void AzureServiceCreateNewInvalidParentDirectoryFail()
 {
     foreach (string invalidName in Data.InvalidFileName)
     {
         Testing.AssertThrows <ArgumentException>(() => new AzureService(string.Empty, serviceName, null), string.Format(Resources.InvalidOrEmptyArgumentMessage, "service parent directory"));
     }
 }
Esempio n. 11
0
 public void AzureServiceCreateNewExistingServiceFail()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         new AzureService(files.RootPath, serviceName, null);
         Testing.AssertThrows <ArgumentException>(() => new AzureService(files.RootPath, serviceName, null), string.Format(Resources.ServiceAlreadyExistsOnDisk, serviceName, Path.Combine(files.RootPath, serviceName)));
     }
 }
Esempio n. 12
0
 public void SetAzureVMSizeProcessTestsEmptyRoleNameFail()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
         Testing.AssertThrows <ArgumentException>(() => service.SetRoleVMSize(service.Paths, string.Empty, RoleSize.Large.ToString()), string.Format(Resources.InvalidOrEmptyArgumentMessage, Resources.RoleName));
     }
 }
        public void TestDeploymentSettingsTestNullConfigPathFail()
        {
            string label           = "MyLabel";
            string deploymentName  = service.ServiceName;
            string expectedMessage = string.Format(Resources.InvalidOrEmptyArgumentMessage, Resources.ServiceConfiguration);

            Testing.AssertThrows <ArgumentException>(() => new DeploymentSettings(settings, packagePath, null, label, deploymentName), expectedMessage);
        }
 public void SetAzureInstancesProcessTestsNullRoleNameFail()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
         Testing.AssertThrows <ArgumentException>(() => service.SetRoleInstances(service.Paths, null, 10), string.Format(Resources.InvalidOrEmptyArgumentMessage, Resources.RoleName));
     }
 }
Esempio n. 15
0
 public void AzureServiceAddExistingNodeRoleFail()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
         service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath, "WebRole");
         Testing.AssertThrows <ArgumentException>(() => service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath, "WebRole"), string.Format(Resources.AddRoleMessageRoleExists, "WebRole"));
     }
 }
Esempio n. 16
0
 public void AzureServiceAddExistingPHPRoleFail()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         AzureService service = new AzureService(files.RootPath, serviceName, null);
         service.AddWebRole(Data.PHPWebRoleScaffoldingPath, "WebRole");
         Testing.AssertThrows <ArgumentException>(() => service.AddWebRole(Data.PHPWebRoleScaffoldingPath, "WebRole"), string.Format(Resources.AddRoleMessageRoleExists, "WebRole"));
     }
 }
        public void TestDeploymentSettingsTestDoesNotPackagePathFail()
        {
            string label           = "MyLabel";
            string deploymentName  = service.ServiceName;
            string doesNotExistDir = Path.Combine(Directory.GetCurrentDirectory(), "qewindw443298.txt");
            string expectedMessage = string.Format(Resources.PathDoesNotExistForElement, Resources.Package, doesNotExistDir);

            Testing.AssertThrows <FileNotFoundException>(() => new DeploymentSettings(settings, doesNotExistDir, configPath, label, deploymentName), expectedMessage);
        }
Esempio n. 18
0
        public void SetAzureServiceProjectRoleInServiecRootDirectoryFail()
        {
            string       serviceName = "AzureService3";
            AzureService service     = new AzureService(Directory.GetCurrentDirectory(), serviceName, null);

            service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
            cmdlet.RoleName = string.Empty;
            Testing.AssertThrows <InvalidOperationException>(() => cmdlet.ExecuteCmdlet(), Resources.CannotFindServiceRoot);
        }
Esempio n. 19
0
        public void SetAzureVMSizeProcessNegativeRoleInstanceFail()
        {
            string roleName = "WebRole1";

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                AzureService service = new AzureService(files.RootPath, serviceName, null);
                Testing.AssertThrows <ArgumentException>(() => service.SetRoleVMSize(service.Paths, roleName, string.Empty), string.Format(Resources.InvalidVMSize, roleName));
            }
        }
Esempio n. 20
0
 public void AzureServiceCreateNewInvalidServiceNameFail()
 {
     foreach (string invalidFileName in Data.InvalidFileName)
     {
         using (FileSystemHelper files = new FileSystemHelper(this))
         {
             Testing.AssertThrows <ArgumentException>(() => new AzureService(files.RootPath, invalidFileName, null), string.Format(Resources.InvalidFileName, "Name"));
         }
     }
 }
Esempio n. 21
0
        public void SetAzureVMSizeProcessTestsLargeRoleInstanceFail()
        {
            string roleName = "WebRole1";

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
                Testing.AssertThrows <ArgumentException>(() => service.SetRoleVMSize(service.Paths, roleName, "Gigantic"), string.Format(Resources.InvalidVMSize, roleName));
            }
        }
 public void EnableRemoteDesktopForEmptyService()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         files.CreateAzureSdkDirectoryAndImportPublishSettings();
         files.CreateNewService("NEW_SERVICE");
         Testing.AssertThrows <InvalidOperationException>(() =>
                                                          EnableRemoteDesktop("user", "GoodPassword!"));
     }
 }
 public void GlobalComponentsLoadInvalidPublishSettingsSchemaFail()
 {
     Testing.AssertThrows <FileNotFoundException>(
         () => GlobalComponents.Load("DoesNotExistDirectory"),
         ex =>
     {
         Assert.AreEqual <string>(ex.Message, Resources.GlobalComponents_Load_PublishSettingsNotFound);
         Assert.IsFalse(Directory.Exists(Data.AzureAppDir));
     });
 }
        public void SetAzureInstancesProcessTestsRoleNameDoesNotExistFail()
        {
            string roleName = "WebRole1";

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
                Testing.AssertThrows <ArgumentException>(() => service.SetRoleInstances(service.Paths, roleName, 10), string.Format(Resources.RoleNotFoundMessage, roleName));
            }
        }
Esempio n. 25
0
        public void SetAzureVMSizeProcessTestsRoleNameDoesNotExistFail()
        {
            string roleName = "WebRole1";

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                AzureService service = new AzureService(files.RootPath, serviceName, null);
                Testing.AssertThrows <ArgumentException>(() => service.SetRoleVMSize(service.Paths, roleName, RoleSize.Medium.ToString()), string.Format(Resources.RoleNotFoundMessage, roleName));
            }
        }
        public void SetAzureInstancesProcessNegativeRoleInstanceFail()
        {
            string roleName = "WebRole1";

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
                Testing.AssertThrows <ArgumentException>(() => service.SetRoleInstances(service.Paths, roleName, -1), string.Format(Resources.InvalidInstancesCount, roleName));
            }
        }
Esempio n. 27
0
        public void ProcessGetWebsiteWithNullSubscription()
        {
            // Setup
            GlobalSettingsManager globalSettingsManager = GlobalSettingsManager.CreateFromPublishSettings(
                GlobalPathInfo.GlobalSettingsDirectory,
                null,
                Data.ValidPublishSettings[0]);
            RemoveAzureSubscriptionCommand removeCmdlet = new RemoveAzureSubscriptionCommand();

            removeCmdlet.CommandRuntime = new MockCommandRuntime();
            ICollection <string> subscriptions = globalSettingsManager.Subscriptions.Keys;

            foreach (string subscription in subscriptions)
            {
                removeCmdlet.RemoveSubscriptionProcess(subscription, null);
            }

            SimpleWebsitesManagement channel = new SimpleWebsitesManagement();

            channel.GetWebSpacesThunk = ar => new WebSpaces(new List <WebSpace> {
                new WebSpace {
                    Name = "webspace1"
                }, new WebSpace {
                    Name = "webspace2"
                }
            });
            channel.GetSitesThunk = ar =>
            {
                if (ar.Values["webspaceName"].Equals("webspace1"))
                {
                    return(new Sites(new List <Site> {
                        new Site {
                            Name = "website1", WebSpace = "webspace1"
                        }
                    }));
                }

                return(new Sites(new List <Site> {
                    new Site {
                        Name = "website2", WebSpace = "webspace2"
                    }
                }));
            };

            // Test
            GetAzureWebsiteCommand getAzureWebsiteCommand = new GetAzureWebsiteCommand(channel)
            {
                ShareChannel        = true,
                CommandRuntime      = new MockCommandRuntime(),
                CurrentSubscription = null
            };

            Testing.AssertThrows <Exception>(() => getAzureWebsiteCommand.ExecuteCmdlet(), Resources.NoDefaultSubscriptionMessage);
        }
Esempio n. 28
0
        public void ImportingFromDirectoryWithNoFilesThrows()
        {
            var testDir = new TestDirBuilder("testdir3");

            using (testDir.Pushd())
            {
                Testing.AssertThrows <Exception>(
                    () => cmdlet.ExecuteCmdlet(),
                    string.Format(Resources.NoPublishSettingsFilesFoundMessage, Directory.GetCurrentDirectory()));
            }
        }
 public void NewAzureServiceWithInvalidNames()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         foreach (string name in Data.InvalidServiceNames)
         {
             cmdlet.ServiceName = name;
             Testing.AssertThrows <ArgumentException>(() => cmdlet.ExecuteCmdlet());
         }
     }
 }
        public void SetAzureInstancesProcessTestsPHPRoleNameDoesNotExistServiceContainsWorkerRoleFail()
        {
            string roleName        = "WorkerRole1";
            string invalidRoleName = "foo";

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
                service.AddWorkerRole(Test.Utilities.Common.Data.PHPWorkerRoleScaffoldingPath, roleName, 1);
                Testing.AssertThrows <ArgumentException>(() => service.SetRoleInstances(service.Paths, invalidRoleName, 10), string.Format(Resources.RoleNotFoundMessage, invalidRoleName));
            }
        }