Skip to content

Commit 66eb3ee

Browse files
author
Hovsep Mkrtchyan
committed
Fixed "Set-AzureSubscription should accept pipeline objects" #429
1 parent 04f2f8d commit 66eb3ee

File tree

5 files changed

+115
-6
lines changed

5 files changed

+115
-6
lines changed

src/ServiceManagement/Profile/Commands.Profile/Subscription/SetAzureSubscription.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@
2727

2828
namespace Microsoft.WindowsAzure.Commands.Profile
2929
{
30-
31-
3230
/// <summary>
3331
/// Sets an azure subscription.
3432
/// </summary>
35-
[Cmdlet(VerbsCommon.Set, "AzureSubscription"), OutputType(typeof(AzureSubscription))]
33+
[Cmdlet(VerbsCommon.Set, "AzureSubscription", DefaultParameterSetName = UpdateSubscriptionByIdParameterSet), OutputType(typeof(AzureSubscription))]
3634
public class SetAzureSubscriptionCommand : SubscriptionCmdletBase, IStorageContextProvider
3735
{
3836
private const string UpdateSubscriptionByIdParameterSet = "UpdateSubscriptionByIdParameterSetName";
@@ -60,11 +58,11 @@ public SetAzureSubscriptionCommand() : base(true)
6058
public string SubscriptionId { get; set; }
6159

6260
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
63-
HelpMessage = "Account subscription ID.", ParameterSetName = AddSubscriptionParameterSet)]
61+
HelpMessage = "X509 Certificate.", ParameterSetName = AddSubscriptionParameterSet)]
6462
[Parameter(ValueFromPipelineByPropertyName = true,
65-
HelpMessage = "Account subscription ID.", ParameterSetName = UpdateSubscriptionByIdParameterSet)]
63+
HelpMessage = "X509 Certificate.", ParameterSetName = UpdateSubscriptionByIdParameterSet)]
6664
[Parameter(Position = 0, ValueFromPipelineByPropertyName = true,
67-
HelpMessage = "Name of the subscription.", ParameterSetName = UpdateSubscriptionByNameParameterSet)]
65+
HelpMessage = "X509 Certificate.", ParameterSetName = UpdateSubscriptionByNameParameterSet)]
6866
public X509Certificate2 Certificate { get; set; }
6967

7068
[Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "Service endpoint.")]

src/ServiceManagement/Services/Commands.Test/Commands.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@
414414
<None Include="SessionRecords\Microsoft.Azure.Commands.Test.Profile.NewAzureProfileTests\TestMakeRdfeCallWithCreatedProfile.json">
415415
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
416416
</None>
417+
<None Include="SessionRecords\Microsoft.Azure.Commands.Test.Profile.SelectAzureSubscriptionTests\GetSubscriptionPipeToSetSubscription.json">
418+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
419+
</None>
417420
<None Include="SessionRecords\Microsoft.Azure.Commands.Test.Profile.SelectAzureSubscriptionTests\StorageAccountIsNotCleaned.json">
418421
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
419422
</None>

src/ServiceManagement/Services/Commands.Test/Profile/SelectAzureSubscriptionTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,12 @@ public void StorageAccountIsNotCleaned()
5151
{
5252
ProfileTestController.NewRdfeInstance.RunPsTest("Test-StorageAccountIsNotCleaned");
5353
}
54+
55+
[Fact]
56+
[Trait(Category.AcceptanceType, Category.CheckIn)]
57+
public void GetSubscriptionPipeToSetSubscription()
58+
{
59+
ProfileTestController.NewRdfeInstance.RunPsTest("Test-GetSubscriptionPipeToSetSubscription");
60+
}
5461
}
5562
}

