Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCacheAuthenticationInfo() throws org.neo4j.kernel.api.security.exception.InvalidAuthTokenException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotCacheAuthenticationInfo()
        {
            // Given
            EnterpriseLoginContext mike = _authManager.login(authToken("mike", "123"));

            assertThat(mike.Subject().AuthenticationResult, equalTo(AuthenticationResult.SUCCESS));
            assertThat("Test realm did not receive a call", _testRealm.takeAuthenticationFlag(), @is(true));

            // When
            mike = _authManager.login(authToken("mike", "123"));
            assertThat(mike.Subject().AuthenticationResult, equalTo(AuthenticationResult.SUCCESS));

            // Then
            assertThat("Test realm did not receive a call", _testRealm.takeAuthenticationFlag(), @is(true));
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotLogPassword() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotLogPassword()
        {
            _database = _databaseBuilder.setConfig(log_queries, Settings.TRUE).setConfig(logs_directory, _logsDirectory.Path).setConfig(GraphDatabaseSettings.auth_enabled, Settings.TRUE).newGraphDatabase();
            GraphDatabaseFacade facade = ( GraphDatabaseFacade )this._database;

            EnterpriseAuthManager  authManager = facade.DependencyResolver.resolveDependency(typeof(EnterpriseAuthManager));
            EnterpriseLoginContext neo         = authManager.Login(AuthToken.newBasicAuthToken("neo4j", "neo4j"));

            string query = "CALL dbms.security.changePassword('abc123')";

            try
            {
                using (InternalTransaction tx = facade.BeginTransaction(KernelTransaction.Type.@explicit, neo))
                {
                    Result res = facade.Execute(tx, query, VirtualValues.EMPTY_MAP);
                    res.Close();
                    tx.Success();
                }
            }
            finally
            {
                facade.Shutdown();
            }

            IList <string> logLines = ReadAllLines(_logFilename);

            assertEquals(1, logLines.Count);
            assertThat(logLines[0], containsString("CALL dbms.security.changePassword(******)"));
            assertThat(logLines[0], not(containsString("abc123")));
            assertThat(logLines[0], containsString(neo.Subject().username()));
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCacheAuthorizationInfo() throws org.neo4j.kernel.api.security.exception.InvalidAuthTokenException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotCacheAuthorizationInfo()
        {
            // Given
            EnterpriseLoginContext mike = _authManager.login(authToken("mike", "123"));

            assertThat(mike.Subject().AuthenticationResult, equalTo(AuthenticationResult.SUCCESS));

            mike.Authorize(_token, GraphDatabaseSettings.DEFAULT_DATABASE_NAME).mode().allowsReads();
            assertThat("Test realm did not receive a call", _testRealm.takeAuthorizationFlag(), @is(true));

            // When
            mike.Authorize(_token, GraphDatabaseSettings.DEFAULT_DATABASE_NAME).mode().allowsWrites();

            // Then
            assertThat("Test realm did not receive a call", _testRealm.takeAuthorizationFlag(), @is(true));
        }