public Compose()
            {
                var timeOfComposing = new DateTimeOffset(2020, 2, 24, 11, 20, 14, TimeSpan.FromHours(1));
                var expires         = TimeSpan.FromMinutes(5);
                var httpRequest     = new HttpRequestForSignatureString {
                    Method     = HttpMethod.Post,
                    RequestUri = "http://dalion.eu/api/resource/id1".ToUri()
                };
                var headerNames = new[] {
                    HeaderName.PredefinedHeaderNames.RequestTarget,
                    HeaderName.PredefinedHeaderNames.Date,
                    new HeaderName("dalion_app_id")
                };
                var requestTargetEscaping = RequestTargetEscaping.Unescaped;
                var nonce = "abc123";

                _compositionRequest = new SigningStringCompositionRequest {
                    Request               = httpRequest,
                    Expires               = expires,
                    Nonce                 = nonce,
                    HeadersToInclude      = headerNames,
                    RequestTargetEscaping = requestTargetEscaping,
                    TimeOfComposing       = timeOfComposing
                };

                FakeFactory.Create(out _headerAppender);
                A.CallTo(() => _headerAppenderFactory.Create(
                             _compositionRequest.Request,
                             _compositionRequest.RequestTargetEscaping,
                             _compositionRequest.TimeOfComposing,
                             _compositionRequest.Expires))
                .Returns(_headerAppender);
            }
 public DefaultHeaderAppenderTests()
 {
     _httpRequest = new HttpRequestForSignatureString {
         Method     = HttpMethod.Post,
         RequestUri = "http://dalion.eu/api/resource/id1".ToUri()
     };
     _sut = new DefaultHeaderAppender(_httpRequest);
 }
Beispiel #3
0
 public Create()
 {
     _timeOfComposing = new DateTimeOffset(2020, 2, 24, 11, 20, 14, TimeSpan.FromHours(1));
     _expires         = TimeSpan.FromMinutes(5);
     _httpRequest     = new HttpRequestForSignatureString {
         Method     = HttpMethod.Post,
         RequestUri = "http://dalion.eu/api/resource/id1".ToUri()
     };
     _requestTargetEscaping = RequestTargetEscaping.RFC3986;
 }
Beispiel #4
0
 public RequestTargetHeaderAppenderTests()
 {
     FakeFactory.Create(out _requestTargetEscaper);
     _httpRequest = new HttpRequestForSignatureString {
         Method     = HttpMethod.Post,
         RequestUri = "/api/resource/id1".ToUri()
     };
     _requestTargetEscaping = RequestTargetEscaping.RFC3986;
     _sut = new RequestTargetHeaderAppender(_httpRequest, _requestTargetEscaping, _requestTargetEscaper);
 }
        public IHeaderAppender Create(HttpRequestForSignatureString request, RequestTargetEscaping requestTargetEscaping, DateTimeOffset?timeOfComposing, TimeSpan?expires)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            return(new CompositeHeaderAppender(
                       new DefaultHeaderAppender(request),
                       new RequestTargetHeaderAppender(request, requestTargetEscaping, _requestTargetEscaper),
                       new CreatedHeaderAppender(timeOfComposing),
                       new ExpiresHeaderAppender(timeOfComposing, expires),
                       new DateHeaderAppender(request)));
        }
 public DefaultHeaderAppender(HttpRequestForSignatureString request)
 {
     _request = request ?? throw new ArgumentNullException(nameof(request));
 }
 public RequestTargetHeaderAppender(HttpRequestForSignatureString request, RequestTargetEscaping requestTargetEscaping, IRequestTargetEscaper requestTargetEscaper)
 {
     _request = request ?? throw new ArgumentNullException(nameof(request));
     _requestTargetEscaping = requestTargetEscaping;
     _requestTargetEscaper  = requestTargetEscaper ?? throw new ArgumentNullException(nameof(requestTargetEscaper));
 }