Zetect Connector Guide Back to zetect.inSwitch portal ⇄

Testing a Connector

Test a connector in two stages: unit tests that call your connector directly with request JSON, then an end-to-end run inside a local agent with real requests from a Zetect test tenant. There is no separate test harness or registry; the JAR you test is the JAR you deploy.

Prerequisite

A built connector JAR, and for end-to-end tests a running agent registered to a test tenant. See Preparing Your Environment.

Required permission

Administrator access to the console, to onboard the test application and trigger requests.

Unit testing without an agent

The publishers are functional interfaces, so a test can collect results in a list. Build the request the same way the agent does, by reading JSON into ConnectorCommand. Provided dependencies are on Maven's test classpath, so you only need to add a test framework such as JUnit 5 at test scope.

@Test
void deleteAccountRequiresNativeId() throws Exception {
    String json = """
        {"action":"DELETE_ACCOUNT","requestId":"pr-test-1","tenantId":"t1",
         "connectorName":"Helpdesk",
         "connectionInfo":{"Connection Settings":{"baseUrl":"https://helpdesk.test","apiToken":"x"}},
         "subject":{"userId":"u1","nativeAccountIdentifier":null}}
        """;
    ConnectorCommand cmd = new ObjectMapper().readValue(json, ConnectorCommand.class);

    List<ProvisioningResult> results = new ArrayList<>();
    new HelpdeskConnector().handleProvisioning(cmd, results::add);

    assertEquals(1, results.size());                 // exactly one result
    assertEquals("ERROR", results.get(0).getStatus());
}

Write at least one test per supported action that checks a single result is published on both the success and the failure path. For aggregation, check that a chunked run ends with exactly one result whose getLastChunk() is true.

Running the connector in a local agent

To load your connector into an agent:

  1. Build the JAR with mvn clean package -DskipTests.
  2. Delete any earlier version of the same connector from the agent's connectors folder.
  3. Copy the new JAR into the connectors folder, the folder set by CYIAM_CONNECTORS_DIR. For an agent in Docker, see Installing the JAR on the agent.
  4. Restart the agent. It reads the connectors folder only at startup.
  5. Check the agent log for Registered connector 'Helpdesk' from cyiam-connector-helpdesk-1.0.0.jar, and that the name appears in the Plugin loading complete line that follows.

Sending test requests from Zetect

Onboard a test application whose catalog entry names your connector, as described in Deploying a Connector. Then trigger each request type from the console.

To testDo this in Zetect
SYNC_USER, SYNC_GROUPRun account or group aggregation on the application. Cover chunking in your unit tests, by passing a request with a small chunkSize. See Aggregating Accounts and Entitlements.
ADD_TO_GROUP, CREATE_ACCOUNTRequest access to one of the application's entitlements for a test identity, and approve it. Use an identity with no account to test account creation.
REMOVE_FROM_GROUP, DELETE_ACCOUNTRevoke the access in a certification, or remove it from a provisioning policy.
SUSPEND_ACCOUNT, RESTORE_ACCOUNTSuspend and then restore one of the application's accounts as an administrator. The operations must be switched on under the application's allowed operations. See Controlling Allowed Operations.

The outcome of each provisioning request appears in Zetect's provisioning activity. See Monitoring Provisioning.

Reading the agent log

The agent logs every round trip. A healthy provisioning request looks like this:

Prov request received — tag=1 body={"action":"ADD_TO_GROUP","requestId":"pr-7c1e…", …}
Dispatching id=pr-7c1e… action=ADD_TO_GROUP to connector 'Helpdesk'
<your connector's own log lines>
Published prov result requestId=pr-7c1e… status=SUCCESS exchange=cyiam.agent routingKey=prov.outbound.<tenantId>

Aggregation results are logged as Published result runId=… success=true …, once per chunk.

Troubleshooting

Log message or symptomMeaning
No connector registered for: HelpdeskNo loaded connector has that name. Check the Registered connector lines, the spelling and case of connectorName(), and the provisioning XML's connector attribute.
Unsupported action '…' on prov queue — discardingThe agent doesn't accept that action, so your connector is never called. See the accepted actions in Understanding Agents and Connectors.
Duplicate requestId/runId=… — discardingThe same request arrived again within 5 minutes and was dropped. This is expected after a broker redelivery.
Plugin 'Helpdesk' threw …Your code threw an exception. The agent published a failure result for you; fix the code path so it publishes its own failure.
Nothing between "Dispatching" and "Published … ERROR"Your connector rejected the request before doing any work, usually a missing field or connection setting. Check the result's message.
Aggregation never finishesNo chunk was published with lastChunk set to true, or the connector published nothing at all. See Publishing Results.