def test_invalid(self): # Validate the exception path request = create_request('foo', [], 'bar') # This will trigger a KeyError when get_response tries to access the # 'userInfo' del request.json['request']['userInfo'] response = group_validation.get_response(request) self.assertEqual("Invalid request", json.loads(response)['response']['status']['message'])
def runtest(self, user, memberGroups, editGroup, expect): failmsg = "expect={}, user={}, memberGroups={}, editGroup={}".format( expect, user, memberGroups, editGroup) request = create_request(user, memberGroups, editGroup) response = group_validation.get_response(request) response = json.loads(response)['response'] self.assertEqual(expect, response['allowed'], failmsg) # On DENY, validate the status message if not expect: self.assertEqual( "User not authorized to update group {}".format(editGroup), response['status']['message'], failmsg)