public void CreateAuthContext_CertWithAlternativeNames_UseAlternativeNamesAsPeerIdentity() { // Arrange X509Certificate2 certificate = new X509Certificate2(TestHelpers.ResolvePath(@"Certs/outlookcom.crt")); // Act var authContext = GrpcProtocolHelpers.CreateAuthContext(certificate); // Assert Assert.AreEqual(true, authContext.IsPeerAuthenticated); Assert.AreEqual(GrpcProtocolConstants.X509SubjectAlternativeNameKey, authContext.PeerIdentityPropertyName); var identity = authContext.PeerIdentity.ToList(); Assert.AreEqual(23, identity.Count); Assert.AreEqual(GrpcProtocolConstants.X509SubjectAlternativeNameKey, identity[0].Name); Assert.AreEqual("*.internal.outlook.com", identity[0].Value); var allProperties = authContext.Properties.ToList(); Assert.AreEqual(24, allProperties.Count); var commonName = authContext.FindPropertiesByName(GrpcProtocolConstants.X509CommonNameKey).Single(); Assert.AreEqual(GrpcProtocolConstants.X509CommonNameKey, commonName.Name); Assert.AreEqual("outlook.com", commonName.Value); }
public void CreateAuthContext_CertWithCommonName_UseCommonNameAsPeerIdentity() { // Arrange var certificate = new X509Certificate2(TestHelpers.ResolvePath(@"Certs/client.crt")); // Act var authContext = GrpcProtocolHelpers.CreateAuthContext(certificate); // Assert Assert.AreEqual(true, authContext.IsPeerAuthenticated); Assert.AreEqual(GrpcProtocolConstants.X509CommonNameKey, authContext.PeerIdentityPropertyName); var identity = authContext.PeerIdentity.ToList(); Assert.AreEqual(1, identity.Count); Assert.AreEqual(GrpcProtocolConstants.X509CommonNameKey, identity[0].Name); Assert.AreEqual("localhost", identity[0].Value); var allProperties = authContext.Properties.ToList(); Assert.AreEqual(1, allProperties.Count); }