<commit_before>his set of curl lines, must be executed in the following way:

first: replace all the occurrence of localhost:8080 by the proper endpoint of the IDM API.
first create 3 users: owner, evil, and dummy, and replace all arround the text their ids by the ids listed below.
When creating groups or entities apply the same procedure.
Remember to update (ids, and lastModifications)

To see more information about groups, and how to list users inside a group check group.txt

#******************************* creation of users ***************************************

owner:
e4b6a486-bf3f-44f0-ab22-60a8029fe8fe

TOKENOWNER=<KEY>


evil
2e0165be-0c4b-42c0-896c-4b2e5e140964

TOKENEVIL=<KEY>

dummy
189653b3-deec-4fd1-aed2-7e03454d12b0

TOKENDUMMY=<KEY>

#******************************* creation of group ************************************************************

#Create a group
curl -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -d '{"name":"grouptest"}' http://localhost:8080/idm/group/

group-id: ba5b1e7c-2fa4-47d4-9770-4110627a8bca

#******************************* attempt to add membeships ************************************************************

#Add dummy to testgroup. Attempt from evil
curl   -H "Authorization: Bearer $TOKENEVIL"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -d '{"group_id":"ba5b1e7c-2fa4-47d4-9770-4110627a8bca","role":"ADMIN"}' -X POST http://localhost:8080/idm/memberships/user/189653b3-deec-4fd1-aed2-7e03454d12b0/
-> Insufficient permissions (OK)

#Evil attempts to add himself to the group. should be successful, but It shouldn't show up in his approved memberships
curl   -H "Authorization: Bearer $TOKENEVIL"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -d '{"group_id":"ba5b1e7c-2fa4-47d4-9770-4110627a8bca","role":"ADMIN"}' -X POST http://localhost:8080/idm/memberships/user/2e0165be-0c4b-42c0-896c-4b2e5e140964/


#Attempt to add Dummy, owner does it
curl   -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -d '{"group_id":"ba5b1e7c-2fa4-47d4-9770-4110627a8bca","role":"ADMIN"}' -X POST http://localhost:8080/idm/memberships/user/189653b3-deec-4fd1-aed2-7e03454d12b0/
->Success

#Try the same line again (Should get an error) (OK)

#******************************* get data for users after attempting membership ************************************************************

#Get data from dummy. We sould have an empty approvedMembership list
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/user/189653b3-deec-4fd1-aed2-7e03454d12b0

#Owner data. Should see an empty list for owner
curl -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/user/189653b3-deec-4fd1-aed2-7e03454d12b0

#Data for  evil
curl -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/user/2e0165be-0c4b-42c0-896c-4b2e5e140964
(OK)


#******************************* Get approvals to add membeships ************************************************************

#Get approvals by Dummy
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/memberships/users/
#Should see the self-approval for the group that OWNER has. And an empty approval as group Owner

#Get approvals by Owner
#Should see approvals evils should show up in group approvals, but self should be empty (OK)
curl -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/memberships/users/

#Get approvals evil
#should be empty (OK)
curl -H "Authorization: Bearer $TOKENEVIL"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/memberships/users/


#Approve the membership (by dummy). Replace If-Unmodified-Since, and also the id of the membership accordingly
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  -H "If-Unmodified-Since: 1399305217000" -X PUT http://localhost:8080/idm/memberships/approve/5ea30baf-4f49-403c-8874-6d2684bbfa30/

#Get approvals dummy
#Should be empty now (OK)
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/memberships/users/

#Get data for dummy (see dummy in the group as admin now)
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/user/189653b3-deec-4fd1-aed2-7e03454d12b0

#*******************************  membeship approvals ************************************************************

#Evil tries to trick the system and tries to approve his own membership. Adjust membership and since...
curl -H "Authorization: Bearer $TOKENEVIL"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  -H "If-Unmodified-Since: 1399305205000" -X PUT http://localhost:8080/idm/memberships/approve/8edd9f9c-1bb3-46ff-952c-1847ad4c255e
#after the previous line we get an error because EVIL wasn't supposed to try to approve that

