Example #1
0
 public Tests()
 {
     _now     = DateTimeOffset.Now;
     _options = new SignOptions {
         Message    = HttpMessageGenerator.GenerateMessage("default-request", _now),
         PrivateKey = "rsa.private",
         Headers    = "digest",
         KeyType    = "rsa",
         KeyId      = "test"
     };
 }
Example #2
0
        public async Task CanVerifyHMACSignature()
        {
            _options.Message = await HttpMessageGenerator
                               .GenerateMessage("hmac-signed-request", _now)
                               .ToServerSideHttpRequest();

            _options.KeyType   = "hmac";
            _options.PublicKey = "s3cr37";

            var isSuccess = await Verifier.Run(_options);

            isSuccess.Should().BeTrue();
        }
Example #3
0
        public async Task CanVerifyP256Signature()
        {
            _options.Message = await HttpMessageGenerator
                               .GenerateMessage("p256-signed-request", _now)
                               .ToServerSideHttpRequest();

            _options.KeyType   = "ecdsa";
            _options.PublicKey = "p256.pub";

            var isSuccess = await Verifier.Run(_options);

            isSuccess.Should().BeTrue();
        }
Example #4
0
        public Tests()
        {
            _now = DateTimeOffset.Now;

            _setKeyId = signature => signature.KeyId = new KeyId("test");
            _options  = new VerifyOptions {
                Message = HttpMessageGenerator
                          .GenerateMessage("rsa-signed-request", _now)
                          .ToServerSideHttpRequest().GetAwaiter().GetResult(),
                PublicKey             = "rsa.pub",
                Headers               = "host,digest",
                KeyType               = "rsa",
                ModifyParsedSignature = (request, signature) => {
                    _setKeyId(signature);
                    return(Task.CompletedTask);
                }
            };
        }