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 WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void assertAuthIniFile(String password) throws Throwable
        private void AssertAuthIniFile(string password)
        {
            assertTrue(_fileSystem.fileExists(_authInitFile));
            FileUserRepository userRepository = new FileUserRepository(_fileSystem, _authInitFile, NullLogProvider.Instance);

            userRepository.Start();
            User neo4j = userRepository.GetUserByName(Org.Neo4j.Kernel.api.security.UserManager_Fields.INITIAL_USER_NAME);

            assertNotNull(neo4j);
            assertTrue(neo4j.Credentials().matchesPassword(password));
            assertFalse(neo4j.HasFlag(User.PASSWORD_CHANGE_REQUIRED));
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateDefaultUserIfNoneExist() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCreateDefaultUserIfNoneExist()
        {
            // 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"));
            assertTrue(user.PasswordChangeRequired());
        }
Beispiel #4
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());
        }