Skip to content

Commit

Permalink
chore: added unit tests for recent cookies changes
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Nov 15, 2024
1 parent d408392 commit 4a65ff8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions dreadnode_cli/tests/test_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ def test_client_init_strips_trailing_slash() -> None:
assert client._base_url == "http://test.com"


def test_client_init_raises_on_invalid_url() -> None:
with pytest.raises(Exception, match="Invalid URL: invalid"):
api.Client("invalid")


def test_client_init_sets_cookie_for_localhost_domain() -> None:
client = api.Client("http://localhost", cookies={"session": "123"})
assert client._client.cookies.get("session", None, domain="localhost.local") == "123"


def test_client_init_sets_cookie_for_non_localhost_domain() -> None:
client = api.Client("http://example.com", cookies={"session": "123"})
assert client._client.cookies.get("session", None, domain="example.com") == "123"


def test_client_init_does_not_set_cookie_for_other_domain() -> None:
client = api.Client("http://example.com", cookies={"session": "123"})
assert client._client.cookies.get("session", None, domain="other.com") is None


def test_get_error_message_json() -> None:
client = api.Client()
response = httpx.Response(
Expand Down

0 comments on commit 4a65ff8

Please sign in to comment.