public void WhenConstructedSetsTheValueProperty() { var header = new BasicAuthorizationHeader("username", "password"); string expected = Convert.ToBase64String(Encoding.UTF8.GetBytes($"username:password")); header.Value.Should().Be($"Basic {expected}"); }
public void Must_parse_correctly(string headerValue, string expectedUserid, string expectedPassword) { BasicAuthorizationHeader header = BasicAuthorizationHeader.Parse(headerValue); Assert.That(header, Is.Not.Null); Assert.That(header.AuthScheme, Is.StringMatching("[Bb]asic")); Assert.That(header.Userid, Is.EqualTo(expectedUserid)); Assert.That(header.Password, Is.EqualTo(expectedPassword)); }
private static BasicAuthorizationHeader ReadBasicAuthHeader(ICommunicationContext context) { try { var header = context.Request.Headers["Authorization"]; return(string.IsNullOrEmpty(header) ? null : BasicAuthorizationHeader.Parse(header)); } catch (ArgumentException ex) { return(null); } }
public void WhenConstructedSetsTheNamePropertyToAuthorization() { var header = new BasicAuthorizationHeader("username", "password"); header.Name.Should().Be("Authorization"); }
public void Must_not_result_in_header(string headerValue) { Assert.That(BasicAuthorizationHeader.Parse(headerValue), Is.Null); }