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()); }
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); }
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); }
public static BrowserContext Authenticated(this BrowserContext context) { context.BasicAuth("admin", "servant"); return(context); }