-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathtest_user_management_revoke_session.py
More file actions
47 lines (38 loc) · 1.5 KB
/
test_user_management_revoke_session.py
File metadata and controls
47 lines (38 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from typing import Union
import pytest
from tests.utils.syncify import syncify
from workos.user_management import AsyncUserManagement, UserManagement
def _mock_session(id: str):
now = "2025-07-23T14:00:00.000Z"
return {
"object": "session",
"id": id,
"user_id": "user_123",
"organization_id": "org_123",
"status": "revoked",
"auth_method": "password",
"ip_address": "192.168.1.1",
"user_agent": "Mozilla/5.0",
"expires_at": "2025-07-23T15:00:00.000Z",
"ended_at": now,
"created_at": now,
"updated_at": now,
}
@pytest.mark.sync_and_async(UserManagement, AsyncUserManagement)
class TestUserManagementRevokeSession:
@pytest.fixture(autouse=True)
def setup(self, module_instance: Union[UserManagement, AsyncUserManagement]):
self.http_client = module_instance._http_client
self.user_management = module_instance
def test_revoke_session(self, capture_and_mock_http_client_request):
mock = _mock_session("session_abc")
request_kwargs = capture_and_mock_http_client_request(
self.http_client, mock, 200
)
response = syncify(
self.user_management.revoke_session(session_id="session_abc")
)
assert request_kwargs["url"].endswith("user_management/sessions/revoke")
assert request_kwargs["method"] == "post"
assert request_kwargs["json"] == {"session_id": "session_abc"}
assert response.id == "session_abc"