Skip to content
Snippets Groups Projects
Commit b7155d14 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

fix(ondelete): local testing and variables

parent e7f1100d
No related branches found
No related tags found
No related merge requests found
Pipeline #42390 passed
...@@ -24,18 +24,12 @@ function getAccountRev() { ...@@ -24,18 +24,12 @@ function getAccountRev() {
/** /**
* Return account secrets. * Return account secrets.
* For local testing, change value with values from your konnector-dev-config.json * For local testing, change value with values from your konnector-dev-config.json
* @returns {Fields}
*/ */
function getAccountSecret() { function getAccountSecret() {
try { try {
return isLocal() return isLocal()
? { ? JSON.parse(process.env.COZY_FIELDS)
baseUrl: 'https://test.fr',
sgeLogin: 'test@test.com',
contractId: '134567',
boBaseUrl: 'https://botest.grandlyon.com/',
boToken: 'tok31n',
apiAuthKey: 'authkeYeasqqd56dsdq',
}
: JSON.parse(process.env.COZY_PARAMETERS).secret : JSON.parse(process.env.COZY_PARAMETERS).secret
} catch (err) { } catch (err) {
throw new Error( throw new Error(
......
...@@ -14,12 +14,23 @@ const ACCOUNT_ID = isLocal() ? 'default_account_id' : 'enedis-sge-grandlyon' ...@@ -14,12 +14,23 @@ const ACCOUNT_ID = isLocal() ? 'default_account_id' : 'enedis-sge-grandlyon'
async function onDeleteAccount() { async function onDeleteAccount() {
log('info', 'Deleting account ...') log('info', 'Deleting account ...')
log('info', 'Getting secrets ...') log('info', 'Getting secrets ...')
const secrets = getAccountSecret()
const accountRev = getAccountRev() const accountRev = getAccountRev()
if (accountRev) { if (accountRev) {
log('info', 'Account rev exist') log('info', 'Account rev exist')
const accountData = await getAccount(ACCOUNT_ID) const accountData = await getAccount(ACCOUNT_ID)
// Parse local info for deletion test
if (isLocal()) {
const fields = JSON.parse(
process.env.COZY_FIELDS ? process.env.COZY_FIELDS : '{}'
)
process.env.COZY_FIELDS = JSON.stringify({
...fields,
...accountData.auth,
})
}
const secrets = getAccountSecret()
const userConsent = await getBoConsent( const userConsent = await getBoConsent(
secrets.boBaseUrl, secrets.boBaseUrl,
secrets.boToken, secrets.boToken,
...@@ -35,8 +46,8 @@ async function onDeleteAccount() { ...@@ -35,8 +46,8 @@ async function onDeleteAccount() {
userConsent.ID userConsent.ID
) )
await terminateContract( await terminateContract(
secrets.baseUrl, secrets.wso2BaseUrl,
secrets.apiAuthKey, secrets.apiToken,
secrets.sgeLogin, secrets.sgeLogin,
secrets.contractId, secrets.contractId,
userConsent.pointID, userConsent.pointID,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment