-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TECH] Permettre la désactivation des CRON liés au CPF (PIX-14388).
- Loading branch information
Showing
8 changed files
with
179 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -298,6 +298,12 @@ const configuration = (function () { | |
importFileJobEnabled: process.env.PGBOSS_IMPORT_FILE_JOB_ENABLED | ||
? toBoolean(process.env.PGBOSS_IMPORT_FILE_JOB_ENABLED) | ||
: true, | ||
plannerJobEnabled: process.env.PGBOSS_PLANNER_JOB_ENABLED | ||
? toBoolean(process.env.PGBOSS_PLANNER_JOB_ENABLED) | ||
: true, | ||
exportSenderJobEnabled: process.env.PGBOSS_EXPORT_SENDER_JOB_ENABLED | ||
? toBoolean(process.env.PGBOSS_EXPORT_SENDER_JOB_ENABLED) | ||
: true, | ||
}, | ||
poleEmploi: { | ||
clientId: process.env.POLE_EMPLOI_CLIENT_ID, | ||
|
@@ -484,6 +490,7 @@ const configuration = (function () { | |
|
||
config.cpf.sendEmailJob = { | ||
recipient: '[email protected]', | ||
cron: '0 3 * * *', | ||
}; | ||
|
||
config.jwtConfig.livretScolaire = { secret: 'secretosmose', tokenLifespan: '1h' }; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { CpfExportSenderJobController } from '../../../../../../src/certification/session-management/application/jobs/cpf-export-sender-job-controller.js'; | ||
import { usecases } from '../../../../../../src/certification/session-management/domain/usecases/index.js'; | ||
import { config } from '../../../../../../src/shared/config.js'; | ||
import { logger } from '../../../../../../src/shared/infrastructure/utils/logger.js'; | ||
import { expect, sinon } from '../../../../../test-helper.js'; | ||
|
||
|
@@ -11,45 +12,71 @@ describe('Unit | Application | Certification | Sessions Management | jobs | cpf- | |
mailService = { sendCpfEmail: sinon.stub() }; | ||
}); | ||
|
||
describe('when generated files are found', function () { | ||
it('should send an email with a list of generated files url', async function () { | ||
// given | ||
usecases.getPreSignedUrls = sinon.stub(); | ||
usecases.getPreSignedUrls.resolves([ | ||
'https://bucket.url.com/file1.xml', | ||
'https://bucket.url.com/file2.xml', | ||
'https://bucket.url.com/file3.xml', | ||
]); | ||
describe('#isJobEnabled', function () { | ||
it('return true when job is enabled', function () { | ||
//given | ||
sinon.stub(config.pgBoss, 'exportSenderJobEnabled').value(true); | ||
|
||
// when | ||
const jobController = new CpfExportSenderJobController(); | ||
await jobController.handle({ dependencies: { mailService } }); | ||
const handler = new CpfExportSenderJobController(); | ||
|
||
// then | ||
expect(mailService.sendCpfEmail).to.have.been.calledWithExactly({ | ||
email: '[email protected]', | ||
generatedFiles: [ | ||
expect(handler.isJobEnabled).to.be.true; | ||
}); | ||
|
||
it('return false when job is disabled', function () { | ||
//given | ||
sinon.stub(config.pgBoss, 'exportSenderJobEnabled').value(false); | ||
|
||
//when | ||
const handler = new CpfExportSenderJobController(); | ||
|
||
//then | ||
expect(handler.isJobEnabled).to.be.false; | ||
}); | ||
}); | ||
|
||
describe('#handle', function () { | ||
describe('when generated files are found', function () { | ||
it('should send an email with a list of generated files url', async function () { | ||
// given | ||
usecases.getPreSignedUrls = sinon.stub(); | ||
usecases.getPreSignedUrls.resolves([ | ||
'https://bucket.url.com/file1.xml', | ||
'https://bucket.url.com/file2.xml', | ||
'https://bucket.url.com/file3.xml', | ||
], | ||
]); | ||
|
||
// when | ||
const jobController = new CpfExportSenderJobController(); | ||
await jobController.handle({ dependencies: { mailService } }); | ||
|
||
// then | ||
expect(mailService.sendCpfEmail).to.have.been.calledWithExactly({ | ||
email: '[email protected]', | ||
generatedFiles: [ | ||
'https://bucket.url.com/file1.xml', | ||
'https://bucket.url.com/file2.xml', | ||
'https://bucket.url.com/file3.xml', | ||
], | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('when no generated file is found', function () { | ||
it('should not send an email', async function () { | ||
// given | ||
usecases.getPreSignedUrls = sinon.stub(); | ||
usecases.getPreSignedUrls.resolves([]); | ||
describe('when no generated file is found', function () { | ||
it('should not send an email', async function () { | ||
// given | ||
usecases.getPreSignedUrls = sinon.stub(); | ||
usecases.getPreSignedUrls.resolves([]); | ||
|
||
// when | ||
const jobController = new CpfExportSenderJobController(); | ||
await jobController.handle({ dependencies: { mailService } }); | ||
// when | ||
const jobController = new CpfExportSenderJobController(); | ||
await jobController.handle({ dependencies: { mailService } }); | ||
|
||
// then | ||
expect(mailService.sendCpfEmail).to.not.have.been.called; | ||
expect(logger.info).to.have.been.calledWithExactly(`No CPF exports files ready to send`); | ||
// then | ||
expect(mailService.sendCpfEmail).to.not.have.been.called; | ||
expect(logger.info).to.have.been.calledWithExactly(`No CPF exports files ready to send`); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters