Skip to content

Commit 59a8eaa

Browse files
authored
New Subscription RP cmdlets (#12830)
* New cmdlets * Adding new create sub cmdlets * Minor changes * Removing files * Removing redundant code * Updated help * Updated help * Updated tests * Update ChangeLog.md
1 parent 13b00fe commit 59a8eaa

22 files changed

+866
-523
lines changed

src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ public SubscriptionTests(Xunit.Abstractions.ITestOutputHelper output)
3434
XunitTracingInterceptor.AddToContext(_logger);
3535
TestExecutionHelpers.SetUpSessionAndProfile();
3636
}
37-
38-
[Fact]
39-
[Trait(Category.AcceptanceType, Category.CheckIn)]
40-
public void TestNewSubscription()
41-
{
42-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewSubscription");
43-
}
4437

4538
[Fact]
4639
[Trait(Category.AcceptanceType, Category.CheckIn)]
@@ -55,5 +48,26 @@ public void TestUpdateCancelSubscription()
5548
{
5649
TestController.NewInstance.RunPowerShellTest(_logger, "Test-UpdateCancelSubscription");
5750
}
51+
52+
[Fact]
53+
[Trait(Category.AcceptanceType, Category.CheckIn)]
54+
public void TestNewSubscriptionAlias()
55+
{
56+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewSubscriptionAlias");
57+
}
58+
59+
[Fact]
60+
[Trait(Category.AcceptanceType, Category.CheckIn)]
61+
public void TestGetSubscriptionAlias()
62+
{
63+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetSubscriptionAlias");
64+
}
65+
66+
[Fact]
67+
[Trait(Category.AcceptanceType, Category.CheckIn)]
68+
public void TestRemoveSubscriptionAlias()
69+
{
70+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-RemoveSubscriptionAlias");
71+
}
5872
}
5973
}

src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,9 @@
1616
.SYNOPSIS
1717
Create subscription
1818
#>
19-
function Test-NewSubscription
20-
{
21-
# $accounts = Get-AzEnrollmentAccount
22-
$accounts = @(@{ ObjectId = "455fd0a7-b04e-4a92-9e1b-d0650c8ba276" })
23-
24-
# Verify the caller has at least one enrollment account.
25-
Assert-True { $accounts.Count -gt 0 }
26-
27-
$myNewSubName = GetAssetName
28-
29-
$newSub = New-AzSubscription -EnrollmentAccountObjectId $accounts[0].ObjectId -Name $myNewSubName -OfferType MS-AZR-0017P
30-
31-
Assert-AreEqual $myNewSubName $newSub.Name
32-
Assert-NotNull $newSub.SubscriptionId
33-
}
34-
3519
function Test-UpdateRenameSubscription
3620
{
37-
$subId = "21cba39d-cbbc-487f-9749-43c5c960f269"
21+
$subId = "bc085fce-1a23-4734-b588-7c36b622317e"
3822

3923
$updateSub = Update-AzSubscription -SubscriptionId $subId -Action "Rename" -Name "RenameFromPowershell"
4024

@@ -43,9 +27,39 @@ function Test-UpdateRenameSubscription
4327

4428
function Test-UpdateCancelSubscription
4529
{
46-
$subId = "21cba39d-cbbc-487f-9749-43c5c960f269"
30+
$subId = "bc085fce-1a23-4734-b588-7c36b622317e"
4731

4832
$updateSub = Update-AzSubscription -SubscriptionId $subId -Action "Cancel"
4933

5034
Assert-NotNull updateSub.SubscriptionId
5135
}
36+
37+
function Test-NewSubscriptionAlias
38+
{
39+
$aliasName = "navyprod1"
40+
$displayName = "testSub1"
41+
$billingScope ="billingScope"
42+
$workload = "Production"
43+
44+
$newsub = New-AzSubscriptionAlias -AliasName $aliasName -SubscriptionName $displayName -BillingScope $billingScope -Workload $workload
45+
46+
Assert-NotNull newsub
47+
}
48+
49+
function Test-GetSubscriptionAlias
50+
{
51+
$aliasName = "navyprod1"
52+
53+
$newsub = Get-AzSubscriptionAlias -AliasName $aliasName
54+
55+
Assert-NotNull newsub
56+
}
57+
58+
function Test-RemoveSubscriptionAlias
59+
{
60+
$aliasName = "navyprod1"
61+
62+
$newsub = Remove-AzSubscriptionAlias -AliasName $aliasName
63+
64+
Assert-NotNull newsub
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/providers/Microsoft.Subscription/aliases/navyprod1?api-version=2020-09-01",
5+
"EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL2FsaWFzZXMvbmF2eXByb2QxP2FwaS12ZXJzaW9uPTIwMjAtMDktMDE=",
6+
"RequestMethod": "GET",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"x-ms-client-request-id": [
10+
"39c471c0-9fd7-434d-8947-38ed4d2be60f"
11+
],
12+
"Accept-Language": [
13+
"en-US"
14+
],
15+
"User-Agent": [
16+
"FxVersion/4.6.29130.01",
17+
"OSName/Windows",
18+
"OSVersion/Microsoft.Windows.10.0.19041.",
19+
"Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.5.0"
20+
]
21+
},
22+
"ResponseHeaders": {
23+
"Cache-Control": [
24+
"no-cache"
25+
],
26+
"Pragma": [
27+
"no-cache"
28+
],
29+
"Vary": [
30+
"Accept-Encoding"
31+
],
32+
"x-ms-ratelimit-remaining-tenant-reads": [
33+
"11999"
34+
],
35+
"x-ms-correlation-request-id": [
36+
"68f53ee5-2184-430d-90ff-f0afcf2d9b69"
37+
],
38+
"request-id": [
39+
"68f53ee5-2184-430d-90ff-f0afcf2d9b69"
40+
],
41+
"x-gsm": [
42+
"1.0.0.0"
43+
],
44+
"X-Content-Type-Options": [
45+
"nosniff"
46+
],
47+
"Server": [
48+
"Microsoft-IIS/10.0"
49+
],
50+
"X-AspNet-Version": [
51+
"4.0.30319"
52+
],
53+
"X-Powered-By": [
54+
"ASP.NET"
55+
],
56+
"x-ms-request-id": [
57+
"68f53ee5-2184-430d-90ff-f0afcf2d9b69"
58+
],
59+
"x-ms-routing-request-id": [
60+
"WESTUS:20200901T220819Z:68f53ee5-2184-430d-90ff-f0afcf2d9b69"
61+
],
62+
"Strict-Transport-Security": [
63+
"max-age=31536000; includeSubDomains"
64+
],
65+
"Date": [
66+
"Tue, 01 Sep 2020 22:08:18 GMT"
67+
],
68+
"Content-Length": [
69+
"222"
70+
],
71+
"Content-Type": [
72+
"application/json; charset=utf-8"
73+
],
74+
"Expires": [
75+
"-1"
76+
]
77+
},
78+
"ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Subscription/aliases/navyprod1\",\r\n \"name\": \"navyprod1\",\r\n \"type\": \"Microsoft.Subscription/aliases\",\r\n \"properties\": {\r\n \"subscriptionId\": \"cef41c82-c4f0-48ae-a336-2ec44ec4375a\",\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}",
79+
"StatusCode": 200
80+
}
81+
],
82+
"Names": {},
83+
"Variables": {
84+
"SubscriptionId": "5b47c35e-863f-4c66-ba9f-52b9d0ced037"
85+
}
86+
}

0 commit comments

Comments
 (0)