From 641052799fc4c4b0d04a8f00f0f7c5de0e13fb95 Mon Sep 17 00:00:00 2001 From: Phil Rzewski Date: Wed, 7 Feb 2018 12:01:53 -0800 Subject: [PATCH 1/2] Make User/Team Management example fail more often --- examples/user_team_mgmt.py | 39 ++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/examples/user_team_mgmt.py b/examples/user_team_mgmt.py index 450a20dc..ae729e66 100755 --- a/examples/user_team_mgmt.py +++ b/examples/user_team_mgmt.py @@ -26,49 +26,64 @@ team_name = sys.argv[2] user_name = sys.argv[3] -print 'Trying to invite a user ', user_name +print 'Trying to invite a user:', user_name res = sdclient.create_user_invite(user_name) if res[0] == False: - print 'User creation failed: ', res[1] + if res[1] == 'user ' + user_name + ' already exists': + print 'User creation failed because', user_name ,'already exists. Continuing.' + else: + print 'User creation failed:', res[1], '. Exiting.' + sys.exit(1) else: print 'User creation succeeded' -print 'Now trying to create a team with name ', team_name +# Possible failures on Team creation might include having reached the +# max limit on Teams for this customer account or if the Team by that +# name already exists. Since a previous successful run of this test +# would have deleted the Team by the same name, and we need to be able +# to configure Teams for this test to pass, we'll treat both types of +# error as a genuine fail of the test. +print 'Now trying to create a team with name:', team_name res = sdclient.create_team(team_name) if res[0] == False: - print 'Team creation failed: ', res[1] + print 'Team creation failed:', res[1], '. Exiting.' + sys.exit(1) else: print 'Team creation succeeded.', res[1] -print 'Now trying to find team with name ', team_name +print 'Now trying to find team with name:', team_name res = sdclient.get_team(team_name) if res[0] == False: - print 'Could not get team info' + print 'Could not get team info:', res[1], '. Exiting.' + sys.exit(1) else: print 'Team fetch succeeded' -print 'Now trying to edit team ', team_name +print 'Now trying to edit team:', team_name memberships = { 'admin@draios.com': 'ROLE_TEAM_MANAGER', 'john-doe@sysdig.com': 'ROLE_TEAM_READ' } res = sdclient.edit_team(team_name, description='Nextgen2', memberships=memberships) if res[0] == False: - print 'Could not edit team ', res[1] + print 'Could not edit team:', res[1], '. Exiting.' + sys.exit(1) else: print 'Edited team to change description and add users' -print 'Now trying to edit user ', user_name +print 'Now trying to edit user:', user_name res = sdclient.edit_user(user_name, firstName='Just', lastName='Edited3', systemRole='ROLE_CUSTOMER') if res[0] == False: - print 'Could not edit user: ', res[1] + print 'Could not edit user:', res[1], '. Exiting.' + sys.exit(1) else: print 'Edit user succeeded' -print 'Now trying to delete the team ', team_name +print 'Now trying to delete the team:', team_name res = sdclient.delete_team(team_name) if res[0] == False: - print 'Could not delete team: ', res[1] + print 'Could not delete team:', res[1], '. Exiting.' + sys.exit(1) else: print 'Delete team succeeded' From 5d60e658caf6ae902711655468314331b903bb2b Mon Sep 17 00:00:00 2001 From: Phil Rzewski Date: Wed, 7 Feb 2018 12:26:46 -0800 Subject: [PATCH 2/2] Trivial change in comment to for Travis re-run now that Teams count is increased. --- examples/user_team_mgmt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/user_team_mgmt.py b/examples/user_team_mgmt.py index ae729e66..5411e25d 100755 --- a/examples/user_team_mgmt.py +++ b/examples/user_team_mgmt.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# This example shows the different aspects of user/team management +# This example shows the different aspects of user/team management. # import os