Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRecoverIfCrashedDuringMove() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRecoverIfCrashedDuringMove()
        {
            // Given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.IOException exception = new java.io.IOException("simulated IO Exception on create");
            IOException           exception          = new IOException("simulated IO Exception on create");
            FileSystemAbstraction crashingFileSystem = new DelegatingFileSystemAbstractionAnonymousInnerClass(this, _fs, exception);

            FileUserRepository users = new FileUserRepository(crashingFileSystem, _authFile, _logProvider);

            users.Start();
            User user = (new User.Builder("jake", LegacyCredential.Inaccessible)).withRequiredPasswordChange(true).build();

            // When
            try
            {
                users.Create(user);
                fail("Expected an IOException");
            }
            catch (IOException e)
            {
                assertSame(exception, e);
            }

            // Then
            assertFalse(crashingFileSystem.FileExists(_authFile));
            assertThat(crashingFileSystem.ListFiles(_authFile.ParentFile).Length, equalTo(0));
        }
Example #2
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());
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStoreAndRetrieveUsersByName() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldStoreAndRetrieveUsersByName()
        {
            // Given
            FileUserRepository users = new FileUserRepository(_fs, _authFile, _logProvider);
            User user = (new User.Builder("jake", LegacyCredential.Inaccessible)).withRequiredPasswordChange(true).build();

            users.Create(user);

            // When
            User result = users.GetUserByName(user.Name());

            // Then
            assertThat(result, equalTo(user));
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotFindUserAfterDelete() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotFindUserAfterDelete()
        {
            // Given
            FileUserRepository users = new FileUserRepository(_fs, _authFile, _logProvider);
            User user = (new User.Builder("jake", LegacyCredential.Inaccessible)).withRequiredPasswordChange(true).build();

            users.Create(user);

            // When
            users.Delete(user);

            // Then
            assertThat(users.GetUserByName(user.Name()), nullValue());
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowIfExistingUserDoesNotMatch() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowIfExistingUserDoesNotMatch()
        {
            // Given
            FileUserRepository users = new FileUserRepository(_fs, _authFile, _logProvider);
            User user = (new User.Builder("jake", LegacyCredential.Inaccessible)).withRequiredPasswordChange(true).build();

            users.Create(user);
            User modifiedUser = user.Augment().withCredentials(LegacyCredential.ForPassword("foo")).build();

            // When
            User updatedUser = user.Augment().withCredentials(LegacyCredential.ForPassword("bar")).build();

            try
            {
                users.Update(modifiedUser, updatedUser);
                fail("expected exception not thrown");
            }
            catch (ConcurrentModificationException)
            {
                // Then continue
            }
        }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldProvideUserByUsernameEvenIfMidSetUsers() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldProvideUserByUsernameEvenIfMidSetUsers()
        {
            // Given
            FileUserRepository users = new FileUserRepository(_fs, _authFile, _logProvider);

            users.Create((new User.Builder("oskar", LegacyCredential.ForPassword("hidden"))).build());
            DoubleLatch latch = new DoubleLatch(2);

            // When
            Future <object> setUsers = Threading.execute(o =>
            {
                users.Users = new HangingListSnapshot(this, latch, 10L, java.util.Collections.emptyList());
                return(null);
            }, null);

            latch.StartAndWaitForAllToStart();

            // Then
            assertNotNull(users.GetUserByName("oskar"));

            latch.Finish();
            setUsers.get();
        }
Example #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowIfUpdateChangesName() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowIfUpdateChangesName()
        {
            // Given
            FileUserRepository users = new FileUserRepository(_fs, _authFile, _logProvider);
            User user = (new User.Builder("jake", LegacyCredential.Inaccessible)).withRequiredPasswordChange(true).build();

            users.Create(user);

            // When
            User updatedUser = (new User.Builder("john", LegacyCredential.Inaccessible)).withRequiredPasswordChange(true).build();

            try
            {
                users.Update(user, updatedUser);
                fail("expected exception not thrown");
            }
            catch (System.ArgumentException)
            {
                // Then continue
            }

            assertThat(users.GetUserByName(user.Name()), equalTo(user));
        }