Skip to content

Commit 3fabf11

Browse files
author
Maddie Clayton
authored
Merge pull request #7063 from bganapa/network-2018
stack network module for 2018-03-01-hybrid profile
2 parents becd9a9 + 62d9c7f commit 3fabf11

File tree

1,064 files changed

+941322
-1832977
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,064 files changed

+941322
-1832977
lines changed

src/StackAdmin/Network/ChangeLog.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--
2+
Please leave this section at the top of the change log.
3+
4+
Changes for the current release should go under the section titled "Current Release", and should adhere to the following format:
5+
6+
## Current Release
7+
* Overview of change #1
8+
- Additional information about change #1
9+
* Overview of change #2
10+
- Additional information about change #2
11+
- Additional information about change #2
12+
* Overview of change #3
13+
* Overview of change #4
14+
- Additional information about change #4
15+
16+
## YYYY.MM.DD - Version X.Y.Z (Previous Release)
17+
* Overview of change #1
18+
- Additional information about change #1
19+
-->
20+
## Current Release

src/StackAdmin/Network/Commands.Network.Test/Commands.Network.Test.csproj

Lines changed: 229 additions & 10 deletions
Large diffs are not rendered by default.

src/StackAdmin/Network/Commands.Network.Test/NetworkResourcesController.cs

Lines changed: 101 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,23 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
16-
using System.Collections.Generic;
17-
using System.Linq;
15+
using Microsoft.Azure.Commands.Common.Authentication;
1816
using Microsoft.Azure.Gallery;
1917
using Microsoft.Azure.Management.Authorization;
18+
using Microsoft.Azure.Management.Compute;
19+
using Microsoft.Azure.Management.Insights;
2020
using Microsoft.Azure.Management.Network;
21+
using Microsoft.Azure.Management.Redis;
2122
using Microsoft.Azure.Management.Resources;
23+
using Microsoft.Azure.Management.Storage;
2224
using Microsoft.Azure.Subscriptions;
23-
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2425
using Microsoft.Azure.Test;
25-
using Microsoft.Azure.Commands.Common.Authentication;
2626
using Microsoft.Azure.Test.HttpRecorder;
27+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
28+
using System;
29+
using System.Collections.Generic;
30+
using System.IO;
31+
using System.Linq;
2732
using RestTestFramework = Microsoft.Rest.ClientRuntime.Azure.TestFramework;
2833

