Skip to content

Commit db5eaa7

Browse files
committed
Merge pull request Azure#160 from huangpf/dev
Fix ADDomain Cmdlets
2 parents e342c77 + ec1dcee commit db5eaa7

File tree

5 files changed

+637
-281
lines changed

5 files changed

+637
-281
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ScenarioTest.cs

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System.Net;
2323
using System.Net.Cache;
2424
using System.Reflection;
25+
using System.Security.Cryptography.X509Certificates;
2526
using System.Text;
2627
using System.Threading;
2728
using System.Xml;
@@ -1059,6 +1060,98 @@ public void AzureServiceDiagnosticsExtensionTest()
10591060
#endregion
10601061

10611062

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+
10621155
#region AzureServiceRemoteDesktopExtension Tests
10631156

10641157
[TestMethod(), TestCategory(Category.Scenario), TestProperty("Feature", "PAAS"), Priority(1), Owner("hylee"), Description("Test the cmdlet (New-AzureServiceRemoteDesktopConfig)")]

src/ServiceManagement/Compute/Commands.ServiceManagement/Extensions/ADDomain/BaseAzureServiceADDomainExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ public virtual PSCredential UnjoinDomainCredential
181181
public BaseAzureServiceADDomainExtensionCmdlet()
182182
: base()
183183
{
184+
PrivateConfig.Password = string.Empty;
185+
PrivateConfig.UnjoinDomainPassword = string.Empty;
184186
}
185187

186188
protected override void ValidateParameters()
187189
{
188190
base.ValidateParameters();
189191
ProviderNamespace = DomainExtensionNamespace;
190192
ExtensionName = DomainExtensionType;
191-
PrivateConfig.Password = string.Empty;
192-
PrivateConfig.UnjoinDomainPassword = string.Empty;
193193
}
194194

195195
protected override void ValidateConfiguration()

src/ServiceManagement/Compute/Commands.ServiceManagement/Extensions/ADDomain/NewAzureServiceADDomainExtensionConfig.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ public override string OUPath
187187
[Parameter(Position = 9, ValueFromPipelineByPropertyName = true, ParameterSetName = DomainThumbprintParameterSet)]
188188
[Parameter(Position = 9, ValueFromPipelineByPropertyName = true, ParameterSetName = DomainJoinOptionParameterSet)]
189189
[Parameter(Position = 9, ValueFromPipelineByPropertyName = true, ParameterSetName = DomainJoinOptionThumbprintParameterSet)]
190+
[Parameter(Position = 6, ValueFromPipelineByPropertyName = true, ParameterSetName = WorkgroupParameterSet)]
191+
[Parameter(Position = 6, ValueFromPipelineByPropertyName = true, ParameterSetName = WorkgroupThumbprintParameterSet)]
190192
[ValidateNotNullOrEmpty]
191193
public override string Version
192194
{

src/ServiceManagement/Compute/Commands.ServiceManagement/Extensions/ADDomain/SetAzureServiceADDomainExtension.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ public override string OUPath
204204
[Parameter(Position = 12, ValueFromPipelineByPropertyName = true, ParameterSetName = DomainThumbprintParameterSet)]
205205
[Parameter(Position = 12, ValueFromPipelineByPropertyName = true, ParameterSetName = DomainJoinOptionParameterSet)]
206206
[Parameter(Position = 12, ValueFromPipelineByPropertyName = true, ParameterSetName = DomainJoinOptionThumbprintParameterSet)]
207+
[Parameter(Position = 8, ValueFromPipelineByPropertyName = true, ParameterSetName = WorkgroupParameterSet)]
208+
[Parameter(Position = 8, ValueFromPipelineByPropertyName = true, ParameterSetName = WorkgroupThumbprintParameterSet)]
207209
[ValidateNotNullOrEmpty]
208210
public override string Version
209211
{

0 commit comments

Comments
 (0)