@@ -39,6 +39,32 @@ test('a non-team moderator cannot update a team', async t => {
3939 t . is ( res2 . status , 401 )
4040} )
4141
42+ test ( 'an org team cannot be updated by non-org user' , async t => {
43+ // Let's create an organization, user100 is the owner
44+ const res = await t . context . agent . post ( '/api/organizations' )
45+ . send ( { name : 'org team cannot be updated by non-org user' } )
46+ . set ( 'Authorization' , 'Bearer user100' )
47+ . expect ( 200 )
48+
49+ // Let's set user101 to be a manager of this organization and create a
50+ // team in the organization
51+ await t . context . agent . put ( `/api/organizations/${ res . body . id } /addManager/101` )
52+ . set ( 'Authorization' , 'Bearer user100' )
53+ . expect ( 200 )
54+
55+ const res2 = await t . context . agent . post ( `/api/organizations/${ res . body . id } /teams` )
56+ . send ( { name : 'org team cannot be updated by non-org user - team' } )
57+ . set ( 'Authorization' , 'Bearer user101' )
58+ . expect ( 200 )
59+
60+ // Use a different user from 101 or 100 to update the team
61+ const res3 = await t . context . agent . put ( `/api/teams/${ res2 . body . id } ` )
62+ . send ( { name : 'org team cannot be updated by non-org user - team2' } )
63+ . set ( 'Authorization' , 'Bearer user102' )
64+
65+ t . is ( res3 . status , 401 )
66+ } )
67+
4268test ( 'an org team can be updated by the the org manager' , async t => {
4369 // Let's create an organization, user100 is the owner
4470 const res = await t . context . agent . post ( '/api/organizations' )
0 commit comments