Skip to content

Commit 2321bdb

Browse files
committed
Comments and class resources cleanup
1 parent 7e23309 commit 2321bdb

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
lines changed

src/ResourceManager/Profile/Commands.Profile/Account/AddAzureRmAccount.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected override void ProcessRecord()
103103
{
104104
if (string.IsNullOrWhiteSpace(AccountId) )
105105
{
106-
throw new PSInvalidOperationException("Access token credentials must contain AccountId parameter.");
106+
throw new PSInvalidOperationException(Resources.AccountIdRequired);
107107
}
108108

109109
azureAccount.Type = AzureAccount.AccountType.AccessToken;
@@ -138,7 +138,8 @@ protected override void ProcessRecord()
138138

139139
var profileClient = new RMProfileClient(AzureRmProfileProvider.Instance.Profile);
140140

141-
WriteObject((PSAzureProfile)profileClient.Login(azureAccount, Environment, Tenant, SubscriptionId, SubscriptionName, password));
141+
WriteObject((PSAzureProfile)profileClient.Login(azureAccount, Environment, Tenant, SubscriptionId,
142+
SubscriptionName, password));
142143
}
143144

144145
/// <summary>

src/ResourceManager/Profile/Commands.Profile/Models/RMProfileClient.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ public RMProfileClient(AzureRMProfile profile)
4545
}
4646
}
4747

48-
public AzureRMProfile Login(AzureAccount account, AzureEnvironment environment, string tenantId, string subscriptionId, string subscriptionName, SecureString password)
48+
public AzureRMProfile Login(AzureAccount account, AzureEnvironment environment, string tenantId, string subscriptionId,
49+
string subscriptionName, SecureString password)
4950
{
5051
AzureSubscription newSubscription = null;
5152
AzureTenant newTenant = null;
52-
ShowDialog promptBehavior = (password == null && account.Type != AzureAccount.AccountType.AccessToken) ? ShowDialog.Always : ShowDialog.Never;
53+
ShowDialog promptBehavior = (password == null && account.Type != AzureAccount.AccountType.AccessToken)
54+
? ShowDialog.Always : ShowDialog.Never;
5355

5456
// (tenant and subscription are present) OR
5557
// (tenant is present and subscription is not provided)

src/ResourceManager/Profile/Commands.Profile/Models/SimpleAccessToken.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,25 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16+
using Microsoft.Azure.Commands.Profile.Properties;
1617
using Microsoft.Azure.Common.Authentication;
1718
using Microsoft.Azure.Common.Authentication.Models;
1819

1920
namespace Microsoft.Azure.Commands.Profile.Models
2021
{
22+
/// <summary>
23+
/// Provides access token information for a bearer token
24+
/// </summary>
2125
public class SimpleAccessToken : IAccessToken
2226
{
2327
public const string _defaultTokenType = "Bearer";
2428
private string _tokenType;
2529

30+
/// <summary>
31+
/// Create a new access token from the given account and tenant id
32+
/// </summary>
33+
/// <param name="account">The account, containign user id, access token information</param>
34+
/// <param name="tenantId">The tenant id for the given access token</param>
2635
public SimpleAccessToken(AzureAccount account, string tenantId)
2736
{
2837
if (account == null)
@@ -31,12 +40,12 @@ public SimpleAccessToken(AzureAccount account, string tenantId)
3140
}
3241
if (string.IsNullOrWhiteSpace(account.Id))
3342
{
34-
throw new ArgumentOutOfRangeException("account", "AccountId must be provided to use an AccessToken credential.");
43+
throw new ArgumentOutOfRangeException("account", Resources.AccessTokenRequiresAccount);
3544
}
3645
if (account.Type != AzureAccount.AccountType.AccessToken ||
3746
!account.IsPropertySet(AzureAccount.Property.AccessToken))
3847
{
39-
throw new ArgumentException("To create an access token credential, you must provide an access token account");
48+
throw new ArgumentException(Resources.TypeNotAccessToken);
4049
}
4150
this.UserId = account.Id;
4251
this._tokenType = _defaultTokenType;

src/ResourceManager/Profile/Commands.Profile/Properties/Resources.Designer.cs

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/Profile/Commands.Profile/Properties/Resources.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120+
<data name="AccessTokenRequiresAccount" xml:space="preserve">
121+
<value>AccountId must be provided to use an AccessToken credential.</value>
122+
</data>
123+
<data name="AccountIdRequired" xml:space="preserve">
124+
<value>Access token credentials must provide the AccountId parameter.</value>
125+
</data>
120126
<data name="AzureProfileMustNotBeNull" xml:space="preserve">
121127
<value>Selected profile must not be null.</value>
122128
</data>
@@ -141,4 +147,7 @@
141147
<data name="TenantAuthFailed" xml:space="preserve">
142148
<value>Could not authenticate with tenant {0}. Please ensure that your account has access to this tenant and log in with Login-AzureRmAccount</value>
143149
</data>
150+
<data name="TypeNotAccessToken" xml:space="preserve">
151+
<value>To create an access token credential, you must provide an access token account.</value>
152+
</data>
144153
</root>

0 commit comments

Comments
 (0)