@@ -20,6 +20,8 @@ import {
2020 USER_CONNECTOR ,
2121 USER_DISINFORMATION_ANALYST ,
2222 USER_EDITOR ,
23+ USER_SECURITY ,
24+ USER_EDITOR ,
2325} from '../../utils/testQuery' ;
2426import { ENTITY_TYPE_IDENTITY_ORGANIZATION } from '../../../src/modules/organization/organization-types' ;
2527import { VIRTUAL_ORGANIZATION_ADMIN } from '../../../src/utils/access' ;
@@ -749,6 +751,7 @@ describe('User list members query behavior', () => {
749751 it ( 'Should user lists all members' , async ( ) => {
750752 const queryResult = await editorQuery ( { query : LIST_MEMBERS_QUERY } ) ;
751753 const usersEdges = queryResult . data . members . edges as { node : Member } [ ] ;
754+ expect ( usersEdges . map ( ( n ) => n . node ) ) . toEqual ( 'test' ) ;
752755 expect ( usersEdges . length ) . toEqual ( 25 ) ;
753756 expect ( usersEdges . filter ( ( { node : { entity_type } } ) => entity_type === ENTITY_TYPE_USER ) . length ) . toEqual ( TESTING_USERS . length + 1 ) ; // +1 = Plus admin user
754757 expect ( usersEdges . filter ( ( { node : { entity_type } } ) => entity_type === ENTITY_TYPE_GROUP ) . length ) . toEqual ( entitiesCounter . Group ) ;
@@ -980,6 +983,18 @@ describe('User has no settings capability and is organization admin query behavi
980983 } ) ;
981984 expect ( queryResult . data . userEdit . fieldPatch . account_status ) . toEqual ( 'Inactive' ) ;
982985 } ) ;
986+ it ( 'should not update user with no organization' , async ( ) => {
987+ await queryAsUserIsExpectedForbidden ( USER_EDITOR . client , {
988+ query : UPDATE_QUERY ,
989+ variables : { id : ADMIN_USER . id , input : { key : 'account_status' , value : [ 'Inactive' ] } } ,
990+ } ) ;
991+ } ) ;
992+ it ( 'should not update user from an other organization' , async ( ) => {
993+ await queryAsUserIsExpectedForbidden ( USER_EDITOR . client , {
994+ query : UPDATE_QUERY ,
995+ variables : { id : USER_SECURITY . id , input : { key : 'account_status' , value : [ 'Inactive' ] } } ,
996+ } ) ;
997+ } ) ;
983998 it ( 'should not add organization to user if not admin' , async ( ) => {
984999 platformOrganizationId = await getOrganizationIdByName ( PLATFORM_ORGANIZATION . name ) ;
9851000 await queryAsUserIsExpectedForbidden ( USER_EDITOR . client , {
@@ -990,6 +1005,15 @@ describe('User has no settings capability and is organization admin query behavi
9901005 } ,
9911006 } ) ;
9921007 } ) ;
1008+ it ( 'should not add organization to user if user is not in its own organization' , async ( ) => {
1009+ await queryAsUserIsExpectedForbidden ( USER_EDITOR . client , {
1010+ query : ORGANIZATION_ADD_QUERY ,
1011+ variables : {
1012+ id : ADMIN_USER . id ,
1013+ organizationId : testOrganizationId ,
1014+ } ,
1015+ } ) ;
1016+ } ) ;
9931017 it ( 'should administrate more than 1 organization' , async ( ) => {
9941018 // Need to add granted_groups to PLATFORM_ORGANIZATION because of line 533 in domain/user.js
9951019 const grantableGroupQueryResult = await adminQuery ( {
0 commit comments