예제 #1
0
        public async void EmptyOwinEnvironment()
        {
            var parser  = new BasicAuthenticationSecretParser();
            var context = new OwinContext();

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

            secret.Should().BeNull();
        }
예제 #2
0
        public async void BasicAuthentication_Request_With_Unknown_Scheme()
        {
            var parser  = new BasicAuthenticationSecretParser();
            var context = new OwinContext();

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

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

            secret.Should().BeNull();
        }
예제 #3
0
        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();
        }
예제 #4
0
        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();
        }
예제 #5
0
        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, TestLogger.Create <BasicAuthenticationSecretParser>());
 }
 public BasicAuthenticationSecretParsing()
 {
     _options = new IdentityServerOptions();
     _parser  = new BasicAuthenticationSecretParser(_options);
 }
 public BasicAuthenticationSecretParsing()
 {
     _options = new IdentityServerOptions();
     _parser  = new BasicAuthenticationSecretParser(_options, new LoggerFactory());
 }