forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix access error when subscripiton has no Tags property
- Fix the issue Azure#15425 - Add related test cases
- Loading branch information
Showing
4 changed files
with
84 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -49,5 +49,70 @@ public void NewPSAzureSubscription() | |
Assert.Equal(psAzureSubscription.SubscriptionPolicies.QuotaId, quotaId); | ||
Assert.Equal(psAzureSubscription.SubscriptionPolicies.SpendingLimit, spendingLimit.ToString()); | ||
} | ||
|
||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void ConvertAzureSubscripitonToPSAzureSubscriptionWithTags() | ||
{ | ||
string tenants = new Guid().ToString(), homeTenant = new Guid().ToString(); | ||
var subscription = new AzureSubscription() | ||
{ | ||
Id = new Guid().ToString(), | ||
Name = "Playground-01", | ||
State = "Enabled", | ||
ExtendedProperties = | ||
{ | ||
{ "SubscriptionPolices", @"{""locationPlacementId"":""Internal_2014-09-01"",""quotaId"":""Internal_2014-09-01"",""spendingLimit"":""Off""}" }, | ||
{ "Environment", "AzureCloud" }, | ||
{ "AuthorizationSource", "RoleBased" }, | ||
{ "Account", "[email protected]" }, | ||
{ "ManagedByTenants", tenants }, | ||
{ "Tenants", tenants }, | ||
{ "Tags", @"{""CigdemTestTag"":""Enabled""}" }, | ||
{ "HomeTenant", homeTenant } | ||
} | ||
}; | ||
|
||
var psSubscription = new PSAzureSubscription(subscription); | ||
Assert.Equal(subscription.Id, psSubscription.Id); | ||
Assert.Equal(subscription.Name, psSubscription.Name); | ||
Assert.Equal(subscription.State, psSubscription.State); | ||
Assert.Equal(homeTenant, psSubscription.TenantId); | ||
Assert.Equal(homeTenant, psSubscription.HomeTenantId); | ||
Assert.Equal("Internal_2014-09-01", psSubscription.SubscriptionPolicies.LocationPlacementId); | ||
Assert.Single(psSubscription.Tags); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void ConvertAzureSubscripitonToPSAzureSubscriptionWithoutTags() | ||
{ | ||
string tenants = new Guid().ToString(), homeTenant = new Guid().ToString(); | ||
var subscription = new AzureSubscription() | ||
{ | ||
Id = new Guid().ToString(), | ||
Name = "Playground-01", | ||
State = "Enabled", | ||
ExtendedProperties = | ||
{ | ||
{ "SubscriptionPolices", @"{""locationPlacementId"":""Internal_2014-09-01"",""quotaId"":""Internal_2014-09-01"",""spendingLimit"":""Off""}" }, | ||
{ "AuthorizationSource", "RoleBased" }, | ||
{ "Account", "[email protected]" }, | ||
{ "ManagedByTenants", tenants }, | ||
{ "Tenants", tenants }, | ||
{ "HomeTenant", homeTenant } | ||
} | ||
}; | ||
|
||
var psSubscription = new PSAzureSubscription(subscription); | ||
Assert.Equal(subscription.Id, psSubscription.Id); | ||
Assert.Equal(subscription.Name, psSubscription.Name); | ||
Assert.Equal(subscription.State, psSubscription.State); | ||
Assert.Equal(homeTenant, psSubscription.TenantId); | ||
Assert.Equal(homeTenant, psSubscription.HomeTenantId); | ||
Assert.Equal("Internal_2014-09-01", psSubscription.SubscriptionPolicies.LocationPlacementId); | ||
Assert.Null(psSubscription.Tags); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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