Skip to content

Commit d7f45c4

Browse files
committed
Complete basic tests for SubscriptionDefinition cmdlets.
1 parent ccfd71a commit d7f45c4

File tree

7 files changed

+14881
-17
lines changed

7 files changed

+14881
-17
lines changed

src/ResourceManager/SubscriptionDefinition/Commands.SubscriptionDefinition.Test/ScenarioTests/SubscriptionDefinitionTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1818
using Xunit;
1919
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
20+
using Microsoft.Azure.Test;
21+
using System;
2022

2123
namespace Microsoft.Azure.Commands.SubscriptionDefinition.Test.ScenarioTests
2224
{
@@ -30,7 +32,7 @@ public SubscriptionDefinitionTests(Xunit.Abstractions.ITestOutputHelper output)
3032
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
3133
TestExecutionHelpers.SetUpSessionAndProfile();
3234
}
33-
35+
3436
[Fact]
3537
[Trait(Category.AcceptanceType, Category.CheckIn)]
3638
public void TestListSubscriptionDefinitions()
@@ -42,7 +44,7 @@ public void TestListSubscriptionDefinitions()
4244
[Trait(Category.AcceptanceType, Category.CheckIn)]
4345
public void TestGetSubscriptionDefinitionByName()
4446
{
45-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetSubscriptionDefinitionInGroupScope");
47+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetSubscriptionDefinitionByName");
4648
}
4749
[Fact]
4850
[Trait(Category.AcceptanceType, Category.CheckIn)]

