Files
developer.sailpoint.com/docs/connectivity/saas-connectivity/connector-customizers/testing.md
darrell-thobe-sp 2cd5ccfc81 Prettified Code!
2024-04-18 10:31:05 +00:00

2.7 KiB

id, title, pagination_label, sidebar_label, sidebar_position, sidebar_class_name, keywords, description, slug, tags
id title pagination_label sidebar_label sidebar_position sidebar_class_name keywords description slug tags
connectivity-customizers-testing Testing and Debugging Testing and Debugging Testing and Debugging 6 saasConnectivity
connectivity
connectors
customizers
Test and debug connectors with customizers. /connectivity/saas-connectivity/customizers/testing
Connectivity

Testing and debugging

Debug locally

Debugging your code locally follows the same process that debugging a connector locally does. The recommended approach is to start a Visual Studio Code debug window and run this command:

npm run debug

You can then set breakpoints in your code step through processes in your IDE (integrated development environment).

Test alongside a custom connector

If you want to test alongside a SaaS custom connector, the easiest way to do so is to copy the customizer code into the connector code.

For example, you want to test this connector:

export const connector = async () => {

    // Get connector source config
    const config = await readConfig()

    // Use the vendor SDK, or implement own client as necessary, to initialize a client
    const myClient = new MyClient(config)

    return createConnector()
        .stdTestConnection(async (context: Context, input: undefined, res: Response<StdTestConnectionOutput>) => {
            logger.info("Running test connection")
            res.send(await myClient.testConnection())
        })
}

You can test a customizer by simply appending the customizer code to the end of the file:

// existing custom connector code
export const connector = async () => {

    // Get connector source config
    const config = await readConfig()

    // Use the vendor SDK, or implement own client as necessary, to initialize a client
    const myClient = new MyClient(config)

    return createConnector()
        .stdTestConnection(async (context: Context, input: undefined, res: Response<StdTestConnectionOutput>) => {
            logger.info("Running test connection")
            res.send(await myClient.testConnection())
        })
}

// appended customizer code that will also get run
export const connectorCustomizer = async () => {

    // Get connector source config
    const config = await readConfig()

    return createConnectorCustomizer()
        .afterStdTestConnection(async (context: Context, output: StdTestConnectionOutput) => {
            logger.info('Running after test connection')
            return output
        })
}

Now, when you run the test-connection command, the customizer after the test-connection command will also run.