Skip to content

Update common code to 1.1.10, make changes for tenant directory removal #8057

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 1 commit into from
Dec 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,6 @@ public void LoadingProfileWorks()
var profile = new AzureRmProfile(path);
Assert.Equal(5, profile.Environments.Count());
Assert.Equal("3c0ff8a7-e8bb-40e8-ae66-271343379af6", profile.DefaultContext.Tenant.Id.ToString());
Assert.Equal("contoso.com", profile.DefaultContext.Tenant.Directory);
Assert.Equal("00000000-0000-0000-0000-000000000000", profile.DefaultContext.Subscription.Id.ToString());
Assert.Equal("testCloud", profile.DefaultContext.Environment.Name);
Assert.Equal("[email protected]", profile.DefaultContext.Account.Id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public static AzureRmProfile CreateAzureRMProfile(string storageAccount)
{
var tenantId = Guid.NewGuid();
var subscriptionId = Guid.NewGuid();
var domain = "Contoso.com";
var context = new PSAzureContext()
{
Account = new PSAzureRmAccount
Expand All @@ -66,7 +65,6 @@ public static AzureRmProfile CreateAzureRMProfile(string storageAccount)
},
Tenant = new PSAzureTenant
{
Directory = domain,
Id = tenantId.ToString()
}
};
Expand Down Expand Up @@ -148,7 +146,7 @@ public void CanClearStorageAccountForSMProfile(string connectionString, string e
Assert.True(string.IsNullOrEmpty(AzureSMProfileProvider.Instance.Profile.DefaultContext.GetCurrentStorageAccountName()));
});
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void CanClearStorageAccountForEmptyProfile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public void LoginWithSubscriptionAndTenant()
cmdlt.InvokeEndProcessing();

Assert.NotNull(AzureRmProfileProvider.Instance.Profile.DefaultContext);
Assert.Equal("microsoft.com", AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Directory);
}

[Fact]
Expand Down Expand Up @@ -140,7 +139,6 @@ public void LoginWithSubscriptionAndNoTenant()
cmdlt.InvokeEndProcessing();

Assert.NotNull(AzureRmProfileProvider.Instance.Profile.DefaultContext);
Assert.Equal("microsoft.com", AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Directory);
}

[Fact]
Expand All @@ -158,7 +156,6 @@ public void LoginWithNoSubscriptionAndNoTenant()
cmdlt.InvokeEndProcessing();

Assert.NotNull(AzureRmProfileProvider.Instance.Profile.DefaultContext);
Assert.Equal("microsoft.com", AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Directory);
}

[Fact]
Expand All @@ -177,7 +174,6 @@ public void LoginWithNoSubscriptionAndTenant()
cmdlt.InvokeEndProcessing();

Assert.NotNull(AzureRmProfileProvider.Instance.Profile.DefaultContext);
Assert.Equal("microsoft.com", AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Directory);
}

[Fact]
Expand All @@ -196,7 +192,6 @@ public void LoginWithNoSubscriptionAndTenantDomain()
cmdlt.InvokeEndProcessing();

Assert.NotNull(AzureRmProfileProvider.Instance.Profile.DefaultContext);
Assert.Equal("microsoft.com", AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Directory);
Assert.Equal("72f988bf-86f1-41af-91ab-2d7cd011db47", AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Id);
}

Expand All @@ -217,7 +212,6 @@ public void LoginWithSubscriptionname()
cmdlt.InvokeEndProcessing();

Assert.NotNull(AzureRmProfileProvider.Instance.Profile.DefaultContext);
Assert.Equal("microsoft.com", AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Directory);
}

[Fact]
Expand All @@ -237,7 +231,6 @@ public void LoginWithRbacTenantOnly()
cmdlt.InvokeEndProcessing();

Assert.NotNull(AzureRmProfileProvider.Instance.Profile.DefaultContext);
Assert.Equal("AzureSDKTeam.onmicrosoft.com", AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Directory);
Assert.Equal(cmdlt.Tenant, AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Id.ToString());
Assert.Null(AzureRmProfileProvider.Instance.Profile.DefaultContext.Subscription);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public void GetTenantWithTenantParameter()

Assert.True(commandRuntimeMock.OutputPipeline.Count == 2);
Assert.Equal("72f988bf-86f1-41af-91ab-2d7cd011db47", ((PSAzureTenant)commandRuntimeMock.OutputPipeline[1]).Id.ToString());
Assert.Equal("microsoft.com", ((PSAzureTenant)commandRuntimeMock.OutputPipeline[1]).Directory);
}

