Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
bc355035
Unverified
Commit
bc355035
authored
5 years ago
by
Brendan Abolivier
Browse files
Options
Downloads
Patches
Plain Diff
Add tests
parent
a4a9ded4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/rest/client/v2_alpha/test_register.py
+37
-0
37 additions, 0 deletions
tests/rest/client/v2_alpha/test_register.py
with
37 additions
and
0 deletions
tests/rest/client/v2_alpha/test_register.py
+
37
−
0
View file @
bc355035
...
@@ -323,6 +323,8 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
...
@@ -323,6 +323,8 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
"
renew_at
"
:
172800000
,
# Time in ms for 2 days
"
renew_at
"
:
172800000
,
# Time in ms for 2 days
"
renew_by_email_enabled
"
:
True
,
"
renew_by_email_enabled
"
:
True
,
"
renew_email_subject
"
:
"
Renew your account
"
,
"
renew_email_subject
"
:
"
Renew your account
"
,
"
account_renewed_html_path
"
:
"
account_renewed.html
"
,
"
invalid_token_html_path
"
:
"
invalid_token.html
"
,
}
}
# Email config.
# Email config.
...
@@ -373,6 +375,19 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
...
@@ -373,6 +375,19 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
self
.
render
(
request
)
self
.
render
(
request
)
self
.
assertEquals
(
channel
.
result
[
"
code
"
],
b
"
200
"
,
channel
.
result
)
self
.
assertEquals
(
channel
.
result
[
"
code
"
],
b
"
200
"
,
channel
.
result
)
# Check that we're getting HTML back.
content_type
=
None
for
header
in
channel
.
result
.
get
(
"
headers
"
,
[]):
if
header
[
0
]
==
b
"
Content-Type
"
:
content_type
=
header
[
1
]
self
.
assertEqual
(
content_type
,
b
"
text/html; charset=utf-8
"
,
channel
.
result
)
# Check that the HTML we're getting is the one we expect on a successful renewal.
expected_html
=
self
.
hs
.
config
.
account_validity
.
account_renewed_html_content
self
.
assertEqual
(
channel
.
result
[
"
body
"
],
expected_html
.
encode
(
"
utf8
"
),
channel
.
result
)
# Move 3 days forward. If the renewal failed, every authed request with
# Move 3 days forward. If the renewal failed, every authed request with
# our access token should be denied from now, otherwise they should
# our access token should be denied from now, otherwise they should
# succeed.
# succeed.
...
@@ -381,6 +396,28 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
...
@@ -381,6 +396,28 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
self
.
render
(
request
)
self
.
render
(
request
)
self
.
assertEquals
(
channel
.
result
[
"
code
"
],
b
"
200
"
,
channel
.
result
)
self
.
assertEquals
(
channel
.
result
[
"
code
"
],
b
"
200
"
,
channel
.
result
)
def
test_renewal_invalid_token
(
self
):
# Hit the renewal endpoint with an invalid token and check that it behaves as
# expected, i.e. that it responds with 404 Not Found and the correct HTML.
url
=
"
/_matrix/client/unstable/account_validity/renew?token=123
"
request
,
channel
=
self
.
make_request
(
b
"
GET
"
,
url
)
self
.
render
(
request
)
self
.
assertEquals
(
channel
.
result
[
"
code
"
],
b
"
404
"
,
channel
.
result
)
# Check that we're getting HTML back.
content_type
=
None
for
header
in
channel
.
result
.
get
(
"
headers
"
,
[]):
if
header
[
0
]
==
b
"
Content-Type
"
:
content_type
=
header
[
1
]
self
.
assertEqual
(
content_type
,
b
"
text/html; charset=utf-8
"
,
channel
.
result
)
# Check that the HTML we're getting is the one we expect when using an
# invalid/unknown token.
expected_html
=
self
.
hs
.
config
.
account_validity
.
invalid_token_html_content
self
.
assertEqual
(
channel
.
result
[
"
body
"
],
expected_html
.
encode
(
"
utf8
"
),
channel
.
result
)
def
test_manual_email_send
(
self
):
def
test_manual_email_send
(
self
):
self
.
email_attempts
=
[]
self
.
email_attempts
=
[]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment