use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class ConfiguredAuthScenariosInteractionTestBase method shouldNotWarnWhenOnlyUsingNativeProvider.
@Test
public void shouldNotWarnWhenOnlyUsingNativeProvider() throws Throwable {
configuredSetup(stringMap(SecuritySettings.auth_provider.name(), "native"));
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(false));
transaction.success();
transaction.close();
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class EmbeddedBuiltInProceduresInteractionTest method shouldNotKillQueryIfNotAuthenticated.
@Test
public void shouldNotKillQueryIfNotAuthenticated() throws Throwable {
EnterpriseSecurityContext authy = createFakeAnonymousEnterpriseSecurityContext();
GraphDatabaseFacade graph = neo.getLocalGraph();
DoubleLatch latch = new DoubleLatch(2);
ThreadedTransaction<EnterpriseSecurityContext> read = new ThreadedTransaction<>(neo, latch);
String query = read.execute(threading, authy, "UNWIND [1,2,3] AS x RETURN x");
latch.startAndWaitForAllToStart();
String id = extractQueryId(query);
try (InternalTransaction tx = graph.beginTransaction(KernelTransaction.Type.explicit, AnonymousContext.none())) {
graph.execute(tx, "CALL dbms.killQuery('" + id + "')", Collections.emptyMap());
throw new AssertionError("Expected exception to be thrown");
} catch (QueryExecutionException e) {
assertThat(e.getMessage(), containsString(PERMISSION_DENIED));
}
latch.finishAndWaitForAllToFinish();
read.closeAndAssertSuccess();
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j-documentation by neo4j.
the class DocsExecutionEngineTest method createTransactionalContext.
private static TransactionalContext createTransactionalContext(String query) {
InternalTransaction transaction = database.beginTransaction(Type.implicit, SecurityContext.AUTH_DISABLED);
BoltConnectionInfo boltConnection = new BoltConnectionInfo("username", "neo4j-java-bolt-driver", new InetSocketAddress("127.0.0.1", 56789), new InetSocketAddress("127.0.0.1", 7687));
return contextFactory.newContext(boltConnection, transaction, query, EMPTY_MAP);
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class IndexingServiceIntegrationTest method tracePageCacheAccessOnIndexUpdatesApply.
@ParameterizedTest
@MethodSource("parameters")
void tracePageCacheAccessOnIndexUpdatesApply(GraphDatabaseSettings.SchemaIndex schemaIndex) throws KernelException {
setUp(schemaIndex);
var marker = Label.label("marker");
var propertyName = "property";
var testConstraint = "testConstraint";
try (Transaction transaction = database.beginTx()) {
transaction.schema().constraintFor(marker).withName(testConstraint).assertPropertyIsUnique(propertyName).create();
transaction.commit();
}
var dependencyResolver = ((GraphDatabaseAPI) database).getDependencyResolver();
var indexingService = dependencyResolver.resolveDependency(IndexingService.class);
var pageCacheTracer = dependencyResolver.resolveDependency(PageCacheTracer.class);
try (Transaction transaction = database.beginTx()) {
var kernelTransaction = ((InternalTransaction) transaction).kernelTransaction();
var indexDescriptor = kernelTransaction.schemaRead().indexGetForName(testConstraint);
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnIndexUpdatesApply"))) {
Iterable<IndexEntryUpdate<IndexDescriptor>> updates = List.of(add(1, indexDescriptor, longValue(4)));
indexingService.applyUpdates(updates, cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertEquals(5L, cursorTracer.pins());
assertEquals(5L, cursorTracer.unpins());
assertEquals(2L, cursorTracer.hits());
assertEquals(3L, cursorTracer.faults());
}
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class MultipleOpenCursorsTest method multipleIteratorsNestedInterleavedExact.
@ParameterizedTest
@MethodSource(value = "params")
void multipleIteratorsNestedInterleavedExact(IndexCoordinator indexCoordinator) throws Exception {
indexCoordinator.init(db);
try (Transaction tx = db.beginTx()) {
// when
KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
try (NodeValueIndexCursor cursor1 = indexCoordinator.queryExact(ktx)) {
List<Long> actual1 = new ArrayList<>();
try (NodeValueIndexCursor cursor2 = indexCoordinator.queryExact(ktx)) {
List<Long> actual2 = new ArrayList<>();
// Interleave
exhaustInterleaved(cursor1, actual1, cursor2, actual2);
// then
indexCoordinator.assertExactResult(actual1);
indexCoordinator.assertExactResult(actual2);
}
}
tx.commit();
}
}
Aggregations