[Fact]
Expand All @@ -78,7 +77,6 @@ public void GetTenantWithDomainParameter()

Assert.True(commandRuntimeMock.OutputPipeline.Count == 3);
Assert.Equal("72f988bf-86f1-41af-91ab-2d7cd011db47", ((PSAzureTenant)commandRuntimeMock.OutputPipeline[1]).Id.ToString());
Assert.Equal("microsoft.com", ((PSAzureTenant)commandRuntimeMock.OutputPipeline[1]).Directory);
}

[Fact]
Expand All @@ -97,7 +95,6 @@ public void GetTenantWithoutParameters()

Assert.True(commandRuntimeMock.OutputPipeline.Count == 3);
Assert.Equal("72f988bf-86f1-41af-91ab-2d7cd011db47", ((PSAzureTenant)commandRuntimeMock.OutputPipeline[1]).Id.ToString());
Assert.Equal("microsoft.com", ((PSAzureTenant)commandRuntimeMock.OutputPipeline[1]).Directory);
}

private void Login(string subscriptionId, string tenantId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ public void CanConvertNullAzureTenants()
Assert.Null((PSAzureTenant)null);
var tenant = (PSAzureTenant)(new AzureTenant());
Assert.NotNull(tenant);
Assert.Null(tenant.Directory);
Assert.Equal(Guid.Empty, tenant.GetId());
Assert.Null(tenant.ToString());
}
Expand All @@ -440,7 +439,6 @@ public void CanConvertValidAzureTenants(string domain)
Id = Guid.NewGuid().ToString(),
};
var tenant = (PSAzureTenant)oldTenant;
Assert.Equal(oldTenant.Directory, tenant.Directory);
Assert.Equal(oldTenant.Id.ToString(), tenant.Id);
Assert.NotNull(tenant.ToString());
Assert.Equal(oldTenant.Id, tenant.TenantId);
Expand All @@ -457,19 +455,15 @@ public void CanConvertNullPSAzureTenants()
Assert.Equal(Guid.Empty, tenant.GetId());
}

