Skip to content

Commit cbf29df

Browse files
committed
resolved PR comments
1 parent 5c32aff commit cbf29df

File tree

12 files changed

+28025
-21042
lines changed

12 files changed

+28025
-21042
lines changed
Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
-----BEGIN CERTIFICATE-----
2-
MIIDYzCCAkugAwIBAgIQXFJpo/ym7ZpFykG0LFTURDANBgkqhkiG9w0BAQsFADAt
2+
MIIDFTCCAf2gAwIBAgIQbVLsBg/TRY9NRrkdiQMMTDANBgkqhkiG9w0BAQsFADAt
33
MSswKQYDVQQDDCJQUyBUZXN0IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4X
4-
DTE3MTEyMjAwNTMwN1oXDTE4MTEyMjAxMTMwN1owLTErMCkGA1UEAwwiUFMgVGVz
4+
DTE3MTIwNDIxMzg1MloXDTI3MTIwNDIxNDg1MlowLTErMCkGA1UEAwwiUFMgVGVz
55
dCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQAD
6-
ggEPADCCAQoCggEBAJyuY7Kpb4T0Ft6B1OBpdzKpUzpadTgeVF7no9J7trb1SCbR
7-
77MUSX11nlUmN6ZYt2YbSg7yix7l49RIXqv6rfUmBSrvT3vUsAJt9RCXpfQrJxDc
8-
//sQkg2qDwl7J3bnbiRGZsvcVUsWP2NZ+40Mut8TWIoaOXf7P/AnoU34BgPExN4m
9-
R6GqKnPIN68vAa0DMmOLmSFisMDch48zr8/nshQ0hWvnK926pc/eB0drndeT9pxI
10-
lrcvZixN4a3tB16ogkqp3ZCcy+FdT2zPzVBI6JUgegigm/LINXIiOLXGSACd9lbx
11-
D1c+gtsnSYkxkOs+94wDCWrzLDQanIJj+wh6ISkCAwEAAaN/MH0wDgYDVR0PAQH/
12-
BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDATAtBgNVHREEJjAk
13-
giJQUyBUZXN0IFJvb3QgQ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M
15+
VQr3/WFYpkJGvjalpFNtm2SVQEHBMsNV36vnWyFw+ZrUKsgi78MxOSXCVuDzxMsI
16+
W2FePpPaGWPwdLpbzKKxW4+4797pOgSlY0XMIQS4nGlzHEUhdcCwIw/faMExyHSv
17+
277aE7MZ4pJdvbaz3HWSLcr2JogeULTu+Sm4btjrCe97hqm5NW5zqHgbcAOvlLUZ
18+
nHULagGHFflWjtLpI37mN1o3RRSJXfoSoQ==
2119
-----END CERTIFICATE-----

src/ResourceManager/IotHub/Commands.IotHub.Test/ScenarioTests/IotHubTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public IotHubTests(ITestOutputHelper output)
3434
public void TestAzureIotHubLifeCycle()
3535
{
3636
IotHubController.NewInstance.RunPsTestWorkflow(
37-
() => { return new[] { string.Format("{0} {1} {2} {3} {4}", "Test-AzureRmIotHubLifecycle", "northeurope", "powershelliothub", "powershellrg", "S1") }; },
38-
null,
39-
null,
40-
TestUtilities.GetCallingClass(),
41-
TestUtilities.GetCurrentMethodName());
37+
() => { return new[] { string.Format("{0} {1} {2} {3} {4}", "Test-AzureRmIotHubLifecycle", "northeurope", "powershelliothub", "powershellrg", "S1") }; },
38+
null,
39+
null,
40+
TestUtilities.GetCallingClass(),
41+
TestUtilities.GetCurrentMethodName());
4242
}
4343
}
4444
}

src/ResourceManager/IotHub/Commands.IotHub.Test/ScenarioTests/IotHubTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ function Test-AzureRmIotHubLifecycle
229229
# Add Certificate
230230
$certificatePath = "ScenarioTestFile\PS-Test-Root-CA.cer"
231231
$certificateSubject = "CN=PS Test Root Certificate Authority"
232-
$certificateThumbprint = "43039D39B36FDB44D98AFA79B56F70A66CED01C2"
232+
$certificateThumbprint = "38303FC7371EC78DDE3E18D732C8414EE50969C7"
233233
$certificateType = "Microsoft.Devices/IotHubs/Certificates"
234234
$certificateName = "TestCertificate"
235235
$newCertificate = Add-AzureRmIotHubCertificate -ResourceGroupName $ResourceGroupName -Name $IotHubName -CertificateName $certificateName -Path $certificatePath

src/ResourceManager/IotHub/Commands.IotHub.Test/SessionRecords/Microsoft.Azure.Commands.IotHub.Test.ScenarioTests.IotHubTests/TestAzureIotHubLifeCycle.json

Lines changed: 27967 additions & 20991 deletions
Large diffs are not rendered by default.

