public void TestUpgradeCloudService() { clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny <HostedServiceCreateParameters>(), It.IsAny <CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); clientMocks.ComputeManagementClientMock.Setup( c => c.Deployments.UpgradeBySlotAsync(It.IsAny <string>(), DeploymentSlot.Production, It.IsAny <DeploymentUpgradeParameters>(), It.IsAny <CancellationToken>())) .Returns(Tasks.FromResult(CreateComputeOperationResponse("req002"))); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); var cloudServiceProject = new CloudServiceProject(rootPath, null); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US")); clientMocks.ComputeManagementClientMock.Verify(c => c.Deployments.UpgradeBySlotAsync(serviceName, DeploymentSlot.Production, It.IsAny <DeploymentUpgradeParameters>(), It.IsAny <CancellationToken>()), Times.Once); } }
public void TestPublishWithCurrentStorageAccount() { RemoveDeployments(); clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny <HostedServiceCreateParameters>(), It.IsAny <CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); var cloudServiceProject = new CloudServiceProject(rootPath, null); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); subscription.CurrentStorageAccountName = storageName; ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US")); cloudBlobUtilityMock.Verify(f => f.UploadPackageToBlob( clientMocks.StorageManagementClientMock.Object, subscription.CurrentStorageAccountName, It.IsAny <string>(), It.IsAny <BlobRequestOptions>()), Times.Once()); } }
public void EnableRemoteDesktopForWebAndWorkerRoles() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole", Instances = 1 }; addNodeWorkerCmdlet.ExecuteCmdlet(); mockCommandRuntime.ResetPipelines(); EnableRemoteDesktop("user", "GoodPassword!"); // Verify the roles have been setup with forwarding, access, // and certs CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath(@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Services")); VerifyWebRole(service.Components.Definition.WebRole[0], false); VerifyWorkerRole(service.Components.Definition.WorkerRole[0], true); VerifyRoleSettings(service); Assert.Equal <int>(0, mockCommandRuntime.OutputPipeline.Count); } }
public void EnableDisableEnableRemoteDesktopForWebAndWorkerRoles() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole" }; addNodeWorkerCmdlet.ExecuteCmdlet(); EnableAzureRemoteDesktopCommandTest.EnableRemoteDesktop("user", "GoodPassword!"); disableRDCmdlet.DisableRemoteDesktop(); EnableAzureRemoteDesktopCommandTest.EnableRemoteDesktop("user", "GoodPassword!"); // Verify the roles have been setup with forwarding, access, // and certs CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); EnableAzureRemoteDesktopCommandTest.VerifyWebRole(service.Components.Definition.WebRole[0], false); EnableAzureRemoteDesktopCommandTest.VerifyWorkerRole(service.Components.Definition.WorkerRole[0], true); EnableAzureRemoteDesktopCommandTest.VerifyRoleSettings(service); } }
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 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")); } }
public void SetDeploymentStatusProcessTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Running; string currentStatus = DeploymentStatus.Suspended; bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => new Deployment(serviceName, slot, currentStatus); using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var startAzureService = new StartAzureService(channel) { ShareChannel = true }; startAzureService.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); Assert.IsTrue(statusUpdated); } }
public void TestCreateStorageServiceWithPublish() { RemoveDeployments(); clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny <HostedServiceCreateParameters>(), It.IsAny <CancellationToken>())) .Returns(Tasks.FromResult(new AzureOperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); storageService.Clear(); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath(@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Services")); cloudServiceProject.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US")); clientMocks.StorageManagementClientMock.Verify(c => c.StorageAccounts.CreateAsync(It.IsAny <StorageAccountCreateParameters>(), It.IsAny <CancellationToken>()), Times.Once); } }
public void SetDeploymentStatusProcessDeploymentDoesNotExistTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Running; string resultMessage; string expectedMessage = string.Format(Resources.ServiceSlotDoesNotExist, slot, serviceName); bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment{Name = serviceName, DeploymentSlot = slot, Status = newStatus}; }; channel.GetDeploymentBySlotThunk = ar => { throw new ServiceManagementClientException(HttpStatusCode.NotFound, new ServiceManagementError(), string.Empty); }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var deploymentManager = new DeploymentStatusManager(channel); deploymentManager.ShareChannel = true; deploymentManager.CommandRuntime = new MockCommandRuntime(); deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName); resultMessage = ((MockCommandRuntime)deploymentManager.CommandRuntime).WarningStream[0]; Assert.IsFalse(statusUpdated); Assert.IsTrue(resultMessage.Contains(expectedMessage)); Assert.IsTrue(((MockCommandRuntime)deploymentManager.CommandRuntime).OutputPipeline.Count.Equals(0)); } }
public void SetDeploymentStatusProcessDeploymentDoesNotExistTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Running; string resultMessage; string expectedMessage = string.Format(Resources.ServiceSlotDoesNotExist, serviceName, slot); bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => { throw new EndpointNotFoundException(); }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); resultMessage = new DeploymentStatusManager(channel).SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); Assert.IsFalse(statusUpdated); Assert.AreEqual <string>(expectedMessage, resultMessage); } }
public void RemoveAzureServiceProcessTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); bool serviceDeleted = false; bool deploymentDeleted = false; channel.GetDeploymentBySlotThunk = ar => { if (deploymentDeleted) throw new EndpointNotFoundException(); return new Deployment(serviceName, ArgumentConstants.Slots[Slot.Production], DeploymentStatus.Suspended); }; channel.DeleteHostedServiceThunk = ar => serviceDeleted = true; channel.DeleteDeploymentBySlotThunk = ar => { deploymentDeleted = true; }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); new RemoveAzureServiceCommand(channel).RemoveAzureServiceProcess(service.Paths.RootPath, string.Empty); Assert.IsTrue(deploymentDeleted); Assert.IsTrue(serviceDeleted); } }
public void SetDeploymentStatusProcessDeploymentDoesNotExistTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Running; string resultMessage; string expectedMessage = string.Format(Resources.ServiceSlotDoesNotExist, serviceName, slot); bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => { throw new EndpointNotFoundException(); }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var deploymentManager = new DeploymentStatusManager(channel); deploymentManager.ShareChannel = true; resultMessage = deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); Assert.IsFalse(statusUpdated); Assert.AreEqual<string>(expectedMessage, resultMessage); } }
public void SetDeploymentStatusProcessSetStatusToActualStatusTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Suspended; string currentStatus = DeploymentStatus.Suspended; string resultMessage; string expectedMessage = string.Format(Resources.DeploymentAlreadyInState, slot, serviceName, currentStatus); bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => new Deployment(serviceName, slot, currentStatus); using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); resultMessage = new DeploymentStatusManager(channel).SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); Assert.IsFalse(statusUpdated); Assert.AreEqual <string>(expectedMessage, resultMessage); } }
public void RemoveAzureServiceProcessTest() { bool serviceDeleted = false; bool deploymentDeleted = false; channel.GetDeploymentBySlotThunk = ar => { if (deploymentDeleted) throw new EndpointNotFoundException(); return new Deployment(serviceName, ArgumentConstants.Slots[Slot.Production], DeploymentStatus.Suspended); }; channel.DeleteHostedServiceThunk = ar => serviceDeleted = true; channel.DeleteDeploymentBySlotThunk = ar => { deploymentDeleted = true; }; channel.IsDNSAvailableThunk = ida => new AvailabilityResponse { Result = false }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); removeServiceCmdlet.PassThru = true; removeServiceCmdlet.RemoveAzureServiceProcess(service.Paths.RootPath, string.Empty, serviceName); Assert.IsTrue(deploymentDeleted); Assert.IsTrue(serviceDeleted); Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[0]); } }
public void DisableRemoteDesktopForEmptyService() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); disableRDCmdlet.DisableRemoteDesktop(); } }
public void DisableRemoteDesktopForEmptyService() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); disableRDCmdlet.DisableRemoteDesktop(); } }
public void PublishAzureServiceCreateBasicPackageTest() { // Create a temp directory that we'll use to "publish" our service using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Import our default publish settings files.CreateAzureSdkDirectoryAndImportPublishSettings(); // Create a new channel to mock the calls to Azure and // determine all of the results that we'll need. SimpleServiceManagement channel = new SimpleServiceManagement(); // Create a new service that we're going to publish string serviceName = "TEST_SERVICE_NAME"; NewAzureServiceCommand newService = new NewAzureServiceCommand(); newService.NewAzureServiceProcess(files.RootPath, serviceName); string servicePath = files.CreateDirectory(serviceName); // Get the publishing process started by creating the package PublishAzureServiceCommand publishService = new PublishAzureServiceCommand(channel); publishService.InitializeSettingsAndCreatePackage(servicePath); // Verify the generated files files.AssertFiles(new Dictionary <string, Action <string> >() { { serviceName + @"\deploymentSettings.json", null }, { serviceName + @"\ServiceDefinition.csdef", p => File.ReadAllText(p).Contains(serviceName) }, { serviceName + @"\ServiceConfiguration.Cloud.cscfg", p => File.ReadAllText(p).Contains(serviceName) }, { serviceName + @"\ServiceConfiguration.Local.cscfg", p => File.ReadAllText(p).Contains(serviceName) }, { serviceName + @"\cloud_package.cspkg", p => { using (Package package = Package.Open(p)) { Assert.AreEqual(5, package.GetParts().Count()); } } } }); } }
public void EnableRemoteDesktopForEmptyService() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); Testing.AssertThrows <InvalidOperationException>(() => EnableRemoteDesktop("user", "GoodPassword!")); } }
public void DisableRemoteDesktopForWebRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string root = files.CreateNewService("NEW_SERVICE"); new AddAzureNodeWebRoleCommand().AddAzureNodeWebRoleProcess("WebRole", 1, root); new DisableAzureServiceProjectRemoteDesktopCommand().DisableRemoteDesktop(); } }
public void TestUpgradeCloudServiceFromAPackage() { clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny <HostedServiceCreateParameters>(), It.IsAny <CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); clientMocks.ComputeManagementClientMock.Setup( c => c.Deployments.UpgradeBySlotAsync(It.IsAny <string>(), DeploymentSlot.Production, It.IsAny <DeploymentUpgradeParameters>(), It.IsAny <CancellationToken>())) .Returns(Tasks.FromResult(CreateComputeOperationResponse("req002"))); clientMocks.ManagementClientMock.Setup(c => c.Locations.ListAsync(It.IsAny <CancellationToken>())) .Returns(Tasks.FromResult(new LocationsListResponse { Locations = { new LocationsListResponse.Location { DisplayName = "East US", Name = "EastUS" } } })); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string packageName = serviceName; string package, configuration; files.CreateDirectoryWithPrebuiltPackage(packageName, out package, out configuration); files.CreateAzureSdkDirectoryAndImportPublishSettings(); // Execute ExecuteInTempCurrentDirectory(Path.GetDirectoryName(package), () => client.PublishCloudService(package, configuration, null, null, null, null, null, false, false)); // Verify clientMocks.ComputeManagementClientMock.Verify(c => c.Deployments.UpgradeBySlotAsync(serviceName, DeploymentSlot.Production, It.IsAny <DeploymentUpgradeParameters>(), It.IsAny <CancellationToken>()), Times.Once); } }
public void GetDefaultLocationWithUnknwonLocation() { // Create a temp directory that we'll use to "publish" our service using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Import our default publish settings files.CreateAzureSdkDirectoryAndImportPublishSettings(); string serviceName = null; string unknownLocation = "Unknown Location"; ServiceSettings settings = ServiceSettings.LoadDefault(null, null, unknownLocation, null, null, null, "My-Custom-Service!", null, out serviceName); Assert.AreEqual<string>(unknownLocation.ToLower(), settings.Location.ToLower()); } }
public void GetDefaultLocationWithWithRandomLocation() { // Create a temp directory that we'll use to "publish" our service using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Import our default publish settings files.CreateAzureSdkDirectoryAndImportPublishSettings(); string serviceName = null; ServiceSettings settings = ServiceSettings.LoadDefault(null, null, null, null, null, null, "My-Custom-Service!", null, out serviceName); Assert.IsTrue(settings.Location.Equals(ArgumentConstants.Locations[Location.WestUS]) || settings.Location.Equals(ArgumentConstants.Locations[Location.EastUS])); } }
public void InvalidStorageAccountName() { // Create a temp directory that we'll use to "publish" our service using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Import our default publish settings files.CreateAzureSdkDirectoryAndImportPublishSettings(); string serviceName = null; Testing.AssertThrows<ArgumentException>(() => ServiceSettings.LoadDefault(null, null, null, null, "I HAVE INVALID CHARACTERS !@#$%", null, null, out serviceName)); Testing.AssertThrows<ArgumentException>(() => ServiceSettings.LoadDefault(null, null, null, null, "ihavevalidcharsbutimjustwaytooooooooooooooooooooooooooooooooooooooooolong", null, null, out serviceName)); } }
public void TestStopAzureService() { stopServiceCmdlet.ServiceName = serviceName; stopServiceCmdlet.Slot = slot; cloudServiceClientMock.Setup(f => f.StopCloudService(serviceName, slot)); using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null); stopServiceCmdlet.ExecuteCmdlet(); Assert.Equal <int>(0, mockCommandRuntime.OutputPipeline.Count); cloudServiceClientMock.Verify(f => f.StopCloudService(serviceName, slot), Times.Once()); } }
public void TestStartAzureService() { stopServiceCmdlet.ServiceName = serviceName; stopServiceCmdlet.Slot = slot; cloudServiceClientMock.Setup(f => f.StartCloudService(serviceName, slot)); using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null); stopServiceCmdlet.ExecuteCmdlet(); Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count); cloudServiceClientMock.Verify(f => f.StartCloudService(serviceName, slot), Times.Once()); } }
public void SanitizeServiceNameForStorageAccountName() { // Create a temp directory that we'll use to "publish" our service using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Import our default publish settings files.CreateAzureSdkDirectoryAndImportPublishSettings(); string serviceName = null; ServiceSettings settings = ServiceSettings.LoadDefault(null, null, null, null, null, "My-Custom-Service!", null, out serviceName); Assert.AreEqual("myx2dcustomx2dservicex21", settings.StorageAccountName); settings = ServiceSettings.LoadDefault(null, null, null, null, null, "MyCustomServiceIsWayTooooooooooooooooooooooooLong", null, out serviceName); Assert.AreEqual("mycustomserviceiswaytooo", settings.StorageAccountName); } }
public void TestCreatePackageWithEmptyServiceSuccessfull() { 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); cmdlet.ExecuteCmdlet(); PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject; Assert.AreEqual<string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]); Assert.AreEqual<string>(packagePath, obj.GetVariableValue<string>(Parameters.PackagePath)); Assert.IsTrue(File.Exists(packagePath)); } }
public void EnableRemoteDesktopUnicodeAndShortPasswordFails() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); Testing.AssertThrows <ArgumentException>(() => EnableRemoteDesktop("㯑䲘䄂㮉", "㯑䲘")); } }
public void EnableRemoteDesktopForMultipleWebAndWorkerRolesTwice() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole_1", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole_2", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole_1", Instances = 1 }; addNodeWorkerCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole_2", Instances = 1 }; addNodeWorkerCmdlet.ExecuteCmdlet(); mockCommandRuntime.ResetPipelines(); enableRDCmdlet.PassThru = true; EnableRemoteDesktop("user", "GoodPassword!"); enableRDCmdlet.PassThru = false; EnableRemoteDesktop("other", "OtherPassword!"); // Verify the roles have been setup with forwarding, access, // and certs AzureService service = new AzureService(rootPath, null); VerifyWebRole(service.Components.Definition.WebRole[0], false); VerifyWebRole(service.Components.Definition.WebRole[0], false); VerifyWorkerRole(service.Components.Definition.WorkerRole[0], true); VerifyWorkerRole(service.Components.Definition.WorkerRole[1], false); VerifyRoleSettings(service); Assert.AreEqual <int>(1, mockCommandRuntime.OutputPipeline.Count); Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[0]); } }
public void TestCreatePackageWithEmptyServiceSuccessfull() { 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); cmdlet.ExecuteCmdlet(); PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject; Assert.Equal <string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]); Assert.Equal <string>(packagePath, obj.GetVariableValue <string>(Parameters.PackagePath)); Assert.True(File.Exists(packagePath)); } }
public void GetDefaultLocationWithUnknwonLocation() { // Create a temp directory that we'll use to "publish" our service using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Import our default publish settings files.CreateAzureSdkDirectoryAndImportPublishSettings(); string serviceName = null; string unknownLocation = "Unknown Location"; ServiceSettings settings = ServiceSettings.LoadDefault(null, null, unknownLocation, null, null, null, "My-Custom-Service!", null, out serviceName); Assert.AreEqual <string>(unknownLocation.ToLower(), settings.Location.ToLower()); } }
public void DisableRemoteDesktopForWebRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); disableRDCmdlet.PassThru = true; disableRDCmdlet.DisableRemoteDesktop(); Assert.True((bool)mockCommandRuntime.OutputPipeline[1]); } }
public void InvalidStorageAccountName() { // Create a temp directory that we'll use to "publish" our service using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Import our default publish settings files.CreateAzureSdkDirectoryAndImportPublishSettings(); string serviceName = null; Testing.AssertThrows <ArgumentException>(() => ServiceSettings.LoadDefault(null, null, null, null, null, "I HAVE INVALID CHARACTERS !@#$%", null, null, out serviceName)); Testing.AssertThrows <ArgumentException>(() => ServiceSettings.LoadDefault(null, null, null, null, null, "ihavevalidcharsbutimjustwaytooooooooooooooooooooooooooooooooooooooooolong", null, null, out serviceName)); } }
public void SanitizeServiceNameForStorageAccountName() { // Create a temp directory that we'll use to "publish" our service using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Import our default publish settings files.CreateAzureSdkDirectoryAndImportPublishSettings(); string serviceName = null; ServiceSettings settings = ServiceSettings.LoadDefault(null, null, null, null, null, null, "My-Custom-Service!", null, out serviceName); Assert.AreEqual("myx2dcustomx2dservicex21", settings.StorageServiceName); settings = ServiceSettings.LoadDefault(null, null, null, null, null, null, "MyCustomServiceIsWayTooooooooooooooooooooooooLong", null, out serviceName); Assert.AreEqual("mycustomserviceiswaytooo", settings.StorageServiceName); } }
public void DisableRemoteDesktopForWebAndWorkerRoles() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole" }; addNodeWorkerCmdlet.ExecuteCmdlet(); disableRDCmdlet.DisableRemoteDesktop(); } }
public void TestCreatePackageSuccessfull() { 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); CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath(@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Services")); service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath); cmdlet.ExecuteCmdlet(); PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject; Assert.Equal <string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]); Assert.Equal <string>(packagePath, obj.GetVariableValue <string>(Parameters.PackagePath)); Assert.True(File.Exists(packagePath)); } }
public void EnableRemoteDesktopForWebRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); EnableRemoteDesktop("user", "GoodPassword!"); // Verify the role has been setup with forwarding, access, // and certs AzureService service = new AzureService(rootPath, null); VerifyWebRole(service.Components.Definition.WebRole[0], true); VerifyRoleSettings(service); } }
public void SetupTest() { helper = new FileSystemHelper(this); helper.CreateAzureSdkDirectoryAndImportPublishSettings(); WebSpacesFile = Path.Combine(GlobalPathInfo.GlobalSettingsDirectory, string.Format("spaces.{0}.json", SubscriptionName)); SitesFile = Path.Combine(GlobalPathInfo.GlobalSettingsDirectory, string.Format("sites.{0}.json", SubscriptionName)); if (File.Exists(WebSpacesFile)) { File.Delete(WebSpacesFile); } if (File.Exists(SitesFile)) { File.Delete(SitesFile); } }
public void SetupTest() { helper = new FileSystemHelper(this); helper.CreateAzureSdkDirectoryAndImportPublishSettings(); WebSpacesFile = Path.Combine(GlobalPathInfo.GlobalSettingsDirectory, string.Format("spaces.{0}.json", SubscriptionName)); SitesFile = Path.Combine(GlobalPathInfo.GlobalSettingsDirectory, string.Format("sites.{0}.json", SubscriptionName)); if (File.Exists(WebSpacesFile)) { File.Delete(WebSpacesFile); } if (File.Exists(SitesFile)) { File.Delete(SitesFile); } }
public CacheTests() { helper = new FileSystemHelper(this); helper.CreateAzureSdkDirectoryAndImportPublishSettings(); WebSpacesFile = Path.Combine(AzurePowerShell.ProfileDirectory, string.Format("spaces.{0}.json", SubscriptionName)); SitesFile = Path.Combine(AzurePowerShell.ProfileDirectory, string.Format("sites.{0}.json", SubscriptionName)); if (File.Exists(WebSpacesFile)) { File.Delete(WebSpacesFile); } if (File.Exists(SitesFile)) { File.Delete(SitesFile); } }
public void TestPublishWithDefaultLocation() { RemoveDeployments(); clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny <HostedServiceCreateParameters>(), It.IsAny <CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); clientMocks.ManagementClientMock.Setup(c => c.Locations.ListAsync(It.IsAny <CancellationToken>())) .Returns(Tasks.FromResult(new LocationsListResponse { Locations = { new LocationsListResponse.Location { DisplayName = "East US", Name = "EastUS" } } })); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); cloudServiceProject.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService()); clientMocks.ManagementClientMock.Verify(c => c.Locations.ListAsync(It.IsAny <CancellationToken>()), Times.Once); } }
public void SetDeploymentStatusProcessTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Running; string currentStatus = DeploymentStatus.Suspended; bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => new Deployment(serviceName, slot, currentStatus); using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); string result = new StartAzureService(channel).SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); Assert.IsTrue(statusUpdated); } }
public void SetDeploymentStatusProcessTest() { string newStatus = DeploymentStatus.Suspended; string currentStatus = DeploymentStatus.Running; bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => new Deployment(serviceName, slot, currentStatus); channel.IsDNSAvailableThunk = ida => new AvailabilityResponse { Result = false }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); stopServiceCmdlet.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName); Assert.IsTrue(statusUpdated); } }
public void TestCreatePackageWithMultipleRolesSuccessfull() { 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); CloudServiceProject service = new CloudServiceProject(rootPath, null); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath); service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); cmdlet.ExecuteCmdlet(); PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject; Assert.AreEqual <string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]); Assert.AreEqual <string>(packagePath, obj.GetVariableValue <string>(Parameters.PackagePath)); Assert.IsTrue(File.Exists(packagePath)); } }
public void EnableRemoteDesktopUnicode() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); EnableRemoteDesktop("㯑䲘䄂㮉", "㯑䲘䄂㮉㮉㮉㮉L"); // Verify the role has been setup with forwarding, access, // and certs CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); VerifyWebRole(service.Components.Definition.WebRole[0], true); VerifyRoleSettings(service); } }
public void EnableRemoteDesktopForMultipleWebAndWorkerRolesTwice() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole_1", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole_2", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole_1", Instances = 1 }; addNodeWorkerCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole_2", Instances = 1 }; addNodeWorkerCmdlet.ExecuteCmdlet(); mockCommandRuntime.ResetPipelines(); enableRDCmdlet.PassThru = true; EnableRemoteDesktop("user", "GoodPassword!"); enableRDCmdlet.PassThru = false; EnableRemoteDesktop("other", "OtherPassword!"); // Verify the roles have been setup with forwarding, access, // and certs CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); VerifyWebRole(service.Components.Definition.WebRole[0], false); VerifyWebRole(service.Components.Definition.WebRole[0], false); VerifyWorkerRole(service.Components.Definition.WorkerRole[0], true); VerifyWorkerRole(service.Components.Definition.WorkerRole[1], false); VerifyRoleSettings(service); Assert.AreEqual<int>(1, mockCommandRuntime.OutputPipeline.Count); Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[0]); } }
public void EnableRemoteDesktopUnicode() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); EnableRemoteDesktop("㯑䲘䄂㮉", "㯑䲘䄂㮉㮉㮉㮉L"); // Verify the role has been setup with forwarding, access, // and certs CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); VerifyWebRole(service.Components.Definition.WebRole[0], true); VerifyRoleSettings(service); } }
public void SetDeploymentStatusProcessSetStatusToActualStatusTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Suspended; string currentStatus = DeploymentStatus.Suspended; string resultMessage; string expectedMessage = string.Format(Resources.DeploymentAlreadyInState, slot, serviceName, currentStatus); bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => new Deployment(serviceName, slot, currentStatus); using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var deploymentManager = new DeploymentStatusManager(channel); deploymentManager.ShareChannel = true; deploymentManager.CommandRuntime = new MockCommandRuntime(); deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName); resultMessage = ((MockCommandRuntime)deploymentManager.CommandRuntime).WarningStream[0]; Assert.IsFalse(statusUpdated); Assert.IsTrue(resultMessage.Contains(expectedMessage)); } }
public void TestPublishWithDefaultLocation() { RemoveDeployments(); clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); clientMocks.ManagementClientMock.Setup(c => c.Locations.ListAsync(It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(new LocationsListResponse { Locations = { new LocationsListResponse.Location {DisplayName = "East US", Name = "EastUS"} } })); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService()); clientMocks.ManagementClientMock.Verify(c => c.Locations.ListAsync(It.IsAny<CancellationToken>()), Times.Once); } }
public void SetupTest() { CmdletSubscriptionExtensions.SessionManager = new InMemorySessionManager(); files = new FileSystemHelper(this); files.CreateAzureSdkDirectoryAndImportPublishSettings(); }
public void SetDeploymentStatusProcessTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Suspended; string currentStatus = DeploymentStatus.Running; bool statusUpdated = false; Deployment expectedDeployment = new Deployment(serviceName, slot, newStatus); channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => expectedDeployment; }; channel.GetDeploymentBySlotThunk = ar => new Deployment(serviceName, slot, currentStatus); using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var deploymentManager = new DeploymentStatusManager(channel); deploymentManager.ShareChannel = true; deploymentManager.CommandRuntime = new MockCommandRuntime(); deploymentManager.PassThru = true; deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName); Assert.IsTrue(statusUpdated); Deployment actual = ((MockCommandRuntime)deploymentManager.CommandRuntime).OutputPipeline[0] as Deployment; Assert.AreEqual<string>(expectedDeployment.Name, actual.Name); Assert.AreEqual<string>(expectedDeployment.Status, actual.Status); Assert.AreEqual<string>(expectedDeployment.DeploymentSlot, actual.DeploymentSlot); } }
public void EnableRemoteDesktopUnicodeAndShortPasswordFails() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); Testing.AssertThrows<ArgumentException>(() => EnableRemoteDesktop("㯑䲘䄂㮉", "㯑䲘")); } }
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 DisableRemoteDesktopForWebAndWorkerRoles() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole" }; addNodeWorkerCmdlet.ExecuteCmdlet(); disableRDCmdlet.DisableRemoteDesktop(); } }
public void TestUpgradeCloudService() { clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); clientMocks.ComputeManagementClientMock.Setup( c => c.Deployments.UpgradeBySlotAsync(It.IsAny<string>(), DeploymentSlot.Production, It.IsAny<DeploymentUpgradeParameters>(), It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(CreateComputeOperationResponse("req002"))); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US")); clientMocks.ComputeManagementClientMock.Verify(c => c.Deployments.UpgradeBySlotAsync(serviceName, DeploymentSlot.Production, It.IsAny<DeploymentUpgradeParameters>(), It.IsAny<CancellationToken>()), Times.Once); } }
public void TestPublishWithCurrentStorageAccount() { RemoveDeployments(); clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); subscription.CurrentStorageAccountName = storageName; ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US")); cloudBlobUtilityMock.Verify(f => f.UploadPackageToBlob( clientMocks.StorageManagementClientMock.Object, subscription.CurrentStorageAccountName, It.IsAny<string>(), It.IsAny<BlobRequestOptions>()), Times.Once()); } }
public void DisableRemoteDesktopForWebRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); disableRDCmdlet.PassThru = true; disableRDCmdlet.DisableRemoteDesktop(); Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[1]); } }
public void TestUpgradeCloudServiceFromAPackage() { clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); clientMocks.ComputeManagementClientMock.Setup( c => c.Deployments.UpgradeBySlotAsync(It.IsAny<string>(), DeploymentSlot.Production, It.IsAny<DeploymentUpgradeParameters>(), It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(CreateComputeOperationResponse("req002"))); clientMocks.ManagementClientMock.Setup(c => c.Locations.ListAsync(It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(new LocationsListResponse { Locations = { new LocationsListResponse.Location {DisplayName = "East US", Name = "EastUS"} } })); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string packageName = serviceName; string package, configuration; files.CreateDirectoryWithPrebuiltPackage(packageName, out package, out configuration); files.CreateAzureSdkDirectoryAndImportPublishSettings(); // Execute ExecuteInTempCurrentDirectory(Path.GetDirectoryName(package), () => client.PublishCloudService(package, configuration, null, null, null, null, null, false, false)); // Verify clientMocks.ComputeManagementClientMock.Verify(c => c.Deployments.UpgradeBySlotAsync(serviceName, DeploymentSlot.Production, It.IsAny<DeploymentUpgradeParameters>(), It.IsAny<CancellationToken>()), Times.Once); } }
public void EnableDisableEnableRemoteDesktopForWebAndWorkerRoles() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole" }; addNodeWorkerCmdlet.ExecuteCmdlet(); EnableAzureRemoteDesktopCommandTest.EnableRemoteDesktop("user", "GoodPassword!"); disableRDCmdlet.DisableRemoteDesktop(); EnableAzureRemoteDesktopCommandTest.EnableRemoteDesktop("user", "GoodPassword!"); // Verify the roles have been setup with forwarding, access, // and certs CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); EnableAzureRemoteDesktopCommandTest.VerifyWebRole(service.Components.Definition.WebRole[0], false); EnableAzureRemoteDesktopCommandTest.VerifyWorkerRole(service.Components.Definition.WorkerRole[0], true); EnableAzureRemoteDesktopCommandTest.VerifyRoleSettings(service); } }
public void EnableRemoteDesktopForEmptyService() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); Testing.AssertThrows<InvalidOperationException>(() => EnableRemoteDesktop("user", "GoodPassword!")); } }