Exemple #1
0
        public async Task ValidateRequestInvalidController()
        {
            var sut = new ExecutionFilterAttribute(Mock.Of <IAuthManager>(), Mock.Of <IContextManager>(), AuthenticationLevel.User);

            var result = await sut.ValidateRequest(null, "token");

            Assert.IsFalse(result.isValid);
            Assert.AreEqual("InvalidController", result.errPhrase);
        }
Exemple #2
0
        public async Task ValidateRequestTokenNotValid()
        {
            const string tokenString = "sampletoken";

            var authManager = GetAuthManager(null);

            var sut = new ExecutionFilterAttribute(authManager, Mock.Of <IContextManager>(), AuthenticationLevel.User);

            var result = await sut.ValidateRequest(Mock.Of <IBaseController>(), tokenString);

            Assert.IsFalse(result.isValid);
            Assert.AreEqual("InvalidToken", result.errPhrase);
        }
Exemple #3
0
        public async Task ValidateRequest()
        {
            const string tokenString = "sampletoken";

            var controller = new Mock <IBaseController>();

            var token       = GetAuthToken(tokenString, true);
            var authManager = GetAuthManager(token);

            AuthToken actual = null;

            controller
            .SetupSet(p => p.Token = It.IsAny <AuthToken>())
            .Callback <AuthToken>(value => actual = value);

            var sut = new ExecutionFilterAttribute(authManager, Mock.Of <IContextManager>(), AuthenticationLevel.User);

            var result = await sut.ValidateRequest(controller.Object, tokenString);

            Assert.AreSame(token, actual);
            Assert.IsTrue(result.isValid);
            Assert.AreEqual("", result.errPhrase);
        }