public VerifySignature() { _signature = new Signature { KeyId = "client1" }; _signedRequest = new HttpRequestForSigning { Method = HttpMethod.Post, RequestUri = "https://unittest.com:9001" }; _client = new Client("client1", "Unit test app", new HMACSignatureAlgorithm("s3cr3t", HashAlgorithmName.SHA256), TimeSpan.FromMinutes(1)); A.CallTo(() => _knownAlgorithmVerificationTask.Verify(A <HttpRequestForSigning> ._, A <Signature> ._, A <Client> ._)).Returns((SignatureVerificationFailure)null); A.CallTo(() => _matchingAlgorithmVerificationTask.Verify(A <HttpRequestForSigning> ._, A <Signature> ._, A <Client> ._)).Returns((SignatureVerificationFailure)null); A.CallTo(() => _createdHeaderGuardVerificationTask.Verify(A <HttpRequestForSigning> ._, A <Signature> ._, A <Client> ._)).Returns((SignatureVerificationFailure)null); A.CallTo(() => _expiresHeaderGuardVerificationTask.Verify(A <HttpRequestForSigning> ._, A <Signature> ._, A <Client> ._)).Returns((SignatureVerificationFailure)null); A.CallTo(() => _allHeadersPresentVerificationTask.Verify(A <HttpRequestForSigning> ._, A <Signature> ._, A <Client> ._)).Returns((SignatureVerificationFailure)null); A.CallTo(() => _creationTimeVerificationTask.Verify(A <HttpRequestForSigning> ._, A <Signature> ._, A <Client> ._)).Returns((SignatureVerificationFailure)null); A.CallTo(() => _expirationTimeVerificationTask.Verify(A <HttpRequestForSigning> ._, A <Signature> ._, A <Client> ._)).Returns((SignatureVerificationFailure)null); A.CallTo(() => _nonceVerificationTask.Verify(A <HttpRequestForSigning> ._, A <Signature> ._, A <Client> ._)).Returns((SignatureVerificationFailure)null); A.CallTo(() => _digestVerificationTask.Verify(A <HttpRequestForSigning> ._, A <Signature> ._, A <Client> ._)).Returns((SignatureVerificationFailure)null); A.CallTo(() => _matchingSignatureStringVerificationTask.Verify(A <HttpRequestForSigning> ._, A <Signature> ._, A <Client> ._)).Returns((SignatureVerificationFailure)null); _sanitizedSignature = (Signature)_signature.Clone(); A.CallTo(() => _signatureSanitizer.Sanitize(_signature, _client)) .Returns(_sanitizedSignature); }
public Task <Signature> Sanitize(Signature signature, Client client) { if (signature == null) { throw new ArgumentNullException(nameof(signature)); } if (client == null) { throw new ArgumentNullException(nameof(client)); } var newSignature = (Signature)signature.Clone(); if (newSignature.Headers == null || !newSignature.Headers.Any()) { newSignature.Headers = _defaultSignatureHeadersProvider.ProvideDefaultHeaders(client.SignatureAlgorithm); } return(Task.FromResult(newSignature)); }