-
Notifications
You must be signed in to change notification settings - Fork 4k
Remove -all parameter from Get-AzureRMSubscription and Set-AzureRMContext #1194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b6f5de3
[#106772718] Search for subscription in all tenants when no tenantId …
507dd02
update test records
yugangw-msft 3349423
address review feedback
yugangw-msft b98745a
update help file
yugangw-msft 13f9592
Merge with changes introduced by other profile/subsccriptions work item
yugangw-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/ResourceManager/Common/Commands.ResourceManager.Common/GlobalSuppressions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// This file is used by Code Analysis to maintain SuppressMessage | ||
// attributes that are applied to this project. | ||
// Project-level suppressions either have no target or are given | ||
// a specific target and scoped to a namespace, type, member, etc. | ||
// | ||
// To add a suppression to this file, right-click the message in the | ||
// Code Analysis results, point to "Suppress Message", and click | ||
// "In Suppression File". | ||
// You do not need to add suppressions to this file manually. | ||
|
||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Scope = "type", Target = "Microsoft.Azure.Management.Internal.Resources.AuthorizationClient")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Scope = "type", Target = "Microsoft.Azure.Management.Internal.Resources.FeatureClient")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Scope = "type", Target = "Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient")] | ||
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Scope = "type", Target = "Microsoft.Azure.Internal.Subscriptions.SubscriptionClient")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,12 +46,12 @@ private static RMProfileClient SetupTestEnvironment(List<string> tenants, params | |
mock.MoqClients = true; | ||
AzureSession.ClientFactory = mock; | ||
var context = new AzureContext(new AzureSubscription() | ||
{ | ||
Account = DefaultAccount, | ||
Environment = EnvironmentName.AzureCloud, | ||
Id = DefaultSubscription, | ||
Name = DefaultSubscriptionName | ||
}, | ||
{ | ||
Account = DefaultAccount, | ||
Environment = EnvironmentName.AzureCloud, | ||
Id = DefaultSubscription, | ||
Name = DefaultSubscriptionName | ||
}, | ||
new AzureAccount() { Id = DefaultAccount, Type = AzureAccount.AccountType.User }, | ||
AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], | ||
new AzureTenant() { Domain = DefaultDomain, Id = DefaultTenant }); | ||
|
@@ -65,17 +65,24 @@ private static RMProfileClient SetupTestEnvironment(List<string> tenants, params | |
public void MultipleTenantsAndSubscriptionsSucceed() | ||
{ | ||
var tenants = new List<string> {Guid.NewGuid().ToString(), DefaultTenant.ToString()}; | ||
var firstList = new List<string> { DefaultSubscription.ToString(), Guid.NewGuid().ToString() }; | ||
var secondsubscriptionInTheFirstTenant = Guid.NewGuid().ToString(); | ||
var firstList = new List<string> { DefaultSubscription.ToString(), secondsubscriptionInTheFirstTenant}; | ||
var secondList = new List<string> { Guid.NewGuid().ToString()}; | ||
var client = SetupTestEnvironment(tenants, firstList, secondList); | ||
var thirdList = new List<string> { DefaultSubscription.ToString(), secondsubscriptionInTheFirstTenant }; | ||
var fourthList = new List<string> { DefaultSubscription.ToString(), secondsubscriptionInTheFirstTenant }; | ||
var client = SetupTestEnvironment(tenants, firstList, secondList, thirdList, fourthList); | ||
var subResults = new List<AzureSubscription>(client.ListSubscriptions()); | ||
Assert.Equal(3, subResults.Count); | ||
var tenantResults = client.ListTenants(); | ||
Assert.Equal(2, tenantResults.Count()); | ||
tenantResults = client.ListTenants(DefaultTenant.ToString()); | ||
Assert.Equal(1, tenantResults.Count()); | ||
AzureSubscription subValue; | ||
Assert.True(client.TryGetSubscription(DefaultTenant.ToString(), DefaultSubscription.ToString(), out subValue)); | ||
Assert.True(client.TryGetSubscriptionById(DefaultTenant.ToString(), DefaultSubscription.ToString(), out subValue)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
Assert.Equal(DefaultSubscription.ToString(), subValue.Id.ToString()); | ||
Assert.True(client.TryGetSubscriptionByName(DefaultTenant.ToString(), | ||
MockSubscriptionClientFactory.GetSubscriptionNameFromId(DefaultSubscription.ToString()), | ||
out subValue)); | ||
Assert.Equal(DefaultSubscription.ToString(), subValue.Id.ToString()); | ||
} | ||
|
||
|
@@ -84,16 +91,22 @@ public void MultipleTenantsAndSubscriptionsSucceed() | |
public void SingleTenantAndSubscriptionSucceeds() | ||
{ | ||
var tenants = new List<string> {DefaultTenant.ToString()}; | ||
var subscriptions = new List<string> {DefaultSubscription.ToString()}; | ||
var client = SetupTestEnvironment(tenants, subscriptions); | ||
var firstList = new List<string> {DefaultSubscription.ToString()}; | ||
var secondList = firstList; | ||
var thirdList = firstList; | ||
var client = SetupTestEnvironment(tenants, firstList, secondList, thirdList); | ||
var subResults = new List<AzureSubscription>(client.ListSubscriptions()); | ||
Assert.Equal(1, subResults.Count); | ||
var tenantResults = client.ListTenants(); | ||
Assert.Equal(1, tenantResults.Count()); | ||
tenantResults = client.ListTenants(DefaultTenant.ToString()); | ||
Assert.Equal(1, tenantResults.Count()); | ||
AzureSubscription subValue; | ||
Assert.True(client.TryGetSubscription(DefaultTenant.ToString(), DefaultSubscription.ToString(), out subValue)); | ||
Assert.True(client.TryGetSubscriptionById(DefaultTenant.ToString(), DefaultSubscription.ToString(), out subValue)); | ||
Assert.Equal(DefaultSubscription.ToString(), subValue.Id.ToString()); | ||
Assert.True(client.TryGetSubscriptionByName(DefaultTenant.ToString(), | ||
MockSubscriptionClientFactory.GetSubscriptionNameFromId(DefaultSubscription.ToString()), | ||
out subValue)); | ||
Assert.Equal(DefaultSubscription.ToString(), subValue.Id.ToString()); | ||
} | ||
|
||
|
@@ -102,12 +115,15 @@ public void SingleTenantAndSubscriptionSucceeds() | |
public void SubscriptionNotFoundDoesNotThrow() | ||
{ | ||
var tenants = new List<string> { DefaultTenant.ToString() }; | ||
var subscriptions = new List<string> { Guid.NewGuid().ToString() }; | ||
var client = SetupTestEnvironment(tenants, subscriptions); | ||
string randomSubscriptionId = Guid.NewGuid().ToString(); | ||
var firstList = new List<string> { randomSubscriptionId }; | ||
var secondList = firstList; | ||
var client = SetupTestEnvironment(tenants, firstList, secondList); | ||
var subResults = new List<AzureSubscription>(client.ListSubscriptions()); | ||
Assert.Equal(1, subResults.Count); | ||
AzureSubscription subValue; | ||
Assert.True(client.TryGetSubscription(DefaultTenant.ToString(), DefaultSubscription.ToString(), out subValue)); | ||
Assert.False(client.TryGetSubscriptionById(DefaultTenant.ToString(), DefaultSubscription.ToString(), out subValue)); | ||
Assert.False(client.TryGetSubscriptionByName("random-tenant", "random-subscription", out subValue)); | ||
} | ||
|
||
[Fact] | ||
|
@@ -127,10 +143,11 @@ public void NoSubscriptionsInListDoesNotThrow() | |
{ | ||
var tenants = new List<string> { DefaultTenant.ToString() }; | ||
var subscriptions = new List<string> () ; | ||
var client = SetupTestEnvironment(tenants, subscriptions); | ||
var client = SetupTestEnvironment(tenants, subscriptions, subscriptions); | ||
Assert.Equal(0, client.ListSubscriptions().Count()); | ||
AzureSubscription subValue; | ||
Assert.True(client.TryGetSubscription(DefaultTenant.ToString(), DefaultSubscription.ToString(), out subValue)); | ||
Assert.False(client.TryGetSubscriptionById(DefaultTenant.ToString(), DefaultSubscription.ToString(), out subValue)); | ||
Assert.False(client.TryGetSubscriptionByName(DefaultTenant.ToString(), "random-name", out subValue)); | ||
} | ||
|
||
[Fact] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also cover GetSUbscriptionByName in this test method, or add another unit test for this?