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");
}
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());
}
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)));
}
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)));
}
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);
}
}
}
Aggregations