Skip to content

Commit

Permalink
Bumps version and release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Omondi committed Jan 16, 2024
1 parent e8f6741 commit a02f2e4
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project does adheres to [Semantic Versioning](https://semver.org/spec/v

## [Unreleased]

## [5.39.0] - 2024-01-16

- Latest metadata updates from 16th January 2024.
- Fixes missing interfaces for changenotification models(https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/2237).

## [5.38.0] - 2024-01-03

- Latest metadata updates from 2nd January 2024.
Expand Down
33 changes: 33 additions & 0 deletions src/Microsoft.Graph/Extensions/SubscriptionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Graph;

namespace Microsoft.Graph.Models
{
public static class SubscriptionExtensions
{
/// <summary>
/// Adds the public encryption certificate information for change notifications with resource data to the subscription creation information.
/// </summary>
/// <param name="subscription">The subscription instance of type <see cref="Subscription"/></param>
/// <param name="certificate">Certificate to use for encryption</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="certificate"/> is null</exception>
public static void AddPublicEncryptionCertificate(this Subscription subscription, X509Certificate2 certificate)
{
if (certificate == null)
throw new ArgumentNullException(nameof(certificate));

var tempSubscription = new EncryptableSubscription();
tempSubscription.AddPublicEncryptionCertificate(certificate);
subscription.EncryptionCertificate = tempSubscription.EncryptionCertificate;
}
}

internal class EncryptableSubscription : IEncryptableSubscription
{
/// <summary>
/// The encryption certificate
/// </summary>
public string EncryptionCertificate { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/Microsoft.Graph/Microsoft.Graph.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<VersionPrefix>5.38.0</VersionPrefix>
<VersionPrefix>5.39.0</VersionPrefix>
<!-- VersionPrefix minor version should not be set when the change comes from the generator. It will be updated automatically. -->
<!-- VersionPrefix minor version must be manually set when making manual changes to code. -->
<!-- VersionPrefix major and patch versions must be manually set. -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
using Microsoft.Graph.Models;
using Xunit;
using System.Security.Cryptography.X509Certificates;
using System.Security;
using System;
using System.Threading.Tasks;
using Microsoft.Kiota.Abstractions.Serialization;
using Microsoft.Kiota.Serialization.Json;

namespace Microsoft.Graph.DotnetCore.Test.Extensions
{
public class ChangeNotificationTests
{
private readonly X509Certificate2 _certificate;
public ChangeNotificationTests()
{
// This is a DUMMY certificate used to validate the functionality
var certificateString = "MIIQagIBAzCCEDAGCSqGSIb3DQEHAaCCECEEghAdMIIQGTCCBg8GCSqGSIb3DQEHBqCCBgAwggX8AgEAMIIF9QYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIEAk4/VMAFtsCAggAgIIFyAXxkPPBcl1MbwgA3SSTHD3WBxi" +
"qiGVC9+0ufNW70SoIyx7V9ZVP/eFXb/moZD7BEir30WCdqqZCvh3aHvoL1SlreKXFmYqLzUViqBsHl3GIox2f/Ic7CS486JCoLHMoTHPcC3Y40zr8HX+Zc0SJs1cT4KFN3UJnoKwD+lWgn7XOiyzKWC6zksqM2spnc5W6+I5eHo" +
"SDEkgPa6mDYtB+0/9bPSV8XkDu9MWGUhq+bNBlenMwAF+QeWBbaTskiEHgloJPzqVop8aT/KRsKLNBrWQ64JJ5dYG/yjqg0/oA//T8/cCDqhTuc0FiS4IRzmKnTsOuVgbwJ8t3vvd6lHRfFZXTYnMmRLuZ62xvzsAIRCg6+CUmU" +
"fJB9SZodYMD1dC3ScIHoNbbgJUfbUOriC9lL6kLPdxBOAmICMy+47t1PvmFpFJe0fzz8M26L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niKbV+fxgcOExbXD1Au9W0wgHnagT+uoik0rshi6nsIel4XmVv/MiQowK35s6Olq4mrdRPoOwoePuo3/CEL+BwRlX0aJhFgRS5O0L/zD8Hc8EPR6CO9+8jbkbBQ80KnVsS25ArgoA45CSFCrmqRxFnnp" +
"R6Dvlr0EmlDfGOnFlnZXZNIuPYZZT6UbH0ObaxDKYMPZ2NRbfETfdDHM+WBPuqGVc6OiMqa7PFkHjispf7saXtSrcpL+UYvNzX4PQwpUi8frl0Aq7w7c8GKosmaNp3VYiTc9cAcd/JlX5dAZK2yndVpmQlUeA028j5Lyc9Hm9Gn" +
"T6wjPT4x2lYvXd+AwOBY/3CY2eAslCN+4nmoRZnovDH4Ffp2bnId9FrsViBDWLKWV63yN2OTnTPJxj7ZQEC6T78sdqEpw5vKdi3xYYj2MhBXNohE0lK3Ig4ijsB9P16bXA8PcKaIwhnpeTKsLcdBPwVapuDku24u4u/Z/A+Q3Ls" +
"lbEJdiRhGrHv6I+MJd2Gx/1qBU6VO4N/vC/VL3uv5VY/zRcA4r4ff7m7nfsuwyz5JsLMIcQEx0LuKyy74XmayhpdDE1RlovO0+JkzFmMCMGCSqGSIb3DQEJFTEWBBRLlTU+CGrTcZZgas+DShRTLwPm2zA/BgkqhkiG9w0BCRQx" +
"Mh4wAHIAaQBjAGgAbgBvAHQAaQBmAGkAYwBhAHQAaQBvAG4AcwBhAHAAcAAuAGMAbwBtMDEwITAJBgUrDgMCGgUABBShhhfLZmAOmqGltImT+9krDrQGAgQId7jD11L05jECAggA";
var secureString = new SecureString();
secureString.AppendChar('r');
secureString.AppendChar('i');
secureString.AppendChar('c');
secureString.AppendChar('h');
this._certificate = new X509Certificate2(Convert.FromBase64String(certificateString), secureString);

// register the default serialization instance as the generator would.
ParseNodeFactoryRegistry.DefaultInstance.ContentTypeAssociatedFactories.TryAdd(CoreConstants.MimeTypeNames.Application.Json, new JsonParseNodeFactory());
}


[Fact]
public void AddPublicEncryptionCertificate()
{
// arrange
var subscription = new Subscription();

// act
subscription.AddPublicEncryptionCertificate(_certificate);

// assert
Assert.NotNull(subscription.EncryptionCertificate);

// Assert that the cert only has the public key
var addedCertificate = new X509Certificate2(Convert.FromBase64String(subscription.EncryptionCertificate));
Assert.False(addedCertificate.HasPrivateKey);
}

[Fact]
public async Task DecryptableContentCanBeDecryptedWithCertificate()
{
// Arrange
var testChangeNotificationEncryptedContent = new ChangeNotificationEncryptedContent
{
Data = "FFYlP1Bgb/fWW2kHMZiq4Y98E+XL0QTWEnGogTF6RRS+i3KqlXw35yy5ax8fEOzJbLc10ky24Ij+5ei2Hwqkzhph35XdLIsVsJZlQNYBwOu4jKvYbbhc1uHpQ/QBbs" +
"4IcdtWKCojqnDYcJmhwkzOZYHUr6XFHHD0GbO3y/wE0BKxMG6d5gNMfbT08OSWl+bhETeGVif8GTgZ0CNA6j7Xlq2T9Jd512cEBtEbXgJoISJVyOo4YzSirrb4R9xr" +
"lw9ASdz+oEzKZeUh0NSKfihjvevg90f7r5ZCHH1bP13Fxi/9NxASS7Sv28kvQbl+bqjNvCXK/Ol7rQr4DfMXPG82BGYU8n5AmWBztTY4mZLR59896coFz4CCDai4aS" +
"WDO1ldldvW9eqsnWTukQSwef3nHMMwTNxGge5YRMFKfVjOKr55xI7bevi2pZ6iZm8Kp8F+Gi+5V1uDpUFqeeFG3z03e7TfqczNIHdIjqxFpdYlrh/7ySd3L3q4D3TT" +
"vVCRdrbjuJ4oZeuFG4PQbAmJBcMwLrWDBmAykTRtrMT1Y1Ur1lX6lTiikGkrlV1VPizykLZmkq6jeoJOnMVLDWpNlQSKKfDicHRWoBHxDHc/g0aPs1g9Jd0I06YsVi" +
"JsEhvRz5Kwp4jAbyDff1XVExYPKRA07EfbOl5dLReE6ATcJGBr1dI4VVECRS7yW+uYTxoUUyePUOGIPGgpCBzJGYoRXKpBibcRib4Xs6WHVrEwNkN2RTHneh7NdzUm" +
"Piv5RoTSBFKRgysb5pWt1aUwIOnvjxLPIvTJmOob6nYvR/qCkfczE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OPJ9+7gXRk4zYdLTWQgZMeXaa" +
"NgJIE0xc8BCuYKacT/iB6aY9JHmj2rbR6EDbMTKWkVBe+Z/qtQFhJFq9WBLXsh719qLl/MQarYCDrTNQtryF0WXn0UuLh2OIJYV9T8eSv4j1ZM0WDKw0X9MLaqF" +
"PZsZ0SXX4t2EArdnrCBf5duPPCcmfhnvrimqiynSJPDQT0e63oLlpW1z37TvZTeyORY1YTQRmaKWD91fiYtuVmSSVVy2vg+Fm7UIG082bc8y7LT241Qd5RosJaf" +
"1w+JPZbttjm7I6uT22XOzaNRouQWx5UxRvWllm46F3pFNq0dn0lztdsW0QckAV4M86wwObVZbqUbnDZ8YloHz0XRRg7cU0H1K60fPMAo7PUoMV+bJC9HzB5O8jp" +
"TScDd4yOYZPB1liV2PHRHuIB23lVUARe3MuMo4i+hAc/ftK9s7yvREBuBSD0wi9R6qCygZ09YwrqfXZjRlKcFnz6EE7sqT1tzs4OxdT8XgAdveV6PU968kQhema" +
"TsSSrmpvsVn46mMb1le2YY5PUukxZoUFiDMZb036C56HAQ2cyWZkNweDxDQXdHOvvfmU=",
DataSignature = "wAtDAqtryLgLo4zhy8BOpqTjf6BYlGv1I9acDpKQo5w=",
EncryptionCertificateId = "custom-id-for-testing",
EncryptionCertificateThumbprint = "4B95353E086AD37196606ACF834A14532F03E6DB"
};

// Act
var chatMessage = await testChangeNotificationEncryptedContent.DecryptAsync<ChatMessage>((_, thumbprint) => Task.FromResult(this._certificate));

// Assert that decryption is okay
Assert.Equal("1625126194597", chatMessage.Etag);
Assert.Equal("Hello World", chatMessage.Body.Content);
Assert.Equal(BodyType.Text, chatMessage.Body.ContentType);
}
}
}

0 comments on commit a02f2e4

Please sign in to comment.