src/ResourceManager/IotHub/Commands.IotHub/IotHub/AddAzureRmIotHubCertificate.cs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Microsoft.Azure.Commands.Management.IotHub
1818
using System.Globalization;
1919
using System.IO;
2020
using System.Management.Automation;
21+
using System.Text;
2122
using Microsoft.Azure.Commands.Management.IotHub.Common;
2223
using Microsoft.Azure.Commands.Management.IotHub.Models;
2324
using Microsoft.Azure.Management.IotHub;
@@ -84,20 +85,29 @@ public override void ExecuteCmdlet()
8485
break;
8586
}
8687

87-
CertificateBodyDescription certificateBodyDescription = new CertificateBodyDescription();
88-
certificateBodyDescription.Certificate = certificate;
89-
90-
CertificateDescription certificateDescription;
91-
if (this.Etag != null)
88+
try
9289
{
93-
certificateDescription = this.IotHubClient.Certificates.CreateOrUpdate(this.ResourceGroupName, this.Name, this.CertificateName, certificateBodyDescription, this.Etag);
90+
certificate = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(certificate));
91+
92+
CertificateBodyDescription certificateBodyDescription = new CertificateBodyDescription();
93+
certificateBodyDescription.Certificate = certificate;
94+
95+
CertificateDescription certificateDescription;
96+
if (this.Etag != null)
97+
{
98+
certificateDescription = this.IotHubClient.Certificates.CreateOrUpdate(this.ResourceGroupName, this.Name, this.CertificateName, certificateBodyDescription, this.Etag);
99+
}
100+
else
101+
{
102+
certificateDescription = this.IotHubClient.Certificates.CreateOrUpdate(this.ResourceGroupName, this.Name, this.CertificateName, certificateBodyDescription);
103+
}
104+
105+
this.WriteObject(IotHubUtils.ToPSCertificateDescription(certificateDescription), true);
94106
}
95-
else
107+
catch(Exception e)
96108
{
97-
certificateDescription = this.IotHubClient.Certificates.CreateOrUpdate(this.ResourceGroupName, this.Name, this.CertificateName, certificateBodyDescription);
109+
throw e;
98110
}
99-
100-
this.WriteObject(IotHubUtils.ToPSCertificateDescription(certificateDescription), true);
101111
}
102112
}
103113
}

src/ResourceManager/IotHub/Commands.IotHub/IotHub/RemoveAzureRmIotHubCertificate.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
namespace Microsoft.Azure.Commands.Management.IotHub
1616
{
17-
using System;
1817
using System.Management.Automation;
1918
using Microsoft.Azure.Management.IotHub;
2019

@@ -55,17 +54,7 @@ public override void ExecuteCmdlet()
5554
{
5655
if (ShouldProcess(Name, Properties.Resources.RemoveIotHubCertificate))
5756
{
58-
try
59-
{
60-
this.IotHubClient.Certificates.Delete(this.ResourceGroupName, this.Name, this.CertificateName, this.Etag);
61-
}
62-
catch (Exception e)
63-
{
64-
if (!e.Message.Contains("NotFound"))
65-
{
66-
throw e;
67-
}
68-
}
57+
this.IotHubClient.Certificates.Delete(this.ResourceGroupName, this.Name, this.CertificateName, this.Etag);
6958
}
7059
}
7160
}

src/ResourceManager/IotHub/Commands.IotHub/IotHub/SetAzureRmIotHubVerifiedCertificate.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Microsoft.Azure.Commands.Management.IotHub
1818
using System.Globalization;
1919
using System.IO;
2020
using System.Management.Automation;
21+
using System.Text;
2122
using Microsoft.Azure.Commands.Management.IotHub.Common;
2223
using Microsoft.Azure.Commands.Management.IotHub.Models;
2324
using Microsoft.Azure.Management.IotHub;
@@ -85,11 +86,20 @@ public override void ExecuteCmdlet()
8586
break;
8687
}
8788

88-
CertificateVerificationDescription certificateVerificationDescription = new CertificateVerificationDescription();
89-
certificateVerificationDescription.Certificate = certificate;
89+
try
90+
{
91+
certificate = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(certificate));
92+
93+
CertificateVerificationDescription certificateVerificationDescription = new CertificateVerificationDescription();
94+
certificateVerificationDescription.Certificate = certificate;
9095

91-
CertificateDescription certificateDescription = this.IotHubClient.Certificates.Verify(this.ResourceGroupName, this.Name, this.CertificateName, certificateVerificationDescription, this.Etag);
92-
this.WriteObject(IotHubUtils.ToPSCertificateDescription(certificateDescription), true);
96+
CertificateDescription certificateDescription = this.IotHubClient.Certificates.Verify(this.ResourceGroupName, this.Name, this.CertificateName, certificateVerificationDescription, this.Etag);
97+
this.WriteObject(IotHubUtils.ToPSCertificateDescription(certificateDescription), true);
98+
}
99+
catch(Exception e)
100+
{
101+
throw e;
102+
}
93103
}
94104
}
95105
}

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,6 @@
151151
<value>Update IoT Hub </value>
152152
</data>
153153
<data name="VerifyIotHubCertificate" xml:space="preserve">
154-
<value>Add an Iot Hub Verified Certificate</value>
154+
<value>Verify an Iot Hub Certificate</value>
155155
</data>
156156
</root>

src/StackAdmin/AzureRM/AzureRM.psm1

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

tools/AzureRM/AzureRM.psm1

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)