Skip to content

Commit d0de488

Browse files
committed
1 parent 79cb4c4 commit d0de488

File tree

10 files changed

+82
-15
lines changed

10 files changed

+82
-15
lines changed

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/ApiManagementClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public IList<PsApiManagementApi> ApiByName(PsApiManagementContext context, strin
529529
context.ServiceName,
530530
new Rest.Azure.OData.ODataQuery<ApiContract>
531531
{
532-
Filter = string.Format("contains('{0}',properties/displayName)", name)
532+
Filter = string.Format("properties/displayName eq '{0}'", name)
533533
}),
534534
nextLink => Client.Api.ListByServiceNext(nextLink));
535535

@@ -1269,7 +1269,7 @@ public IList<PsApiManagementProduct> ProductList (PsApiManagementContext context
12691269
var query = new Rest.Azure.OData.ODataQuery<ProductContract>();
12701270
if (!string.IsNullOrWhiteSpace(title))
12711271
{
1272-
query.Filter = string.Format("contains('{0}',properties/displayName)", title);
1272+
query.Filter = string.Format("properties/displayName eq '{0}'", title);
12731273
}
12741274

12751275
var results = ListPagedAndMap<PsApiManagementProduct, ProductContract>(

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands/ImportAzureApiManagementApi.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414

1515
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
1616
{
17-
using Models;
1817
using System;
18+
using System.Globalization;
19+
using System.IO;
1920
using System.Management.Automation;
2021
using Management.ApiManagement.Models;
22+
using Models;
23+
using Properties;
2124

2225
[Cmdlet("Import", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApiManagementApi", DefaultParameterSetName = FromLocalFile)]
2326
[OutputType(typeof(PsApiManagementApi))]
@@ -109,15 +112,21 @@ public override void ExecuteApiManagementCmdlet()
109112
else
110113
{
111114
apiId = Guid.NewGuid().ToString("N");
112-
}
115+
}
113116

114117
if (ParameterSetName.Equals(FromLocalFile))
115118
{
119+
FileInfo localFile = new FileInfo(this.GetUnresolvedProviderPathFromPSPath(this.SpecificationPath));
120+
if (!localFile.Exists)
121+
{
122+
throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.SourceFileNotFound, this.SpecificationPath));
123+
}
124+
116125
Client.ApiImportFromFile(
117126
Context,
118127
apiId,
119128
SpecificationFormat,
120-
SpecificationPath,
129+
localFile.FullName,
121130
Path,
122131
WsdlServiceName,
123132
WsdlEndpointName,

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands/NewAzureApiManagementCertificate.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414

1515
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
1616
{
17-
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
1817
using System;
18+
using System.Globalization;
1919
using System.IO;
2020
using System.Management.Automation;
2121
using System.Security.Cryptography.X509Certificates;
22+
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
23+
using Properties;
2224

2325
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApiManagementCertificate", DefaultParameterSetName = FromFile)]
2426
[OutputType(typeof(PsApiManagementCertificate))]
@@ -67,7 +69,13 @@ public override void ExecuteApiManagementCmdlet()
6769
byte[] rawBytes;
6870
if (ParameterSetName.Equals(FromFile))
6971
{
70-
using (var certStream = File.OpenRead(PfxFilePath))
72+
FileInfo localFile = new FileInfo(this.GetUnresolvedProviderPathFromPSPath(this.PfxFilePath));
73+
if (!localFile.Exists)
74+
{
75+
throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.SourceFileNotFound, PfxFilePath));
76+
}
77+
78+
using (var certStream = File.OpenRead(localFile.Name))
7179
{
7280
rawBytes = new byte[certStream.Length];
7381
certStream.Read(rawBytes, 0, rawBytes.Length);

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands/SetAzureApiManagementCertificate.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414

1515
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
1616
{
17-
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
1817
using System;
18+
using System.Globalization;
1919
using System.IO;
2020
using System.Management.Automation;
2121
using System.Security.Cryptography.X509Certificates;
22+
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
23+
using Properties;
2224

2325
[Cmdlet("Set", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApiManagementCertificate", DefaultParameterSetName = FromFile)]
2426
[OutputType(typeof(PsApiManagementCertificate))]
@@ -77,7 +79,13 @@ public override void ExecuteApiManagementCmdlet()
7779
byte[] rawBytes;
7880
if (ParameterSetName.Equals(FromFile))
7981
{
80-
using (var certStream = File.OpenRead(PfxFilePath))
82+
FileInfo localFile = new FileInfo(this.GetUnresolvedProviderPathFromPSPath(this.PfxFilePath));
83+
if (!localFile.Exists)
84+
{
85+
throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.SourceFileNotFound, this.PfxFilePath));
86+
}
87+
88+
using (var certStream = File.OpenRead(localFile.Name))
8189
{
8290
rawBytes = new byte[certStream.Length];
8391
certStream.Read(rawBytes, 0, rawBytes.Length);

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Properties/Resources.resx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@
299299
<value>Confirm</value>
300300
<comment>Process workflow</comment>
301301
</data>
302+
<data name="SourceFileNotFound" xml:space="preserve">
303+
<value>File '{0}' does not exist.</value>
304+
<comment>Process workflow</comment>
305+
</data>
302306
<data name="SubscriptionRemoveDescription" xml:space="preserve">
303307
<value>Removing Subscription "{0}".</value>
304308
<comment>Process workflow</comment>

src/ResourceManager/ApiManagement/Commands.ApiManagement/Commands/NewAzureApiManagementCustomHostnameConfiguration.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414

1515
namespace Microsoft.Azure.Commands.ApiManagement.Commands
1616
{
17-
using Microsoft.Azure.Commands.ApiManagement.Models;
18-
using ResourceManager.Common;
1917
using System;
18+
using System.Globalization;
2019
using System.IO;
2120
using System.Management.Automation;
2221
using System.Security;
22+
using Microsoft.Azure.Commands.ApiManagement.Models;
23+
using Properties;
24+
using ResourceManager.Common;
2325
using WindowsAzure.Commands.Common;
2426

2527
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApiManagementCustomHostnameConfiguration", DefaultParameterSetName = "NoChangeCertificate")]
@@ -99,8 +101,14 @@ public override void ExecuteCmdlet()
99101
}
100102
else if (!string.IsNullOrWhiteSpace(PfxPath))
101103
{
104+
FileInfo localFile = new FileInfo(this.GetUnresolvedProviderPathFromPSPath(this.PfxPath));
105+
if (!localFile.Exists)
106+
{
107+
throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.SourceFileNotFound, this.PfxPath));
108+
}
109+
102110
byte[] certificate;
103-
using (var certStream = File.OpenRead(PfxPath))
111+
using (var certStream = File.OpenRead(localFile.Name))
104112
{
105113
certificate = new byte[certStream.Length];
106114
certStream.Read(certificate, 0, certificate.Length);

src/ResourceManager/ApiManagement/Commands.ApiManagement/Commands/NewAzureApiManagementSystemCertificate.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414

1515
namespace Microsoft.Azure.Commands.ApiManagement.Commands
1616
{
17-
using Microsoft.Azure.Commands.ApiManagement.Models;
18-
using ResourceManager.Common;
1917
using System;
18+
using System.Globalization;
2019
using System.IO;
2120
using System.Management.Automation;
2221
using System.Security;
22+
using Microsoft.Azure.Commands.ApiManagement.Models;
23+
using Properties;
24+
using ResourceManager.Common;
2325
using WindowsAzure.Commands.Common;
2426

2527
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApiManagementSystemCertificate")]
@@ -48,9 +50,15 @@ public override void ExecuteCmdlet()
4850
{
4951
var systemCertificate = new PsApiManagementSystemCertificate();
5052
systemCertificate.StoreName = StoreName;
53+
54+
FileInfo localFile = new FileInfo(this.GetUnresolvedProviderPathFromPSPath(this.PfxPath));
55+
if (!localFile.Exists)
56+
{
57+
throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.SourceFileNotFound, this.PfxPath));
58+
}
5159

5260
byte[] certificate;
53-
using (var certStream = File.OpenRead(PfxPath))
61+
using (var certStream = File.OpenRead(localFile.Name))
5462
{
5563
certificate = new byte[certStream.Length];
5664
certStream.Read(certificate, 0, certificate.Length);

src/ResourceManager/ApiManagement/Commands.ApiManagement/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/ApiManagement/Commands.ApiManagement/Properties/Resources.resx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@
145145
<value>Confirm</value>
146146
<comment>Process workflow</comment>
147147
</data>
148+
<data name="SourceFileNotFound" xml:space="preserve">
149+
<value>File at path '{0}' does not exist</value>
150+
<comment>Process workflow</comment>
151+
</data>
148152
<data name="UpdateApiManagementService" xml:space="preserve">
149153
<value>Update an Api Management Service.</value>
150154
<comment>Process workflow</comment>

0 commit comments

Comments
 (0)