diff --git a/frontend/cypress/e2e/import/navigation-module-access-spec.js b/frontend/cypress/e2e/import/navigation-module-access-spec.js index 5a6482768c..ccf89f5566 100644 --- a/frontend/cypress/e2e/import/navigation-module-access-spec.js +++ b/frontend/cypress/e2e/import/navigation-module-access-spec.js @@ -26,6 +26,15 @@ describe(`Should be able to acces the import module`, () => { cy.visitImport(); cy.checkCurrentPageIsImport(); }); + + it('Should be able to visit synthese upload', () => { + cy.visit('/#/import/synthese/process/upload'); + }); + + it('Should not be able to visit bad-destination upload', () => { + cy.visit('/#/import/bad-destination/process/upload'); + cy.checkCurrentPageIsImport(); + }); }); }); }); diff --git a/frontend/cypress/support/import/checkCurrentPageIsImportUpload.js b/frontend/cypress/support/import/checkCurrentPageIsImportUpload.js new file mode 100644 index 0000000000..4f139126e9 --- /dev/null +++ b/frontend/cypress/support/import/checkCurrentPageIsImportUpload.js @@ -0,0 +1,9 @@ +Cypress.Commands.add('checkCurrentPageIsImportUpload', (destination) => { + // Check the url + cy.url().should( + 'be.equal', + `${Cypress.config('baseUrl')}/#/import/${destination}/process/upload` + ); + // Check that the main component is there + cy.get('[data-qa="import-new-upload-file"]').should('exist'); +}); diff --git a/frontend/cypress/support/import/index.js b/frontend/cypress/support/import/index.js index aac0a74e1e..320d8cdfbd 100644 --- a/frontend/cypress/support/import/index.js +++ b/frontend/cypress/support/import/index.js @@ -1,6 +1,7 @@ import './backToImportList'; import './checkCellValueExistsInColumn'; import './checkCurrentPageIsImport'; +import './checkCurrentPageIsImportUpload'; import './checkImportListSize'; import './configureImportContentMapping'; import './configureImportFieldMapping'; diff --git a/frontend/src/app/modules/imports/components/import_process/import-process.resolver.ts b/frontend/src/app/modules/imports/components/import_process/import-process.resolver.ts index 86473db4dc..891db32640 100644 --- a/frontend/src/app/modules/imports/components/import_process/import-process.resolver.ts +++ b/frontend/src/app/modules/imports/components/import_process/import-process.resolver.ts @@ -27,6 +27,15 @@ export class ImportProcessResolver implements Resolve { let step: Step = route.data.step; let destination: string = route.params['destination']; + // Check that import in this destination is authorized + const fetchDestination = this.ds.getDestinations('C'); + fetchDestination.subscribe((destinations) => { + if(!destinations.find(item => item?.code == destination)){ + this.router.navigate([this.config.IMPORT.MODULE_URL]); + return EMPTY; + } + }); + this.ds.setDestination(destination); if (step == Step.Upload && route.params.id_import === undefined) { // creating new import