예제 #1
0
        public void WhenInvalidHeader(string value)
        {
            Action action = () =>
            {
                var context = new HttpActionContext();

                var request = new HttpRequestMessage();
                request.Headers.Add(Constants.RequestHeaderNames.UserNote, value);

                context.ControllerContext = new HttpControllerContext {
                    Request = request
                };
                var filter = new ProviderAuthorisationFilter();
                filter.OnActionExecuting(context);
            };

            action.ShouldThrow <UnauthorisedException>().WithMessage(Constants.AuthorisationErrorMessages.InvalidUkprn);
        }
예제 #2
0
        public void WhenValidHeader(string value)
        {
            const string expectedValue = "12345678";
            var          context       = new HttpActionContext();

            var request = new HttpRequestMessage();

            request.Headers.Add(Constants.RequestHeaderNames.UserNote, value);

            context.ControllerContext = new HttpControllerContext {
                Request = request
            };
            var filter = new ProviderAuthorisationFilter();

            filter.OnActionExecuting(context);

            context.Request.GetHeaderValue(Constants.RequestHeaderNames.ProviderUkprn).Should().Be(expectedValue);

            Assert.IsNull(context.Response);
        }