Skip to content

Commit 46ff78b

Browse files
committed
Update test and fix parameter issue
1 parent e7b2502 commit 46ff78b

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed

src/Compute/Compute.Test/ScenarioTests/DiskRPTests.ps1

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,23 +1959,29 @@ Test SupportedSecurityOption Parameter during creation of managed disk using Cre
19591959
function Test-SupportedSecurityOption
19601960
{
19611961
$rgname = Get-ComputeTestResourceName;
1962-
$loc = "eastus2euap";
1962+
$loc = Get-ComputeVMLocation;
19631963

19641964
try{
19651965
New-AzResourceGroup -Name $rgname -Location $loc -Force;
1966-
$sourceUri = "https://teststorage.blob.core.windows.net/vhds/test.vhd"
1967-
$subId = Get-SubscriptionIdFromResourceGroup $rgname;
1968-
$storageAccountId = "/subscriptions/$subId/resourceGroups/$rgname/providers/Microsoft.Storage/storageAccounts/teststorage"
1969-
1970-
$diskConfig = New-AzDiskConfig -Location $loc -AccountType 'Premium_LRS' -CreateOption Import -SourceUri $sourceUri -StorageAccountId $storageAccountId -SupportedSecurityOption "TrustedLaunchSupported"
1966+
# Get the current Azure context (subscription, tenant, account)
1967+
$context = Get-AzContext
1968+
Write-Debug "Current Subscription: $($context.Subscription.Name) ($($context.Subscription.Id))"
1969+
Write-Debug "Current Tenant: $($context.Tenant.Id)"
1970+
Write-Debug "Current Account: $($context.Account.Id)"
1971+
Write-Debug "Current region: $loc"
1972+
1973+
$diskConfig = New-AzDiskConfig -Location $loc -SkuName 'PremiumV2_LRS' -DiskSizeGB 2 -CreateOption Empty -SupportedSecurityOption 'TrustedLaunchSupported';
19711974
$diskname = "disk" + $rgname;
19721975
New-AzDisk -ResourceGroupName $rgname -DiskName $diskname -Disk $diskConfig;
19731976
$disk = Get-AzDisk -ResourceGroupName $rgname -DiskName $diskname;
1974-
Assert-AreEqual $disk.SupportedSecurityOption "TrustedLaunchSupported";
1977+
1978+
# Check the SupportedCapabilities object
1979+
Assert-NotNull $disk.SupportedCapabilities;
1980+
Assert-AreEqual "TrustedLaunchSupported" $disk.SupportedCapabilities.SupportedSecurityOption;
19751981

19761982
$updateconfig = New-AzDiskUpdateConfig -SupportedSecurityOption "TrustedLaunchAndConfidentialVMSupported";
19771983
$disk = Update-AzDisk -ResourceGroupName $rgname -DiskName $diskname -DiskUpdate $updateconfig;
1978-
Assert-AreEqual $disk.SupportedSecurityOption "TrustedLaunchAndConfidentialVMSupported";
1984+
Assert-AreEqual $disk.SupportedCapabilities.SupportedSecurityOption; "TrustedLaunchAndConfidentialVMSupported";
19791985
}
19801986

19811987
finally

src/Compute/Compute/Generated/Disk/Config/NewAzureRmDiskConfigCommand.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,15 @@ private void Run()
498498
vSupportedCapabilities.Architecture = this.Architecture;
499499
}
500500

501+
if (this.IsParameterBound(c => c.SupportedSecurityOption))
502+
{
503+
if (vSupportedCapabilities == null)
504+
{
505+
vSupportedCapabilities = new SupportedCapabilities();
506+
}
507+
vSupportedCapabilities.SupportedSecurityOption = this.SupportedSecurityOption;
508+
}
509+
501510
var vDisk = new PSDisk
502511
{
503512
Zones = this.IsParameterBound(c => c.Zone) ? this.Zone : null,
@@ -525,8 +534,7 @@ private void Run()
525534
SupportedCapabilities = vSupportedCapabilities,
526535
PublicNetworkAccess = this.IsParameterBound(c => c.PublicNetworkAccess) ? PublicNetworkAccess : null,
527536
DataAccessAuthMode = this.IsParameterBound(c => c.DataAccessAuthMode) ? DataAccessAuthMode : null,
528-
OptimizedForFrequentAttach = this.IsParameterBound(c => c.OptimizedForFrequentAttach) ? OptimizedForFrequentAttach : null,
529-
SupportedSecurityOption = this.IsParameterBound(c => c.SupportedSecurityOption) ? SupportedSecurityOption : null
537+
OptimizedForFrequentAttach = this.IsParameterBound(c => c.OptimizedForFrequentAttach) ? OptimizedForFrequentAttach : null
530538
};
531539

532540
WriteObject(vDisk);

src/Compute/Compute/Generated/Disk/Config/NewAzureRmDiskUpdateConfigCommand.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ public partial class NewAzureRmDiskUpdateConfigCommand : Microsoft.Azure.Command
179179
[PSArgumentCompleter("X64", "Arm64")]
180180
public string Architecture { get; set; }
181181

182+
[Parameter(
183+
Mandatory = false,
184+
ValueFromPipelineByPropertyName = true,
185+
HelpMessage = "Refers to the security capability of the disk supported to create a Trusted launch or Confidential VM.")]
186+
[PSArgumentCompleter("TrustedLaunchSupported", "TrustedLaunchAndConfidentialVMSupported")]
187+
public string SupportedSecurityOption { get; set; }
182188

183189
protected override void ProcessRecord()
184190
{
@@ -301,6 +307,15 @@ private void Run()
301307
vSupportedCapabilities.Architecture = this.Architecture;
302308
}
303309

310+
if (this.IsParameterBound(c => c.SupportedSecurityOption))
311+
{
312+
if (vSupportedCapabilities == null)
313+
{
314+
vSupportedCapabilities = new SupportedCapabilities();
315+
}
316+
vSupportedCapabilities.SupportedSecurityOption = this.SupportedSecurityOption;
317+
}
318+
304319
var vDiskUpdate = new PSDiskUpdate
305320
{
306321
OsType = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,

src/Compute/Compute/Generated/Models/PSDisk.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,5 @@ public string ResourceGroupName
8181
public bool? OptimizedForFrequentAttach { get; set; }
8282
public string SecurityDataUri { get; set; }
8383
public string SecurityMetadataUri { get; set; }
84-
public string SupportedSecurityOption { get; set; }
8584
}
8685
}

0 commit comments

Comments
 (0)