src/ResourceManager/SubscriptionDefinition/Commands.SubscriptionDefinition.Test/ScenarioTests/SubscriptionDefinitionTests.ps1

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function Test-ListSubscriptionDefinitions
2020
{
2121
$definitions = Get-AzureRmSubscriptionDefinition
2222

23-
Assert-AreEqual 3 $definitions.Count
23+
Assert-AreEqual 4 $definitions.Count
2424
Foreach($def in $definitions)
2525
{
2626
Assert-NotNull $def.Name
@@ -33,8 +33,9 @@ Get subscription definition by name
3333
#>
3434
function Test-GetSubscriptionDefinitionByName
3535
{
36-
$definition = Get-AzureRmSubscriptionDefinition -Name "mySubDef"
37-
Assert-AreEqual "mySubDef", $definition.Name
36+
$definition = Get-AzureRmSubscriptionDefinition -Name "MyProdSubscription"
37+
Assert-AreEqual "MyProdSubscription" $definition.Name
38+
Assert-AreEqual "MyProdSubscription" $definition.SubscriptionDisplayName
3839
}
3940

4041
<#
@@ -46,11 +47,14 @@ function Test-NewSubscriptionDefinition
4647
$definitions = Get-AzureRmSubscriptionDefinition
4748
$previousDefinitionCount = $definitions.Count
4849

49-
$definition = New-AzureRmSubscriptionDefinition -Name "myNewSubDef" -OfferType "MS-AZR-0017P"
50+
$myNewSubDefName = "MyProdSubDef99"
5051

51-
Assert-NotNull $definition.Name
52+
$definition = New-AzureRmSubscriptionDefinition -Name $myNewSubDefName -OfferType "MS-AZR-0017P"
53+
54+
Assert-AreEqual $myNewSubDefName $definition.Name
55+
Assert-AreEqual $myNewSubDefName $definition.SubscriptionDisplayName
5256
Assert-NotNull $definition.SubscriptionId
5357

5458
$definitions = Get-AzureRmSubscriptionDefinition
55-
Assert-AreEqual $definitions.Count, ($previousDefinitionCount + 1)
59+
Assert-AreEqual $definitions.Count ($previousDefinitionCount + 1)
5660
}

src/ResourceManager/SubscriptionDefinition/Commands.SubscriptionDefinition.Test/ScenarioTests/TestController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,16 @@ public void RunPsTestWorkflow(
115115

116116
using (var context = MockContext.Start(callingClassType, mockName))
117117
{
118+
// NOTE: Uncomment to force interactive login when you need to record tests.
119+
// var x = Rest.Azure.Authentication.UserTokenProvider.LoginWithPromptAsync(new Rest.Azure.Authentication.ActiveDirectoryClientSettings(clientId: "1950a258-227b-4e31-a9cf-717495945fc2", clientRedirectUri: new Uri("urn:ietf:wg:oauth:2.0:oob")), "[email protected]").Result;
118120

119121
_csmTestFactory = new CSMTestEnvironmentFactory();
120122

121123
if (initialize != null)
122124
{
123125
initialize(_csmTestFactory);
124126
}
125-
127+
126128
SetupManagementClients(context);
127129

128130
_helper.SetupEnvironment(AzureModule.AzureResourceManager);
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,77 @@
11
{
2-
"foo": "bar"
2+
"Entries": [
3+
{
4+
"RequestUri": "/providers/Microsoft.Subscription/subscriptionDefinitions/MyProdSubscription?api-version=2017-11-01-preview",
5+
"EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL3N1YnNjcmlwdGlvbkRlZmluaXRpb25zL015UHJvZFN1YnNjcmlwdGlvbj9hcGktdmVyc2lvbj0yMDE3LTExLTAxLXByZXZpZXc=",
6+
"RequestMethod": "GET",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"x-ms-client-request-id": [
10+
"8c346b47-e8fa-4b2b-940b-dccca378e876"
11+
],
12+
"accept-language": [
13+
"en-US"
14+
],
15+
"User-Agent": [
16+
"FxVersion/4.7.2556.0",
17+
"OSName/Windows_10_Enterprise",
18+
"OSVersion/6.3.16299",
19+
"Microsoft.Azure.Management.ResourceManager.SubscriptionDefinitionsClient/1.6.0-preview"
20+
]
21+
},
22+
"ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Subscription/subscriptionDefinitions/MyProdSubscription\",\r\n \"name\": \"MyProdSubscription\",\r\n \"properties\": {\r\n \"etag\": \"MfjP0w==\",\r\n \"subscriptionDisplayName\": \"MyProdSubscription\",\r\n \"subscriptionId\": \"86869d42-1782-4337-98b0-c905fb937d46\",\r\n \"offerType\": \"MS-AZR-0017P\"\r\n },\r\n \"type\": \"Microsoft.Subscription/subscriptionDefinitions\"\r\n}",
23+
"ResponseHeaders": {
24+
"Content-Length": [
25+
"332"
26+
],
27+
"Content-Type": [
28+
"application/json; charset=utf-8"
29+
],
30+
"Expires": [
31+
"-1"
32+
],
33+
"Pragma": [
34+
"no-cache"
35+
],
36+
"x-content-type-options": [
37+
"nosniff"
38+
],
39+
"Strict-Transport-Security": [
40+
"max-age=31536000; includeSubDomains"
41+
],
42+
"x-ms-ratelimit-remaining-tenant-reads": [
43+
"14999"
44+
],
45+
"x-ms-request-id": [
46+
"30080cab-b277-45fb-ba65-a19a71866cc9"
47+
],
48+
"x-ms-correlation-request-id": [
49+
"30080cab-b277-45fb-ba65-a19a71866cc9"
50+
],
51+
"x-ms-routing-request-id": [
52+
"WESTUS2:20171123T073847Z:30080cab-b277-45fb-ba65-a19a71866cc9"
53+
],
54+
"Cache-Control": [
55+
"no-cache"
56+
],
57+
"Date": [
58+
"Thu, 23 Nov 2017 07:38:47 GMT"
59+
],
60+
"Server": [
61+
"Microsoft-IIS/8.5"
62+
],
63+
"X-AspNet-Version": [
64+
"4.0.30319"
65+
],
66+
"X-Powered-By": [
67+
"ASP.NET"
68+
]
69+
},
70+
"StatusCode": 200
71+
}
72+
],
73+
"Names": {},
74+
"Variables": {
75+
"SubscriptionId": "430ed244-e513-4b13-b113-e877158ed7f5"
76+
}
377
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,77 @@
11
{
2-
"foo": "bar"
2+
"Entries": [
3+
{
4+
"RequestUri": "/providers/Microsoft.Subscription/subscriptionDefinitions?api-version=2017-11-01-preview",
5+
"EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL3N1YnNjcmlwdGlvbkRlZmluaXRpb25zP2FwaS12ZXJzaW9uPTIwMTctMTEtMDEtcHJldmlldw==",
6+
"RequestMethod": "GET",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"x-ms-client-request-id": [
10+
"fbeb25a7-aa70-4f2f-981e-6e908f5d0280"
11+
],
12+
"accept-language": [
13+
"en-US"
14+
],
15+
"User-Agent": [
16+
"FxVersion/4.7.2556.0",
17+
"OSName/Windows_10_Enterprise",
18+
"OSVersion/6.3.16299",
19+
"Microsoft.Azure.Management.ResourceManager.SubscriptionDefinitionsClient/1.6.0-preview"
20+
]
21+
},
22+
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Subscription/subscriptionDefinitions/MyProdSubscription\",\r\n \"name\": \"MyProdSubscription\",\r\n \"properties\": {\r\n \"etag\": \"MfjP0w==\",\r\n \"subscriptionDisplayName\": \"MyProdSubscription\",\r\n \"subscriptionId\": \"86869d42-1782-4337-98b0-c905fb937d46\",\r\n \"offerType\": \"MS-AZR-0017P\"\r\n },\r\n \"type\": \"Microsoft.Subscription/subscriptionDefinitions\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Subscription/subscriptionDefinitions/e2esubprod1\",\r\n \"name\": \"e2esubprod1\",\r\n \"properties\": {\r\n \"etag\": \"To8acg==\",\r\n \"subscriptionDisplayName\": \"mye2esubprod1\",\r\n \"subscriptionId\": \"430ed244-e513-4b13-b113-e877158ed7f5\",\r\n \"offerType\": \"MS-AZR-0017P\"\r\n },\r\n \"type\": \"Microsoft.Subscription/subscriptionDefinitions\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Subscription/subscriptionDefinitions/e2esubprod6\",\r\n \"name\": \"e2esubprod6\",\r\n \"properties\": {\r\n \"etag\": \"YRP88g==\",\r\n \"subscriptionDisplayName\": \"e2esubprod6\",\r\n \"subscriptionId\": \"a21087f6-05f2-4be3-a831-185aad424df6\",\r\n \"offerType\": \"MS-AZR-0148P\"\r\n },\r\n \"type\": \"Microsoft.Subscription/subscriptionDefinitions\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Subscription/subscriptionDefinitions/e2esubprod7\",\r\n \"name\": \"e2esubprod7\",\r\n \"properties\": {\r\n \"etag\": \"DqdLvg==\",\r\n \"subscriptionDisplayName\": \"e2esubprod7\",\r\n \"subscriptionId\": \"519fce51-f304-4f10-9d03-777b7c47c8f0\",\r\n \"offerType\": \"MS-AZR-0148P\"\r\n },\r\n \"type\": \"Microsoft.Subscription/subscriptionDefinitions\"\r\n }\r\n ]\r\n}",
23+
"ResponseHeaders": {
24+
"Content-Length": [
25+
"1282"
26+
],
27+
"Content-Type": [
28+
"application/json; charset=utf-8"
29+
],
30+
"Expires": [
31+
"-1"
32+
],
33+
"Pragma": [
34+
"no-cache"
35+
],
36+
"x-content-type-options": [
37+
"nosniff"
38+
],
39+
"Strict-Transport-Security": [
40+
"max-age=31536000; includeSubDomains"
41+
],
42+
"x-ms-ratelimit-remaining-tenant-reads": [
43+
"14998"
44+
],
45+
"x-ms-request-id": [
46+
"e914624d-5e6f-4dd8-92dc-162d876085d1"
47+
],
48+
"x-ms-correlation-request-id": [
49+
"e914624d-5e6f-4dd8-92dc-162d876085d1"
50+
],
51+
"x-ms-routing-request-id": [
52+
"WESTUS2:20171123T073143Z:e914624d-5e6f-4dd8-92dc-162d876085d1"
53+
],
54+
"Cache-Control": [
55+
"no-cache"
56+
],
57+
"Date": [
58+
"Thu, 23 Nov 2017 07:31:43 GMT"
59+
],
60+
"Server": [
61+
"Microsoft-IIS/8.5"
62+
],
63+
"X-AspNet-Version": [
64+
"4.0.30319"
65+
],
66+
"X-Powered-By": [
67+
"ASP.NET"
68+
]
69+
},
70+
"StatusCode": 200
71+
}
72+
],
73+
"Names": {},
74+
"Variables": {
75+
"SubscriptionId": "430ed244-e513-4b13-b113-e877158ed7f5"
76+
}
377
}

0 commit comments

Comments
 (0)