Skip to content

Commit 4ec1b41

Browse files
cmdlets for new compute resource: SSH Public Key (#15120)
* four cmdlets * location to follow resource group * add supportshouldprocess * update test * update key save location * capitalization * change * change * add two new parameter sets
1 parent 4a304aa commit 4ec1b41

File tree

19 files changed

+2443
-23
lines changed

19 files changed

+2443
-23
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
19+
{
20+
public class sshKeyTests : ComputeTestRunner
21+
{
22+
public sshKeyTests(Xunit.Abstractions.ITestOutputHelper output)
23+
: base(output)
24+
{
25+
}
26+
27+
[Fact]
28+
[Trait(Category.AcceptanceType, Category.CheckIn)]
29+
public void TestSshKey()
30+
{
31+
TestRunner.RunTestScript("Test-SshKey");
32+
}
33+
}
34+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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

Comments
 (0)