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

            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 received a call", _testRealm.takeAuthorizationFlag(), @is(false));
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInvalidateAuthorizationCacheAfterTTL() throws org.neo4j.kernel.api.security.exception.InvalidAuthTokenException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldInvalidateAuthorizationCacheAfterTTL()
        {
            // Given
            EnterpriseLoginContext mike = _authManager.login(authToken("mike", "123"));

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

            // When
            _fakeTicker.advance(99, TimeUnit.MILLISECONDS);
            mike.Authorize(_token, GraphDatabaseSettings.DEFAULT_DATABASE_NAME).mode().allowsWrites();

            // Then
            assertThat("Test realm received a call", _testRealm.takeAuthorizationFlag(), @is(false));

            // When
            _fakeTicker.advance(2, TimeUnit.MILLISECONDS);
            mike.Authorize(_token, GraphDatabaseSettings.DEFAULT_DATABASE_NAME).mode().allowsWrites();

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