src/ServiceManagement/Services/Commands.Test/Profile/SelectAzureSubscriptionTests.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,14 @@ function Test-StorageAccountIsNotCleaned
2323
$subscription = Get-AzureSubscription -SubscriptionId 2c224e7e-3ef5-431d-a57b-e71f4662e3a6
2424
Assert-NotNull $($subscription.CurrentStorageAccountName)
2525
}
26+
27+
<#
28+
.SYNOPSIS
29+
Tests creating new azure profile with access token
30+
#>
31+
function Test-GetSubscriptionPipeToSetSubscription
32+
{
33+
Get-AzureSubscription -Current | Set-AzureSubscription -CurrentStorageAccount teststorage1220
34+
$subscription = Get-AzureSubscription -Current
35+
Assert-NotNull $($subscription.CurrentStorageAccountName)
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/2c224e7e-3ef5-431d-a57b-e71f4662e3a6/services/storageservices/teststorage1220",
5+
"EncodedRequestUri": "LzJjMjI0ZTdlLTNlZjUtNDMxZC1hNTdiLWU3MWY0NjYyZTNhNi9zZXJ2aWNlcy9zdG9yYWdlc2VydmljZXMvdGVzdHN0b3JhZ2UxMjIw",
6+
"RequestMethod": "GET",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"x-ms-version": [
10+
"2014-10-01"
11+
],
12+
"User-Agent": [
13+
"Microsoft.WindowsAzure.Management.Storage.StorageManagementClient/5.0.0.0"
14+
]
15+
},
16+
"ResponseBody": "<StorageService xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <Url>https://management.core.windows.net/2c224e7e-3ef5-431d-a57b-e71f4662e3a6/services/storageservices/teststorage1220</Url>\r\n <ServiceName>teststorage1220</ServiceName>\r\n <StorageServiceProperties>\r\n <Description i:nil=\"true\" />\r\n <Location>West US</Location>\r\n <Label>dGVzdHN0b3JhZ2UxMjIw</Label>\r\n <Status>Created</Status>\r\n <Endpoints>\r\n <Endpoint>https://teststorage1220.blob.core.windows.net/</Endpoint>\r\n <Endpoint>https://teststorage1220.queue.core.windows.net/</Endpoint>\r\n <Endpoint>https://teststorage1220.table.core.windows.net/</Endpoint>\r\n <Endpoint>https://teststorage1220.file.core.windows.net/</Endpoint>\r\n </Endpoints>\r\n <GeoPrimaryRegion>West US</GeoPrimaryRegion>\r\n <StatusOfPrimary>Available</StatusOfPrimary>\r\n <GeoSecondaryRegion />\r\n <StatusOfSecondary />\r\n <CreationTime>2014-07-09T19:35:26Z</CreationTime>\r\n <CustomDomains />\r\n <AccountType>Standard_LRS</AccountType>\r\n </StorageServiceProperties>\r\n <ExtendedProperties>\r\n <ExtendedProperty>\r\n <Name>ResourceGroup</Name>\r\n <Value>Default-Storage-WestUS</Value>\r\n </ExtendedProperty>\r\n <ExtendedProperty>\r\n <Name>ResourceLocation</Name>\r\n <Value>West US</Value>\r\n </ExtendedProperty>\r\n </ExtendedProperties>\r\n <Capabilities>\r\n <Capability>PersistentVMRole</Capability>\r\n </Capabilities>\r\n</StorageService>",
17+
"ResponseHeaders": {
18+
"Content-Length": [
19+
"1293"
20+
],
21+
"Content-Type": [
22+
"application/xml; charset=utf-8"
23+
],
24+
"x-ms-servedbyregion": [
25+
"ussouth3"
26+
],
27+
"x-ms-request-id": [
28+
"64a608392568aa4b8597f8e1c1de417e"
29+
],
30+
"Cache-Control": [
31+
"no-cache"
32+
],
33+
"Date": [
34+
"Sat, 14 May 2016 00:43:05 GMT"
35+
],
36+
"Server": [
37+
"1.0.6198.373",
38+
"(rd_rdfe_stable.160510-1522)",
39+
"Microsoft-HTTPAPI/2.0"
40+
]
41+
},
42+
"StatusCode": 200
43+
},
44+
{
45+
"RequestUri": "/2c224e7e-3ef5-431d-a57b-e71f4662e3a6/services/storageservices/teststorage1220/keys",
46+
"EncodedRequestUri": "LzJjMjI0ZTdlLTNlZjUtNDMxZC1hNTdiLWU3MWY0NjYyZTNhNi9zZXJ2aWNlcy9zdG9yYWdlc2VydmljZXMvdGVzdHN0b3JhZ2UxMjIwL2tleXM=",
47+
"RequestMethod": "GET",
48+
"RequestBody": "",
49+
"RequestHeaders": {
50+
"x-ms-version": [
51+
"2014-10-01"
52+
],
53+
"User-Agent": [
54+
"Microsoft.WindowsAzure.Management.Storage.StorageManagementClient/5.0.0.0"
55+
]
56+
},
57+
"ResponseBody": "<StorageService xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <Url>https://management.core.windows.net/2c224e7e-3ef5-431d-a57b-e71f4662e3a6/services/storageservices/teststorage1220</Url>\r\n <StorageServiceKeys>\r\n <Primary>/hYt36JRM3StLgfEuTa4IOi9yWzKhBKhRY3V3WZjq97Fv/84wToozLuT0aVqioUtreSTBJMD+LXI4g5jI5MGWA==</Primary>\r\n <Secondary>R1oLky011b/RZa9K6qVWKpnSsLjHMqvupJfg+DsbAZJxi1nN6Toc9ZNUQjMskDxQkdHaXmYY00jVxr86v4QPww==</Secondary>\r\n </StorageServiceKeys>\r\n</StorageService>",
58+
"ResponseHeaders": {
59+
"Content-Length": [
60+
"518"
61+
],
62+
"Content-Type": [
63+
"application/xml; charset=utf-8"
64+
],
65+
"x-ms-servedbyregion": [
66+
"ussouth3"
67+
],
68+
"x-ms-request-id": [
69+
"e3954c128b6ba0c9955b90b86900f4af"
70+
],
71+
"Cache-Control": [
72+
"no-cache"
73+
],
74+
"Date": [
75+
"Sat, 14 May 2016 00:43:05 GMT"
76+
],
77+
"Server": [
78+
"1.0.6198.373",
79+
"(rd_rdfe_stable.160510-1522)",
80+
"Microsoft-HTTPAPI/2.0"
81+
]
82+
},
83+
"StatusCode": 200
84+
}
85+
],
86+
"Names": {},
87+
"Variables": {
88+
"SubscriptionId": "2c224e7e-3ef5-431d-a57b-e71f4662e3a6"
89+
}
90+
}

0 commit comments

Comments
 (0)