def test_enable_user(admin_user): stubber = stubs.mock_cognito_admin_enable_user(admin_user["email"]) with stubber: enabled = cognito.enable_user(admin_user["email"]) assert enabled stubber.deactivate()
data = load_data(args.user_file, args.aws_profile) # We can check, create, disable or enable user now if args.check: for user in data["users"]: print(user) elif args.disable: # Disable user for user in data["users"]: response = cognito.disable_user(data["client"], data["profile"], user) cognito.show_error_response(response, args.debug) elif args.enable: # Enable user for user in data["users"]: response = cognito.enable_user(data["client"], data["profile"], user) cognito.show_error_response(response, args.debug) elif args.remove_from_group: # Remove users from group for user in data["users"]: response = cognito.remove_from_group(data["client"], data["profile"], user, args.remove_from_group) cognito.show_error_response(response, args.debug) elif args.verified: # Enable user for user in data["users"]: response = cognito.update_user_attributes(data["client"], data["profile"], user, "email_verified", "true") cognito.show_error_response(response, args.debug)
def enable(self): if not self.email_address_is_valid(): LOG.error("ERR: %s: the email %s is not valid", "user-admin", self.email_address) return False return cognito.enable_user(self.email_address)