@@ -17,15 +17,15 @@ const orgFixtures = require('./mockObjects.user')
1717const orgController = require ( '../../../src/controller/org.controller/org.controller' )
1818const orgParams = require ( '../../../src/controller/org.controller/org.middleware' )
1919
20- describe . skip ( 'Testing the GET /org/:shortname/users endpoint in Org Controller' , ( ) => {
20+ describe ( 'Testing the GET /org/:shortname/users endpoint in Org Controller' , ( ) => {
2121 context ( 'Negative Tests' , ( ) => {
2222 it ( 'should return 404 not found because org does not exist' , ( done ) => {
2323 class NoOrg {
2424 async getOrgUUID ( ) {
2525 return null
2626 }
2727
28- async isSecretariat ( ) {
28+ async isSecretariatByShortName ( ) {
2929 return false
3030 }
3131 }
@@ -39,8 +39,8 @@ describe.skip('Testing the GET /org/:shortname/users endpoint in Org Controller'
3939 app . route ( '/org-does-not-exist/:shortname/users' )
4040 . get ( ( req , res , next ) => {
4141 const factory = {
42- getOrgRepository : ( ) => { return new NoOrg ( ) } ,
43- getUserRepository : ( ) => { return new Blank ( ) }
42+ getBaseOrgRepository : ( ) => { return new NoOrg ( ) } ,
43+ getBaseUserRepository : ( ) => { return new Blank ( ) }
4444 }
4545 req . ctx . repositories = factory
4646 next ( )
@@ -69,7 +69,7 @@ describe.skip('Testing the GET /org/:shortname/users endpoint in Org Controller'
6969 return 'not-an-org'
7070 }
7171
72- async isSecretariat ( ) {
72+ async isSecretariatByShortName ( ) {
7373 return false
7474 }
7575 }
@@ -83,8 +83,8 @@ describe.skip('Testing the GET /org/:shortname/users endpoint in Org Controller'
8383 app . route ( '/requester-does-not-belong/:shortname/users' )
8484 . get ( ( req , res , next ) => {
8585 const factory = {
86- getOrgRepository : ( ) => { return new NotSameOrg ( ) } ,
87- getUserRepository : ( ) => { return new Blank ( ) }
86+ getBaseOrgRepository : ( ) => { return new NotSameOrg ( ) } ,
87+ getBaseUserRepository : ( ) => { return new Blank ( ) }
8888 }
8989 req . ctx . repositories = factory
9090 next ( )
@@ -115,34 +115,23 @@ describe.skip('Testing the GET /org/:shortname/users endpoint in Org Controller'
115115 return orgFixtures . owningOrg . UUID
116116 }
117117
118- async isSecretariat ( ) {
118+ async isSecretariatByShortName ( ) {
119119 return false
120120 }
121121 }
122122
123- class GetAllOrgUsers {
124- async aggregatePaginate ( ) {
125- const res = {
126- itemsList : [ orgFixtures . existentUserDummy ] ,
127- itemCount : 1 ,
128- itemsPerPage : 1000 ,
129- currentPage : 1 ,
130- pageCount : 1 ,
131- pagingCounter : 1 ,
132- hasPrevPage : false ,
133- hasNextPage : false ,
134- prevPage : null ,
135- nextPage : null
123+ class GetAllUsersByOrgShortname {
124+ async getAllUsersByOrgShortname ( ) {
125+ return {
126+ users : [ orgFixtures . existentUserDummy ]
136127 }
137- return res
138128 }
139129 }
140-
141130 app . route ( '/user-list-returned-same-org/:shortname/users' )
142131 . get ( ( req , res , next ) => {
143132 const factory = {
144- getOrgRepository : ( ) => { return new GetOrgUUID ( ) } ,
145- getUserRepository : ( ) => { return new GetAllOrgUsers ( ) }
133+ getBaseOrgRepository : ( ) => { return new GetOrgUUID ( ) } ,
134+ getBaseUserRepository : ( ) => { return new GetAllUsersByOrgShortname ( ) }
146135 }
147136 req . ctx . repositories = factory
148137 next ( )
@@ -170,34 +159,24 @@ describe.skip('Testing the GET /org/:shortname/users endpoint in Org Controller'
170159 return orgFixtures . owningOrg . UUID
171160 }
172161
173- async isSecretariat ( ) {
162+ async isSecretariatByShortName ( ) {
174163 return true
175164 }
176165 }
177166
178- class GetAllOrgUsers {
179- async aggregatePaginate ( ) {
180- const res = {
181- itemsList : [ orgFixtures . existentUserDummy ] ,
182- itemCount : 1 ,
183- itemsPerPage : 1000 ,
184- currentPage : 1 ,
185- pageCount : 1 ,
186- pagingCounter : 1 ,
187- hasPrevPage : false ,
188- hasNextPage : false ,
189- prevPage : null ,
190- nextPage : null
167+ class GetAllUsersByOrgShortname {
168+ async getAllUsersByOrgShortname ( ) {
169+ return {
170+ users : [ orgFixtures . existentUserDummy ]
191171 }
192- return res
193172 }
194173 }
195174
196175 app . route ( '/user-list-returned-secretariat/:shortname/users' )
197176 . get ( ( req , res , next ) => {
198177 const factory = {
199- getOrgRepository : ( ) => { return new GetOrgUUID ( ) } ,
200- getUserRepository : ( ) => { return new GetAllOrgUsers ( ) }
178+ getBaseOrgRepository : ( ) => { return new GetOrgUUID ( ) } ,
179+ getBaseUserRepository : ( ) => { return new GetAllUsersByOrgShortname ( ) }
201180 }
202181 req . ctx . repositories = factory
203182 next ( )
@@ -225,34 +204,23 @@ describe.skip('Testing the GET /org/:shortname/users endpoint in Org Controller'
225204 return orgFixtures . owningOrg . UUID
226205 }
227206
228- async isSecretariat ( ) {
207+ async isSecretariatByShortName ( ) {
229208 return false
230209 }
231210 }
232211
233- class GetAllOrgUsers {
234- async aggregatePaginate ( ) {
235- const res = {
236- itemsList : orgFixtures . allOwningOrgUsers ,
237- itemCount : orgFixtures . allOwningOrgUsers . length ,
238- itemsPerPage : 500 ,
239- currentPage : 1 ,
240- pageCount : 1 ,
241- pagingCounter : 1 ,
242- hasPrevPage : false ,
243- hasNextPage : false ,
244- prevPage : null ,
245- nextPage : null
246- }
247- return res
212+ class GetAllUsersByOrgShortname {
213+ async getAllUsersByOrgShortname ( ) {
214+ const payload = { users : orgFixtures . allOwningOrgUsers }
215+ return payload
248216 }
249217 }
250218
251219 app . route ( '/user-list-returned-not-secretariat-limit-default/:shortname/users' )
252220 . get ( ( req , res , next ) => {
253221 const factory = {
254- getOrgRepository : ( ) => { return new GetOrgUUID ( ) } ,
255- getUserRepository : ( ) => { return new GetAllOrgUsers ( ) }
222+ getBaseOrgRepository : ( ) => { return new GetOrgUUID ( ) } ,
223+ getBaseUserRepository : ( ) => { return new GetAllUsersByOrgShortname ( ) }
256224 }
257225 req . ctx . repositories = factory
258226 next ( )
@@ -282,34 +250,33 @@ describe.skip('Testing the GET /org/:shortname/users endpoint in Org Controller'
282250 return orgFixtures . owningOrg . UUID
283251 }
284252
285- async isSecretariat ( ) {
253+ async isSecretariatByShortName ( ) {
286254 return false
287255 }
288256 }
289257
290- class GetAllOrgUsers {
291- async aggregatePaginate ( ) {
292- const res = {
293- itemsList : [ orgFixtures . allOwningOrgUsers [ 0 ] , orgFixtures . allOwningOrgUsers [ 1 ] , orgFixtures . allOwningOrgUsers [ 2 ] ] ,
294- itemCount : orgFixtures . allOwningOrgUsers . length ,
295- itemsPerPage : itemsPerPage ,
296- currentPage : 1 ,
297- pageCount : 2 ,
298- pagingCounter : 1 ,
299- hasPrevPage : false ,
300- hasNextPage : true ,
301- prevPage : null ,
302- nextPage : 2
303- }
304- return res
258+ class GetAllUsersByOrgShortname {
259+ async getAllUsersByOrgShortname ( ) {
260+ const payload = { users : [ orgFixtures . allOwningOrgUsers [ 0 ] , orgFixtures . allOwningOrgUsers [ 1 ] , orgFixtures . allOwningOrgUsers [ 2 ] ] }
261+ payload . totalCount = orgFixtures . allOwningOrgUsers . length
262+ payload . itemsPerPage = 3
263+ payload . pageCount = 2
264+ payload . currentPage = 1
265+ payload . pagingCounter = 1
266+ payload . hasPrevPage = false
267+ payload . hasNextPage = true
268+ payload . prevPage = null
269+ payload . nextPage = 2
270+
271+ return payload
305272 }
306273 }
307274
308275 app . route ( '/user-list-returned-not-secretariat-limit-3-1/:shortname/users' )
309276 . get ( ( req , res , next ) => {
310277 const factory = {
311- getOrgRepository : ( ) => { return new GetOrgUUID ( ) } ,
312- getUserRepository : ( ) => { return new GetAllOrgUsers ( ) }
278+ getBaseOrgRepository : ( ) => { return new GetOrgUUID ( ) } ,
279+ getBaseUserRepository : ( ) => { return new GetAllUsersByOrgShortname ( ) }
313280 }
314281 req . ctx . repositories = factory
315282 // temporary fix for #920: force pagnation
@@ -339,34 +306,33 @@ describe.skip('Testing the GET /org/:shortname/users endpoint in Org Controller'
339306 return orgFixtures . owningOrg . UUID
340307 }
341308
342- async isSecretariat ( ) {
309+ async isSecretariatByShortName ( ) {
343310 return false
344311 }
345312 }
346313
347- class GetAllOrgUsers {
348- async aggregatePaginate ( ) {
349- const res = {
350- itemsList : [ orgFixtures . allOwningOrgUsers [ 3 ] , orgFixtures . allOwningOrgUsers [ 4 ] ] ,
351- itemCount : orgFixtures . allOwningOrgUsers . length ,
352- itemsPerPage : 3 ,
353- currentPage : 2 ,
354- pageCount : 2 ,
355- pagingCounter : 1 ,
356- hasPrevPage : true ,
357- hasNextPage : false ,
358- prevPage : 1 ,
359- nextPage : null
360- }
361- return res
314+ class GetAllUsersByOrgShortname {
315+ async getAllUsersByOrgShortname ( ) {
316+ const payload = { users : [ orgFixtures . allOwningOrgUsers [ 3 ] , orgFixtures . allOwningOrgUsers [ 4 ] ] }
317+ payload . totalCount = orgFixtures . allOwningOrgUsers . length
318+ payload . itemsPerPage = 3
319+ payload . pageCount = 2
320+ payload . currentPage = 2
321+ payload . pagingCounter = 1
322+ payload . hasPrevPage = true
323+ payload . hasNextPage = false
324+ payload . prevPage = 1
325+ payload . nextPage = null
326+
327+ return payload
362328 }
363329 }
364330
365331 app . route ( '/user-list-returned-not-secretariat-limit-3-2/:shortname/users' )
366332 . get ( ( req , res , next ) => {
367333 const factory = {
368- getOrgRepository : ( ) => { return new GetOrgUUID ( ) } ,
369- getUserRepository : ( ) => { return new GetAllOrgUsers ( ) }
334+ getBaseOrgRepository : ( ) => { return new GetOrgUUID ( ) } ,
335+ getBaseUserRepository : ( ) => { return new GetAllUsersByOrgShortname ( ) }
370336 }
371337 req . ctx . repositories = factory
372338 // temporary fix for #920: force pagnation
@@ -396,34 +362,23 @@ describe.skip('Testing the GET /org/:shortname/users endpoint in Org Controller'
396362 return orgFixtures . owningOrg . UUID
397363 }
398364
399- async isSecretariat ( ) {
365+ async isSecretariatByShortName ( ) {
400366 return false
401367 }
402368 }
403369
404- class GetAllOrgUsers {
405- async aggregatePaginate ( ) {
406- const res = {
407- itemsList : [ ] ,
408- itemCount : 0 ,
409- itemsPerPage : 500 ,
410- currentPage : 1 ,
411- pageCount : 1 ,
412- pagingCounter : 1 ,
413- hasPrevPage : false ,
414- hasNextPage : false ,
415- prevPage : null ,
416- nextPage : null
417- }
418- return res
370+ class GetAllUsersByOrgShortname {
371+ async getAllUsersByOrgShortname ( ) {
372+ const payload = { users : [ ] }
373+ return payload
419374 }
420375 }
421376
422377 app . route ( '/user-list-no-users/:shortname/users' )
423378 . get ( ( req , res , next ) => {
424379 const factory = {
425- getOrgRepository : ( ) => { return new GetOrgUUID ( ) } ,
426- getUserRepository : ( ) => { return new GetAllOrgUsers ( ) }
380+ getBaseOrgRepository : ( ) => { return new GetOrgUUID ( ) } ,
381+ getBaseUserRepository : ( ) => { return new GetAllUsersByOrgShortname ( ) }
427382 }
428383 req . ctx . repositories = factory
429384 next ( )
0 commit comments