Securing data, such as login credentials, within Insomnia Collection requests is essential to prevent exposure to restricted users in your Dotcom-Monitor account. In Dotcom-Monitor, this is achieved by storing sensitive data in encrypted variables using Dotcom-Monitor Secure Vault.
Once added to Secure Vault, data is encrypted and stored in Crypt containers, accessible only to authorized users with corresponding access permissions. The Prepare Script function facilitates passing encrypted values from Crypt variables to the script, ensuring security during test execution. Prepare Script runs before the Insomnia tests are executed. It retrieves variable values from the related Crypt container and passes the values to the Insomnia Collection.
Let’s assume that you have already imported an Insomnia Collection with variables that must be secured into Dotcom-Monitor.
The next step is to add the variables and set their values in Secure Vault. To do this, from the left sidebar menu, select Manage > Secure Vault. Please read the Secure Vault article for detailed explanations on how to add new variables to Secure Vault.
Finally, when the variables are added to a Crypt and saved to Secure Vault, we can access the Crypt variable values by using the following expression in the Prepare Script field of the Insomnia Collection task:
context.<Variable_name> = SecureVault.<Crypt_name>.<CryptVariable_name>;
where Crypt_name is the name of the Crypt that contains encrypted values and CryptVariable_name is a variable name as it appears in the Crypt.
Note that variable names in the Prepare Script field must be identical to the names referred to in the imported Insomnia Collection.
The variable values are passed to the test before the collection run and cleared up in all reportable data once used. The corresponding request parameter values will be masked in the test reports with asterisk symbols.