Skip to content

Commit b8e1142

Browse files
committed
[GPCAPIM-395]: Preliminary implementation of in-memory APIM APP Auth API stub
1 parent 320e7bd commit b8e1142

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

gateway-api/stubs/stubs/apim_app_auth/__init__.py

Whitespace-only changes.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"""
2+
In-memory APIM APP Auth API stub.
3+
4+
The stub does **not** implement the full APIM APP Auth API surface.
5+
"""
6+
7+
from typing import Any
8+
9+
from requests import Response
10+
11+
from stubs.base_stub import PostStub, StubBase
12+
13+
14+
class APIMAppAuthStub(StubBase, PostStub):
15+
def __init__(self) -> None:
16+
self._post_url: str = ""
17+
self._post_headers: dict[str, str] = {}
18+
self._post_data: str = ""
19+
self._post_timeout: int | None = None
20+
21+
@property
22+
def post_url(self) -> str:
23+
return self._post_url
24+
25+
@property
26+
def post_headers(self) -> dict[str, str]:
27+
return self._post_headers
28+
29+
@property
30+
def post_data(self) -> str:
31+
return self._post_data
32+
33+
@property
34+
def post_timeout(self) -> int | None:
35+
return self._post_timeout
36+
37+
# TODO: validation?
38+
39+
def post(
40+
self,
41+
url: str,
42+
data: str,
43+
**kwargs: Any, # noqa: ARG002 - kwargs are required to match subclass signature
44+
) -> Response:
45+
self._post_url = url
46+
self._post_data = data
47+
48+
response = self._create_response(
49+
status_code=200,
50+
json_data={
51+
"access_token": "access_token",
52+
"expires_in": "599",
53+
"token_type": "Bearer",
54+
"issued_at": "1777366854223",
55+
},
56+
)
57+
58+
return response

0 commit comments

Comments
 (0)