Example #1
0
        public void AddBasicAuthenticationHeader_should_not_add_header_without_credentials()
        {
            // Arrange
            var fakeRequest = new FakeRequest();

            // Act
            UrlResourceAccessor.AddBasicAuthenticationHeader(fakeRequest, null);

            // Assert
            fakeRequest.Headers.Should().HaveCount(0);
        }
Example #2
0
        public void AddCustomHeaders_should_add_headers_based_on_custom_options()
        {
            // Arrange
            var fakeRequest = new FakeRequest();
            var options = new ResourceAccessorOptions();
            var header = "Foo";
            var headerValue = "Bar";
            options[header] = headerValue;

            // Act
            UrlResourceAccessor.AddCustomHeaders(fakeRequest, options);

            // Assert
            fakeRequest.Headers.Keys.Should().Contain(header);
            fakeRequest.Headers[header].Should().Be(headerValue);
        }
Example #3
0
        public void AddBasicAuthenticationHeader_should_add_Authorization_header_based_on_credentials()
        {
            // Arrange
            var userName = "******";
            var password = "******";
            var credentials = new Credentials(userName, password);
            var fakeRequest = new FakeRequest();

            // Act
            UrlResourceAccessor.AddBasicAuthenticationHeader(fakeRequest, credentials);

            // Assert
            fakeRequest.Headers.Keys.Should().Contain(HttpRequestHeader.Authorization.ToString());

            var header = fakeRequest.Headers[HttpRequestHeader.Authorization.ToString()];
            header.Should().BeBasicAuthorizationHeader(userName, password);
        }
Example #4
0
        public void AddCustomHeaders_should_not_add_headers_if_options_are_null()
        {
            // Arrange
            var fakeRequest = new FakeRequest();

            // Act
            UrlResourceAccessor.AddCustomHeaders(fakeRequest, null);

            // Assert
            fakeRequest.Headers.Should().HaveCount(0);
        }