cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Integration test for custom procedures using dbms.security

Hey,

I am writing a custom procedure which calls the procedure dbms.security.listUsers()
(db.execute("CALL dbms.security.listUsers()")) but when I try to write an integration test
for the procedure I get the following error:

There is no procedure with the name dbms.security.listUsers registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.

How do I add the dbms.security procedures to the Neo4j test harness, so that I can test my procedure?

Thank you in advance for the response

3 REPLIES 3

You need to have the enterprise jars on classpath and you need to explicitly register the procedures to be used for the test. Registration is different in 3.5 and 4.0, see https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/4.0/src/test/java/apoc/util/TestUtil.jav... for 4.0 and https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/3.5/src/test/java/apoc/util/TestUtil.jav... for 3.5

@stefan.armbruster thank you for the quick response.
I have all enterprise jars on my classpath and have registered the dbms.security procedures
with:

TestUtils.registerProcedure(db, UserManagementProcedures.class);

from https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/3.5/src/test/java/apoc/util/TestUtil.jav....

But now I get the following exception and don't know how to continue

org.neo4j.kernel.api.exceptions.ComponentInjectionException: Unable to set up injection for procedure UserManagementProcedures, the field securityContexthas typeclass org.neo4j.kernel.enterprise.api.security.EnterpriseSecurityContext which is not a known injectable component.

Shouldn't you be using SecurityContext instead of EnterpriseSecurityContext in you code?