Skip to content

Commit

Permalink
[FEATURE] Change l'URL du endpoint Parcoursup vers `/api/parcoursup/c…
Browse files Browse the repository at this point in the history
…ertification/search?ine={ine}` (PIX-15913).

 #10931
  • Loading branch information
pix-service-auto-merge authored Jan 3, 2025
2 parents db4e530 + 4e02346 commit 5603315
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 104 deletions.
51 changes: 49 additions & 2 deletions api/datamart/seeds/csv/data_export_parcoursup_certif_result.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,49 @@
national_student_id
123456789OK
birthdate,certification_date,competence_id,competence_level,first_name,last_name,national_student_id,organization_uai,pix_score,status
1926-01-07,2024-12-22 11:11:16.18144+00,recsvLz0W2ShyfD63,2,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recIkYm646lrGvLNT,1,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recNv8qhaY887jQb2,4,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recDH19F7kKrfL3Ii,0,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,rec6rHqas39zvLZep,3,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recgxqQfz3BqEbtzh,5,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recMiZPNl7V1hyE1d,6,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recFpYXCKcyhLI3Nu,5,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recOdC9UDVJbAXHAm,6,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recbDTF8KwupqkeZ6,2,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recHmIWG6D0huq6Kx,3,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,rece6jYwH4WEw549z,3,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recofJCxg0NqTqTdP,1,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recfr0ax8XrfvJ3ER,0,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recIhdrmCuEmCDAzj,2,Mathilde,Durand,714347660RP,8664450K,314,validated
1926-01-07,2024-12-22 11:11:16.18144+00,recudHE5Omrr10qrx,2,Mathilde,Durand,714347660RP,8664450K,314,validated
2000-12-02,2024-12-04 20:41:38.430868+00,recsvLz0W2ShyfD63,7,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recIkYm646lrGvLNT,6,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recNv8qhaY887jQb2,2,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recDH19F7kKrfL3Ii,6,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,rec6rHqas39zvLZep,4,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recgxqQfz3BqEbtzh,6,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recMiZPNl7V1hyE1d,3,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recFpYXCKcyhLI3Nu,7,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recOdC9UDVJbAXHAm,2,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recbDTF8KwupqkeZ6,7,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recHmIWG6D0huq6Kx,3,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,rece6jYwH4WEw549z,4,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recofJCxg0NqTqTdP,6,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recfr0ax8XrfvJ3ER,6,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recIhdrmCuEmCDAzj,1,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
2000-12-02,2024-12-04 20:41:38.430868+00,recudHE5Omrr10qrx,3,Sylvie,Lacroix,544890735EF,8045351T,397,cancelled
1937-10-25,2024-12-07 06:22:50.031555+00,recsvLz0W2ShyfD63,0,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recIkYm646lrGvLNT,1,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recNv8qhaY887jQb2,4,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recDH19F7kKrfL3Ii,6,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,rec6rHqas39zvLZep,5,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recgxqQfz3BqEbtzh,6,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recMiZPNl7V1hyE1d,1,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recFpYXCKcyhLI3Nu,1,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recOdC9UDVJbAXHAm,5,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recbDTF8KwupqkeZ6,7,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recHmIWG6D0huq6Kx,4,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,rece6jYwH4WEw549z,1,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recofJCxg0NqTqTdP,2,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recfr0ax8XrfvJ3ER,3,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recIhdrmCuEmCDAzj,6,Julien,Boyer,127885732NY,5325800E,650,rejected
1937-10-25,2024-12-07 06:22:50.031555+00,recudHE5Omrr10qrx,7,Julien,Boyer,127885732NY,5325800E,650,rejected
3 changes: 1 addition & 2 deletions api/src/parcoursup/application/certification-controller.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { usecases } from '../domain/usecases/index.js';

const getCertificationResult = async function (request) {
const ine = request.params.ine;
return usecases.getCertificationResult({ ine, ...request.query });
return usecases.getCertificationResult(request.query);
};

const certificationController = {
Expand Down
139 changes: 47 additions & 92 deletions api/src/parcoursup/application/certification-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,102 +5,57 @@ import { responseObjectErrorDoc } from '../../shared/infrastructure/open-api-doc
import { certificationController } from './certification-controller.js';

const register = async function (server) {
server.route([
{
method: 'GET',
path: '/api/parcoursup/students/{ine}/certification',
config: {
auth: 'jwt-parcoursup',
validate: {
params: Joi.object({
ine: studentIdentifierType,
}),
},
handler: certificationController.getCertificationResult,
tags: ['api', 'parcoursup'],
notes: [
'- **Cette route est accessible uniquement à Parcours Sup**\n' +
'- Récupère les informations de la dernière certification de l‘année en cours pour l‘élève identifié via son INE',
],
response: {
failAction: 'log',
status: {
200: Joi.object({
organizationUai: Joi.string().description('UAI de l‘établissement scolaire'),
ine: Joi.string().description('INE de l‘élève'),
lastName: Joi.string().description('Nom de famille de l‘élève'),
firstName: Joi.string().description('Prénom de l‘élève'),
birthdate: Joi.date().description('Date de naissance au format JJ/MM/AAAA'),
status: Joi.string().description('Statut de la certification'),
pixScore: Joi.number().min(0).max(1024).description('Score en nombre de pix'),
certificationDate: Joi.date().description('Date de passage de la certification'),
competences: Joi.array()
.items(
Joi.object({
id: Joi.string().description('Identifiant unique de la compétence'),
level: Joi.number().min(0).max(8).description('Niveau obtenu sur la compétence'),
}).label('Competence-Result-Object'),
)
.description('Résultats par compétence')
.label('Competence-Results-Array'),
}).label('Certification-Result-Object'),
401: responseObjectErrorDoc,
403: responseObjectErrorDoc,
404: responseObjectErrorDoc,
},
},
server.route({
method: 'GET',
path: '/api/parcoursup/certification/search',
config: {
auth: 'jwt-parcoursup',
validate: {
query: Joi.object({
ine: studentIdentifierType,
organizationUai: Joi.string(),
lastName: Joi.string(),
firstName: Joi.string(),
birthdate: Joi.string(),
})
.xor('ine', 'organizationUai')
.and('organizationUai', 'lastName', 'firstName', 'birthdate'),
},
},
{
method: 'GET',
path: '/api/parcoursup/certification/search',
config: {
auth: 'jwt-parcoursup',
validate: {
query: Joi.object({
organizationUai: Joi.string().required(),
lastName: Joi.string().required(),
firstName: Joi.string().required(),
birthdate: Joi.string().required(),
}),
},
handler: certificationController.getCertificationResult,
tags: ['api', 'parcoursup'],
notes: [
'- **Cette route est accessible uniquement à Parcours Sup**\n' +
'- Récupère les informations de la dernière certification de l‘année en cours pour l‘élève identifié via l’UAI de son établissement, ainsi que le nom, prénom et date de naissance de l’élève.',
],
response: {
failAction: 'log',
status: {
200: Joi.object({
organizationUai: Joi.string().description('UAI de l‘établissement scolaire'),
ine: Joi.string().description('INE de l‘élève'),
lastName: Joi.string().description('Nom de famille de l‘élève'),
firstName: Joi.string().description('Prénom de l‘élève'),
birthdate: Joi.date().description('Date de naissance au format JJ/MM/AAAA'),
status: Joi.string().description('Statut de la certification'),
pixScore: Joi.number().min(0).max(1024).description('Score en nombre de pix'),
certificationDate: Joi.date().description('Date de passage de la certification'),
competences: Joi.array()
.items(
Joi.object({
id: Joi.string().description('Identifiant unique de la compétence'),
level: Joi.number().min(0).max(8).description('Niveau obtenu sur la compétence'),
}).label('Competence-Result-Object'),
)
.description('Résultats par compétence')
.label('Competence-Results-Array'),
}).label('Certification-Result-Object'),
401: responseObjectErrorDoc,
403: responseObjectErrorDoc,
404: responseObjectErrorDoc,
},
handler: certificationController.getCertificationResult,
tags: ['api', 'parcoursup'],
notes: [
'- **Cette route est accessible uniquement à Parcoursup**\n' +
'- Récupère la dernière certification de l‘année en cours pour l‘élève identifié via ses informations',
],
response: {
failAction: 'log',
status: {
200: Joi.object({
organizationUai: Joi.string().description('UAI de l‘établissement scolaire'),
ine: Joi.string().description('INE de l‘élève'),
lastName: Joi.string().description('Nom de famille de l‘élève'),
firstName: Joi.string().description('Prénom de l‘élève'),
birthdate: Joi.date().description('Date de naissance au format AAAA-MM-JJ'),
status: Joi.string().description('Statut de la certification'),
pixScore: Joi.number().min(0).max(1024).description('Score en nombre de pix'),
certificationDate: Joi.date().description('Date de passage de la certification'),
competences: Joi.array()
.items(
Joi.object({
id: Joi.string().description('Identifiant unique de la compétence'),
level: Joi.number().min(0).max(8).description('Niveau obtenu sur la compétence'),
}).label('Competence-Result-Object'),
)
.description('Résultats par compétence')
.label('Competence-Results-Array'),
}).label('Certification-Result-Object'),
401: responseObjectErrorDoc,
403: responseObjectErrorDoc,
404: responseObjectErrorDoc,
},
},
},
]);
});
};

const name = 'parcoursup-api';
export { name, register };
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Parcoursup | Acceptance | Application | certification-route', function
server = await createServer();
});

describe('GET /api/parcoursup/students/{ine}/certification', function () {
describe('GET /api/parcoursup/certification/search', function () {
it('should return 200 HTTP status code and a certification for a given INE', async function () {
// given
const ine = '123456789OK';
Expand Down Expand Up @@ -45,7 +45,7 @@ describe('Parcoursup | Acceptance | Application | certification-route', function

const options = {
method: 'GET',
url: `/api/parcoursup/students/${ine}/certification`,
url: `/api/parcoursup/certification/search?ine=${ine}`,
headers: {
authorization: generateValidRequestAuthorizationHeaderForApplication(
PARCOURSUP_CLIENT_ID,
Expand Down
74 changes: 68 additions & 6 deletions api/tests/parcoursup/unit/application/certification-route_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../../test-helper.js';

describe('Parcoursup | Unit | Application | Routes | Certification', function () {
describe('GET /parcoursup/students/{ine}/certification', function () {
describe('GET /parcoursup/certification/search?ine={ine}', function () {
it('should return 200', async function () {
//given
sinon.stub(certificationController, 'getCertificationResult').callsFake((request, h) => h.response().code(200));
Expand All @@ -22,7 +22,7 @@ describe('Parcoursup | Unit | Application | Routes | Certification', function ()
const PARCOURSUP_SOURCE = 'parcoursup';

const method = 'GET';
const url = '/api/parcoursup/students/123456789OK/certification';
const url = '/api/parcoursup/certification/search?ine=123456789OK';
const headers = {
authorization: generateValidRequestAuthorizationHeaderForApplication(
PARCOURSUP_CLIENT_ID,
Expand All @@ -38,6 +38,37 @@ describe('Parcoursup | Unit | Application | Routes | Certification', function ()
expect(response.statusCode).to.equal(200);
});

context('when the param is missing', function () {
let httpTestServer, headers;
beforeEach(async function () {
httpTestServer = new HttpTestServer();
httpTestServer.setupAuthentication();
await httpTestServer.register(moduleUnderTest);

const PARCOURSUP_CLIENT_ID = 'test-parcoursupClientId';
const PARCOURSUP_SCOPE = 'parcoursup';
const PARCOURSUP_SOURCE = 'parcoursup';

headers = {
authorization: generateValidRequestAuthorizationHeaderForApplication(
PARCOURSUP_CLIENT_ID,
PARCOURSUP_SOURCE,
PARCOURSUP_SCOPE,
),
};
});

it('return 400 error', async function () {
const url = '/api/parcoursup/certification/search?ine=';

// when
const response = await httpTestServer.request('GET', url, null, null, headers);

// then
expect(response.statusCode).to.equal(400);
});
});

context('with the wrong scope', function () {
it('should return 403', async function () {
//given
Expand All @@ -50,7 +81,7 @@ describe('Parcoursup | Unit | Application | Routes | Certification', function ()
const PARCOURSUP_SOURCE = 'parcoursup';

const method = 'GET';
const url = '/api/parcoursup/students/123456789OK/certification';
const url = '/api/parcoursup/certification/search?ine=123456789OK';
const headers = {
authorization: generateValidRequestAuthorizationHeaderForApplication(
PARCOURSUP_CLIENT_ID,
Expand Down Expand Up @@ -79,7 +110,7 @@ describe('Parcoursup | Unit | Application | Routes | Certification', function ()
const PARCOURSUP_SOURCE = 'parcoursup';

const method = 'GET';
const url = '/api/parcoursup/students/123456789OK/certification';
const url = '/api/parcoursup/certification/search?ine=123456789OK';
const headers = {
authorization: generateValidRequestAuthorizationHeaderForApplication(
PARCOURSUP_CLIENT_ID,
Expand Down Expand Up @@ -131,8 +162,6 @@ describe('Parcoursup | Unit | Application | Routes | Certification', function ()
context('return 400 error when any required query param is missing', function () {
let httpTestServer, headers;
beforeEach(async function () {
sinon.stub(certificationController, 'getCertificationResult').callsFake((request, h) => h.response().code(200));

httpTestServer = new HttpTestServer();
httpTestServer.setupAuthentication();
await httpTestServer.register(moduleUnderTest);
Expand Down Expand Up @@ -192,4 +221,37 @@ describe('Parcoursup | Unit | Application | Routes | Certification', function ()
});
});
});

describe('GET /parcoursup/certification/search?ine={ine}&organizationUai={organizationUai}', function () {
context('when both ine and organizationUai are used', function () {
let httpTestServer, headers;
beforeEach(async function () {
httpTestServer = new HttpTestServer();
httpTestServer.setupAuthentication();
await httpTestServer.register(moduleUnderTest);

const PARCOURSUP_CLIENT_ID = 'test-parcoursupClientId';
const PARCOURSUP_SCOPE = 'parcoursup';
const PARCOURSUP_SOURCE = 'parcoursup';

headers = {
authorization: generateValidRequestAuthorizationHeaderForApplication(
PARCOURSUP_CLIENT_ID,
PARCOURSUP_SOURCE,
PARCOURSUP_SCOPE,
),
};
});

it('returns 400 error ', async function () {
const url = '/api/parcoursup/certification/search?ine=123456789OK&organizationUai=123orgaUai';

// when
const response = await httpTestServer.request('GET', url, null, null, headers);

// then
expect(response.statusCode).to.equal(400);
});
});
});
});

0 comments on commit 5603315

Please sign in to comment.