예제 #1
0
            public void WhenHashAlgorithmIsNotSupported_ThrowsNotSupportedException()
            {
                var    sut = new HMACSignatureAlgorithm("s3cr3t", new HashAlgorithmName("unsupporteed"));
                Action act = () => sut.ComputeHash("payload");

                act.Should().Throw <NotSupportedException>();
            }
예제 #2
0
            public void CreatesHash()
            {
                var sut     = new HMACSignatureAlgorithm("", HashAlgorithmName.SHA384);
                var payload = "_abc_123_";
                var actual  = sut.ComputeHash(payload);

                actual.Should().NotBeNull().And.NotBeEmpty();
            }
            public void CanUseEmptySecret()
            {
                var sut       = new HMACSignatureAlgorithm("", HashAlgorithmName.SHA384);
                var payload   = "_abc_123_";
                var signature = sut.ComputeHash(payload);
                var actual    = sut.VerifySignature(payload, signature);

                actual.Should().BeTrue();
            }