Skip to content

Commit c20d25c

Browse files
author
Hovsep
committed
Merge branch 'dev' of github.com:Azure/azure-powershell into NoWarning
2 parents c1f8abd + df0d205 commit c20d25c

26 files changed

+855
-81
lines changed

src/Common/Commands.Common/Common/AzurePowerShellClientFactory.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,24 @@ private void RegisterServiceManagementProviders<T>(AzureContext context) where T
119119
}
120120
}
121121

122-
private void UpdateSubscriptionRegisteredProviders(AzureSubscription subscription, List<string> providers)
122+
private void UpdateSubscriptionRegisteredProviders(AzureSubscription subscription, List<string> providers)
123123
{
124-
if (providers != null && providers.Count > 0)
125-
{
126-
subscription.SetOrAppendProperty(AzureSubscription.Property.RegisteredResourceProviders,
127-
providers.ToArray());
128-
ProfileClient profileClient = new ProfileClient();
129-
profileClient.AddOrSetSubscription(subscription);
130-
profileClient.Profile.Save();
131-
}
124+
     if (providers != null && providers.Count > 0)
125+
     {
126+
         subscription.SetOrAppendProperty(AzureSubscription.Property.RegisteredResourceProviders,
127+
             providers.ToArray());
128+
         try
129+
         {
130+
             ProfileClient profileClient = new ProfileClient();
131+
             profileClient.AddOrSetSubscription(subscription);
132+
             profileClient.Profile.Save();
133+
         }
134+
         catch (KeyNotFoundException)
135+
         {
136+
             // if using a subscription data file, do not write registration to disk
137+
             // long term solution is using -Profile parameter
138+
         }
139+
     }
132140
}
133141
}
134142
}

src/ResourceManager/DataFactories/Commands.DataFactories.Test/ScenarioTests/DataFactoryTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,4 @@ function Test-DataFactoryPiping
124124

125125
# Test the data factory no longer exists
126126
Assert-ThrowsContains { Get-AzureDataFactory -ResourceGroupName $rgname -Name $dfname } "ResourceNotFound"
127-
}
127+
}

src/ResourceManager/DataFactories/Commands.DataFactories.Test/UnitTests/GetHubTests.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Collections.Generic;
1615
using Microsoft.Azure.Commands.DataFactories.Models;
1716
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1817
using Moq;
18+
using System;
19+
using System.Collections.Generic;
20+
using System.Management.Automation;
1921
using Xunit;
2022

2123
namespace Microsoft.Azure.Commands.DataFactories.Test
@@ -78,6 +80,30 @@ public void CanGetHub()
7880
commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once());
7981
}
8082

83+
[Fact]
84+
[Trait(Category.AcceptanceType, Category.CheckIn)]
85+
public void GetHubWithEmptyName()
86+
{
87+
// Action
88+
cmdlet.Name = String.Empty;
89+
Exception exception = Assert.Throws<PSArgumentNullException>(() => cmdlet.ExecuteCmdlet());
90+
91+
// Assert
92+
Assert.Contains("Value cannot be null", exception.Message);
93+
}
94+
95+
[Fact]
96+
[Trait(Category.AcceptanceType, Category.CheckIn)]
97+
public void GetHubWithWhiteSpaceName()
98+
{
99+
// Action
100+
cmdlet.Name = " ";
101+
Exception exception = Assert.Throws<PSArgumentNullException>(() => cmdlet.ExecuteCmdlet());
102+
103+
// Assert
104+
Assert.Contains("Value cannot be null", exception.Message);
105+
}
106+
81107
[Fact]
82108
[Trait(Category.AcceptanceType, Category.CheckIn)]
83109
public void CanListHubs()

src/ResourceManager/DataFactories/Commands.DataFactories.Test/UnitTests/GetPipelineTests.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Collections.Generic;
1615
using Microsoft.Azure.Commands.DataFactories.Models;
1716
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1817
using Moq;
18+
using System;
19+
using System.Collections.Generic;
20+
using System.Management.Automation;
1921
using Xunit;
2022

2123
namespace Microsoft.Azure.Commands.DataFactories.Test
@@ -78,6 +80,30 @@ public void CanGetPipeline()
7880
commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once());
7981
}
8082

83+
[Fact]
84+
[Trait(Category.AcceptanceType, Category.CheckIn)]
85+
public void GetPipelineWithEmptyName()
86+
{
87+
// Action
88+
cmdlet.Name = String.Empty;
89+
Exception exception = Assert.Throws<PSArgumentNullException>(() => cmdlet.ExecuteCmdlet());
90+
91+
// Assert
92+
Assert.Contains("Value cannot be null", exception.Message);
93+
}
94+
95+
[Fact]
96+
[Trait(Category.AcceptanceType, Category.CheckIn)]
97+
public void GetPipelineWithWhiteSpaceName()
98+
{
99+
// Action
100+
cmdlet.Name = " ";
101+
Exception exception = Assert.Throws<PSArgumentNullException>(() => cmdlet.ExecuteCmdlet());
102+
103+
// Assert
104+
Assert.Contains("Value cannot be null", exception.Message);
105+
}
106+
81107
[Fact]
82108
[Trait(Category.AcceptanceType, Category.CheckIn)]
83109
public void CanListPipelines()

