use of org.neo4j.logging.Log in project neo4j by neo4j.
the class UserAggregationFunctionTest method shouldNotLoadNoneWhiteListedFunction.
@Test
void shouldNotLoadNoneWhiteListedFunction() throws Throwable {
// Given
Log log = spy(Log.class);
procedureCompiler = new ProcedureCompiler(new TypeCheckers(), components, new ComponentRegistry(), log, new ProcedureConfig(Config.defaults(GraphDatabaseSettings.procedure_allowlist, List.of("WrongName"))));
List<CallableUserAggregationFunction> method = compile(SingleAggregationFunction.class);
verify(log).warn("The function 'org.neo4j.procedure.impl.collectCool' is not on the allowlist and won't be loaded.");
assertThat(method.size()).isEqualTo(0);
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class UserFunctionTest method shouldNotLoadNoneWhiteListedFunction.
@Test
void shouldNotLoadNoneWhiteListedFunction() throws Throwable {
// Given
Log log = spy(Log.class);
procedureCompiler = new ProcedureCompiler(new TypeCheckers(), components, new ComponentRegistry(), log, new ProcedureConfig(Config.defaults(GraphDatabaseSettings.procedure_allowlist, List.of("WrongName"))));
List<CallableUserFunction> method = compile(SingleReadOnlyFunction.class);
verify(log).warn("The function 'org.neo4j.procedure.impl.listCoolPeople' is not on the allowlist and won't be loaded.");
assertThat(method.size()).isEqualTo(0);
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ProcedureTest method shouldInjectLogging.
@Test
void shouldInjectLogging() throws KernelException {
// Given
Log log = spy(Log.class);
components.register(Log.class, ctx -> log);
CallableProcedure procedure = procedureCompiler.compileProcedure(LoggingProcedure.class, null, true).get(0);
// When
procedure.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
// Then
verify(log).debug("1");
verify(log).info("2");
verify(log).warn("3");
verify(log).error("4");
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ProcedureTest method shouldNotLoadAnyProcedureIfConfigIsEmpty.
@Test
void shouldNotLoadAnyProcedureIfConfigIsEmpty() throws Throwable {
// Given
ProcedureConfig config = new ProcedureConfig(Config.defaults(procedure_allowlist, List.of("")));
Log log = mock(Log.class);
ProcedureCompiler procedureCompiler = new ProcedureCompiler(new TypeCheckers(), components, components, log, config);
// When
List<CallableProcedure> proc = procedureCompiler.compileProcedure(SingleReadOnlyProcedure.class, null, false);
// Then
verify(log).warn("The procedure 'org.neo4j.procedure.impl.listCoolPeople' is not on the allowlist and won't be loaded.");
assertThat(proc.isEmpty()).isTrue();
}
use of org.neo4j.logging.Log in project neo4j by neo4j.
the class ProcedureTest method shouldIgnoreWhiteListingIfFullAccess.
@Test
void shouldIgnoreWhiteListingIfFullAccess() throws Throwable {
// Given
ProcedureConfig config = new ProcedureConfig(Config.defaults(procedure_allowlist, List.of("empty")));
Log log = mock(Log.class);
ProcedureCompiler procedureCompiler = new ProcedureCompiler(new TypeCheckers(), components, components, log, config);
// When
CallableProcedure proc = procedureCompiler.compileProcedure(SingleReadOnlyProcedure.class, null, true).get(0);
// Then
RawIterator<AnyValue[], ProcedureException> result = proc.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
assertEquals(result.next()[0], stringValue("Bonnie"));
}
Aggregations