13
13
# limitations under the License.
14
14
15
15
import os
16
+ from http import HTTPStatus
17
+
18
+ from twisted .test .proto_helpers import MemoryReactor
16
19
17
20
import synapse .rest .admin
18
21
from synapse .api .urls import ConsentURIBuilder
19
22
from synapse .rest .client import login , room
20
23
from synapse .rest .consent import consent_resource
24
+ from synapse .server import HomeServer
25
+ from synapse .util import Clock
21
26
22
27
from tests import unittest
23
28
from tests .server import FakeSite , make_request
@@ -32,7 +37,7 @@ class ConsentResourceTestCase(unittest.HomeserverTestCase):
32
37
user_id = True
33
38
hijack_auth = False
34
39
35
- def make_homeserver (self , reactor , clock ) :
40
+ def make_homeserver (self , reactor : MemoryReactor , clock : Clock ) -> HomeServer :
36
41
37
42
config = self .default_config ()
38
43
config ["form_secret" ] = "123abc"
@@ -56,7 +61,7 @@ def make_homeserver(self, reactor, clock):
56
61
hs = self .setup_test_homeserver (config = config )
57
62
return hs
58
63
59
- def test_render_public_consent (self ):
64
+ def test_render_public_consent (self ) -> None :
60
65
"""You can observe the terms form without specifying a user"""
61
66
resource = consent_resource .ConsentResource (self .hs )
62
67
channel = make_request (
@@ -66,9 +71,9 @@ def test_render_public_consent(self):
66
71
"/consent?v=1" ,
67
72
shorthand = False ,
68
73
)
69
- self .assertEqual (channel .code , 200 )
74
+ self .assertEqual (channel .code , HTTPStatus . OK )
70
75
71
- def test_accept_consent (self ):
76
+ def test_accept_consent (self ) -> None :
72
77
"""
73
78
A user can use the consent form to accept the terms.
74
79
"""
@@ -92,7 +97,7 @@ def test_accept_consent(self):
92
97
access_token = access_token ,
93
98
shorthand = False ,
94
99
)
95
- self .assertEqual (channel .code , 200 )
100
+ self .assertEqual (channel .code , HTTPStatus . OK )
96
101
97
102
# Get the version from the body, and whether we've consented
98
103
version , consented = channel .result ["body" ].decode ("ascii" ).split ("," )
@@ -107,7 +112,7 @@ def test_accept_consent(self):
107
112
access_token = access_token ,
108
113
shorthand = False ,
109
114
)
110
- self .assertEqual (channel .code , 200 )
115
+ self .assertEqual (channel .code , HTTPStatus . OK )
111
116
112
117
# Fetch the consent page, to get the consent version -- it should have
113
118
# changed
@@ -119,7 +124,7 @@ def test_accept_consent(self):
119
124
access_token = access_token ,
120
125
shorthand = False ,
121
126
)
122
- self .assertEqual (channel .code , 200 )
127
+ self .assertEqual (channel .code , HTTPStatus . OK )
123
128
124
129
# Get the version from the body, and check that it's the version we
125
130
# agreed to, and that we've consented to it.
0 commit comments