33
44from infrahub import config
55from infrahub .core .branch import Branch
6+ from infrahub .core .node import Node
67from infrahub .database import InfrahubDatabase
78
89EXPIRED_ACCESS_TOKEN = (
2223)
2324
2425
25- async def test_password_based_login (db : InfrahubDatabase , default_branch , client , first_account ) -> None :
26+ async def test_password_based_login (
27+ db : InfrahubDatabase , default_branch : Branch , client : TestClient , first_account : Node
28+ ) -> None :
2629 with client :
2730 response = client .post ("/api/auth/login" , json = {"username" : "First Account" , "password" : "FirstPassword123" })
2831
@@ -37,7 +40,9 @@ async def test_password_based_login(db: InfrahubDatabase, default_branch, client
3740 assert first_account .id == decoded ["sub" ]
3841
3942
40- async def test_refresh_with_invalidated_token (db : InfrahubDatabase , default_branch , client , first_account ) -> None :
43+ async def test_refresh_with_invalidated_token (
44+ db : InfrahubDatabase , default_branch : Branch , client : TestClient , first_account : Node
45+ ) -> None :
4146 with client :
4247 response = client .post ("/api/auth/login" , json = {"username" : "First Account" , "password" : "FirstPassword123" })
4348
@@ -64,7 +69,9 @@ async def test_refresh_with_invalidated_token(db: InfrahubDatabase, default_bran
6469 }
6570
6671
67- async def test_refresh_access_token (db : InfrahubDatabase , default_branch , client , first_account ) -> None :
72+ async def test_refresh_access_token (
73+ db : InfrahubDatabase , default_branch : Branch , client : TestClient , first_account : Node
74+ ) -> None :
6875 """Validate that it's possible to refresh an access token using a refresh token"""
6976 with client :
7077 login_response = client .post (
@@ -88,7 +95,9 @@ async def test_refresh_access_token(db: InfrahubDatabase, default_branch, client
8895 assert decoded_access ["session_id" ] == decoded_refresh ["session_id" ]
8996
9097
91- async def test_refresh_access_token_with_cookies (db : InfrahubDatabase , default_branch , client , first_account ) -> None :
98+ async def test_refresh_access_token_with_cookies (
99+ db : InfrahubDatabase , default_branch : Branch , client : TestClient , first_account : Node
100+ ) -> None :
92101 """Validate that it's possible to refresh an access token using a refresh token stored in cookies"""
93102 with client :
94103 login_response = client .post (
@@ -119,7 +128,7 @@ async def test_refresh_access_token_with_cookies(db: InfrahubDatabase, default_b
119128
120129
121130async def test_fail_to_refresh_access_token_with_access_token (
122- db : InfrahubDatabase , default_branch , client , first_account
131+ db : InfrahubDatabase , default_branch : Branch , client : TestClient , first_account : Node
123132) -> None :
124133 """Validate that it's not possible to refresh an access token using an access token"""
125134 with client :
@@ -143,7 +152,9 @@ async def test_fail_to_refresh_access_token_with_access_token(
143152 }
144153
145154
146- async def test_password_based_login_unknown_user (db : InfrahubDatabase , default_branch , client , first_account ) -> None :
155+ async def test_password_based_login_unknown_user (
156+ db : InfrahubDatabase , default_branch : Branch , client : TestClient , first_account : Node
157+ ) -> None :
147158 with client :
148159 response = client .post ("/api/auth/login" , json = {"username" : "i-do-not-exist" , "password" : "something" })
149160
@@ -155,7 +166,7 @@ async def test_password_based_login_unknown_user(db: InfrahubDatabase, default_b
155166
156167
157168async def test_password_based_login_invalid_password (
158- db : InfrahubDatabase , default_branch , client , first_account
169+ db : InfrahubDatabase , default_branch : Branch , client : TestClient , first_account : Node
159170) -> None :
160171 with client :
161172 response = client .post ("/api/auth/login" , json = {"username" : "First Account" , "password" : "incorrect" })
@@ -190,7 +201,9 @@ async def test_refresh_access_token_with_expired_refresh_token(
190201 assert response .json () == {"data" : None , "errors" : [{"message" : "Expired Signature" , "extensions" : {"code" : 401 }}]}
191202
192203
193- async def test_access_resource_using_refresh_token (db : InfrahubDatabase , default_branch , client , first_account ) -> None :
204+ async def test_access_resource_using_refresh_token (
205+ db : InfrahubDatabase , default_branch : Branch , client : TestClient , first_account : Node
206+ ) -> None :
194207 """It should not be possible to access a resource using a refresh token"""
195208 with client :
196209 login_response = client .post (
@@ -210,7 +223,9 @@ async def test_access_resource_using_refresh_token(db: InfrahubDatabase, default
210223 }
211224
212225
213- async def test_generate_api_token (db : InfrahubDatabase , default_branch , client , create_test_admin ) -> None :
226+ async def test_generate_api_token (
227+ db : InfrahubDatabase , default_branch : Branch , client : TestClient , create_test_admin : Node
228+ ) -> None :
214229 """It should not be possible to generate an API token using a JWT token"""
215230 with client :
216231 login_response = client .post (
0 commit comments