Skip to content

Commit 15daba3

Browse files
committed
resolve conflicts with commit for certificates
2 parents 8e66b0e + b5625c3 commit 15daba3

35 files changed

+1429
-43
lines changed

src/ServiceManagement/Automation/Commands.Automation.Test/Commands.Automation.Test.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,17 @@
110110
</ItemGroup>
111111
<ItemGroup>
112112
<Compile Include="Properties\AssemblyInfo.cs" />
113+
<Compile Include="UnitTests\GetAzureAutomationCertificateTest.cs" />
114+
<Compile Include="UnitTests\NewAzureAutomationAccountTest.cs" />
115+
<Compile Include="UnitTests\GetAzureAutomationAccountTest.cs" />
113116
<Compile Include="UnitTests\GetAzureAutomationRunbookDefinitionTest.cs" />
114117
<Compile Include="UnitTests\GetAzureAutomationRunbookTest.cs" />
115118
<Compile Include="UnitTests\GetAzureAutomationScheduledRunbookTest.cs" />
119+
<Compile Include="UnitTests\NewAzureAutomationCertificateTest.cs" />
116120
<Compile Include="UnitTests\NewAzureAutomationRunbookTest.cs" />
117121
<Compile Include="UnitTests\PublishAzureAutomationRunbookTest.cs" />
122+
<Compile Include="UnitTests\RemoveAzureAutomationAccountTest.cs" />
123+
<Compile Include="UnitTests\RemoveAzureAutomationCertificateTest.cs" />
118124
<Compile Include="UnitTests\RegisterAzureAutomationScheduledRunbookTest.cs" />
119125
<Compile Include="UnitTests\RemoveAzureAutomationRunbookTest.cs" />
120126
<Compile Include="UnitTests\SetAzureAutomationRunbookDefinitionTest.cs" />
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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.Azure.Commands.Automation.Cmdlet;
16+
using Microsoft.Azure.Commands.Automation.Common;
17+
using Microsoft.VisualStudio.TestTools.UnitTesting;
18+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
19+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
20+
using Moq;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
23+
{
24+
[TestClass]
25+
public class GetAzureAutomationAccountTest : TestBase
26+
{
27+
private Mock<IAutomationClient> mockAutomationClient;
28+
29+
private MockCommandRuntime mockCommandRuntime;
30+
31+
private GetAzureAutomationAccount cmdlet;
32+
33+
[TestInitialize]
34+
public void SetupTest()
35+
{
36+
this.mockAutomationClient = new Mock<IAutomationClient>();
37+
this.mockCommandRuntime = new MockCommandRuntime();
38+
this.cmdlet = new GetAzureAutomationAccount
39+
{
40+
AutomationClient = this.mockAutomationClient.Object,
41+
CommandRuntime = this.mockCommandRuntime
42+
};
43+
}
44+
45+
[TestMethod]
46+
public void GetAzureAutomationAllAccountsSuccessfull()
47+
{
48+
// Setup
49+
this.mockAutomationClient.Setup(f => f.ListAutomationAccounts(null, null));
50+
51+
// Test
52+
this.cmdlet.ExecuteCmdlet();
53+
54+
// Assert
55+
this.mockAutomationClient.Verify(f => f.ListAutomationAccounts(null, null), Times.Once());
56+
}
57+
58+
[TestMethod]
59+
public void GetAzureAutomationAccountSuccessfull()
60+
{
61+
// Setup
62+
string accountName = "account";
63+
string location = "East US";
64+
65+
this.mockAutomationClient.Setup(f => f.ListAutomationAccounts(accountName, location));
66+
67+
// Test
68+
this.cmdlet.Name = accountName;
69+
this.cmdlet.Location = location;
70+
this.cmdlet.ExecuteCmdlet();
71+
72+
// Assert
73+
this.mockAutomationClient.Verify(f => f.ListAutomationAccounts(accountName, location), Times.Once());
74+
}
75+
}
76+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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 System;
16+
using System.Collections.Generic;
17+
using Microsoft.Azure.Commands.Automation.Cmdlet;
18+
using Microsoft.Azure.Commands.Automation.Common;
19+
using Microsoft.Azure.Commands.Automation.Model;
20+
using Microsoft.VisualStudio.TestTools.UnitTesting;
21+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
22+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
23+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
24+
using Moq;
25+
26+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
27+
{
28+
[TestClass]
29+
public class GetAzureAutomationCertificateTest : TestBase
30+
{
31+
private Mock<IAutomationClient> mockAutomationClient;
32+
33+
private MockCommandRuntime mockCommandRuntime;
34+
35+
private GetAzureAutomationCertificate cmdlet;
36+
37+
[TestInitialize]
38+
public void SetupTest()
39+
{
40+
this.mockAutomationClient = new Mock<IAutomationClient>();
41+
this.mockCommandRuntime = new MockCommandRuntime();
42+
this.cmdlet = new GetAzureAutomationCertificate
43+
{
44+
AutomationClient = this.mockAutomationClient.Object,
45+
CommandRuntime = this.mockCommandRuntime
46+
};
47+
}
48+
49+
[TestMethod]
50+
public void GetAzureAutomationCertificateByNameSuccessfull()
51+
{
52+
// Setup
53+
string accountName = "automation";
54+
string certificateName = "certificate";
55+
56+
this.mockAutomationClient.Setup(f => f.GetCertificate(accountName, certificateName));
57+
58+
// Test
59+
this.cmdlet.AutomationAccountName = accountName;
60+
this.cmdlet.Name = certificateName;
61+
this.cmdlet.SetParameterSet("ByCertificateName");
62+
this.cmdlet.ExecuteCmdlet();
63+
64+
// Assert
65+
this.mockAutomationClient.Verify(f => f.GetCertificate(accountName, certificateName), Times.Once());
66+
}
67+
68+
[TestMethod]
69+
public void GetAzureAutomationCertificateByAllSuccessfull()
70+
{
71+
// Setup
72+
string accountName = "automation";
73+
74+
this.mockAutomationClient.Setup(f => f.ListCertificates(accountName)).Returns((string a) => new List<Certificate>());
75+
76+
// Test
77+
this.cmdlet.AutomationAccountName = accountName;
78+
this.cmdlet.ExecuteCmdlet();
79+
80+
// Assert
81+
this.mockAutomationClient.Verify(f => f.ListCertificates(accountName), Times.Once());
82+
}
83+
}
84+
}

src/ServiceManagement/Automation/Commands.Automation.Test/UnitTests/GetAzureAutomationRunbookTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void GetAzureAutomationRunbookByNameSuccessfull()
5858
// Test
5959
this.cmdlet.AutomationAccountName = accountName;
6060
this.cmdlet.Name = runbookName;
61-
this.cmdlet.SetParameterSet("ByName");
61+
this.cmdlet.SetParameterSet("ByRunbookName");
6262
this.cmdlet.ExecuteCmdlet();
6363

6464
// Assert
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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.Azure.Commands.Automation.Cmdlet;
16+
using Microsoft.Azure.Commands.Automation.Common;
17+
using Microsoft.VisualStudio.TestTools.UnitTesting;
18+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
19+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
20+
using Moq;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
23+
{
24+
[TestClass]
25+
public class NewAzureAutomationAccountTest : TestBase
26+
{
27+
private Mock<IAutomationClient> mockAutomationClient;
28+
29+
private MockCommandRuntime mockCommandRuntime;
30+
31+
private NewAzureAutomationAccount cmdlet;
32+
33+
[TestInitialize]
34+
public void SetupTest()
35+
{
36+
this.mockAutomationClient = new Mock<IAutomationClient>();
37+
this.mockCommandRuntime = new MockCommandRuntime();
38+
this.cmdlet = new NewAzureAutomationAccount
39+
{
40+
AutomationClient = this.mockAutomationClient.Object,
41+
CommandRuntime = this.mockCommandRuntime
42+
};
43+
}
44+
45+
[TestMethod]
46+
public void NewAzureAutomationAccountByNameSuccessfull()
47+
{
48+
// Setup
49+
string accountName = "account";
50+
string location = "East US";
51+
52+
this.mockAutomationClient.Setup(f => f.CreateAutomationAccount(accountName, location));
53+
54+
// Test
55+
this.cmdlet.Name = accountName;
56+
this.cmdlet.Location = location;
57+
this.cmdlet.ExecuteCmdlet();
58+
59+
// Assert
60+
this.mockAutomationClient.Verify(f => f.CreateAutomationAccount(accountName, location), Times.Once());
61+
}
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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 System.Collections.Generic;
16+
using Microsoft.Azure.Commands.Automation.Cmdlet;
17+
using Microsoft.Azure.Commands.Automation.Common;
18+
using Microsoft.VisualStudio.TestTools.UnitTesting;
19+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
20+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
21+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
22+
using Moq;
23+
using System.Management.Automation;
24+
using System.Security;
25+
using System;
26+
27+
namespace Microsoft.Azure.Commands.Automation.Test.UnitTests
28+
{
29+
[TestClass]
30+
public class NewAzureAutomationCertificateTest : TestBase
31+
{
32+
private Mock<IAutomationClient> mockAutomationClient;
33+
34+
private MockCommandRuntime mockCommandRuntime;
35+
36+
private NewAzureAutomationCertificate cmdlet;
37+
38+
[TestInitialize]
39+
public void SetupTest()
40+
{
41+
this.mockAutomationClient = new Mock<IAutomationClient>();
42+
this.mockCommandRuntime = new MockCommandRuntime();
43+
this.cmdlet = new NewAzureAutomationCertificate
44+
{
45+
AutomationClient = this.mockAutomationClient.Object,
46+
CommandRuntime = this.mockCommandRuntime
47+
};
48+
}
49+
50+
[TestMethod]
51+
public void NewAzureAutomationCertificateByNameSuccessfull()
52+
{
53+
// Setup
54+
string accountName = "automation";
55+
string certificateName = "certificate";
56+
string path = "testCert.pfx";
57+
string password = "password";
58+
string description = "desc";
59+
60+
var secureString = new SecureString();
61+
Array.ForEach(password.ToCharArray(), secureString.AppendChar);
62+
secureString.MakeReadOnly();
63+
64+
this.mockAutomationClient.Setup(
65+
f => f.CreateCertificate(accountName, certificateName, path, secureString, description, false));
66+
67+
this.cmdlet.AutomationAccountName = accountName;
68+
this.cmdlet.Name = certificateName;
69+
this.cmdlet.Description = description;
70+
this.cmdlet.Path = path;
71+
this.cmdlet.Password = secureString;
72+
this.cmdlet.ExecuteCmdlet();
73+
74+
// Assert
75+
this.mockAutomationClient.Verify(f => f.CreateCertificate(accountName, certificateName, path, secureString, description, false), Times.Once());
76+
}
77+
}
78+
}

src/ServiceManagement/Automation/Commands.Automation.Test/UnitTests/NewAzureAutomationRunbookTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void NewAzureAutomationRunbookByNameSuccessfull()
8585
this.cmdlet.Name = runbookName;
8686
this.cmdlet.Description = description;
8787
this.cmdlet.Tags = tags;
88-
this.cmdlet.SetParameterSet("ByName");
88+
this.cmdlet.SetParameterSet("ByRunbookName");
8989
this.cmdlet.ExecuteCmdlet();
9090

9191
// Assert

0 commit comments

Comments
 (0)