@@ -65,7 +65,6 @@ describe('Testing org put endpoint', () => {
65
65
await chai . request ( app )
66
66
. put ( '/api/org/win_5' )
67
67
. set ( { ...constants . nonSecretariatUserHeaders } )
68
- . query ( params )
69
68
. send ( )
70
69
. then ( ( res , err ) => {
71
70
// Assert that that the last_active field was updated under 2 seconds ago
@@ -75,8 +74,9 @@ describe('Testing org put endpoint', () => {
75
74
expect ( withinTwoSeconds ) . to . be . true
76
75
// Assert no other fields were changed
77
76
expect ( res ) . to . have . status ( 200 )
78
- expect ( res . body . updated . name ) . to . equal ( cnaParams . name )
79
- expect ( res . body . updated . policies . id_quota ) . to . equal ( cnaParams . id_quota )
77
+ expect ( res . body . updated . active_roles ) . to . be . undefined
78
+ expect ( res . body . updated . name ) . to . be . undefined
79
+ expect ( res . body . updated . policies ) . to . be . undefined
80
80
expect ( err ) . to . be . undefined
81
81
} )
82
82
} )
@@ -88,10 +88,23 @@ describe('Testing org put endpoint', () => {
88
88
. set ( { ...constants . nonSecretariatUserHeaders } )
89
89
. send ( )
90
90
. then ( ( res , err ) => {
91
- expect ( res ) . to . have . status ( 401 )
91
+ expect ( res ) . to . have . status ( 403 )
92
+ expect ( err ) . to . be . undefined
93
+ expect ( res . body ) . to . haveOwnProperty ( 'error' )
94
+ expect ( res . body . error ) . to . equal ( 'SECRETARIAT_ONLY' )
95
+ } )
96
+ } )
97
+ it ( 'Fails update to fields made by a non-secretariat org to itself' , async ( ) => {
98
+ await chai . request ( app )
99
+ . put ( '/api/org/win_5' )
100
+ . set ( { ...constants . nonSecretariatUserHeaders } )
101
+ . query ( params )
102
+ . send ( )
103
+ . then ( ( res , err ) => {
104
+ expect ( res ) . to . have . status ( 403 )
92
105
expect ( err ) . to . be . undefined
93
106
expect ( res . body ) . to . haveOwnProperty ( 'error' )
94
- expect ( res . body . error ) . to . equal ( 'UNAUTHORIZED ' )
107
+ expect ( res . body . error ) . to . equal ( 'SECRETARIAT_ONLY ' )
95
108
} )
96
109
} )
97
110
it ( 'Fails update made by a non-secretariat org to a secretariat' , async ( ) => {
@@ -100,10 +113,10 @@ describe('Testing org put endpoint', () => {
100
113
. set ( { ...constants . nonSecretariatUserHeaders } )
101
114
. send ( )
102
115
. then ( ( res , err ) => {
103
- expect ( res ) . to . have . status ( 401 )
116
+ expect ( res ) . to . have . status ( 403 )
104
117
expect ( err ) . to . be . undefined
105
118
expect ( res . body ) . to . haveOwnProperty ( 'error' )
106
- expect ( res . body . error ) . to . equal ( 'UNAUTHORIZED ' )
119
+ expect ( res . body . error ) . to . equal ( 'SECRETARIAT_ONLY ' )
107
120
} )
108
121
} )
109
122
} )
0 commit comments