Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAddInitialUserIfUsersExist() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotAddInitialUserIfUsersExist()
        {
            // Given
            FileUserRepository initialUserRepository = CommunitySecurityModule.GetInitialUserRepository(Config, NullLogProvider.Instance, FsRule.get());

            initialUserRepository.Start();
            initialUserRepository.Create(NewUser("initUser", "123", false));
            initialUserRepository.Shutdown();
            Users.start();
            Users.create(NewUser("oldUser", "321", false));
            Users.shutdown();

            // When
            AuthManager().start();

            // Then
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.security.User initUser = users.getUserByName("initUser");
            User initUser = Users.getUserByName("initUser");

            assertNull(initUser);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.security.User oldUser = users.getUserByName("oldUser");
            User oldUser = Users.getUserByName("oldUser");

            assertNotNull(oldUser);
            assertTrue(oldUser.Credentials().matchesPassword("321"));
            assertFalse(oldUser.PasswordChangeRequired());
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            Config = Config.defaults();
            Users  = CommunitySecurityModule.GetUserRepository(Config, NullLogProvider.Instance, FsRule.get());
            UserRepository initUserRepository = CommunitySecurityModule.GetInitialUserRepository(Config, NullLogProvider.Instance, FsRule.get());

            _manager = new BasicAuthManager(Users, mock(typeof(PasswordPolicy)), _authStrategy, initUserRepository);
            _manager.init();
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLoadInitialUserIfNoneExistEvenWithSamePassword() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLoadInitialUserIfNoneExistEvenWithSamePassword()
        {
            // Given
            FileUserRepository initialUserRepository = CommunitySecurityModule.GetInitialUserRepository(Config, NullLogProvider.Instance, FsRule.get());

            initialUserRepository.Start();
            initialUserRepository.create(new User.Builder("neo4j", LegacyCredential.ForPassword("neo4j"))
                                         .withRequiredPasswordChange(false).build());
            initialUserRepository.Shutdown();

            // When
            AuthManager().start();

            // Then
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.security.User user = users.getUserByName("neo4j");
            User user = Users.getUserByName("neo4j");

            assertNotNull(user);
            assertTrue(user.Credentials().matchesPassword("neo4j"));
            assertFalse(user.PasswordChangeRequired());
        }