Skip to content

Commit

Permalink
Consider ReuseKey and Exportable CertificatePolicy KeyProperties for …
Browse files Browse the repository at this point in the history
…serialization (#12958)
  • Loading branch information
christothes authored Jun 23, 2020
1 parent e3b81ad commit f84211c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Fixed concurrency issue in our challenge-based authentication policy ([#9737](https://github.com/Azure/azure-sdk-for-net/issues/9737))
- Fixed an issue where the issuer name was always null ([#10908](https://github.com/Azure/azure-sdk-for-net/issues/10908))
- Fixed an issue where GetIssuerAsync would throw for issuers with contact information populated ([#10905](https://github.com/Azure/azure-sdk-for-net/issues/10905))
- Fixed an issue where some Certificate policy properties were not serialized properly ([#11669](https://github.com/azure/azure-sdk-for-net/issues/11669))

## 4.0.1 (2020-03-03)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void IJsonDeserializable.ReadProperties(JsonElement json)
void IJsonSerializable.WriteProperties(Utf8JsonWriter json)
{
// Key Props
if (KeyType.HasValue || KeyCurveName.HasValue || KeySize.HasValue)
if (KeyType.HasValue || KeyCurveName.HasValue || KeySize.HasValue || ReuseKey.HasValue || Exportable.HasValue)
{
json.WriteStartObject(s_keyPropsPropertyNameBytes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,27 @@ public void DisablePolicySerialized()
}
}

public static object[] KeyPolicySerializationTestCases =
{
new object[] {new CertificatePolicy() { KeyType = CertificateKeyType.Rsa }, @"{""key_props"":{""kty"":""RSA""}}" },
new object[] {new CertificatePolicy() { ReuseKey = false }, @"{""key_props"":{""reuse_key"":false}}" },
new object[] {new CertificatePolicy() { Exportable = false }, @"{""key_props"":{""exportable"":false}}" },
new object[] {new CertificatePolicy() { KeyCurveName = CertificateKeyCurveName.P256 }, @"{""key_props"":{""crv"":""P-256""}}" },
new object[] {new CertificatePolicy() { KeySize = 2048 }, @"{""key_props"":{""key_size"":2048}}" },
};

[Test]
[TestCaseSource(nameof(KeyPolicySerializationTestCases))]
public void KeyPolicySerialized(CertificatePolicy policy, string expectedJson)
{
using (JsonStream json = new JsonStream())
{
json.WriteObject(policy);

Assert.That(json.ToString(), Is.EqualTo(expectedJson));
}
}

[Test]
public void DefaultWithSubjectName()
{
Expand Down

0 comments on commit f84211c

Please # to comment.