Skip to content

Commit

Permalink
fix(dps-service): Remove client side validation of x509 CA references…
Browse files Browse the repository at this point in the history
… format (Azure#2172)
  • Loading branch information
timtay-microsoft authored Sep 24, 2021
1 parent 1757556 commit 2bfc88f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
13 changes: 3 additions & 10 deletions provisioning/service/src/Config/X509CAReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.Azure.Devices.Provisioning.Service
/// </summary>
/// <remarks>
/// This class creates a representation of an X509 CA references. It can receive primary and secondary
/// CA references, but only the primary is mandatory.
/// CA references.
///
/// Users must provide the CA reference as a <code>String</code>. This class will encapsulate both in a
/// single <see cref="X509Attestation"/>.
Expand All @@ -36,18 +36,11 @@ public class X509CAReferences
/// The CA reference is a <code>String</code> with the name that you gave for your certificate.
/// </remarks>
///
/// <param name="primary">the <code>String</code> with the primary CA reference. It cannot be <code>null</code> or empty.</param>
/// <param name="secondary">the <code>String</code> with the secondary CA reference. It can be <code>null</code> or empty.</param>
/// <exception cref="ProvisioningServiceClientException">if the primary CA reference is <code>null</code> or empty.</exception>
/// <param name="primary">the <code>String</code> with the primary CA reference.</param>
/// <param name="secondary">the <code>String</code> with the secondary CA reference.</param>
[JsonConstructor]
internal X509CAReferences(string primary, string secondary = null)
{
/* SRS_X509_CAREFERENCE_21_001: [The constructor shall throw ArgumentException if the primary CA reference is null or empty.] */
if(string.IsNullOrWhiteSpace(primary))
{
throw new ProvisioningServiceClientException("Primary CA reference cannot be null or empty");
}
/* SRS_X509_CAREFERENCE_21_002: [The constructor shall store the primary and secondary CA references.] */
Primary = primary;
Secondary = secondary;
}
Expand Down
14 changes: 0 additions & 14 deletions provisioning/service/tests/Config/X509CAReferencesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@ namespace Microsoft.Azure.Devices.Provisioning.Service.Test
[TestCategory("Unit")]
public class X509CAReferencesTests
{
/* SRS_X509_CAREFERENCE_21_001: [The constructor shall throw ArgumentException if the primary CA reference is null or empty.] */

[TestMethod]
public void X509CAReferencesThrowsOnInvalidPrimaryReferences()
{
// act and assert
#pragma warning disable CA1806 // Do not ignore method results
TestAssert.Throws<ProvisioningServiceClientException>(() => new X509CAReferences(null));
TestAssert.Throws<ProvisioningServiceClientException>(() => new X509CAReferences(""));
TestAssert.Throws<ProvisioningServiceClientException>(() => new X509CAReferences(" "));
TestAssert.Throws<ProvisioningServiceClientException>(() => new X509CAReferences(null, "valid-ca-reference"));
#pragma warning restore CA1806 // Do not ignore method results
}

/* SRS_X509_CAREFERENCE_21_002: [The constructor shall store the primary and secondary CA references.] */

[TestMethod]
Expand Down

0 comments on commit 2bfc88f

Please sign in to comment.