Skip to content
Snippets Groups Projects
konnectors.md 2.48 KiB
Newer Older
# Konnectors

Konnectors are mocked in local with [createConnections](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/scripts/createConnections.js?ref_type=heads) script.

## Use local konnectors

:::warning Not complete yet.
This section is not fully fully tested.
:::

In most case you will use mocked konnectors with mock data, but for some testing goals you will need real accounts.
In local, it is possible to run EGL en SGE-Enedis konnectors, with real accounts, but it needs some specific manipulation as well as you'll need to use api secrets that are, of course, basically not available in the project. If you need to use konnectors with real accounts in testing goals, please follow the following steps. Otherwise, refer to the next two sections 'Import Mock Data' et 'Simulate konnector connections'.

First step, make sure your stack is running. Then open your [CouchDB](http://localhost:5984/_utils/) and look for the `secrets/io-cozy-account_types` entry.
Then add a new document like this :

EGL Example

```json
{
  "_id": "eglgrandlyon",
  "grant_mode": "secret",
  "slug": "eglgrandlyon",
  "secret": {
    "eglBaseURL": "******",
    "eglAPIAuthKey": "*****"
  }
}
```

SGE Enedis example

```json
{
  "_id": "enedis-sge-grandlyon",
  "grant_mode": "secret",
  "slug": "enedissgegrandlyon",
  "secret": {
    "loginUtilisateur": "******",
    "wso2BaseUrl": "*****",
    "contractId": "*****",
    "apiToken": "*****"
  }
}
```

:::info
You'll need to use konnector slug as is to make it work properly
:::

You can contact an administrator in order to get the proper information to fill in your secret.
Once it is done, you will be able to use these 2 Konnectors with real accounts.

:::warning You might see this message before trying to log with SGE Account
Make sure you have the person's consent to use their PDL number, as it is sensitive data.
:::

## Stimulate konnector errors in local

:::tip Mongo query to select GRDF related documents

```json
{
   "selector": {
      "worker": "konnector",
      "message.konnector": "grdfgrandlyon"
   }
}
```

:::

1. Consult the `triggers` table
   1. Run a Query with Mongo
   2. Check that only one GRDF trigger exists
   3. Copy the trigger's ID
2. Consult the `jobs` table
   1. Run a Query with Mongo
   2. Check that only one job exists / delete other GRDF jobs
   3. Verify that the 'trigger_id' corresponds to the previously copied trigger ID
   4. Update the `state` to `errored` and set the `error` field to `CHALLENGE_ASKED`...