def test_get_redirect_url_from_query(self, non_formatted_url: str, redirect_param_name: str, expected: str): """ Given: - URL with redirect URL (Proof Point / ATP). When: - Given URL with redirect URL is valid. Then: - Ensure redirected URL is returned. """ from FormatURL import get_redirect_url_from_query assert get_redirect_url_from_query(non_formatted_url, urlparse(non_formatted_url), redirect_param_name) == expected
def test_get_redirect_url_from_query_no_url_query_param(self, mocker): """ Given: - Proof Point v1 URL. When: - Given URL is invalid and does not contain redirect URL query parameter. Then: - Ensure the full URL is returned. - Ensure a call to demisto.error is made. """ from FormatURL import get_redirect_url_from_query import demistomock as demisto url_ = 'https://urldefense.proofpoint.com/v1/url?x=bla' mocker.patch.object(demisto, 'error') assert get_redirect_url_from_query(url_, urlparse(url_), 'q') == url_ assert demisto.error.called
def test_get_redirect_url_from_query_duplicate_url_query_param(self, mocker): """ Given: - Proof Point v1 URL. When: - Given URL is invalid and contains duplicate redirect URL parameters. Then: - Ensure the full URL is returned. - Ensure a call to demisto.debug is made. """ from FormatURL import get_redirect_url_from_query import demistomock as demisto url_ = 'https://urldefense.proofpoint.com/v1/url?u=url_1&u=url_2' mocker.patch.object(demisto, 'debug') assert get_redirect_url_from_query(url_, urlparse(url_), 'u') == 'url_1' assert demisto.debug.called