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

                act.Should().Throw <NotSupportedException>();
            }
Exemplo n.º 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();
            }
Exemplo n.º 4
0
 public SigningSettingsTests()
 {
     _sut = new SigningSettings {
         Expires            = TimeSpan.FromMinutes(5),
         KeyId              = new KeyId("client1"),
         SignatureAlgorithm = new HMACSignatureAlgorithm("s3cr3t", HashAlgorithmName.SHA384),
         Headers            = new[] {
             HeaderName.PredefinedHeaderNames.RequestTarget,
             HeaderName.PredefinedHeaderNames.Date,
             new HeaderName("dalion_app_id")
         },
         DigestHashAlgorithm = default
     };
 }
 public HMACSignatureAlgorithmTests()
 {
     _sut = new HMACSignatureAlgorithm("s3cr3t", HashAlgorithmName.SHA384);
 }