Skip to content

Commit

Permalink
Add simple test cases
Browse files Browse the repository at this point in the history
Should not get auth expired with Ldap or Plugin if cache expires within
a transaction.
  • Loading branch information
henriknyman committed Oct 12, 2016
1 parent 5d17789 commit 081eed5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Expand Up @@ -337,6 +337,24 @@ public void shouldFailIfAuthorizationExpiredWithUserLdapContext() throws Throwab
msgFailure( Status.Security.AuthorizationExpired, "LDAP authorization info expired." ) ) );
}

@Test
public void shouldSucceedIfAuthorizationExpiredWithinTransactionWithUserLdapContext() throws Throwable
{
restartNeo4jServerWithOverriddenSettings( settings -> {
settings.put( SecuritySettings.ldap_authorization_use_system_account, "false" );
} );

// Then
assertAuth( "neo4j", "abc123" );

// We need to replace this with a two thread test.
client.send( TransportTestUtil.chunk(
run( "CALL dbms.security.clearAuthCache() MATCH (n) RETURN n" ), pullAll() ) );

// Then
assertThat( client, eventuallyReceives( msgSuccess(), msgSuccess() ) );
}

@Test
public void shouldBeAbleToLoginAndAuthorizeNoPermissionUserWithUserLdapContext() throws Throwable
{
Expand Down
Expand Up @@ -232,6 +232,23 @@ public void shouldFailIfAuthorizationExpiredWithAuthPlugin() throws Throwable
"Plugin 'plugin-TestCacheableAdminAuthPlugin' authorization info expired." ) ) );
}

@Test
public void shouldSucceedIfAuthorizationExpiredWithinTransactionWithAuthPlugin() throws Throwable
{
restartNeo4jServerWithOverriddenSettings( settings -> {
settings.put( SecuritySettings.active_realms, "plugin-TestCacheableAdminAuthPlugin" );
});

// Then
assertConnectionSucceeds( authToken( "neo4j", "neo4j", "plugin-TestCacheableAdminAuthPlugin" ) );

client.send( TransportTestUtil.chunk(
run( "CALL dbms.security.clearAuthCache() MATCH (n) RETURN n" ), pullAll() ) );

// Then
assertThat( client, eventuallyReceives( msgSuccess(), msgSuccess() ) );
}

@Test
public void shouldAuthenticateWithTestCustomParametersAuthenticationPlugin() throws Throwable
{
Expand Down

0 comments on commit 081eed5

Please sign in to comment.