Bin
2025-12-17 262fecaa75b2909ad244f12c3b079ed3ff4ae329
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
---
test_name: sessions
strict: false
marks:
- usefixtures:
  - django_live_url
  - freeze_clock
stages:
- id: signup
  name: Sign up
  request:
    url: "{django_live_url}/user/signup"
    data:
      email: test_suites_user@heartex.com
      password: 12345678
    method: POST
  response:
    status_code: 302
 
- id: login
  name: Login
  request:
    url: "{django_live_url}/user/login"
    data:
      email: test_suites_user@heartex.com
      password: 12345678
    method: POST
  response:
    status_code: 302
 
# Configure session timeout policy for the user's organization
- id: get_session_policy
  name: Get Session Policy
  request:
    url: "{django_live_url}/api/session-policy/"
    method: GET
  response:
    status_code: 200
 
- id: set_session_policy
  name: Set Session Policy (short)
  request:
    url: "{django_live_url}/api/session-policy/"
    method: PATCH
    headers:
      Content-Type: application/json
    json:
      max_session_age: 1                 # 1 minute total age
      max_time_between_activity: 1       # 1 minute idle time
  response:
    status_code: 200
 
# A request right after login should be sucessful
- name: get_projects
  request:
    method: POST
    url: '{django_live_url}/api/projects'
  response:
    save:
      json:
        pk: id
    status_code: 201
    # hack to let us call a function after each stage
    verify_response_with:
      - function: label_studio.tests.conftest:tick_clock
        extra_kwargs:
          seconds: 65
 
# After max_time_between_activity has passed, the session will be over and requests will be denied
- name: get_projects
  request:
    method: POST
    url: '{django_live_url}/api/projects'
  response:
    save:
      json:
        pk: id
    status_code: 401
 
# login again
- id: login
  name: Login
  request:
    url: "{django_live_url}/user/login"
    data:
      email: test_suites_user@heartex.com
      password: 12345678
    method: POST
  response:
    status_code: 302
    verify_response_with:
      function: label_studio.tests.conftest:tick_clock
 
# make another request within max_time_between_activity
- name: get_projects_1
  request:
    method: POST
    url: '{django_live_url}/api/projects'
  response:
    save:
      json:
        pk: id
    status_code: 201
    verify_response_with:
      function: label_studio.tests.conftest:tick_clock
 
# and five more
- name: get_projects_2
  request:
    method: POST
    url: '{django_live_url}/api/projects'
  response:
    save:
      json:
        pk: id
    status_code: 201
    verify_response_with:
      function: label_studio.tests.conftest:tick_clock
 
- name: get_projects_3
  request:
    method: POST
    url: '{django_live_url}/api/projects'
  response:
    save:
      json:
        pk: id
    status_code: 201
    verify_response_with:
      function: label_studio.tests.conftest:tick_clock
 
- name: get_projects_4
  request:
    method: POST
    url: '{django_live_url}/api/projects'
  response:
    save:
      json:
        pk: id
    status_code: 201
    verify_response_with:
      - function: label_studio.tests.conftest:tick_clock
        extra_kwargs:
          seconds: 65
 
# and by now we reach MAX_SESSION_AGE and hte session end even if we were active
- name: get_projects_5
  request:
    method: POST
    url: '{django_live_url}/api/projects'
  response:
    save:
      json:
        pk: id
    status_code: 401