src/ResourceManager/DataFactories/Commands.DataFactories/Hubs/GetAzureDataFactoryHubCommand.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.DataFactories.Models;
16+
using Microsoft.Azure.Commands.DataFactories.Properties;
1517
using System.Collections.Generic;
18+
using System.Globalization;
1619
using System.Management.Automation;
1720
using System.Security.Permissions;
18-
using Microsoft.Azure.Commands.DataFactories.Models;
19-
using System.Globalization;
20-
using Microsoft.Azure.Commands.DataFactories.Properties;
2121

2222
namespace Microsoft.Azure.Commands.DataFactories
2323
{
@@ -31,6 +31,12 @@ public class GetAzureDataFactoryHubCommand : HubContextBaseCmdlet
3131
[EnvironmentPermission(SecurityAction.Demand, Unrestricted = true)]
3232
public override void ExecuteCmdlet()
3333
{
34+
// ValidationNotNullOrEmpty doesn't handle whitespaces well
35+
if (Name != null && string.IsNullOrWhiteSpace(Name))
36+
{
37+
throw new PSArgumentNullException("Name");
38+
}
39+
3440
if (ParameterSetName == ByFactoryObject)
3541
{
3642
if (DataFactory == null)

src/ResourceManager/DataFactories/Commands.DataFactories/Pipelines/GetAzureDataFactoryPipelineCommand.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.DataFactories.Models;
16+
using Microsoft.Azure.Commands.DataFactories.Properties;
1517
using System;
18+
using System.Collections;
1619
using System.Collections.Generic;
20+
using System.Globalization;
1721
using System.Management.Automation;
1822
using System.Security.Permissions;
19-
using Microsoft.Azure.Commands.DataFactories.Models;
20-
using System.Collections;
21-
using System.Globalization;
22-
using Microsoft.Azure.Commands.DataFactories.Properties;
2323

2424
namespace Microsoft.Azure.Commands.DataFactories
2525
{
@@ -42,6 +42,12 @@ public class GetAzureDataFactoryPipelineCommand : DataFactoryBaseCmdlet
4242
[EnvironmentPermission(SecurityAction.Demand, Unrestricted = true)]
4343
public override void ExecuteCmdlet()
4444
{
45+
// ValidationNotNullOrEmpty doesn't handle whitespaces well
46+
if (Name != null && string.IsNullOrWhiteSpace(Name))
47+
{
48+
throw new PSArgumentNullException("Name");
49+
}
50+
4551
if (ParameterSetName == ByFactoryObject)
4652
{
4753
if (DataFactory == null)

src/ServiceManagement/Services/Commands.Utilities/Commands.Utilities.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
</Reference>
120120
<Reference Include="Microsoft.WindowsAzure.Management.Scheduler, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
121121
<SpecificVersion>False</SpecificVersion>
122-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Scheduler.3.0.2\lib\net40\Microsoft.WindowsAzure.Management.Scheduler.dll</HintPath>
122+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Scheduler.4.1.0\lib\net40\Microsoft.WindowsAzure.Management.Scheduler.dll</HintPath>
123123
</Reference>
124124
<Reference Include="Microsoft.WindowsAzure.Management.ServiceBus">
125125
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.ServiceBus.0.15.0-preview\lib\net40\Microsoft.WindowsAzure.Management.ServiceBus.dll</HintPath>
@@ -246,6 +246,9 @@
246246
<Compile Include="Scheduler\Common\Constants.cs" />
247247
<Compile Include="Scheduler\Common\ExtensionMethods.cs" />
248248
<Compile Include="Scheduler\Common\SchedulerUtils.cs" />
249+
<Compile Include="Scheduler\Model\PSAADOAuthenticationJobDetail.cs" />
250+
<Compile Include="Scheduler\Model\PSBasicAuthenticationJobDetail.cs" />
251+
<Compile Include="Scheduler\Model\PSClientCertAuthenticationJobDetail.cs" />
249252
<Compile Include="Scheduler\Model\PSCreateJobCollectionParams.cs" />
250253
<Compile Include="Scheduler\Model\PSCreateJobParams.cs" />
251254
<Compile Include="Scheduler\Model\PSHttpJobDetail.cs" />

0 commit comments

Comments
 (0)