Skip to content

Commit

Permalink
Reverted some refactoring in security procedures tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fickludd committed Sep 12, 2016
1 parent eaefb0e commit d9b33e0
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 61 deletions.
Expand Up @@ -404,6 +404,7 @@ private Procedures setupProcedures( PlatformModule platform, EditionModule editi
procedures.registerComponent( DependencyResolver.class, ( ctx ) -> platform.dependencies );
procedures.registerComponent( KernelTransaction.class, ( ctx ) -> ctx.get( KERNEL_TRANSACTION ) );
procedures.registerComponent( GraphDatabaseAPI.class, ( ctx ) -> platform.graphDatabaseFacade );
procedures.registerComponent( AuthSubject.class, ctx -> ctx.get( AUTH_SUBJECT ) );

// Edition procedures
try
Expand All @@ -417,8 +418,6 @@ private Procedures setupProcedures( PlatformModule platform, EditionModule editi
}

// Security procedures
procedures.registerComponent( AuthSubject.class, ctx -> ctx.get( AUTH_SUBJECT ) );

for ( ProceduresProvider candidate : Service.load( ProceduresProvider.class ) )
{
candidate.registerProcedures( procedures );
Expand Down
Expand Up @@ -621,7 +621,7 @@ private AssertableLogProvider.LogMatcher error( String message, String... argume
return inLog( this.getClass() ).error( message, arguments );
}

private static class TestAuthSubject extends EnterpriseAuthSubject
private static class TestAuthSubject extends StandardEnterpriseAuthSubject
{
private final String name;
private final boolean isAdmin;
Expand Down
Expand Up @@ -20,24 +20,16 @@
package org.neo4j.server.security.enterprise.auth;

import org.junit.Rule;
import org.junit.rules.RuleChain;

import java.util.Map;

import org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket;
import org.neo4j.graphdb.config.Setting;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.test.TestEnterpriseGraphDatabaseFactory;
import org.neo4j.test.TestGraphDatabaseFactory;
import org.neo4j.test.rule.SuppressOutput;

public class BoltAuthProceduresInteractionTest extends AuthProceduresInteractionTestBase<BoltInteraction.BoltSubject>
{
private Neo4jWithSocket server = new Neo4jWithSocket( getTestGraphDatabaseFactory(),
settings -> settings.put( GraphDatabaseSettings.auth_enabled, "true" ) );

@Rule
public final RuleChain ruleChain = RuleChain.outerRule( SuppressOutput.suppressAll() ).around( server );
public SuppressOutput suppressOutput = SuppressOutput.suppressAll();

public BoltAuthProceduresInteractionTest()
{
Expand All @@ -46,11 +38,6 @@ public BoltAuthProceduresInteractionTest()
IS_BOLT = true;
}

private TestGraphDatabaseFactory getTestGraphDatabaseFactory()
{
return new TestEnterpriseGraphDatabaseFactory();
}

@Override
public NeoInteractionLevel<BoltInteraction.BoltSubject> setUpNeoServer( Map<Setting<?>, String> config ) throws Throwable
{
Expand Down
Expand Up @@ -20,24 +20,16 @@
package org.neo4j.server.security.enterprise.auth;

import org.junit.Rule;
import org.junit.rules.RuleChain;

import java.util.Map;

import org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket;
import org.neo4j.graphdb.config.Setting;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.test.TestEnterpriseGraphDatabaseFactory;
import org.neo4j.test.TestGraphDatabaseFactory;
import org.neo4j.test.rule.SuppressOutput;

public class BoltAuthScenariosInteractionTest extends AuthScenariosInteractionTestBase<BoltInteraction.BoltSubject>
{
private Neo4jWithSocket server = new Neo4jWithSocket( getTestGraphDatabaseFactory(),
settings -> settings.put( GraphDatabaseSettings.auth_enabled, "true" ) );

@Rule
public final RuleChain ruleChain = RuleChain.outerRule( SuppressOutput.suppressAll() ).around( server );
public SuppressOutput suppressOutput = SuppressOutput.suppressAll();

public BoltAuthScenariosInteractionTest()
{
Expand All @@ -46,11 +38,6 @@ public BoltAuthScenariosInteractionTest()
IS_BOLT = true;
}

private TestGraphDatabaseFactory getTestGraphDatabaseFactory()
{
return new TestEnterpriseGraphDatabaseFactory();
}

@Override
public NeoInteractionLevel<BoltInteraction.BoltSubject> setUpNeoServer( Map<Setting<?>, String> config ) throws Throwable
{
Expand Down
Expand Up @@ -20,21 +20,16 @@
package org.neo4j.server.security.enterprise.auth;

import org.junit.Rule;
import org.junit.rules.RuleChain;

import org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.test.TestEnterpriseGraphDatabaseFactory;
import org.neo4j.test.TestGraphDatabaseFactory;
import java.util.Map;

import org.neo4j.graphdb.config.Setting;
import org.neo4j.test.rule.SuppressOutput;

public class BoltBuiltInProceduresInteractionTest extends BuiltInProceduresInteractionTestBase<BoltInteraction.BoltSubject>
{
private Neo4jWithSocket server = new Neo4jWithSocket( getTestGraphDatabaseFactory(),
settings -> settings.put( GraphDatabaseSettings.auth_enabled, "true" ) );

@Rule
public final RuleChain ruleChain = RuleChain.outerRule( SuppressOutput.suppressAll() ).around( server );
public SuppressOutput suppressOutput = SuppressOutput.suppressAll();

public BoltBuiltInProceduresInteractionTest()
{
Expand All @@ -43,14 +38,10 @@ public BoltBuiltInProceduresInteractionTest()
IS_BOLT = true;
}

private TestGraphDatabaseFactory getTestGraphDatabaseFactory()
{
return new TestEnterpriseGraphDatabaseFactory();
}

@Override
public NeoInteractionLevel<BoltInteraction.BoltSubject> setUpNeoServer() throws Throwable
public NeoInteractionLevel<BoltInteraction.BoltSubject> setUpNeoServer( Map<Setting<?>, String> config ) throws
Throwable
{
return new BoltInteraction( server );
return new BoltInteraction( config );
}
}
Expand Up @@ -74,8 +74,7 @@ public class BoltInteraction implements NeoInteractionLevel<BoltInteraction.Bolt
protected final Factory<TransportConnection> connectionFactory = SocketConnection::new;
private final Neo4jWithSocket server;
private Map<String,BoltSubject> subjects = new HashMap<>();
private FileSystemAbstraction _fileSystem;

private FileSystemAbstraction fileSystem;
EnterpriseAuthManager authManager;

BoltInteraction( Map<Setting<?>, String> config ) throws IOException
Expand All @@ -89,7 +88,7 @@ public class BoltInteraction implements NeoInteractionLevel<BoltInteraction.Bolt
settings.putAll( config );
} );
server.restartDatabase( r -> {} );
this._fileSystem = factory.getFileSystem();
this.fileSystem = factory.getFileSystem();
GraphDatabaseFacade db = (GraphDatabaseFacade) server.graphDatabaseService();
authManager = db.getDependencyResolver().resolveDependency( EnterpriseAuthManager.class );
}
Expand All @@ -109,7 +108,7 @@ public GraphDatabaseFacade getLocalGraph()
@Override
public FileSystemAbstraction fileSystem()
{
return _fileSystem;
return fileSystem;
}

@Override
Expand Down
Expand Up @@ -19,13 +19,17 @@
*/
package org.neo4j.server.security.enterprise.auth;

import java.util.Map;

import org.neo4j.graphdb.config.Setting;
import org.neo4j.kernel.enterprise.api.security.EnterpriseAuthSubject;

public class EmbeddedAuthProceduresInteractionTest extends AuthProceduresInteractionTestBase<EnterpriseAuthSubject>
{
@Override
protected NeoInteractionLevel<EnterpriseAuthSubject> setUpNeoServer() throws Throwable
protected NeoInteractionLevel<EnterpriseAuthSubject> setUpNeoServer( Map<Setting<?>, String> config )
throws Throwable
{
return new EmbeddedInteraction();
return new EmbeddedInteraction( config );
}
}
Expand Up @@ -25,7 +25,6 @@

import org.neo4j.bolt.BoltKernelExtension;
import org.neo4j.graphdb.ResourceIterator;
import org.neo4j.graphdb.Result;
import org.neo4j.graphdb.config.Setting;
import org.neo4j.graphdb.factory.GraphDatabaseBuilder;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
Expand Down
Expand Up @@ -39,11 +39,6 @@ public interface NeoInteractionLevel<S>

FileSystemAbstraction fileSystem();

default InternalTransaction beginLocalTransactionAsUser( S subject ) throws Throwable
{
return beginLocalTransactionAsUser( subject, KernelTransaction.Type.explicit );
}

InternalTransaction beginLocalTransactionAsUser( S subject, KernelTransaction.Type txType ) throws Throwable;

/*
Expand Down
Expand Up @@ -21,6 +21,9 @@

import org.junit.Rule;

import java.util.Map;

import org.neo4j.graphdb.config.Setting;
import org.neo4j.server.security.enterprise.auth.BuiltInProceduresInteractionTestBase;
import org.neo4j.server.security.enterprise.auth.NeoInteractionLevel;
import org.neo4j.test.rule.SuppressOutput;
Expand All @@ -41,8 +44,8 @@ public RESTBuiltInProceduresInteractionTest()
}

@Override
public NeoInteractionLevel<RESTSubject> setUpNeoServer() throws Throwable
public NeoInteractionLevel<RESTSubject> setUpNeoServer( Map<Setting<?>, String> config ) throws Throwable
{
return new RESTInteraction();
return new RESTInteraction( config );
}
}

0 comments on commit d9b33e0

Please sign in to comment.