def test_wrong_connection(): """ Given: - an api token When: - checking api access Then: - raise error if there is no access because of wrong api token """ from iDefense_v2 import test_module with requests_mock.Mocker() as m: mock_address = 'https://test.com/rest/threatindicator/v0/' m.get(mock_address, status_code=401, json={}) client = Client('bad_api_key', 'wrong_token', True, False) try: test_module(client) except DemistoException as err: assert 'Error in API call - check the input parameters' in str(err)
def test_connection(): """ Given: - an api token When: - checking api access Then: - ok if there is access """ from iDefense_v2 import test_module with requests_mock.Mocker() as m: mock_address = 'https://test.com/rest/threatindicator/v0/' m.get(mock_address, status_code=200, json={}) client = Client(API_URL, 'api_token', True, False) assert test_module(client) in "ok"