public void ParseValidToken() { // Arrange var expectedSamlToken = "<xml>samltoken</xml>"; var expectedNonce = Nonce.FromNow(); var expectedBodyHash = new byte[] { 1, 2, 3 }; var expectedSignature = new byte[] { 1, 4, 1 }; var expectedSignatureAlg = SigningAlgorithm.RSA_SHA384; var token = GetExpected( expectedSamlToken, expectedNonce, expectedBodyHash, expectedSignatureAlg, expectedSignature); // Act var actual = new TokenFormatter().Parse(new [] { token }); // Assert Assert.AreEqual(expectedSamlToken, actual.SamlToken); Assert.AreEqual(expectedNonce, actual.Nonce); Assert.That(expectedBodyHash, Is.EqualTo(actual.BodyHash)); Assert.AreEqual(expectedSignature, actual.Signature); Assert.That(expectedSignatureAlg, Is.EqualTo(actual.SignatureAlgorithm)); }
public void ParseMissingSignatureToken() { // Arrange var expectedSamlToken = "<xml>samltoken</xml>"; var expectedNonce = Nonce.FromNow(); var expectedBodyHash = new byte[] { 1, 2, 3 }; var expectedSignature = new byte[] { 1, 4, 1 }; var expectedSignatureAlg = SigningAlgorithm.RSA_SHA384; var token = GetExpected( expectedSamlToken, expectedNonce, expectedBodyHash, expectedSignatureAlg, expectedSignature); token = token.Substring(0, token.IndexOf(", signature=")); // Act & Assert Assert.Throws <AuthException>(() => new TokenFormatter().Parse(new[] { token })); }