|
| 1 | +# ---------------------------------------------------------------------------------- |
| 2 | +# |
| 3 | +# Copyright Microsoft Corporation |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# Unless required by applicable law or agreed to in writing, software |
| 9 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +# See the License for the specific language governing permissions and |
| 12 | +# limitations under the License. |
| 13 | +# ---------------------------------------------------------------------------------- |
| 14 | + |
| 15 | +<# |
| 16 | +.SYNOPSIS |
| 17 | +Test SshKeyResource creation |
| 18 | +#> |
| 19 | +function Test-SshKey |
| 20 | +{ |
| 21 | + $loc = 'westus' |
| 22 | + $rgname = Get-ComputeTestResourceName |
| 23 | + |
| 24 | + try |
| 25 | + { |
| 26 | + New-AzResourceGroup -Name $rgname -Location $loc -Force; |
| 27 | + |
| 28 | + #create sshkey1 |
| 29 | + $sshkey1 = New-AzSshKey -ResourceGroupName $rgname -Name "sshkey1" |
| 30 | + |
| 31 | + #create sshkey2 |
| 32 | + $sshkey2 = New-AzSshKey -ResourceGroupName $rgname -Name "sshkey2" |
| 33 | + |
| 34 | + #Get-AzSshKey should return 2 |
| 35 | + $sshKeysResult = Get-AzSshKey -ResourceGroupName $rgname |
| 36 | + Assert-AreEqual $sshKeysResult.count 2 |
| 37 | + |
| 38 | + #update key1.publickey with publickey2 |
| 39 | + Update-AzSshKey -ResourceGroupName $rgname -Name "sshkey1" -publickey $sshKey2.publicKey |
| 40 | + |
| 41 | + #check key1 |
| 42 | + $sshkey1 = Get-AzSshKey -ResourceGroupName $rgname -Name "sshkey1" |
| 43 | + Assert-AreEqual $sshkey1.publickey $sshkey2.publickey |
| 44 | + |
| 45 | + #remove sshkey2 |
| 46 | + Remove-AzSshKey -ResourceGroupName $rgname -Name "sshkey2" |
| 47 | + |
| 48 | + #getshould return1 |
| 49 | + $sshKeysResult = Get-AzSshKey -ResourceGroupName $rgname |
| 50 | + Assert-AreEqual $sshKeysResult.count 1 |
| 51 | + } |
| 52 | + finally |
| 53 | + { |
| 54 | + Clean-ResourceGroup $rgname |
| 55 | + } |
| 56 | + |
| 57 | +} |
0 commit comments