Esempio n. 1
0
        public void Should_add_basic_authentication_credentials_to_the_headers_of_the_request()
        {
            // Given
            var context = new BrowserContext();

            // When
            context.BasicAuth("username", "password");

            // Then
            IBrowserContextValues values = context;

            var credentials        = string.Format("{0}:{1}", "username", "password");
            var encodedCredentials = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials));

            Assert.Equal(1, values.Headers.Count);
            Assert.Equal("Basic " + encodedCredentials, values.Headers["Authorization"].First());
        }
Esempio n. 2
0
        public void Should_add_basic_authentication_credentials_to_the_headers_of_the_request()
        {
            // Given
            var context = new BrowserContext(A.Fake<INancyEnvironment>());

            // When
            context.BasicAuth("username", "password");

            // Then
            IBrowserContextValues values = context;

            var credentials = string.Format("{0}:{1}", "username", "password");
            var encodedCredentials = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials));

            values.Headers["Authorization"].ShouldHaveCount(1);
            values.Headers["Authorization"].First().ShouldEqual("Basic " + encodedCredentials);
        }
Esempio n. 3
0
        public async Task Should_add_basic_authentication_credentials_to_the_headers_of_the_request()
        {
            // Given
            var context = new BrowserContext(A.Fake <INancyEnvironment>());

            // When
            context.BasicAuth("username", "password");

            // Then
            IBrowserContextValues values = context;

            var credentials        = string.Format("{0}:{1}", "username", "password");
            var encodedCredentials = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials));

            values.Headers["Authorization"].ShouldHaveCount(1);
            values.Headers["Authorization"].First().ShouldEqual("Basic " + encodedCredentials);
        }
Esempio n. 4
0
 public static BrowserContext Authenticated(this BrowserContext context)
 {
     context.BasicAuth("admin", "servant");
     return(context);
 }