Skip to content

Commit

Permalink
Added live test for ssh key (#21056)
Browse files Browse the repository at this point in the history
* Added live test cases for Network and DNS

* Added live test cases for modules Automation, Databricks and Functions
Added more detailed error info and enabled Debug preference during the last retry

* Updated live test to make it support no built-in resource group

* Added live test for ssh key
  • Loading branch information
vidai-msft authored Feb 27, 2023
1 parent 49459fb commit 6837fd0
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/Compute/Compute.Test/LiveTests/TestLiveScenarios.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,64 @@ Invoke-LiveTestScenario -Name "Remove a managed disk" -Description "Test removin
$actual = Get-AzDisk -ResourceGroupName $rgName -DiskName $diskName -ErrorAction SilentlyContinue
Assert-Null $actual
}

Invoke-LiveTestScenario -Name "Create a ssh key" -Description "Test creating a ssh key" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$keyName = New-LiveTestResourceName

New-AzSshKey -ResourceGroupName $rgName -Name $keyName

$actual = Get-AzSshKey -ResourceGroupName $rgName -Name $keyName
Assert-NotNull $actual
Assert-AreEqual $keyName $actual.Name
}

Invoke-LiveTestScenario -Name "Update a ssh key" -Description "Test updating an existing ssh key" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$key1Name = New-LiveTestResourceName
$key2Name = New-LiveTestResourceName

$key1 = New-AzSshKey -ResourceGroupName $rgName -Name $key1Name
$publicKey1 = $key1.publicKey

$key2 = New-AzSshKey -ResourceGroupname $rgName -Name $key2Name
$publicKey2 = $key2.publicKey

Get-AzSshKey -ResourceGroupName $rgName -Name $key1Name | Update-AzSshKey -PublicKey $publicKey2
Update-AzSshKey -ResourceId $key2.Id -PublicKey $publicKey1

$actual1 = Get-AzSshKey -ResourceGroupname $rgName -Name $key1Name
Assert-NotNull $actual1
Assert-AreEqual $key1Name $actual1.Name
Assert-AreEqual $publicKey2 $actual1.publicKey

$actual2 = Get-AzSshKey -ResourceGroupname $rgName -Name $key2Name
Assert-NotNull $actual2
Assert-AreEqual $key2Name $actual2.Name
Assert-AreEqual $publicKey1 $actual2.publicKey
}

Invoke-LiveTestScenario -Name "Delete a ssh key" -Description "Test deleting a ssh key" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$key1Name = New-LiveTestResourceName
$key2Name = New-LiveTestResourceName

New-AzSshKey -ResourceGroupName $rgName -Name $key1Name
Remove-AzSshKey -ResourceGroupName $rgName -name $key1Name
$actual = Get-AzSshKey -ResourceGroupName $rgName -Name $key1Name
Assert-Null $actual

$key2 = New-AzSshKey -ResourceGroupName $rgName -Name $key2Name
Remove-AzSshKey -ResourceId $key2.Id
$actual = Get-AzSshKey -ResourceGroupName $rgName -Name $key2Name
Assert-Null $actual
}

0 comments on commit 6837fd0

Please sign in to comment.