[Theory,
InlineData(null),
InlineData("contoso.org")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void CanConvertValidPSAzureTenants(string domain)
public void CanConvertValidPSAzureTenants()
{
var oldTenant = new PSAzureTenant()
{
Directory = domain,
Id = Guid.NewGuid().ToString()
};
var tenant = (AzureTenant)oldTenant;
Assert.Equal(oldTenant.Directory, tenant.Directory);
Assert.Equal(oldTenant.Id, tenant.Id.ToString());
}

Expand Down Expand Up @@ -574,7 +568,6 @@ public void CanConvertValidAzureContexts(string account, string subscriptionName
Assert.Equal(oldContext.Account.Type.ToString(), context.Account.Type);
Assert.Equal(oldContext.Account.Id, context.Account.Id);
Assert.NotNull(context.Tenant);
Assert.Equal(oldContext.Tenant.Directory, context.Tenant.Directory);
Assert.Equal(oldContext.Tenant.Id.ToString(), context.Tenant.Id);
Assert.NotNull(context.Subscription);
Assert.Equal(oldContext.Subscription.Name, context.Subscription.Name);
Expand Down Expand Up @@ -638,7 +631,6 @@ public void CanConvertValidPSAzureContexts(string account, string subscription,
},
Tenant = new PSAzureTenant
{
Directory = domain,
Id = tenantId.ToString()
}
};
Expand All @@ -648,7 +640,6 @@ public void CanConvertValidPSAzureContexts(string account, string subscription,
Assert.Equal(oldContext.Account.Type, context.Account.Type.ToString());
Assert.Equal(oldContext.Account.Id, context.Account.Id);
Assert.NotNull(context.Tenant);
Assert.Equal(oldContext.Tenant.Directory, context.Tenant.Directory);
Assert.Equal(oldContext.Tenant.Id, context.Tenant.Id.ToString());
Assert.NotNull(context.Subscription);
Assert.Equal(oldContext.Subscription.Name, context.Subscription.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,22 @@ public override void ExecuteCmdlet()
}
else if (TenantOnlyParameters())
{
var tenantId = Tenant ?? TenantObject?.Directory;
if (string.IsNullOrWhiteSpace(tenantId))
if (string.IsNullOrWhiteSpace(Tenant))
{
throw new ArgumentException("You must supply a valid tenant object with a valid Id or a valid tenant id string. Please check the input tenant value and try again.");
}
if (DefaultContext != null && ShouldProcess(string.Format(Resources.ChangingContextTenant, tenantId),
if (DefaultContext != null && ShouldProcess(string.Format(Resources.ChangingContextTenant, Tenant),
Resources.TenantChangeWarning, string.Empty))
{
SetContextWithOverwritePrompt((profile, client, name) =>
{
client.SetCurrentContext(null, tenantId, name);
client.SetCurrentContext(null, Tenant, name);
CompleteContextProcessing(profile);
});
}
}
else
{
var tenantId = Tenant ?? TenantObject?.Directory;
var subscriptionId = Subscription ?? SubscriptionObject?.Id ?? SubscriptionObject?.Name;
if (DefaultContext != null && !string.IsNullOrWhiteSpace(subscriptionId))
{
Expand All @@ -121,7 +119,7 @@ public override void ExecuteCmdlet()
{
SetContextWithOverwritePrompt((profile, client, name) =>
{
client.SetCurrentContext(subscriptionId, tenantId, name);
client.SetCurrentContext(subscriptionId, Tenant, name);
CompleteContextProcessing(profile);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,6 @@ private bool TryGetTenantSubscription(IAccessToken accessToken,

tenant = new AzureTenant();
tenant.Id = accessToken.TenantId;
tenant.Directory = accessToken.GetDomain();
return true;
}

Expand All @@ -613,14 +612,6 @@ private bool TryGetTenantSubscription(IAccessToken accessToken,
{
tenant = new AzureTenant();
tenant.Id = accessToken.TenantId;
if (accessToken.UserId != null)
{
var domain = accessToken.UserId.Split(new[] { '@' }, StringSplitOptions.RemoveEmptyEntries);
if (domain.Length == 2)
{
tenant.Directory = domain[1];
}
}
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions tools/Common.Netcore.Dependencies.Test.targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="Microsoft.Azure.PowerShell.ScenarioTest.ResourceManager" Version="1.0.233-preview" >
<PackageReference Include="Microsoft.Azure.PowerShell.ScenarioTest.ResourceManager" Version="1.1.10-preview" >
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down Expand Up @@ -55,7 +55,7 @@
</ItemGroup>

<PropertyGroup>
<ScenarioTestToolsPath>$(NugetPackageRoot)microsoft.azure.powershell.scenariotest.resourcemanager\1.0.233-preview\tools\</ScenarioTestToolsPath>
<ScenarioTestToolsPath>$(NugetPackageRoot)microsoft.azure.powershell.scenariotest.resourcemanager\1.1.10-preview\tools\</ScenarioTestToolsPath>
</PropertyGroup>

<ItemGroup>
Expand Down
32 changes: 16 additions & 16 deletions tools/Common.Netcore.Dependencies.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,49 @@
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.18">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.ResourceManager" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.ResourceManager" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.0.233-preview">
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.1.10-preview">
<PrivateAssets Condition="'$(HideReferenceDependencies)' == 'true'">All</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand All @@ -66,7 +66,7 @@
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0-preview-06" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup>
<StorageToolsPath>$(NugetPackageRoot)microsoft.azure.powershell.storage\1.0.233-preview\tools\</StorageToolsPath>
<StorageToolsPath>$(NugetPackageRoot)microsoft.azure.powershell.storage\1.1.10-preview\tools\</StorageToolsPath>
</PropertyGroup>
<ItemGroup Condition="'$(OmitJsonPackage)' != 'true'">
<PackageReference Include="Newtonsoft.Json" Version="10.0.3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<HintPath>..\..\..\src\packages\Microsoft.ApplicationInsights.1.2.0\lib\net45\Microsoft.ApplicationInsights.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Commands.Common.Authentication.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\src\packages\Microsoft.Azure.PowerShell.Authentication.Abstractions.1.0.233-preview\lib\net452\Microsoft.Azure.Commands.Common.Authentication.Abstractions.dll</HintPath>
<HintPath>..\..\..\src\packages\Microsoft.Azure.PowerShell.Authentication.Abstractions.1.1.10-preview\lib\net452\Microsoft.Azure.Commands.Common.Authentication.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\src\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
Expand All @@ -58,7 +58,7 @@
<HintPath>..\..\..\src\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Commands.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\src\packages\Microsoft.Azure.PowerShell.Common.1.0.233-preview\lib\net452\Microsoft.WindowsAzure.Commands.Common.dll</HintPath>
<HintPath>..\..\..\src\packages\Microsoft.Azure.PowerShell.Common.1.1.10-preview\lib\net452\Microsoft.WindowsAzure.Commands.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\src\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
Expand Down
Loading