示例#1
0
        public void When_user_exist_in_db_user_is_not_locked_basic_auth_then_auth_is_invalid()
        {
            var user = new WmsUser
            {
                Login              = "******",
                UserPassword       = "******",
                UserLocked         = false,
                UserAuthentication = false
            };

            var factory = GetSessionFactoryMock();

            using (ShimsContext.Create())
            {
                ShimLinqExtensionMethods.QueryOf1ISession(s => new[] { user }.AsQueryable());
                string userName;

                var authService = new AuthService(factory.Object, new SvcWmsEnvironmentInfoProvider());
                var res         = authService.Authenticate(user.Login, "1", out userName);
                res.Should().BeFalse();

                res = authService.Authenticate("1", user.UserPassword, out userName);
                res.Should().BeFalse();

                res = authService.Authenticate("5", "6", out userName);
                res.Should().BeFalse();
            }
        }
示例#2
0
        public void When_user_exist_in_db_user_is_not_locked_ad_auth_then_auth_is_valid()
        {
            var user = new WmsUser
            {
                Login              = "******",
                UserPassword       = "******",
                UserLocked         = false,
                UserAuthentication = true
            };

            var factory = GetSessionFactoryMock();

            using (ShimsContext.Create())
            {
                ShimLinqExtensionMethods.QueryOf1ISession(s => new[] { user }.AsQueryable());

                ShimConfigurationManager.AppSettingsGet = () =>
                {
                    var nameValueCollection = new NameValueCollection
                    {
                        { "AdPath", "AD" }
                    };
                    return(nameValueCollection);
                };

                ShimDirectorySearcher.ConstructorDirectoryEntryString = (@this, dentry, filter) =>
                {
                    var dirSearcher = new ShimDirectorySearcher(@this)
                    {
                        FindOne = () => SearchResultFactory.Construct(new
                        {
                            name = "testUser"
                        })
                    };
                };

                string userName;

                var authService = new AuthService(factory.Object, new SvcWmsEnvironmentInfoProvider());
                var res         = authService.Authenticate(user.Login, user.UserPassword, out userName);
                res.Should().BeTrue();
            }
        }
示例#3
0
 private bool BasicAuth(WmsUser user, string password)
 {
     return(user.UserPassword == password);
 }