use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class QueryLoggerIT method shouldNotLogPassword.
@Test
public void shouldNotLogPassword() throws Exception {
GraphDatabaseFacade database = (GraphDatabaseFacade) databaseBuilder.setConfig(GraphDatabaseSettings.log_queries, Settings.TRUE).setConfig(GraphDatabaseSettings.logs_directory, logsDirectory.getPath()).setConfig(GraphDatabaseSettings.auth_enabled, Settings.TRUE).newGraphDatabase();
EnterpriseAuthManager authManager = database.getDependencyResolver().resolveDependency(EnterpriseAuthManager.class);
EnterpriseSecurityContext neo = authManager.login(AuthToken.newBasicAuthToken("neo4j", "neo4j"));
String query = "CALL dbms.security.changePassword('abc123')";
try (InternalTransaction tx = database.beginTransaction(KernelTransaction.Type.explicit, neo)) {
Result res = database.execute(tx, query, Collections.emptyMap());
res.close();
tx.success();
} finally {
database.shutdown();
}
List<String> logLines = readAllLines(logFilename);
assertEquals(1, logLines.size());
assertThat(logLines.get(0), containsString("CALL dbms.security.changePassword(******)"));
assertThat(logLines.get(0), not(containsString("abc123")));
assertThat(logLines.get(0), containsString(neo.subject().username()));
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class Start method createTransactionContext.
private TransactionalContext createTransactionContext(String queryText, Map<String, Object> queryParameters, Session session) {
DependencyResolver dependencyResolver = getDependencyResolver();
GraphDatabaseQueryService graph = dependencyResolver.resolveDependency(GraphDatabaseQueryService.class);
TransactionalContextFactory contextFactory = Neo4jTransactionalContextFactory.create(graph, new PropertyContainerLocker());
InternalTransaction transaction = graph.beginTransaction(KernelTransaction.Type.implicit, SecurityContext.AUTH_DISABLED);
return contextFactory.newContext(new ShellConnectionInfo(session.getId()), transaction, queryText, queryParameters);
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class ExecutionEngineTests method shouldConvertListsAndMapsWhenPassingFromScalaToJava.
@Test
public void shouldConvertListsAndMapsWhenPassingFromScalaToJava() throws Exception {
GraphDatabaseQueryService graph = new GraphDatabaseCypherService(this.database.getGraphDatabaseAPI());
KernelAPI kernelAPI = graph.getDependencyResolver().resolveDependency(KernelAPI.class);
Monitors monitors = graph.getDependencyResolver().resolveDependency(Monitors.class);
NullLogProvider nullLogProvider = NullLogProvider.getInstance();
CommunityCompatibilityFactory compatibilityFactory = new CommunityCompatibilityFactory(graph, kernelAPI, monitors, nullLogProvider);
ExecutionEngine executionEngine = new ExecutionEngine(graph, nullLogProvider, compatibilityFactory);
Result result;
try (InternalTransaction tx = graph.beginTransaction(KernelTransaction.Type.implicit, SecurityContext.AUTH_DISABLED)) {
String query = "RETURN { key : 'Value' , collectionKey: [{ inner: 'Map1' }, { inner: 'Map2' }]}";
TransactionalContext tc = createTransactionContext(graph, tx, query);
result = executionEngine.executeQuery(query, NO_PARAMS, tc);
tx.success();
}
Map firstRowValue = (Map) result.next().values().iterator().next();
assertThat(firstRowValue.get("key"), is("Value"));
List theList = (List) firstRowValue.get("collectionKey");
assertThat(((Map) theList.get(0)).get("inner"), is("Map1"));
assertThat(((Map) theList.get(1)).get("inner"), is("Map2"));
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class EmbeddedBuiltInProceduresInteractionTest method shouldNotListAnyQueriesIfNotAuthenticated.
@Test
public void shouldNotListAnyQueriesIfNotAuthenticated() {
GraphDatabaseFacade graph = neo.getLocalGraph();
try (InternalTransaction tx = graph.beginTransaction(KernelTransaction.Type.explicit, AnonymousContext.none())) {
Result result = graph.execute(tx, "CALL dbms.listQueries", Collections.emptyMap());
assertFalse(result.hasNext());
tx.success();
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class ConfiguredAuthScenariosInteractionTestBase method shouldWarnWhenUsingNativeAndOtherProvider.
@Test
public void shouldWarnWhenUsingNativeAndOtherProvider() throws Throwable {
configuredSetup(stringMap(SecuritySettings.auth_providers.name(), "native ,LDAP"));
assertSuccess(adminSubject, "CALL dbms.security.listUsers", r -> assertKeyIsMap(r, "username", "roles", userList));
GraphDatabaseFacade localGraph = neo.getLocalGraph();
InternalTransaction transaction = localGraph.beginTransaction(KernelTransaction.Type.explicit, StandardEnterpriseSecurityContext.AUTH_DISABLED);
Result result = localGraph.execute(transaction, "EXPLAIN CALL dbms.security.listUsers", Collections.emptyMap());
String description = String.format("%s (%s)", Status.Procedure.ProcedureWarning.code().description(), "dbms.security.listUsers only applies to native users.");
assertThat(containsNotification(result, description), equalTo(true));
transaction.success();
transaction.close();
}
Aggregations