Skip to content

Bugfix for June release #2262

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 7 commits into from
May 19, 2016
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
9 changes: 9 additions & 0 deletions src/Common/Commands.Common/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Common/Commands.Common/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1544,4 +1544,7 @@ Select Y to enable data collection [Y/N]:</value>
<data name="NoCurrentContextForDataCmdlet" xml:space="preserve">
<value>"There is no current context, please log in using Login-AzureRmAccount for Azure Resource Manager or Add-AzureAccount for Azure Service Management."</value>
</data>
<data name="NoSubscriptionFoundForTenant" xml:space="preserve">
<value>No subscriptions are associated with the logged in account in Azure Service Management (RDFE). This means that the logged in user is not an administrator or co-administrator for any account.\r\nDid you mean to execute Login-AzureRmAccount?</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,26 @@ namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class CustomDomainTests
{
private ServiceManagemenet.Common.Models.XunitTracingInterceptor _logger;

public CustomDomainTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
_logger = new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output);
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCustomDomainGetRemoveWithRunningEndpoint()
{
TestController.NewInstance.RunPowerShellTest("Test-CustomDomainGetRemoveWithRunningEndpoint");
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CustomDomainGetRemoveWithRunningEndpoint");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCustomDomainGetRemoveWithStoppedEndpoint()
{
TestController.NewInstance.RunPowerShellTest("Test-CustomDomainGetRemoveWithStoppedEndpoint");
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CustomDomainGetRemoveWithStoppedEndpoint");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,40 @@ namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class EndpointTests
{
private ServiceManagemenet.Common.Models.XunitTracingInterceptor _logger;

public EndpointTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
_logger = new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output);
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestEndpointCrudAndAction()
{
TestController.NewInstance.RunPowerShellTest("Test-EndpointCrudAndAction");
TestController.NewInstance.RunPowerShellTest(_logger, "Test-EndpointCrudAndAction");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestEndpointCrudAndActionWithPiping()
{
TestController.NewInstance.RunPowerShellTest("Test-EndpointCrudAndActionWithPiping");
TestController.NewInstance.RunPowerShellTest(_logger, "Test-EndpointCrudAndActionWithPiping");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestEndpointCrudAndActionWithAllProperties()
{
TestController.NewInstance.RunPowerShellTest("Test-EndpointCrudAndActionWithAllProperties");
TestController.NewInstance.RunPowerShellTest(_logger, "Test-EndpointCrudAndActionWithAllProperties");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestEndpointCrudAndActionWithAllPropertiesWithPiping()
{
TestController.NewInstance.RunPowerShellTest("Test-EndpointCrudAndActionWithAllPropertiesWithPiping");
TestController.NewInstance.RunPowerShellTest(_logger, "Test-EndpointCrudAndActionWithAllPropertiesWithPiping");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,33 @@ namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class OriginTests
{
private ServiceManagemenet.Common.Models.XunitTracingInterceptor _logger;

public OriginTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
_logger = new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output);
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestOriginGetSetWithRunningEndpoint()
{
TestController.NewInstance.RunPowerShellTest("Test-OriginGetSetWithRunningEndpoint");
TestController.NewInstance.RunPowerShellTest(_logger, "Test-OriginGetSetWithRunningEndpoint");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestOriginGetSetWithStoppedEndpoint()
{
TestController.NewInstance.RunPowerShellTest("Test-OriginGetSetWithStoppedEndpoint");
TestController.NewInstance.RunPowerShellTest(_logger, "Test-OriginGetSetWithStoppedEndpoint");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestOriginGetSetWhenEndpointDoesnotExist()
{
TestController.NewInstance.RunPowerShellTest("Test-OriginGetSetWhenEndpointDoesnotExist");
TestController.NewInstance.RunPowerShellTest(_logger, "Test-OriginGetSetWhenEndpointDoesnotExist");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,26 @@ namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class ProfileTests
{
private ServiceManagemenet.Common.Models.XunitTracingInterceptor _logger;

public ProfileTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
_logger = new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output);
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestProfileCrud()
{
TestController.NewInstance.RunPowerShellTest("Test-ProfileCrud");
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ProfileCrud");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestProfileCrudWithPiping()
{
TestController.NewInstance.RunPowerShellTest("Test-ProfileDeleteAndSsoWithPiping");
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ProfileDeleteAndSsoWithPiping");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ protected void SetupManagementClients(MockContext context)
CdnManagementClient);
}

public void RunPowerShellTest(params string[] scripts)
public void RunPowerShellTest(ServiceManagemenet.Common.Models.XunitTracingInterceptor logger, params string[] scripts)
{
var callingClassType = TestUtilities.GetCallingClass(2);
var mockName = TestUtilities.GetCurrentMethodName(2);

_helper.TracingInterceptor = logger;
RunPsTestWorkflow(
() => scripts,
// no custom initializer
Expand Down Expand Up @@ -136,7 +137,6 @@ public void RunPsTestWorkflow(
_helper.RMProfileModule,
_helper.RMResourceModule,
@"AzureRM.Cdn.psd1");

try
{
if (scriptBuilder != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void OnImport()
System.Management.Automation.PowerShell invoker = null;
invoker = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace);
invoker.AddScript(File.ReadAllText(FileUtilities.GetContentFilePath(
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory),
"CdnStartup.ps1")));
invoker.Invoke();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;
using System.Linq;
using System.Management.Automation;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -76,6 +77,21 @@ public void SelectAzureProfileNull()
cmdlt.InvokeEndProcessing();
}


[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void SelectAzureProfileBadPath()
{
SelectAzureRMProfileCommand cmdlt = new SelectAzureRMProfileCommand();
cmdlt.Path = "z:\non-existent-path\non-existent-file.ext";
// Setup
cmdlt.CommandRuntime = commandRuntimeMock;

// Act
cmdlt.InvokeBeginProcessing();
Assert.Throws<PSArgumentException>(() => cmdlt.ExecuteCmdlet());
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void SelectAzureProfileFromDisk()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
<Label>SubscriptionId</Label>
<ScriptBlock>$_.Context.Subscription.ToString()</ScriptBlock>
</ListItem>
<ListItem>
<Label>SubscriptionName</Label>
<ScriptBlock>$_.Context.Subscription.SubscriptionName.ToString()</ScriptBlock>
</ListItem>
<ListItem>
<Label>CurrentStorageAccount</Label>
<ScriptBlock>if ($_.Context.Subscription -ne $null -and $_.Context.Subscription.CurrentStorageAccountName -ne $null) {$_.Context.Subscription.CurrentStorageAccountName} else {$null} </ScriptBlock>
Expand Down Expand Up @@ -58,6 +62,10 @@
<Label>SubscriptionId</Label>
<ScriptBlock>$_.Subscription.ToString()</ScriptBlock>
</ListItem>
<ListItem>
<Label>SubscriptionName</Label>
<ScriptBlock>$_.Subscription.SubscriptionName.ToString()</ScriptBlock>
</ListItem>
<ListItem>
<Label>CurrentStorageAccount</Label>
<ScriptBlock>if ($_.Subscription -ne $null -and $_.Subscription.CurrentStorageAccountName -ne $null) {$_.Subscription.CurrentStorageAccountName} else {$null} </ScriptBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ public override void ExecuteCmdlet()
{
if (!string.IsNullOrEmpty(Path))
{
if(!Common.Authentication.AzureSession.DataStore.FileExists(Path))
{
throw new PSArgumentException(string.Format(
Microsoft.Azure.Commands.Profile.Properties.Resources.FileNotFound,
Path));
}

AzureRmProfileProvider.Instance.Profile = new AzureRMProfile(Path);
}
else
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@
<data name="CurrentTenantInUse" xml:space="preserve">
<value>Current tenant with Id '{0}' will be used.</value>
</data>
<data name="FileNotFound" xml:space="preserve">
<value>Cannot find file '{0}'</value>
</data>
<data name="InvalidSubscriptionId" xml:space="preserve">
<value>The provided subscription ID "{0}" is not a valid Guid.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ public AzureAccount AddAccountAndLoadSubscriptions(AzureAccount account, AzureEn
password,
password == null ? ShowDialog.Always : ShowDialog.Never).ToList();

if (subscriptionsFromServer == null ||
subscriptionsFromServer.Count ==0 )
{
throw new ArgumentException(Resources.NoSubscriptionFoundForTenant);
}
// If account id is null the login failed
if (account.Id != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@

namespace Microsoft.WindowsAzure.Commands.Profile
{


/// <summary>
/// Sets an azure subscription.
/// </summary>
[Cmdlet(VerbsCommon.Set, "AzureSubscription"), OutputType(typeof(AzureSubscription))]
[Cmdlet(VerbsCommon.Set, "AzureSubscription", DefaultParameterSetName = UpdateSubscriptionByIdParameterSet), OutputType(typeof(AzureSubscription))]
public class SetAzureSubscriptionCommand : SubscriptionCmdletBase, IStorageContextProvider
{
private const string UpdateSubscriptionByIdParameterSet = "UpdateSubscriptionByIdParameterSetName";
Expand Down Expand Up @@ -60,11 +58,11 @@ public SetAzureSubscriptionCommand() : base(true)
public string SubscriptionId { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "Account subscription ID.", ParameterSetName = AddSubscriptionParameterSet)]
HelpMessage = "X509 Certificate.", ParameterSetName = AddSubscriptionParameterSet)]
[Parameter(ValueFromPipelineByPropertyName = true,
HelpMessage = "Account subscription ID.", ParameterSetName = UpdateSubscriptionByIdParameterSet)]
HelpMessage = "X509 Certificate.", ParameterSetName = UpdateSubscriptionByIdParameterSet)]
[Parameter(Position = 0, ValueFromPipelineByPropertyName = true,
HelpMessage = "Name of the subscription.", ParameterSetName = UpdateSubscriptionByNameParameterSet)]
HelpMessage = "X509 Certificate.", ParameterSetName = UpdateSubscriptionByNameParameterSet)]
public X509Certificate2 Certificate { get; set; }

[Parameter(ValueFromPipelineByPropertyName = true, HelpMessage = "Service endpoint.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Test.Profile.NewAzureProfileTests\TestMakeRdfeCallWithCreatedProfile.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Test.Profile.SelectAzureSubscriptionTests\GetSubscriptionPipeToSetSubscription.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Test.Profile.SelectAzureSubscriptionTests\StorageAccountIsNotCleaned.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,35 @@ public void CanAddAccountToCustomProfile()
Assert.Equal(profile.Context.Subscription.Id, rdfeSubscription);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void AddAzureAccountThrowsForEmptySubscriptions()
{
var cmdlet = new AddAzureAccount();
var csmSubscription = Guid.NewGuid();
var rdfeSubscription = Guid.NewGuid();
var credential = GenerateCredential("mySillyPassword");
var profile = new AzureSMProfile();
var client = new ProfileClient(profile);
cmdlet.Credential = credential;
cmdlet.Profile = profile;
cmdlet.SetParameterSet("User");

AzureSession.ClientFactory =
new MockClientFactory(
new List<object>
{
ProfileClientHelper.CreateRdfeSubscriptionClient(rdfeSubscription),
ProfileClientHelper.CreateCsmSubscriptionClient(new List<string>(),
new List<string>{csmSubscription.ToString(), rdfeSubscription.ToString()})
}, true);
AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory(credential.UserName,
Guid.NewGuid().ToString());
cmdlet.CommandRuntime = commandRuntimeMock;
cmdlet.InvokeBeginProcessing();
Assert.Throws<ArgumentException>(() => cmdlet.ExecuteCmdlet());
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void CanCreateProfieWithSPAuth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,12 @@ public void StorageAccountIsNotCleaned()
{
ProfileTestController.NewRdfeInstance.RunPsTest("Test-StorageAccountIsNotCleaned");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetSubscriptionPipeToSetSubscription()
{
ProfileTestController.NewRdfeInstance.RunPsTest("Test-GetSubscriptionPipeToSetSubscription");
}
}
}
Loading