コード例 #1
0
        public async Task OnActionExecutingAsync_AllowCookieAndNoSessionTokenOrCookie_Unauthorized()
        {
            // Arrange
            var attribute     = new SessionAttribute(true);
            var request       = new HttpRequestMessage(HttpMethod.Get, "");
            var actionContext = HttpFilterHelper.CreateHttpActionContext(request);

            // Act
            await attribute.OnActionExecutingAsync(actionContext, CancellationToken.None);

            // Assert
            Assert.AreEqual(HttpStatusCode.Unauthorized, actionContext.Response.StatusCode);
        }
コード例 #2
0
        public async Task OnActionExecutingAsync_IgnoreBadTokenAndNoSessionToken_ResponseIsNull()
        {
            // Arrange
            string session       = Session.Convert(new Guid());
            var    attribute     = new SessionAttribute(false, true, CreateHttpClientProvider(session), CreateCache());
            var    request       = new HttpRequestMessage(HttpMethod.Put, "");
            var    actionContext = HttpFilterHelper.CreateHttpActionContext(request);

            // Act
            await attribute.OnActionExecutingAsync(actionContext, CancellationToken.None);

            // Assert
            Assert.IsNull(actionContext.Response);
        }
コード例 #3
0
        public async Task OnActionExecutingAsync_BlueprintSessionIgnoreToken_ResponseIsNull()
        {
            // Arrange
            var attribute = new SessionAttribute();
            var request   = new HttpRequestMessage(HttpMethod.Get, "");

            request.Headers.Add("e51d8f58-0c62-46ad-a6fc-7e7994670f34", "");
            var actionContext = HttpFilterHelper.CreateHttpActionContext(request);

            // Act
            await attribute.OnActionExecutingAsync(actionContext, CancellationToken.None);

            // Assert
            Assert.IsNull(actionContext.Response);
        }
コード例 #4
0
        public async Task OnActionExecutingAsync_AllowCookieAndValidCookie_ResponseIsNull()
        {
            // Arrange
            string session   = Session.Convert(new Guid());
            var    attribute = new SessionAttribute(true, false, CreateHttpClientProvider(session, false), CreateCache());
            var    request   = new HttpRequestMessage(HttpMethod.Get, "");

            request.Headers.Add("Cookie", "BLUEPRINT_SESSION_TOKEN=" + session);
            var actionContext = HttpFilterHelper.CreateHttpActionContext(request);

            // Act
            await attribute.OnActionExecutingAsync(actionContext, CancellationToken.None);

            // Assert
            Assert.IsNull(actionContext.Response);
        }
コード例 #5
0
        public async Task OnActionExecutingAsync_Exception_InternalServerError()
        {
            // Arrange
            string session   = Session.Convert(new Guid());
            var    attribute = new SessionAttribute(false, false, new TestHttpClientProvider(r => { throw new Exception(); }), CreateCache());
            var    request   = new HttpRequestMessage(HttpMethod.Get, "");

            request.Headers.Add("Session-Token", session);
            var actionContext = HttpFilterHelper.CreateHttpActionContext(request);

            // Act
            await attribute.OnActionExecutingAsync(actionContext, CancellationToken.None);

            // Assert
            Assert.AreEqual(HttpStatusCode.InternalServerError, actionContext.Response.StatusCode);
        }
コード例 #6
0
        public async Task OnActionExecutingAsync_InvalidSessionToken_()
        {
            // Arrange
            string session   = Session.Convert(new Guid());
            var    attribute = new SessionAttribute(false, false, CreateHttpClientProvider(""), CreateCache());

            var request = new HttpRequestMessage(HttpMethod.Get, "");

            request.Headers.Add("Session-Token", session);
            var actionContext = HttpFilterHelper.CreateHttpActionContext(request);

            // Act
            await attribute.OnActionExecutingAsync(actionContext, CancellationToken.None);

            // Assert
            Assert.AreEqual(HttpStatusCode.Unauthorized, actionContext.Response.StatusCode);
        }