Skip to content

Commit

Permalink
test with default_login
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien Coelho committed Mar 12, 2024
1 parent 20e1d14 commit af3ae62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion FlaskTester.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def request(self, method: str, path: str, status: int|None = None, auth: str|Non
if "login" in kwargs:
login = kwargs["login"]
del kwargs["login"]
else: # pragma: no cover
else:
login = self._default_login

self._auth.setAuth(login, kwargs, auth=auth)
Expand Down
11 changes: 11 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

@pytest.fixture
def api(ft_client):
# set a default
ft_client._default_login = "calvin"
# bad password / token
ft_client.setPass("moe", None)
ft_client.setToken("moe", None)
Expand All @@ -41,6 +43,15 @@ def api(ft_client):
assert res.json["user"] == "hobbes"
res = ft_client.get("/who-am-i", login="susie", status=200, auth="bearer")
assert res.json["user"] == "susie"
# with defaults
res = ft_client.get("/who-am-i", auth="basic", status=200)
assert res.json["user"] == "calvin"
res = ft_client.get("/who-am-i", auth="param", status=200)
assert res.json["user"] == "calvin"
res = ft_client.get("/who-am-i", auth="bearer", status=200)
assert res.json["user"] == "calvin"
res = ft_client.get("/who-am-i", status=200)
assert res.json["user"] == "calvin"
# add a bad password
yield ft_client

Expand Down

0 comments on commit af3ae62

Please sign in to comment.