|
22 | 22 | using System.Net;
|
23 | 23 | using System.Net.Cache;
|
24 | 24 | using System.Reflection;
|
| 25 | +using System.Security.Cryptography.X509Certificates; |
25 | 26 | using System.Text;
|
26 | 27 | using System.Threading;
|
27 | 28 | using System.Xml;
|
@@ -1059,6 +1060,98 @@ public void AzureServiceDiagnosticsExtensionTest()
|
1059 | 1060 | #endregion
|
1060 | 1061 |
|
1061 | 1062 |
|
| 1063 | + |
| 1064 | + [TestMethod(), TestCategory(Category.Scenario), TestProperty("Feature", "PAAS"), Priority(1), Owner("huangpf"), Description("Test the ADDomain cmdlets.")] |
| 1065 | + [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\Resources\\package.csv", "package#csv", DataAccessMethod.Sequential)] |
| 1066 | + public void AzureServiceADDomainExtensionTest() |
| 1067 | + { |
| 1068 | + StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); |
| 1069 | + |
| 1070 | + // Choose the package and config files from local machine |
| 1071 | + string packageName = Convert.ToString(TestContext.DataRow["upgradePackage"]); |
| 1072 | + string configName = Convert.ToString(TestContext.DataRow["upgradeConfig"]); |
| 1073 | + var packagePath1 = new FileInfo(Directory.GetCurrentDirectory() + "\\" + packageName); |
| 1074 | + var configPath1 = new FileInfo(Directory.GetCurrentDirectory() + "\\" + configName); |
| 1075 | + |
| 1076 | + Assert.IsTrue(File.Exists(packagePath1.FullName), "VHD file not exist={0}", packagePath1); |
| 1077 | + Assert.IsTrue(File.Exists(configPath1.FullName), "VHD file not exist={0}", configPath1); |
| 1078 | + |
| 1079 | + string deploymentName = "deployment1"; |
| 1080 | + string deploymentLabel = "label1"; |
| 1081 | + DeploymentInfoContext result; |
| 1082 | + |
| 1083 | + PSCredential cred = new PSCredential(username, Utilities.convertToSecureString(password)); |
| 1084 | + |
| 1085 | + try |
| 1086 | + { |
| 1087 | + serviceName = Utilities.GetUniqueShortName(serviceNamePrefix); |
| 1088 | + vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName); |
| 1089 | + Console.WriteLine("service, {0}, is created.", serviceName); |
| 1090 | + |
| 1091 | + // Workgroup Config |
| 1092 | + var workGroupName = "test"; |
| 1093 | + ExtensionConfigurationInput config = vmPowershellCmdlets.NewAzureServiceDomainJoinExtensionConfig( |
| 1094 | + workGroupName, null, null, false, null, null, null); |
| 1095 | + |
| 1096 | + vmPowershellCmdlets.NewAzureDeployment(serviceName, packagePath1.FullName, configPath1.FullName, DeploymentSlotType.Production, deploymentLabel, deploymentName, false, false, config); |
| 1097 | + |
| 1098 | + result = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Production); |
| 1099 | + pass = Utilities.PrintAndCompareDeployment(result, serviceName, deploymentName, deploymentLabel, DeploymentSlotType.Production, null, 2); |
| 1100 | + Console.WriteLine("successfully deployed the package"); |
| 1101 | + |
| 1102 | + var resultContext = vmPowershellCmdlets.GetAzureServiceDomainJoinExtension(serviceName); |
| 1103 | + Assert.IsTrue(string.IsNullOrEmpty(resultContext.User)); |
| 1104 | + Assert.IsTrue(resultContext.Name == workGroupName); |
| 1105 | + Assert.IsTrue(resultContext.Restart == false); |
| 1106 | + |
| 1107 | + vmPowershellCmdlets.RemoveAzureServiceDomainJoinExtension(serviceName, DeploymentSlotType.Production); |
| 1108 | + |
| 1109 | + // Join a Workgroup |
| 1110 | + vmPowershellCmdlets.SetAzureServiceDomainJoinExtension( |
| 1111 | + workGroupName, serviceName, DeploymentSlotType.Production, null, null, false, null, null, "1.*"); |
| 1112 | + resultContext = vmPowershellCmdlets.GetAzureServiceDomainJoinExtension(serviceName); |
| 1113 | + Assert.IsTrue(string.IsNullOrEmpty(resultContext.User)); |
| 1114 | + Assert.IsTrue(resultContext.Name == workGroupName); |
| 1115 | + Assert.IsTrue(resultContext.Restart == false); |
| 1116 | + Assert.IsTrue(resultContext.Version == "1.*"); |
| 1117 | + |
| 1118 | + vmPowershellCmdlets.RemoveAzureDeployment(serviceName, DeploymentSlotType.Production, true); |
| 1119 | + |
| 1120 | + // Domain Config |
| 1121 | + var domainName = "test.bing.com"; |
| 1122 | + config = vmPowershellCmdlets.NewAzureServiceDomainJoinExtensionConfig( |
| 1123 | + domainName, null, null, null, null, null, 35, true, cred, "1.*"); |
| 1124 | + Assert.IsTrue(config.Roles.Any(r => r.Default)); |
| 1125 | + Assert.IsTrue(config.PublicConfiguration.Contains(cred.UserName)); |
| 1126 | + Assert.IsTrue(config.PublicConfiguration.Contains(domainName)); |
| 1127 | + Assert.IsTrue(config.PublicConfiguration.Contains("35")); |
| 1128 | + |
| 1129 | + vmPowershellCmdlets.NewAzureDeployment(serviceName, packagePath1.FullName, configPath1.FullName, DeploymentSlotType.Production, deploymentLabel, deploymentName, false, false, config); |
| 1130 | + |
| 1131 | + vmPowershellCmdlets.RemoveAzureServiceDomainJoinExtension(serviceName, DeploymentSlotType.Production); |
| 1132 | + |
| 1133 | + // Join a Domain |
| 1134 | + vmPowershellCmdlets.SetAzureServiceDomainJoinExtension( |
| 1135 | + domainName, cred, 35, false, serviceName, DeploymentSlotType.Production, null, (X509Certificate2)null, null, (PSCredential)null, null, "1.*"); |
| 1136 | + |
| 1137 | + resultContext = vmPowershellCmdlets.GetAzureServiceDomainJoinExtension(serviceName); |
| 1138 | + Assert.IsTrue(resultContext.User == cred.UserName); |
| 1139 | + Assert.IsTrue(resultContext.Name == domainName); |
| 1140 | + Assert.IsTrue(resultContext.JoinOption == 35); |
| 1141 | + Assert.IsTrue(resultContext.Restart == false); |
| 1142 | + Assert.IsTrue(resultContext.Version == "1.*"); |
| 1143 | + |
| 1144 | + vmPowershellCmdlets.RemoveAzureDeployment(serviceName, DeploymentSlotType.Production, true); |
| 1145 | + |
| 1146 | + pass &= Utilities.CheckRemove(vmPowershellCmdlets.GetAzureDeployment, serviceName, DeploymentSlotType.Production); |
| 1147 | + } |
| 1148 | + catch (Exception e) |
| 1149 | + { |
| 1150 | + pass = false; |
| 1151 | + Assert.Fail("Exception occurred: {0}", e.ToString()); |
| 1152 | + } |
| 1153 | + } |
| 1154 | + |
1062 | 1155 | #region AzureServiceRemoteDesktopExtension Tests
|
1063 | 1156 |
|
1064 | 1157 | [TestMethod(), TestCategory(Category.Scenario), TestProperty("Feature", "PAAS"), Priority(1), Owner("hylee"), Description("Test the cmdlet (New-AzureServiceRemoteDesktopConfig)")]
|
|
0 commit comments