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); }
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); }
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); }