Search in sources :

Example 6 with ProcedureSignature

use of org.neo4j.kernel.api.proc.ProcedureSignature in project neo4j by neo4j.

the class ConfiguredProceduresTestBase method shouldNotRunProcedureWithMismatchingWildCardAllowed.

@Test
public void shouldNotRunProcedureWithMismatchingWildCardAllowed() throws Throwable {
    configuredSetup(stringMap(SecuritySettings.procedure_roles.name(), "tes.*:role1"));
    userManager.newRole("role1", "noneSubject");
    Procedures procedures = neo.getLocalGraph().getDependencyResolver().resolveDependency(Procedures.class);
    ProcedureSignature numNodes = procedures.procedure(new QualifiedName(new String[] { "test" }, "numNodes"));
    assertThat(Arrays.asList(numNodes.allowed()), empty());
    assertFail(noneSubject, "CALL test.numNodes", "Read operations are not allowed");
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) QualifiedName(org.neo4j.kernel.api.proc.QualifiedName) Procedures(org.neo4j.kernel.impl.proc.Procedures) Test(org.junit.Test)

Example 7 with ProcedureSignature

use of org.neo4j.kernel.api.proc.ProcedureSignature in project neo4j by neo4j.

the class ConfiguredProceduresTestBase method shouldNotSetProcedureAllowedIfSettingNotSet.

@Test
public void shouldNotSetProcedureAllowedIfSettingNotSet() throws Throwable {
    configuredSetup(defaultConfiguration());
    Procedures procedures = neo.getLocalGraph().getDependencyResolver().resolveDependency(Procedures.class);
    ProcedureSignature numNodes = procedures.procedure(new QualifiedName(new String[] { "test" }, "numNodes"));
    assertThat(Arrays.asList(numNodes.allowed()), empty());
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) QualifiedName(org.neo4j.kernel.api.proc.QualifiedName) Procedures(org.neo4j.kernel.impl.proc.Procedures) Test(org.junit.Test)

Example 8 with ProcedureSignature

use of org.neo4j.kernel.api.proc.ProcedureSignature in project neo4j by neo4j.

the class GetServersProcedureV1Test method shouldHaveCorrectSignature.

@Test
public void shouldHaveCorrectSignature() throws Exception {
    // given
    final LegacyGetServersProcedure proc = new LegacyGetServersProcedure(null, null, config, getInstance());
    // when
    ProcedureSignature signature = proc.signature();
    // then
    assertThat(signature.outputSignature(), containsInAnyOrder(new FieldSignature("ttl", NTInteger), new FieldSignature("servers", NTMap)));
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) FieldSignature(org.neo4j.kernel.api.proc.FieldSignature) Test(org.junit.Test)

Example 9 with ProcedureSignature

use of org.neo4j.kernel.api.proc.ProcedureSignature in project neo4j by neo4j.

the class GetServersProcedureV2Test method shouldHaveCorrectSignature.

@Test
public void shouldHaveCorrectSignature() throws Exception {
    // given
    GetServersProcedureForMultiDC proc = new GetServersProcedureForMultiDC(null);
    // when
    ProcedureSignature signature = proc.signature();
    // then
    assertThat(signature.inputSignature(), containsInAnyOrder(new FieldSignature("context", NTMap)));
    assertThat(signature.outputSignature(), containsInAnyOrder(new FieldSignature("ttl", NTInteger), new FieldSignature("servers", NTMap)));
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) FieldSignature(org.neo4j.kernel.api.proc.FieldSignature) Test(org.junit.Test)

Example 10 with ProcedureSignature

use of org.neo4j.kernel.api.proc.ProcedureSignature in project neo4j by neo4j.

the class ProcedureRegistry method register.

/**
     * Register a new procedure.
     *
     * @param proc the procedure.
     */
public void register(CallableProcedure proc, boolean overrideCurrentImplementation) throws ProcedureException {
    ProcedureSignature signature = proc.signature();
    QualifiedName name = signature.name();
    String descriptiveName = signature.toString();
    validateSignature(descriptiveName, signature.inputSignature(), "input");
    validateSignature(descriptiveName, signature.outputSignature(), "output");
    if (!signature.isVoid() && signature.outputSignature().isEmpty()) {
        throw new ProcedureException(Status.Procedure.ProcedureRegistrationFailed, "Procedures with zero output fields must be declared as VOID");
    }
    CallableProcedure oldImplementation = procedures.get(name);
    if (oldImplementation == null) {
        procedures.put(name, proc);
    } else {
        if (overrideCurrentImplementation) {
            procedures.put(name, proc);
        } else {
            throw new ProcedureException(Status.Procedure.ProcedureRegistrationFailed, "Unable to register procedure, because the name `%s` is already in use.", name);
        }
    }
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) QualifiedName(org.neo4j.kernel.api.proc.QualifiedName) CallableProcedure(org.neo4j.kernel.api.proc.CallableProcedure) ProcedureException(org.neo4j.kernel.api.exceptions.ProcedureException)

Aggregations

ProcedureSignature (org.neo4j.kernel.api.proc.ProcedureSignature)15 Test (org.junit.Test)13 CallableProcedure (org.neo4j.kernel.api.proc.CallableProcedure)6 QualifiedName (org.neo4j.kernel.api.proc.QualifiedName)5 URL (java.net.URL)4 BasicContext (org.neo4j.kernel.api.proc.BasicContext)3 FieldSignature (org.neo4j.kernel.api.proc.FieldSignature)3 Procedures (org.neo4j.kernel.impl.proc.Procedures)3 ProcedureException (org.neo4j.kernel.api.exceptions.ProcedureException)2 MethodHandle (java.lang.invoke.MethodHandle)1 ComponentInjectionException (org.neo4j.kernel.api.exceptions.ComponentInjectionException)1 CallableUserFunction (org.neo4j.kernel.api.proc.CallableUserFunction)1 FailedLoadProcedure (org.neo4j.kernel.api.proc.FailedLoadProcedure)1 NTString (org.neo4j.kernel.api.proc.Neo4jTypes.NTString)1 UserFunctionSignature (org.neo4j.kernel.api.proc.UserFunctionSignature)1 OutputMapper (org.neo4j.kernel.impl.proc.OutputMappers.OutputMapper)1 Mode (org.neo4j.procedure.Mode)1 Procedure (org.neo4j.procedure.Procedure)1