Source code for api.users.v1.test_helpers.group.find_groups


[docs]def success(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/group/search, respond with HTTP 200""" import requests_mock from argus_api.helpers.tests import fake_response def mock_response(*args, **kwargs): with requests_mock.Mocker(real_http=True) as mock: mock.register_uri( "POST", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/group/search", status_code=200, json=fake_response({'offset': {'type': 'int', 'name': 'offset'}, 'limit': {'type': 'int', 'name': 'limit'}, 'responseCode': {'type': 'int', 'name': 'responseCode'}, 'count': {'type': 'int', 'name': 'count'}, 'data': {'type': 'list', 'items': {'id': {'type': 'int', 'position': 0, 'description': 'ID of subject '}, 'userName': {'type': 'str', 'position': 0, 'description': 'User name '}, 'name': {'type': 'str', 'position': 0, 'description': 'Name of subject '}, 'customer': {'id': {'type': 'int'}, 'name': {'type': 'str'}, 'shortName': {'type': 'str'}, 'domain': {'$ref': '#/definitions/DomainInfo'}}, 'createdTimestamp': {'type': 'int', 'position': 0, 'description': 'Created timestamp in ms '}, 'createdByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'lastUpdatedTimestamp': {'type': 'int', 'position': 0, 'description': 'Last updated timestamp in ms '}, 'lastUpdatedByUser': {'id': {'type': 'int'}, 'customerID': {'type': 'int'}, 'domain': {'$ref': '#/definitions/DomainInfo'}, 'userName': {'type': 'str'}, 'name': {'type': 'str'}, 'type': 'str', 'options': ['user', 'group']}, 'domain': {'id': {'type': 'int'}, 'name': {'type': 'str'}}, 'properties': {'type': 'dict', 'position': 0, 'description': 'Properties of subject ', 'additionalProperties': {'type': 'str'}}, 'groupName': {'type': 'str'}, 'description': {'type': 'str'}, 'ascendantIDs': {'type': 'list', 'position': 0, 'description': 'IDs of ascendants ', 'uniqueItems': True, 'items': {'type': 'int'}}, 'flags': {'type': 'list', 'position': 0, 'description': 'Flags assigned to the object. ', 'uniqueItems': True, 'items': {'type': 'str', 'enum': ['DISABLED', 'AUTH_RADIUS', 'AUTH_SMS', 'AUTH_LDAP', 'AUTH_LOCAL', 'BLOCKED', 'FORCE_PWCHANGE', 'DAEMON_ACCOUNT', 'PASSWORD_NOT_SET', 'AUTH_CRYPTO', 'AUTH_TOTP', 'AUTH_APIKEY', 'ANONYMOUS_USER']}}}, 'name': 'data'}, 'metaData': {'type': 'dict', 'additionalProperties': {'type': 'dict'}, 'name': 'metaData'}, 'messages': {'type': 'list', 'items': {'message': {'type': 'str'}, 'messageTemplate': {'type': 'str'}, 'type': 'str', 'field': {'type': 'str'}, 'parameter': {'type': 'dict'}, 'timestamp': {'type': 'int'}, 'options': ['FIELD_ERROR', 'ACTION_ERROR', 'WARNING', 'NOTIFICATION', 'INFO']}, 'name': 'messages'}, 'currentPage': {'type': 'int', 'name': 'currentPage'}, 'size': {'type': 'int', 'name': 'size'}}) ) return function(*args, **kwargs) return mock_response return decorator
[docs]def unauthorized(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/group/search, respond with HTTP 401""" import requests_mock from argus_api.helpers.tests import fake_response def mock_response(*args, **kwargs): with requests_mock.Mocker(real_http=True) as mock: mock.register_uri( "POST", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/group/search", status_code=401, json=None ) return function(*args, **kwargs) return mock_response return decorator
[docs]def forbidden(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/group/search, respond with HTTP 403""" import requests_mock from argus_api.helpers.tests import fake_response def mock_response(*args, **kwargs): with requests_mock.Mocker(real_http=True) as mock: mock.register_uri( "POST", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/group/search", status_code=403, json=None ) return function(*args, **kwargs) return mock_response return decorator
[docs]def not_found(function): """Mock https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/group/search, respond with HTTP 404""" import requests_mock from argus_api.helpers.tests import fake_response def mock_response(*args, **kwargs): with requests_mock.Mocker(real_http=True) as mock: mock.register_uri( "POST", r"https://osl-argus-trunk-web1.mnemonic.no/web/api/users/v1/group/search", status_code=404, json=None ) return function(*args, **kwargs) return mock_response return decorator