From 4314be32e31f9464babdf8d761c426e867c2e945 Mon Sep 17 00:00:00 2001
From: build-token <build-token>
Date: Tue, 27 Sep 2022 09:34:50 +0000
Subject: [PATCH] publish: fix tests

generated from commit 8007def6d1685d91b87c3a46d0e5195dab7fae17
---
 index.js           | 10 +++++++---
 onDeleteAccount.js | 17 ++++++++++-------
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/index.js b/index.js
index 24e6273..a51243e 100644
--- a/index.js
+++ b/index.js
@@ -173,6 +173,7 @@ async function start(fields, cozyParameters) {
     await saveAccountData(this.accountId, {
       ...accountData.data,
       consentId: consent.ID,
+      expirationDate: contractEndDate,
     })
   } else {
     log('info', 'Alternate start...')
@@ -228560,11 +228561,14 @@ function isLocal() {
  * Verify if it's an alpha URL
  * @returns {boolean}
  */
-function isAlpha() {
-  return process.env.COZY_URL.includes('alpha')
+function isDev() {
+  return (
+    process.env.COZY_URL.includes('alpha') ||
+    process.env.COZY_URL.includes('cozy.tools')
+  )
 }
 
-module.exports = { isLocal, isAlpha }
+module.exports = { isLocal, isDev }
 
 
 /***/ })
diff --git a/onDeleteAccount.js b/onDeleteAccount.js
index b77b00b..4c0c6af 100644
--- a/onDeleteAccount.js
+++ b/onDeleteAccount.js
@@ -227461,11 +227461,14 @@ function isLocal() {
  * Verify if it's an alpha URL
  * @returns {boolean}
  */
-function isAlpha() {
-  return process.env.COZY_URL.includes('alpha')
+function isDev() {
+  return (
+    process.env.COZY_URL.includes('alpha') ||
+    process.env.COZY_URL.includes('cozy.tools')
+  )
 }
 
-module.exports = { isLocal, isAlpha }
+module.exports = { isLocal, isDev }
 
 
 /***/ }),
@@ -227486,8 +227489,7 @@ const moment = __webpack_require__(1373)
 __webpack_require__(1510)
 moment.locale('fr') // set the language
 moment.tz.setDefault('Europe/Paris') // set the timezone
-const { isLocal, isAlpha } = __webpack_require__(1605)
-// const ACCOUNT_ID = isLocal() ? 'default_account_id' : 'enedis-sge-grandlyon'
+const { isLocal, isDev } = __webpack_require__(1605)
 
 async function onDeleteAccount() {
   log('info', 'Deleting account ...')
@@ -227510,13 +227512,14 @@ async function onDeleteAccount() {
       })
     }
     const secrets = getAccountSecret()
+    log('warn', `Account DATAA InOndelete ${JSON.stringify(accountData)}`)
     const userConsent = await getBoConsent(
       secrets.boBaseUrl,
       secrets.boToken,
       accountData.data.consentId
     )
 
-    log('info', `isAlpha: ${isAlpha()}`)
+    log('info', `isAlpha: ${isDev()}`)
     log('info', `userConsent: ${JSON.stringify(userConsent)}`)
     if (userConsent.ID && userConsent.pointID) {
       log('log', `Consent ${userConsent.ID} found for user`)
@@ -227527,7 +227530,7 @@ async function onDeleteAccount() {
           userConsent.ID
         )
         // Verify if it's dev env to prevent delete of real data
-        if (!isAlpha()) {
+        if (!isDev()) {
           await terminateContract(
             secrets.wso2BaseUrl,
             secrets.apiToken,
-- 
GitLab