public async void EmptyOwinEnvironment()
        {
            var parser = new BasicAuthenticationSecretParser();
            var context = new OwinContext();

            var secret = await parser.ParseAsync(context.Environment);

            secret.Should().BeNull();
        }
        public async void BasicAuthentication_Request_With_Empty_Basic_Header_Variation()
        {
            var parser = new BasicAuthenticationSecretParser();
            var context = new OwinContext();

            context.Request.Headers.Add(
                new KeyValuePair<string, string[]>("Authorization", new[] { "Basic " }));

            var secret = await parser.ParseAsync(context.Environment);

            secret.Should().BeNull();
        }
        public async void Valid_BasicAuthentication_Request()
        {
            var parser = new BasicAuthenticationSecretParser();
            var context = new OwinContext();

            var headerValue = string.Format("Basic {0}",
                Convert.ToBase64String(Encoding.UTF8.GetBytes("client:secret")));
            context.Request.Headers.Add(
                new KeyValuePair<string, string[]>("Authorization", new[] { headerValue }));

            var secret = await parser.ParseAsync(context.Environment);

            secret.Type.Should().Be(Constants.ParsedSecretTypes.SharedSecret);
            secret.Id.Should().Be("client");
            secret.Credential.Should().Be("secret");
        }
 public BasicAuthenticationSecretParsing()
 {
     _options = new IdentityServerOptions();
     _parser = new BasicAuthenticationSecretParser(_options);
 }
        public async void BasicAuthentication_Request_With_Malformed_Credentials_Base64_Encoding_UserName_Only_With_Colon()
        {
            var parser = new BasicAuthenticationSecretParser();
            var context = new OwinContext();

            var headerValue = string.Format("Basic {0}",
                Convert.ToBase64String(Encoding.UTF8.GetBytes("client:")));
            context.Request.Headers.Add(
                new KeyValuePair<string, string[]>("Authorization", new[] { headerValue }));

            var secret = await parser.ParseAsync(context.Environment);

            secret.Should().BeNull();
        }
        public async void BasicAuthentication_Request_With_Malformed_Credentials_NoBase64_Encoding()
        {
            var parser = new BasicAuthenticationSecretParser();
            var context = new OwinContext();

            context.Request.Headers.Add(
                new KeyValuePair<string, string[]>("Authorization", new[] { "Basic somerandomdata" }));

            var secret = await parser.ParseAsync(context.Environment);

            secret.Should().BeNull();
        }