#Dummy should be able to see now the approval from evil.
#At this point dummy could approve the membership for evil. same line as before. Just change the token
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  -H "If-Unmodified-Since: 1399305205000" -X PUT http://localhost:8080/idm/memberships/approve/8edd9f9c-1bb3-46ff-952c-1847ad4c255e
#Approve should be successful 

#No more pending approvals
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/memberships/users/
curl -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/memberships/users/

#see evil info
curl -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/user/2e0165be-0c4b-42c0-896c-4b2e5e140964

#Now dummy notices this, and deletes the membership from evil!
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  -H "If-Unmodified-Since: 1399305205000" -X DELETE http://localhost:8080/idm/memberships/delete/8edd9f9c-1bb3-46ff-952c-1847ad4c255e

#see evil info. HE should be out!
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/user/2e0165be-0c4b-42c0-896c-4b2e5e140964

Question... Admins, can kick other admins then? :-(  This should be possible in case some mallicious guy becomes admin, but still, it might lead to problems...

#Get group data
curl -H "Authorization: Bearer $TOKEN"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  http://localhost:8080/idm/group/ba5b1e7c-2fa4-47d4-9770-4110627a8bca

#attempt to delete the group which has memberships (by dummy). This should not be possible due to permissions
curl -H "If-Unmodified-Since: 1399305134000" -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  -X DELETE http://localhost:8080/idm/group/ba5b1e7c-2fa4-47d4-9770-4110627a8bca

#attempt to delete the group which has memberships (by owner). This should not be possible due to references
curl -H "If-Unmodified-Since: 1399305134000" -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  -X DELETE http://localhost:8080/idm/group/ba5b1e7c-2fa4-47d4-9770-4110627a8bca
<commit_msg>change curl line to match the delete controller of removing memberships...<commit_after>his set of curl lines, must be executed in the following way:

first: replace all the occurrence of localhost:8080 by the proper endpoint of the IDM API.
first create 3 users: owner, evil, and dummy, and replace all arround the text their ids by the ids listed below.
When creating groups or entities apply the same procedure.
Remember to update (ids, and lastModifications)

To see more information about groups, and how to list users inside a group check group.txt

#******************************* creation of users ***************************************

owner:
e4b6a486-bf3f-44f0-ab22-60a8029fe8fe

TOKENOWNER=<KEY>


evil
2e0165be-0c4b-42c0-896c-4b2e5e140964

TOKENEV<KEY>

dummy
189653b3-deec-4fd1-aed2-7e03454d12b0

TOKENDUMMY=<KEY>

#******************************* creation of group ************************************************************

#Create a group
curl -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -d '{"name":"grouptest"}' http://localhost:8080/idm/group/

group-id: ba5b1e7c-2fa4-47d4-9770-4110627a8bca

#******************************* attempt to add membeships ************************************************************

#Add dummy to testgroup. Attempt from evil
curl   -H "Authorization: Bearer $TOKENEVIL"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -d '{"group_id":"ba5b1e7c-2fa4-47d4-9770-4110627a8bca","role":"ADMIN"}' -X POST http://localhost:8080/idm/memberships/user/189653b3-deec-4fd1-aed2-7e03454d12b0/
-> Insufficient permissions (OK)

#Evil attempts to add himself to the group. should be successful, but It shouldn't show up in his approved memberships
curl   -H "Authorization: Bearer $TOKENEVIL"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -d '{"group_id":"ba5b1e7c-2fa4-47d4-9770-4110627a8bca","role":"ADMIN"}' -X POST http://localhost:8080/idm/memberships/user/2e0165be-0c4b-42c0-896c-4b2e5e140964/


#Attempt to add Dummy, owner does it
curl   -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -d '{"group_id":"ba5b1e7c-2fa4-47d4-9770-4110627a8bca","role":"ADMIN"}' -X POST http://localhost:8080/idm/memberships/user/189653b3-deec-4fd1-aed2-7e03454d12b0/
->Success

#Try the same line again (Should get an error) (OK)

#******************************* get data for users after attempting membership ************************************************************

#Get data from dummy. We sould have an empty approvedMembership list
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/user/189653b3-deec-4fd1-aed2-7e03454d12b0

#Owner data. Should see an empty list for owner
curl -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/user/189653b3-deec-4fd1-aed2-7e03454d12b0

#Data for  evil
curl -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/user/2e0165be-0c4b-42c0-896c-4b2e5e140964
(OK)


#******************************* Get approvals to add membeships ************************************************************

#Get approvals by Dummy
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/memberships/users/
#Should see the self-approval for the group that OWNER has. And an empty approval as group Owner

#Get approvals by Owner
#Should see approvals evils should show up in group approvals, but self should be empty (OK)
curl -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/memberships/users/

#Get approvals evil
#should be empty (OK)
curl -H "Authorization: Bearer $TOKENEVIL"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/memberships/users/


#Approve the membership (by dummy). Replace If-Unmodified-Since, and also the id of the membership accordingly
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  -H "If-Unmodified-Since: 1399305217000" -X PUT http://localhost:8080/idm/memberships/approve/5ea30baf-4f49-403c-8874-6d2684bbfa30/

#Get approvals dummy
#Should be empty now (OK)
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/memberships/users/

#Get data for dummy (see dummy in the group as admin now)
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/user/189653b3-deec-4fd1-aed2-7e03454d12b0

#*******************************  membeship approvals ************************************************************

#Evil tries to trick the system and tries to approve his own membership. Adjust membership and since...
curl -H "Authorization: Bearer $TOKENEVIL"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  -H "If-Unmodified-Since: 1399305205000" -X PUT http://localhost:8080/idm/memberships/approve/8edd9f9c-1bb3-46ff-952c-1847ad4c255e
#after the previous line we get an error because EVIL wasn't supposed to try to approve that

#Dummy should be able to see now the approval from evil.
#At this point dummy could approve the membership for evil. same line as before. Just change the token
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  -H "If-Unmodified-Since: 1399305205000" -X PUT http://localhost:8080/idm/memberships/approve/8edd9f9c-1bb3-46ff-952c-1847ad4c255e
#Approve should be successful 

#No more pending approvals
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/memberships/users/
curl -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/memberships/users/

#see evil info
curl -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/user/2e0165be-0c4b-42c0-896c-4b2e5e140964

#Now dummy notices this, and deletes the membership from evil!
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  -H "If-Unmodified-Since: 1399305205000" -X DELETE http://localhost:8080/idm/memberships/8edd9f9c-1bb3-46ff-952c-1847ad4c255e

#see evil info. HE should be out!
curl -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -X GET http://localhost:8080/idm/user/2e0165be-0c4b-42c0-896c-4b2e5e140964

Question... Admins, can kick other admins then? :-(  This should be possible in case some mallicious guy becomes admin, but still, it might lead to problems...

#Get group data
curl -H "Authorization: Bearer $TOKEN"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  http://localhost:8080/idm/group/ba5b1e7c-2fa4-47d4-9770-4110627a8bca

#attempt to delete the group which has memberships (by dummy). This should not be possible due to permissions
curl -H "If-Unmodified-Since: 1399305134000" -H "Authorization: Bearer $TOKENDUMMY"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  -X DELETE http://localhost:8080/idm/group/ba5b1e7c-2fa4-47d4-9770-4110627a8bca

#attempt to delete the group which has memberships (by owner). This should not be possible due to references
curl -H "If-Unmodified-Since: 1399305134000" -H "Authorization: Bearer $TOKENOWNER"  -H "Transferjson;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8"  -X DELETE http://localhost:8080/idm/group/ba5b1e7c-2fa4-47d4-9770-4110627a8bca

{'fraction_non_alphanumeric': 0.17872264297215099, 'fraction_numerical': 0.0806249627288449, 'mean_word_length': 5.408100878868934, 'pattern_counts': {'":': 14, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4437073', 'n_tokens_mistral': 6647, 'n_tokens_neox': 5854, 'n_words': 1502}