Search in sources :

Example 16 with SecurityContext

use of org.neo4j.kernel.api.security.SecurityContext in project neo4j by neo4j.

the class SecurityContextDescriptionTest method shouldMakeNiceDescriptionOverridden.

@Test
public void shouldMakeNiceDescriptionOverridden() throws Throwable {
    SecurityContext overridden = context.withMode(new OverriddenAccessMode(context.mode(), AccessMode.Static.READ));
    assertThat(overridden.description(), equalTo("user 'johan' with FULL overridden by READ"));
}
Also used : OverriddenAccessMode(org.neo4j.kernel.impl.api.security.OverriddenAccessMode) SecurityContext(org.neo4j.kernel.api.security.SecurityContext) Test(org.junit.Test)

Example 17 with SecurityContext

use of org.neo4j.kernel.api.security.SecurityContext in project neo4j by neo4j.

the class SecurityContextDescriptionTest method shouldMakeNiceDescriptionFrozen.

@Test
public void shouldMakeNiceDescriptionFrozen() throws Throwable {
    SecurityContext frozen = context.freeze();
    assertThat(frozen.description(), equalTo("user 'johan' with FULL"));
}
Also used : SecurityContext(org.neo4j.kernel.api.security.SecurityContext) Test(org.junit.Test)

Example 18 with SecurityContext

use of org.neo4j.kernel.api.security.SecurityContext in project neo4j by neo4j.

the class SecurityContextDescriptionTest method shouldMakeNiceDescriptionAuthDisabled.

@Test
public void shouldMakeNiceDescriptionAuthDisabled() throws Throwable {
    SecurityContext disabled = SecurityContext.AUTH_DISABLED;
    assertThat(disabled.description(), equalTo("AUTH_DISABLED with FULL"));
}
Also used : SecurityContext(org.neo4j.kernel.api.security.SecurityContext) Test(org.junit.Test)

Example 19 with SecurityContext

use of org.neo4j.kernel.api.security.SecurityContext in project neo4j by neo4j.

the class MultiRealmAuthManagerTest method userWithAdminRoleShouldHaveCorrectPermissions.

@Test
public void userWithAdminRoleShouldHaveCorrectPermissions() throws Throwable {
    // Given
    createTestUsers();
    manager.start();
    // When
    SecurityContext securityContext = manager.login(authToken("morpheus", "abc123"));
    // Then
    assertTrue(securityContext.mode().allowsReads());
    assertTrue(securityContext.mode().allowsWrites());
    assertTrue(securityContext.mode().allowsSchemaWrites());
}
Also used : SecurityContext(org.neo4j.kernel.api.security.SecurityContext) Test(org.junit.Test)

Example 20 with SecurityContext

use of org.neo4j.kernel.api.security.SecurityContext in project neo4j by neo4j.

the class MultiRealmAuthManagerTest method userWithNonPredefinedRoleShouldHaveNoPermissions.

@Test
public void userWithNonPredefinedRoleShouldHaveNoPermissions() throws Throwable {
    // Given
    createTestUsers();
    manager.start();
    // When
    SecurityContext securityContext = manager.login(authToken("smith", "abc123"));
    // Then
    assertFalse(securityContext.mode().allowsReads());
    assertFalse(securityContext.mode().allowsWrites());
    assertFalse(securityContext.mode().allowsSchemaWrites());
}
Also used : SecurityContext(org.neo4j.kernel.api.security.SecurityContext) Test(org.junit.Test)

Aggregations

SecurityContext (org.neo4j.kernel.api.security.SecurityContext)33 Test (org.junit.Test)20 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)6 ThreadToStatementContextBridge (org.neo4j.kernel.impl.core.ThreadToStatementContextBridge)4 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 IOException (java.io.IOException)2 Principal (java.security.Principal)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Consumes (javax.ws.rs.Consumes)2 Produces (javax.ws.rs.Produces)2 InOrder (org.mockito.InOrder)2 ReturnsDeepStubs (org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs)2 Transaction (org.neo4j.graphdb.Transaction)2 QueryRegistryOperations (org.neo4j.kernel.api.QueryRegistryOperations)2 Statement (org.neo4j.kernel.api.Statement)2 InvalidArgumentsException (org.neo4j.kernel.api.exceptions.InvalidArgumentsException)2 ExecutingQuery (org.neo4j.kernel.api.query.ExecutingQuery)2 KernelStatement (org.neo4j.kernel.impl.api.KernelStatement)2 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)2