@@ -98,7 +98,7 @@ describe("isFeasibilityManager", () => {
98
98
expect ( resp . json ( ) . errors [ 0 ] . message ) . toBe ( ERROR_MESSAGES . UNAUTHORIZED ) ;
99
99
} ) ;
100
100
101
- test ( "should deny access when feasibility does not exist" , async ( ) => {
101
+ test ( "should deny access when candidacy does not exist" , async ( ) => {
102
102
const resp = await getActiveFeasibilityByCandidacyId ( {
103
103
candidacyId : faker . string . uuid ( ) ,
104
104
keycloakId : faker . string . uuid ( ) ,
@@ -110,6 +110,43 @@ describe("isFeasibilityManager", () => {
110
110
) ;
111
111
} ) ;
112
112
113
+ test ( "should deny access when feasibility file does not exist" , async ( ) => {
114
+ const certification = await createCertificationHelper ( ) ;
115
+ const certificationAuthority = await createCertificationAuthorityHelper ( ) ;
116
+ const candidacy = await createCandidacyHelper ( {
117
+ candidacyArgs : {
118
+ certificationId : certification . id ,
119
+ } ,
120
+ } ) ;
121
+
122
+ await prismaClient . certificationAuthorityLocalAccount . create ( {
123
+ data : {
124
+ certificationAuthorityId : certificationAuthority . id ,
125
+ accountId : certificationAuthority . Account [ 0 ] . id ,
126
+ certificationAuthorityLocalAccountOnCertification : {
127
+ create : {
128
+ certificationId : certification . id ,
129
+ } ,
130
+ } ,
131
+ certificationAuthorityLocalAccountOnDepartment : {
132
+ create : {
133
+ departmentId : candidacy . departmentId ?? faker . string . uuid ( ) ,
134
+ } ,
135
+ } ,
136
+ } ,
137
+ } ) ;
138
+
139
+ const resp = await getActiveFeasibilityByCandidacyId ( {
140
+ candidacyId : candidacy . id ,
141
+ keycloakId : certificationAuthority ?. Account [ 0 ] . keycloakId ,
142
+ } ) ;
143
+
144
+ expect ( resp . json ( ) ) . toHaveProperty ( "errors" ) ;
145
+ expect ( resp . json ( ) . errors [ 0 ] . message ) . toBe (
146
+ ERROR_MESSAGES . CANDIDACY_NOT_FOUND ,
147
+ ) ;
148
+ } ) ;
149
+
113
150
test ( "should deny access when account is not found" , async ( ) => {
114
151
const feasibility = await createFeasibilityUploadedPdfHelper ( ) ;
115
152
@@ -240,19 +277,6 @@ describe("isFeasibilityManager", () => {
240
277
expect ( resp . json ( ) . errors [ 0 ] . message ) . toBe ( ERROR_MESSAGES . UNAUTHORIZED ) ;
241
278
} ) ;
242
279
243
- test ( "should deny access when certification authority does not match" , async ( ) => {
244
- const feasibility = await createFeasibilityUploadedPdfHelper ( ) ;
245
- const differentAuthority = await createCertificationAuthorityHelper ( ) ;
246
-
247
- const resp = await getActiveFeasibilityByCandidacyId ( {
248
- candidacyId : feasibility . candidacyId ,
249
- keycloakId : differentAuthority . Account [ 0 ] . keycloakId ,
250
- } ) ;
251
-
252
- expect ( resp . json ( ) ) . toHaveProperty ( "errors" ) ;
253
- expect ( resp . json ( ) . errors [ 0 ] . message ) . toBe ( ERROR_MESSAGES . UNAUTHORIZED ) ;
254
- } ) ;
255
-
256
280
test ( "should deny access when feasibility is not active" , async ( ) => {
257
281
const certificationAuthority = await createCertificationAuthorityHelper ( ) ;
258
282
const candidacy = await createCandidacyHelper ( ) ;
0 commit comments