2934
namespace Commands.Network.Test
@@ -32,7 +37,7 @@ public sealed class NetworkResourcesController
3237
{
3338
private CSMTestEnvironmentFactory csmTestFactory;
3439
private EnvironmentSetupHelper helper;
35-
40+
3641
public ResourceManagementClient ResourceManagementClient { get; private set; }
3742

3843
public SubscriptionClient SubscriptionClient { get; private set; }
@@ -43,11 +48,16 @@ public sealed class NetworkResourcesController
4348

4449
public NetworkManagementClient NetworkManagementClient { get; private set; }
4550

46-
public Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient InternalResourceManagementClient { get; private set; }
47-
public Microsoft.Azure.Management.ResourceManager.ResourceManagementClient LegacyResourceManagementClient { get; private set; }
51+
public ComputeManagementClient ComputeManagementClient { get; private set; }
52+
53+
public StorageManagementClient StorageManagementClient { get; private set; }
4854

49-
public static NetworkResourcesController NewInstance
50-
{
55+
public InsightsManagementClient InsightsManagementClient { get; private set; }
56+
57+
public RedisManagementClient RedisManagementClient { get; private set; }
58+
59+
public static NetworkResourcesController NewInstance
60+
{
5161
get
5262
{
5363
return new NetworkResourcesController();
@@ -61,60 +71,68 @@ public NetworkResourcesController()
6171

6272
public void RunPsTest(params string[] scripts)
6373
{
74+
Dictionary<string, string> d = new Dictionary<string, string>();
75+
d.Add("Microsoft.Resources", null);
76+
d.Add("Microsoft.Compute", null);
77+
d.Add("Microsoft.Features", null);
78+
d.Add("Microsoft.Authorization", null);
79+
d.Add("Microsoft.Storage", null);
80+
var providersToIgnore = new Dictionary<string, string>();
81+
providersToIgnore.Add("Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01");
82+
providersToIgnore.Add("Microsoft.Azure.Management.Network.NetworkManagementClient", "2017-09-01");
83+
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
84+
6485
var callingClassType = TestUtilities.GetCallingClass(2);
6586
var mockName = TestUtilities.GetCurrentMethodName(2);
6687

6788
RunPsTestWorkflow(
68-
() => scripts,
89+
() => scripts,
6990
// no custom initializer
70-
null,
91+
null,
7192
// no custom cleanup
7293
null,
7394
callingClassType,
7495
mockName);
7596
}
7697

7798
public void RunPsTestWorkflow(
78-
Func<string[]> scriptBuilder,
79-
Action<CSMTestEnvironmentFactory> initialize,
99+
Func<string[]> scriptBuilder,
100+
Action<CSMTestEnvironmentFactory> initialize,
80101
Action cleanup,
81102
string callingClassType,
82103
string mockName)
83104
{
84-
Dictionary<string, string> d = new Dictionary<string, string>();
85-
d.Add("Microsoft.Resources", null);
86-
d.Add("Microsoft.Features", null);
87-
d.Add("Microsoft.Authorization", null);
88-
d.Add("Microsoft.Compute", null);
89-
var providersToIgnore = new Dictionary<string, string>();
90-
providersToIgnore.Add("Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01");
91-
providersToIgnore.Add("Microsoft.Azure.Management.ResourceManager.ResourceManagementClient", "2016-02-01");
92-
providersToIgnore.Add("Microsoft.Azure.Management.Storage.StorageManagementClient", "2015-06-15");
93-
94-
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
95-
105+
HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");
96106
using (RestTestFramework.MockContext context = RestTestFramework.MockContext.Start(callingClassType, mockName))
97107
{
98108
this.csmTestFactory = new CSMTestEnvironmentFactory();
99109

100-
if(initialize != null)
110+
if (initialize != null)
101111
{
102112
initialize(this.csmTestFactory);
103113
}
104114

105115
SetupManagementClients(context);
106116

107117
helper.SetupEnvironment(AzureModule.AzureResourceManager);
108-
118+
119+
var networkPath = helper.GetStackRMModulePath("AzureRM.Network");
120+
var computePath= helper.GetStackRMModulePath("AzureRM.Compute");
121+
109122
var callingClassName = callingClassType
110123
.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries)
111124
.Last();
112-
helper.SetupModules(AzureModule.AzureResourceManager,
113-
"ScenarioTests\\Common.ps1",
114-
"ScenarioTests\\" + callingClassName + ".ps1",
115-
helper.StackRMProfileModule,
116-
helper.StackRMResourceModule,
117-
helper.GetStackRMModulePath("AzureRM.Network.psd1"));
125+
helper.SetupModules(AzureModule.AzureResourceManager,
126+
"ScenarioTests\\Common.ps1",
127+
"ScenarioTests\\" + callingClassName + ".ps1",
128+
helper.StackRMProfileModule,
129+
helper.StackRMResourceModule,
130+
helper.GetRMModulePath("AzureRM.Insights.psd1"),
131+
helper.GetRMModulePath("AzureRM.RedisCache.psd1"),
132+
networkPath,
133+
computePath,
134+
helper.RMStorageDataPlaneModule,
135+
helper.StackRMStorageModule);
118136

119137
try
120138
{
@@ -130,32 +148,53 @@ public void RunPsTestWorkflow(
130148
}
131149
finally
132150
{
133-
if(cleanup !=null)
151+
if (cleanup != null)
134152
{
135153
cleanup();
136154
}
137155
}
138156
}
139157
}
140158

159+
private Microsoft.Azure.Management.Resources.ResourceManagementClient GetLegacyResourceManagementClient()
160+
{
161+
return Microsoft.Azure.Test.TestBase.GetServiceClient<Microsoft.Azure.Management.Resources.ResourceManagementClient>(this.csmTestFactory);
162+
}
163+
164+
private Microsoft.Azure.Subscriptions.SubscriptionClient GetLegacySubscriptionClient()
165+
{
166+
return Microsoft.Azure.Test.TestBase.GetServiceClient<Microsoft.Azure.Subscriptions.SubscriptionClient>(this.csmTestFactory);
167+
}
168+
169+
private Microsoft.Azure.Management.ResourceManager.ResourceManagementClient GetResourceManagerResourceManagementClient(RestTestFramework.MockContext context)
170+
{
171+
return context.GetServiceClient<Microsoft.Azure.Management.ResourceManager.ResourceManagementClient>(RestTestFramework.TestEnvironmentFactory.GetTestEnvironment());
172+
}
173+
141174
private void SetupManagementClients(RestTestFramework.MockContext context)
142175
{
176+
Microsoft.Azure.Management.ResourceManager.ResourceManagementClient ResourceManagerResourceManagementClient = GetResourceManagerResourceManagementClient(context);
143177
this.ResourceManagementClient = this.GetResourceManagementClient();
144178
this.SubscriptionClient = this.GetSubscriptionClient();
145-
InternalResourceManagementClient = GetInternalResourceManagementClient(context);
146-
LegacyResourceManagementClient = GetLegacyResourceManagementClient(context);
147179
this.GalleryClient = this.GetGalleryClient();
148180
this.NetworkManagementClient = this.GetNetworkManagementClient(context);
181+
this.ComputeManagementClient = this.GetComputeManagementClient(context);
182+
this.StorageManagementClient = this.GetStorageManagementClient(context);
149183
this.AuthorizationManagementClient = this.GetAuthorizationManagementClient();
184+
this.InsightsManagementClient = this.GetInsightsManagementClient();
185+
this.RedisManagementClient = this.GetRedisManagementClient(context);
150186

151187
helper.SetupManagementClients(
188+
ResourceManagerResourceManagementClient,
152189
ResourceManagementClient,
153-
InternalResourceManagementClient,
154-
LegacyResourceManagementClient,
155190
SubscriptionClient,
156191
GalleryClient,
157-
AuthorizationManagementClient,
158-
this.NetworkManagementClient);
192+
this.NetworkManagementClient,
193+
this.ComputeManagementClient,
194+
this.StorageManagementClient,
195+
this.AuthorizationManagementClient,
196+
this.InsightsManagementClient,
197+
this.RedisManagementClient);
159198
}
160199

161200
private AuthorizationManagementClient GetAuthorizationManagementClient()
@@ -167,15 +206,6 @@ private ResourceManagementClient GetResourceManagementClient()
167206
{
168207
return TestBase.GetServiceClient<ResourceManagementClient>(this.csmTestFactory);
169208
}
170-
private Microsoft.Azure.Management.ResourceManager.ResourceManagementClient GetLegacyResourceManagementClient(RestTestFramework.MockContext context)
171-
{
172-
return context.GetServiceClient<Microsoft.Azure.Management.ResourceManager.ResourceManagementClient>(Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory.GetTestEnvironment());
173-
}
174-
175-
private Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient GetInternalResourceManagementClient(RestTestFramework.MockContext context)
176-
{
177-
return context.GetServiceClient<Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient>(Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory.GetTestEnvironment());
178-
}
179209

180210
private SubscriptionClient GetSubscriptionClient()
181211
{
@@ -186,9 +216,30 @@ private NetworkManagementClient GetNetworkManagementClient(RestTestFramework.Moc
186216
{
187217
return context.GetServiceClient<NetworkManagementClient>(RestTestFramework.TestEnvironmentFactory.GetTestEnvironment());
188218
}
219+
220+
private StorageManagementClient GetStorageManagementClient(RestTestFramework.MockContext context)
221+
{
222+
return context.GetServiceClient<StorageManagementClient>(RestTestFramework.TestEnvironmentFactory.GetTestEnvironment());
223+
}
224+
189225
private GalleryClient GetGalleryClient()
190226
{
191227
return TestBase.GetServiceClient<GalleryClient>(this.csmTestFactory);
192228
}
229+
230+
private InsightsManagementClient GetInsightsManagementClient()
231+
{
232+
return TestBase.GetServiceClient<InsightsManagementClient>(this.csmTestFactory);
233+
}
234+
235+
private RedisManagementClient GetRedisManagementClient(RestTestFramework.MockContext context)
236+
{
237+
return context.GetServiceClient<RedisManagementClient>(RestTestFramework.TestEnvironmentFactory.GetTestEnvironment());
238+
}
239+
240+
private ComputeManagementClient GetComputeManagementClient(RestTestFramework.MockContext context)
241+
{
242+
return context.GetServiceClient<ComputeManagementClient>(RestTestFramework.TestEnvironmentFactory.GetTestEnvironment());
243+
}
193244
}
194245
}

src/StackAdmin/Network/Commands.Network.Test/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232

3333
[assembly: Guid("d1e9969e-7b83-4dfc-a7a2-523d4f7e6cc9")]
3434

35-
[assembly: AssemblyVersion("4.3.2")]
36-
[assembly: AssemblyFileVersion("4.3.2")]
35+
[assembly: AssemblyVersion("5.0.1")]
36+
[assembly: AssemblyFileVersion("5.0.1")]
3737
[assembly: CollectionBehavior(DisableTestParallelization = true)]
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 Microsoft.Azure.ServiceManagemenet.Common.Models;
17+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
19+
using Xunit;
20+
using Xunit.Abstractions;
21+
22+
namespace Commands.Network.Test.ScenarioTests
23+
{
24+
public class ApplicationGatewayTests : RMTestBase
25+
{
26+
public ApplicationGatewayTests(ITestOutputHelper output)
27+
{
28+
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
29+
}
30+
31+
[Fact]
32+
[Trait(Category.AcceptanceType, Category.CheckIn)]
33+
public void TestAvailableSslOptions()
34+
{
35+
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-AvailableSslOptions"));
36+
}
37+
38+
[Fact]
39+
[Trait(Category.AcceptanceType, Category.CheckIn)]
40+
public void TestAvailableWafRuleSets()
41+
{
42+
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-AvailableWafRuleSets"));
43+
}
44+
45+
[Fact]
46+
[Trait(Category.AcceptanceType, Category.CheckIn)]
47+
public void TestApplicationGatewayCRUD()
48+
{
49+
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-ApplicationGatewayCRUD -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
50+
}
51+
52+
[Fact]
53+
[Trait(Category.AcceptanceType, Category.CheckIn)]
54+
public void TestApplicationGatewayCRUD2()
55+
{
56+
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-ApplicationGatewayCRUD2 -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
57+
}
58+
}
59+
}

0 commit comments

Comments
 (0)