Skip to content

Commit c9e8da0

Browse files
committed
Add ADDomain extension cmdlets and tests.
1 parent 8a7b2cd commit c9e8da0

18 files changed

+9540
-89
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,12 @@
354354
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineExtensionTests\TestVirtualMachineAccessExtension.json">
355355
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
356356
</None>
357+
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineExtensionTests\TestVirtualMachineADDomainExtension.json">
358+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
359+
</None>
360+
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineExtensionTests\TestVirtualMachineADDomainExtensionDomainJoin.json">
361+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
362+
</None>
357363
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineExtensionTests\TestVirtualMachineBginfoExtension.json">
358364
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
359365
</None>

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/ComputeTestCommon.ps1

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
$PLACEHOLDER = "PLACEHOLDER"
16+
1517
<#
1618
.SYNOPSIS
1719
Gets valid resource name for compute test
@@ -113,7 +115,7 @@ function Create-VirtualMachine($rgname, $vmname, $loc)
113115
$rgname = if ([string]::IsNullOrEmpty($rgname)) { Get-ComputeTestResourceName } else { $rgname }
114116
$vmname = if ([string]::IsNullOrEmpty($vmname)) { 'vm' + $rgname } else { $vmname }
115117
$loc = if ([string]::IsNullOrEmpty($loc)) { Get-ComputeVMLocation } else { $loc }
116-
Write-Host $vmname
118+
Write-Host $vmname
117119

118120
# Common
119121
$g = New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
@@ -479,17 +481,17 @@ function Get-SasUri
479481
{
480482
param ([string] $storageAccount, [string] $storageKey, [string] $container, [string] $file, [TimeSpan] $duration, [Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions] $type)
481483

482-
$uri = [string]::Format("https://{0}.blob.core.windows.net/{1}/{2}", $storageAccount, $container, $file);
484+
$uri = [string]::Format("https://{0}.blob.core.windows.net/{1}/{2}", $storageAccount, $container, $file);
483485

484-
$destUri = New-Object -TypeName System.Uri($uri);
485-
$cred = New-Object -TypeName Microsoft.WindowsAzure.Storage.Auth.StorageCredentials($storageAccount, $storageKey);
486-
$destBlob = New-Object -TypeName Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob($destUri, $cred);
487-
$policy = New-Object Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy;
488-
$policy.Permissions = $type;
489-
$policy.SharedAccessExpiryTime = [DateTime]::UtcNow.Add($duration);
490-
$uri += $destBlob.GetSharedAccessSignature($policy);
486+
$destUri = New-Object -TypeName System.Uri($uri);
487+
$cred = New-Object -TypeName Microsoft.WindowsAzure.Storage.Auth.StorageCredentials($storageAccount, $storageKey);
488+
$destBlob = New-Object -TypeName Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob($destUri, $cred);
489+
$policy = New-Object Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy;
490+
$policy.Permissions = $type;
491+
$policy.SharedAccessExpiryTime = [DateTime]::UtcNow.Add($duration);
492+
$uri += $destBlob.GetSharedAccessSignature($policy);
491493

492-
return $uri;
494+
return $uri;
493495
}
494496

495497
# Get a Location according to resource provider.
@@ -564,13 +566,13 @@ function Get-SubscriptionIdFromResourceGroup
564566
{
565567
param ([string] $rgname)
566568

567-
$rg = Get-AzureRmResourceGroup -ResourceGroupName $rgname;
569+
$rg = Get-AzureRmResourceGroup -ResourceGroupName $rgname;
568570

569-
$rgid = $rg.ResourceId;
571+
$rgid = $rg.ResourceId;
570572

571-
# ResouceId is a form of "/subscriptions/<subId>/resourceGroups/<resourgGroupName>"
572-
# So return the second part to get subscription Id
573-
$first = $rgid.IndexOf('/', 1);
574-
$last = $rgid.IndexOf('/', $first + 1);
575-
return $rgid.Substring($first + 1, $last - $first - 1);
573+
# ResouceId is a form of "/subscriptions/<subId>/resourceGroups/<resourgGroupName>"
574+
# So return the second part to get subscription Id
575+
$first = $rgid.IndexOf('/', 1);
576+
$last = $rgid.IndexOf('/', $first + 1);
577+
return $rgid.Substring($first + 1, $last - $first - 1);
576578
}

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineExtensionTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,19 @@ public void TestVirtualMachineExtensionWithSwitch()
8686
{
8787
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineExtensionWithSwitch");
8888
}
89+
90+
[Fact]
91+
[Trait(Category.AcceptanceType, Category.CheckIn)]
92+
public void TestVirtualMachineADDomainExtension()
93+
{
94+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineADDomainExtension");
95+
}
96+
97+
[Fact]
98+
[Trait(Category.AcceptanceType, Category.CheckIn)]
99+
public void TestVirtualMachineADDomainExtensionDomainJoin()
100+
{
101+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineADDomainExtensionDomainJoin");
102+
}
89103
}
90104
}

0 commit comments

Comments
 (0)