public void NewDomainJoinExtConfigWithDomianJoinThumbprintParameterSetTests() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); try { ExtensionConfigurationInput domainJoinExtensionConfig = vmPowershellCmdlets.NewAzureServiceDomainJoinExtensionConfig( domainName: DomainName, certificateThumbprint: _cert.Thumbprint, oUPath: null, unjoinDomainCredential: null, role: _role, thumbprintAlgorithm: ThumbprintAlgorithm, joinOption: 35, restart: true, credential: _cred); NewAzureDeployment(domainJoinExtensionConfig); GetAzureServiceDomainJoinExtension(); RemoveAzureServiceDomainJoinExtesnion(_role); vmPowershellCmdlets.RemoveAzureDeployment(_serviceName, DeploymentSlotType.Production, true); //TO DO: add test cases to test cmdlet with UnjoinCrednetial patameter. pass = true; } catch (Exception e) { Console.WriteLine("Exception occurred: {0}", e); throw; } }
public void NewAzureServiceDomainJoinExtensionConfigWithWorkgroupCertificateParmateSetTests() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); try { //Prepare a new domain join config with workgroup default parameter set ExtensionConfigurationInput domainJoinExtensionConfig = vmPowershellCmdlets.NewAzureServiceDomainJoinExtensionConfig( workGroupName: WorkgroupName, x509Certificate: _cert, restart: true); //Create a new Azure Iaas VM and set Domain Join extension, get domain join extension and then remove domain join extension NewAzureDeployment(domainJoinExtensionConfig); GetAzureServiceDomainJoinExtension(); RemoveAzureServiceDomainJoinExtesnion(_role); vmPowershellCmdlets.RemoveAzureDeployment(_serviceName, DeploymentSlotType.Production, true); //TO DO: add test cases to test cmdlet with UnjoinCrednetial patameter. pass = true; } catch (Exception e) { Console.WriteLine("Exception occurred: {0}", e); throw; } }
public void NewDomainJoinExtConfigWithDomainParameterSetAndCertTest() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); try { ExtensionConfigurationInput domainJoinExtensionConfig = vmPowershellCmdlets.NewAzureServiceDomainJoinExtensionConfig( domainName: DomainName, x509Certificate: _cert, options: JoinOptions.JoinDomain, oUPath: null, unjoinDomainCredential: null, role: null, thumbprintAlgorithm: null, restart: true, credential: _cred); NewAzureDeployment(domainJoinExtensionConfig); GetAzureServiceDomainJoinExtension(); RemoveAzureServiceDomainJoinExtesnion(); vmPowershellCmdlets.RemoveAzureDeployment(_serviceName, DeploymentSlotType.Production, true); pass = true; } catch (Exception e) { Console.WriteLine("Exception occurred: {0}", e); throw; } }
public void NewDomainJoinExtConfigWithDomainParmateSetTests() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); try { //Prepare a new domain join config with DomainParameterSet (using only X509certicate2) ExtensionConfigurationInput domainJoinExtensionConfig = vmPowershellCmdlets.NewAzureServiceDomainJoinExtensionConfig( domainName: DomainName, x509Certificate: _cert, //options: null, //oUPath: null, unjoinDomainCredential: null, role: null, thumbprintAlgorithm: null, restart: true, credential: _cred); NewAzureDeployment(domainJoinExtensionConfig); GetAzureServiceDomainJoinExtension(); RemoveAzureServiceDomainJoinExtesnion(); vmPowershellCmdlets.RemoveAzureDeployment(_serviceName, DeploymentSlotType.Production, true); //TO DO: add test cases to test cmdlet with UnjoinCrednetial patameter. pass = true; } catch (Exception e) { Console.WriteLine("Exception occurred: {0}", e); throw; } }
public void NewDomainJoinExtConfigWithDefaultParmateSetAndJoinOptionsTests() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); try { //Prepare a new domain join config with default parameter set and one of the join options ExtensionConfigurationInput domainJoinExtensionConfig = vmPowershellCmdlets.NewAzureServiceDomainJoinExtensionConfig( domainName: DomainName, x509Certificate: null, options: JoinOptions.JoinDomain, oUPath: null, unjoinDomainCredential: null, role: null, thumbprintAlgorithm: null, restart: true, credential: _cred); //Create a new Azure Iaas VM and set Domain Join extension, get domain join extension and then remove domain join extension NewAzureDeployment(domainJoinExtensionConfig); GetAzureServiceDomainJoinExtension(); RemoveAzureServiceDomainJoinExtesnion(); vmPowershellCmdlets.RemoveAzureDeployment(_serviceName, DeploymentSlotType.Production, true); //TO DO: add test cases to test cmdlet with UnjoinCrednetial patameter. pass = true; } catch (Exception e) { Console.WriteLine("Exception occurred: {0}", e); throw; } }
public NewAzureDeploymentCmdletInfo(string serviceName, string packagePath, string configName, string slot, string label, string name, bool doNotStart, bool warning, ExtensionConfigurationInput config) { cmdletName = Utilities.NewAzureDeploymentCmdletName; cmdletParams.Add(new CmdletParam("ServiceName", serviceName)); cmdletParams.Add(new CmdletParam("Package", packagePath)); cmdletParams.Add(new CmdletParam("Configuration", configName)); cmdletParams.Add(new CmdletParam("Slot", slot)); if (label != null) { cmdletParams.Add(new CmdletParam("Label", label)); } if (name != null) { cmdletParams.Add(new CmdletParam("Name", name)); } if (doNotStart) { cmdletParams.Add(new CmdletParam("DoNotStart")); } if (warning) { cmdletParams.Add(new CmdletParam("TreatWarningsAsError")); } if (config != null) { cmdletParams.Add(new CmdletParam("ExtensionConfiguration", config)); } }
private void NewAzureDeployment(ExtensionConfigurationInput domainJoinExtensionConfig = null) { //Create a new Azure Iaas VM and set Domain Join extension, get domain join extension and then remove domain join extension Console.WriteLine("Creating a new Azure Iaas VM"); vmPowershellCmdlets.NewAzureService(_serviceName, _serviceName, null, AffinityGroupName); Console.WriteLine("Service, {0}, is created.", _serviceName); vmPowershellCmdlets.AddAzureCertificate(_serviceName, _rdpCertPath.FullName, password); if (domainJoinExtensionConfig == null) { vmPowershellCmdlets.NewAzureDeployment(_serviceName, _packagePath1.FullName, _configPath1.FullName, DeploymentSlotType.Production, _deploymentLabel, _deploymentName, false, false); Console.WriteLine("New deployment created successfully."); } else { vmPowershellCmdlets.NewAzureDeployment(_serviceName, _packagePath1.FullName, _configPath1.FullName, DeploymentSlotType.Production, _deploymentLabel, _deploymentName, false, false, domainJoinExtensionConfig); Console.WriteLine("{0}:New deployment {1} with domain join {2} created successfully.", DateTime.Now, _serviceName, domainJoinExtensionConfig.Type); } }
public NewAzureDeploymentCmdletInfo(string serviceName, string packagePath, string configName, string slot, string label, string name, bool doNotStart, bool warning, ExtensionConfigurationInput config) { cmdletName = Utilities.NewAzureDeploymentCmdletName; cmdletParams.Add(new CmdletParam("ServiceName", serviceName)); cmdletParams.Add(new CmdletParam("Package", packagePath)); cmdletParams.Add(new CmdletParam("Configuration", configName)); cmdletParams.Add(new CmdletParam("Slot", slot)); if (label != null) { cmdletParams.Add(new CmdletParam("Label", label)); } if (name != null) { cmdletParams.Add(new CmdletParam("Name", name)); } if (doNotStart) { cmdletParams.Add(new CmdletParam("DoNotStart")); } if (warning) { cmdletParams.Add(new CmdletParam("TreatWarningsAsError")); } if (config != null) { cmdletParams.Add(new CmdletParam("ExtensionConfiguration", config)); } }
private void NewAzureDeployment(ExtensionConfigurationInput domainJoinExtensionConfig = null) { //Create a new Azure Iaas VM and set Domain Join extension, get domain join extension and then remove domain join extension Console.WriteLine("Creating a new Azure Iaas VM"); vmPowershellCmdlets.NewAzureService(_serviceName, _serviceName, null, AffinityGroupName); Console.WriteLine("Service, {0}, is created.", _serviceName); vmPowershellCmdlets.AddAzureCertificate(_serviceName, _rdpCertPath.FullName, password); if (domainJoinExtensionConfig == null) { vmPowershellCmdlets.NewAzureDeployment(_serviceName, _packagePath1.FullName, _configPath1.FullName, DeploymentSlotType.Production, _deploymentLabel, _deploymentName, false, false); Console.WriteLine("New deployment created successfully."); } else { vmPowershellCmdlets.NewAzureDeployment(_serviceName, _packagePath1.FullName, _configPath1.FullName, DeploymentSlotType.Production, _deploymentLabel, _deploymentName, false, false, domainJoinExtensionConfig); Console.WriteLine("{0}:New deployment {1} with domain join {2} created successfully.", DateTime.Now, _serviceName, domainJoinExtensionConfig.Type); } }
private bool VerifyExtensionConfigRDP(ExtensionConfigurationInput resultConfig, string user, string pass, List<string> roles, DateTime exp, string thumbprint = null, string algorithm = null, X509Certificate2 cert = null) { try { string resultUserName = GetInnerText(resultConfig.PublicConfiguration, "UserName"); string resultPassword = GetInnerText(resultConfig.PrivateConfiguration, "Password"); string resultExpDate = GetInnerText(resultConfig.PublicConfiguration, "Expiration"); Console.WriteLine("Type: {0}, UserName:{1}, Password: {2}, ExpirationDate: {3}, CertificateThumbprint: {4}, ThumbprintAlgorithm: {5}, X509Certificate: {6}", resultConfig.Type, resultUserName, resultPassword, resultExpDate, resultConfig.CertificateThumbprint, resultConfig.ThumbprintAlgorithm, resultConfig.X509Certificate); Assert.AreEqual(resultConfig.Type, "RDP", "Type is not equal!"); Assert.AreEqual(resultUserName, user); Assert.AreEqual(resultPassword, pass); Assert.IsTrue(Utilities.CompareDateTime(exp, resultExpDate)); if (string.IsNullOrWhiteSpace(thumbprint)) { Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.CertificateThumbprint)); } else { Assert.AreEqual(resultConfig.CertificateThumbprint, thumbprint, "Certificate thumbprint is not equal!"); } if (string.IsNullOrWhiteSpace(algorithm)) { Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.ThumbprintAlgorithm)); } else { Assert.AreEqual(resultConfig.ThumbprintAlgorithm, algorithm, "Thumbprint algorithm is not equal!"); } Assert.AreEqual(resultConfig.X509Certificate, cert, "X509Certificate is not equal!"); if (resultConfig.Roles.Count == 1 && string.IsNullOrEmpty(resultConfig.Roles[0].RoleName)) { Assert.IsTrue(roles.Contains(resultConfig.Roles[0].RoleType.ToString())); } else { foreach (ExtensionRole role in resultConfig.Roles) { Assert.IsTrue(roles.Contains(role.RoleName)); } } return true; } catch { return false; } }
private bool VerifyExtensionConfigDiag(ExtensionConfigurationInput resultConfig, string storage, List<string> roles, XmlDocument wadconfig = null, string thumbprint = null, string algorithm = null, X509Certificate2 cert = null) { try { string resultStorageAccount = GetInnerText(resultConfig.PublicConfiguration, "Name"); string resultWadCfg = Utilities.GetInnerXml(resultConfig.PublicConfiguration, "WadCfg"); if (string.IsNullOrWhiteSpace(resultWadCfg)) { resultWadCfg = null; } string resultStorageKey = GetInnerText(resultConfig.PrivateConfiguration, "StorageKey"); Console.WriteLine("Type: {0}, StorageAccountName:{1}, StorageKey: {2}, WadCfg: {3}, CertificateThumbprint: {4}, ThumbprintAlgorithm: {5}, X509Certificate: {6}", resultConfig.Type, resultStorageAccount, resultStorageKey, resultWadCfg, resultConfig.CertificateThumbprint, resultConfig.ThumbprintAlgorithm, resultConfig.X509Certificate); Assert.AreEqual(resultConfig.Type, "Diagnostics", "Type is not equal!"); Assert.AreEqual(resultStorageAccount, storage); Assert.IsTrue(Utilities.CompareWadCfg(resultWadCfg, wadconfig)); if (string.IsNullOrWhiteSpace(thumbprint)) { Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.CertificateThumbprint)); } else { Assert.AreEqual(resultConfig.CertificateThumbprint, thumbprint, "Certificate thumbprint is not equal!"); } if (string.IsNullOrWhiteSpace(algorithm)) { Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.ThumbprintAlgorithm)); } else { Assert.AreEqual(resultConfig.ThumbprintAlgorithm, algorithm, "Thumbprint algorithm is not equal!"); } Assert.AreEqual(resultConfig.X509Certificate, cert, "X509Certificate is not equal!"); if (resultConfig.Roles.Count == 1 && string.IsNullOrEmpty(resultConfig.Roles[0].RoleName)) { Assert.IsTrue(roles.Contains(resultConfig.Roles[0].RoleType.ToString())); } else { foreach (ExtensionRole role in resultConfig.Roles) { Assert.IsTrue(roles.Contains(role.RoleName)); } } return true; } catch { return false; } }
public void AzureServiceExtensionConfigScenarioTest() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); const string rdpPath = @".\WebRole1.rdp"; try { Collection <ExtensionImageContext> resultExtensions = vmPowershellCmdlets.GetAzureServiceAvailableExtension(); foreach (var extension in resultExtensions) { if (extension.ExtensionName == "RDP") { _extensionName = extension.ExtensionName; _providerNamespace = extension.ProviderNameSpace; _version = extension.Version; break; } } vmPowershellCmdlets.NewAzureService(_serviceName, _serviceName, locationName); Console.WriteLine("service, {0}, is created.", _serviceName); ExtensionConfigurationInput config = vmPowershellCmdlets.NewAzureServiceExtensionConfig( extensionName: _extensionName, providerNamespace: _providerNamespace, publicConfig: PublicConfig, privateConfig: PrivateConfig, version: _version ); vmPowershellCmdlets.NewAzureDeployment(_serviceName, _packagePath.FullName, _configPath.FullName, DeploymentSlotType.Production, DeploymentLabel, DeploymentName, false, false, config); DeploymentInfoContext result = vmPowershellCmdlets.GetAzureDeployment(_serviceName, DeploymentSlotType.Production); pass = Utilities.PrintAndCompareDeployment(result, _serviceName, DeploymentName, DeploymentLabel, DeploymentSlotType.Production, null, 2); Console.WriteLine("successfully deployed the package"); ExtensionContext resultExtensionContext = vmPowershellCmdlets.GetAzureServiceExtension(_serviceName)[0]; Utilities.PrintContext(resultExtensionContext); VerifyExtensionContext(resultExtensionContext, "AllRoles", _extensionName, _providerNamespace, _version); RemoteDesktopExtensionContext resultContext = vmPowershellCmdlets.GetAzureServiceRemoteDesktopExtension(_serviceName)[0]; Utilities.PrintContext(resultContext); VerifyRDP(_serviceName, rdpPath); vmPowershellCmdlets.RemoveAzureServiceExtension( serviceName: _serviceName, extensionName: _extensionName, providerNamespace: _providerNamespace); try { vmPowershellCmdlets.GetAzureRemoteDesktopFile("WebRole1_IN_0", _serviceName, rdpPath, false); Assert.Fail("Succeeded, but extected to fail!"); } catch (Exception e) { if (e is AssertFailedException) { throw; } Console.WriteLine("Failed to get RDP file as expected"); } vmPowershellCmdlets.RemoveAzureDeployment(_serviceName, DeploymentSlotType.Production, true); pass &= Utilities.CheckRemove(vmPowershellCmdlets.GetAzureDeployment, _serviceName, DeploymentSlotType.Production); } catch (Exception e) { Console.WriteLine("Exception occurred: {0}", e); throw; } }
public static SetAzureDeploymentCmdletInfo SetAzureDeploymentConfigCmdletInfo(string serviceName, string slot, string configPath, ExtensionConfigurationInput extConfig = null) { SetAzureDeploymentCmdletInfo result = new SetAzureDeploymentCmdletInfo(serviceName, slot); result.cmdletParams.Add(new CmdletParam("Config")); result.cmdletParams.Add(new CmdletParam("Configuration", configPath)); if (extConfig != null) { result.cmdletParams.Add(new CmdletParam("ExtensionConfiguration", extConfig)); } return(result); }