Skip to content
Snippets Groups Projects
Commit f753daba authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

test: test login flow from invoices

parent 58938747
No related branches found
No related tags found
1 merge request!29Resolve "[SGE] - Semi-automatiser les tests avec facture"
......@@ -43,6 +43,7 @@
"grandlyon",
"HISTO",
"insee",
"konnector",
"konnectors",
"lastname",
"llle",
......
......@@ -42,6 +42,7 @@
"pretest": "npm run clean",
"release": "standard-version --no-verify",
"standalone": "cozy-konnector-standalone",
"standalone-no-data": "NO_DATA=true cozy-konnector-standalone src/index.js",
"start": "node ./src/index.js",
"test:cov": "jest --coverage",
"test": "jest",
......
......@@ -56,6 +56,7 @@ const startLoadDate = moment().subtract(7, 'day')
const endDate = moment()
const endDateString = endDate.format('YYYY-MM-DD')
const ACCOUNT_ID = isLocal() ? 'default_account_id' : 'enedissgegrandlyon'
const NO_DATA = process.env.NO_DATA === 'true'
module.exports = new BaseKonnector(start)
......@@ -92,6 +93,13 @@ async function start(fields, cozyParameters) {
try {
log('info', 'Konnector configuration ...')
log('info', `isManual execution: ${manualExecution}`)
if (NO_DATA) {
log(
'debug',
'NO_DATA is enabled, konnector will stop after verifyUserIdentity()'
)
}
const transaction = Sentry.startTransaction({
op: 'konnector',
name: 'SGE Konnector',
......@@ -149,6 +157,8 @@ async function start(fields, cozyParameters) {
sgeLogin
)
exitIfDebug(user)
let consent = await createBoConsent(
boBaseUrl,
boToken,
......@@ -230,6 +240,8 @@ async function start(fields, cozyParameters) {
accountData.data.inseeCode
)
exitIfDebug(user)
if (!userConsent) {
const errorMessage = 'No user consent found'
log('error', errorMessage)
......@@ -623,3 +635,19 @@ function isFirstStart(account) {
log('info', 'Konnector first start')
return true
}
/**
* Check if konnector is launched in local with NO_DATA option
* If so, logs result from verifyUserIdentity() and stops the konnector before getting any data
* @param {User} user - The user object to log
*/
function exitIfDebug(user) {
if (NO_DATA) {
log(
'debug',
`Stopping konnector before getting data, user found from verifyUserIdentity():`
)
log('debug', user)
process.exit()
}
}
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