@@ -32,40 +32,12 @@ describe('LIST organization config', () => {
32
32
] ;
33
33
34
34
beforeEach ( ( ) => testUtil . clearDb ( )
35
- . then ( ( ) => models . OrgConfig . create ( configs [ 0 ] ) )
36
- . then ( ( ) => models . OrgConfig . create ( configs [ 1 ] ) )
37
- . then ( ( ) => Promise . resolve ( ) ) ,
35
+ . then ( ( ) => models . OrgConfig . bulkCreate ( configs ) ) ,
38
36
) ;
39
37
after ( testUtil . clearDb ) ;
40
38
41
39
describe ( 'GET /orgConfig' , ( ) => {
42
- it ( 'should return 200 for admin' , ( done ) => {
43
- request ( server )
44
- . get ( `${ orgConfigPath } ` )
45
- . set ( {
46
- Authorization : `Bearer ${ testUtil . jwts . admin } ` ,
47
- } )
48
- . expect ( 200 )
49
- . end ( ( err , res ) => {
50
- const config = configs [ 0 ] ;
51
-
52
- const resJson = res . body . result . content ;
53
- resJson . should . have . length ( 2 ) ;
54
- resJson [ 0 ] . id . should . be . eql ( config . id ) ;
55
- resJson [ 0 ] . orgId . should . be . eql ( config . orgId ) ;
56
- resJson [ 0 ] . configName . should . be . eql ( config . configName ) ;
57
- resJson [ 0 ] . configValue . should . be . eql ( config . configValue ) ;
58
- should . exist ( resJson [ 0 ] . createdAt ) ;
59
- resJson [ 0 ] . updatedBy . should . be . eql ( config . updatedBy ) ;
60
- should . exist ( resJson [ 0 ] . updatedAt ) ;
61
- should . not . exist ( resJson [ 0 ] . deletedBy ) ;
62
- should . not . exist ( resJson [ 0 ] . deletedAt ) ;
63
-
64
- done ( ) ;
65
- } ) ;
66
- } ) ;
67
-
68
- it ( 'should return 200 with filters' , ( done ) => {
40
+ it ( 'should return 200 for admin with filter' , ( done ) => {
69
41
request ( server )
70
42
. get ( `${ orgConfigPath } ?filter=orgId%3Din%28${ configs [ 0 ] . orgId } %29%26configName=${ configs [ 0 ] . configName } ` )
71
43
. set ( {
@@ -91,48 +63,60 @@ describe('LIST organization config', () => {
91
63
} ) ;
92
64
} ) ;
93
65
94
- it ( 'should return 200 even if user is not authenticated' , ( done ) => {
66
+ it ( 'should return 200 even if user is not authenticated with filter ' , ( done ) => {
95
67
request ( server )
96
- . get ( `${ orgConfigPath } ` )
68
+ . get ( `${ orgConfigPath } ?filter=orgId%3Din%28 ${ configs [ 0 ] . orgId } %29%26configName= ${ configs [ 0 ] . configName } ` )
97
69
. expect ( 200 , done ) ;
98
70
} ) ;
99
71
100
- it ( 'should return 200 for connect admin' , ( done ) => {
72
+ it ( 'should return 200 for connect admin with filter ' , ( done ) => {
101
73
request ( server )
102
- . get ( `${ orgConfigPath } ` )
74
+ . get ( `${ orgConfigPath } ?filter=orgId%3Din%28 ${ configs [ 0 ] . orgId } %29%26configName= ${ configs [ 0 ] . configName } ` )
103
75
. set ( {
104
76
Authorization : `Bearer ${ testUtil . jwts . connectAdmin } ` ,
105
77
} )
106
78
. expect ( 200 )
107
79
. end ( done ) ;
108
80
} ) ;
109
81
110
- it ( 'should return 200 for connect manager' , ( done ) => {
82
+ it ( 'should return 200 for connect manager with filter ' , ( done ) => {
111
83
request ( server )
112
- . get ( `${ orgConfigPath } ` )
84
+ . get ( `${ orgConfigPath } ?filter=orgId%3Din%28 ${ configs [ 0 ] . orgId } %29%26configName= ${ configs [ 0 ] . configName } ` )
113
85
. set ( {
114
86
Authorization : `Bearer ${ testUtil . jwts . manager } ` ,
115
87
} )
116
88
. expect ( 200 )
117
89
. end ( done ) ;
118
90
} ) ;
119
91
120
- it ( 'should return 200 for member' , ( done ) => {
92
+ it ( 'should return 200 for member with filter ' , ( done ) => {
121
93
request ( server )
122
- . get ( `${ orgConfigPath } ` )
94
+ . get ( `${ orgConfigPath } ?filter=orgId%3Din%28 ${ configs [ 0 ] . orgId } %29%26configName= ${ configs [ 0 ] . configName } ` )
123
95
. set ( {
124
96
Authorization : `Bearer ${ testUtil . jwts . member } ` ,
125
97
} )
126
98
. expect ( 200 , done ) ;
127
99
} ) ;
128
100
129
- it ( 'should return 200 for copilot' , ( done ) => {
101
+ it ( 'should return 200 for copilot with filter ' , ( done ) => {
130
102
request ( server )
131
- . get ( `${ orgConfigPath } ` )
103
+ . get ( `${ orgConfigPath } ?filter=orgId%3Din%28 ${ configs [ 0 ] . orgId } %29%26configName= ${ configs [ 0 ] . configName } ` )
132
104
. set ( {
133
105
Authorization : `Bearer ${ testUtil . jwts . copilot } ` ,
134
106
} )
135
107
. expect ( 200 , done ) ;
136
108
} ) ;
109
+
110
+ it ( 'should return 422 without filter query param' , ( done ) => {
111
+ request ( server )
112
+ . get ( `${ orgConfigPath } ` )
113
+ . expect ( 422 , done ) ;
114
+ } ) ;
115
+
116
+ it ( 'should return 422 with filter query param but without orgId defined' , ( done ) => {
117
+ request ( server )
118
+ . get ( `${ orgConfigPath } ?filter=configName=${ configs [ 0 ] . configName } ` )
119
+ . expect ( 422 , done ) ;
120
+ } ) ;
137
121
} ) ;
138
122
} ) ;
0 commit comments