Ejemplo n.º 1
0
        public async Task ShouldSkipAuthOnWMissingHostHeader()
        {
            var request = new HttpRequestMessage();

            request.Headers.Authorization = new AuthenticationHeaderValue("Hawk", "id = \"123\", ts = \"1353788437\", mac = \"/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=\", ext = \"hello\"");

            var c = new HttpAuthenticationContext(new HttpActionContext()
            {
                ControllerContext = new HttpControllerContext()
                {
                    Request = request
                }
            }, null);

            var handler = new HawkAuthentication(typeof(HawkCredentialRepository));
            await handler.AuthenticateAsync(c, new CancellationToken());

            Assert.IsNull(c.Principal);
        }
Ejemplo n.º 2
0
        public async Task ShouldSkipAuthOnWrongAuthScheme()
        {
            var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com:8080/resource/4?filter=a");

            request.Headers.Authorization = new AuthenticationHeaderValue("Basic");

            var c = new HttpAuthenticationContext(new HttpActionContext()
            {
                ControllerContext = new HttpControllerContext()
                {
                    Request = request
                }
            }, null);

            var handler = new HawkAuthentication(typeof(HawkCredentialRepository));
            await handler.AuthenticateAsync(c, new CancellationToken());

            Assert.IsNull(c.Principal);
        }
Ejemplo n.º 3
0
        public async Task ShouldSkipAuthOnMissingAuthAttribute()
        {
            var request = new HttpRequestMessage(HttpMethod.Get, "http://example.com:8080/resource/4?filter=a");

            request.Headers.Authorization = new AuthenticationHeaderValue("Hawk", "ts = \"1353788437\", mac = \"/qwS4UjfVWMcUyW6EEgUH4jlr7T/wuKe3dKijvTvSos=\", ext = \"hello\"");
            request.Headers.Host          = "localhost";

            var c = new HttpAuthenticationContext(new HttpActionContext()
            {
                ControllerContext = new HttpControllerContext()
                {
                    Request = request
                }
            }, null);

            var handler = new HawkAuthentication(typeof(HawkCredentialRepository));
            await handler.AuthenticateAsync(c, new CancellationToken());

            Assert.IsNull(c.Principal);
        }