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
Package registry
Container Registry
Model registry
Operate
Terraform modules
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
Timo Ley
synapse
Commits
caa9d6fe
Commit
caa9d6fe
authored
5 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Add test for admin redaction ratelimiting.
parent
c64c3bb4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/rest/client/test_redactions.py
+25
-0
25 additions, 0 deletions
tests/rest/client/test_redactions.py
with
25 additions
and
0 deletions
tests/rest/client/test_redactions.py
+
25
−
0
View file @
caa9d6fe
...
...
@@ -30,6 +30,14 @@ class RedactionsTestCase(HomeserverTestCase):
sync
.
register_servlets
,
]
def
make_homeserver
(
self
,
reactor
,
clock
):
config
=
self
.
default_config
()
config
[
"
rc_message
"
]
=
{
"
per_second
"
:
0.2
,
"
burst_count
"
:
10
}
config
[
"
rc_admin_redaction
"
]
=
{
"
per_second
"
:
1
,
"
burst_count
"
:
100
}
return
self
.
setup_test_homeserver
(
config
=
config
)
def
prepare
(
self
,
reactor
,
clock
,
hs
):
# register a couple of users
self
.
mod_user_id
=
self
.
register_user
(
"
user1
"
,
"
pass
"
)
...
...
@@ -177,3 +185,20 @@ class RedactionsTestCase(HomeserverTestCase):
self
.
_redact_event
(
self
.
other_access_token
,
self
.
room_id
,
create_event_id
,
expect_code
=
403
)
def
test_redact_event_as_moderator_ratelimit
(
self
):
"""
Tests that the correct ratelimiting is applied to redactions
"""
message_ids
=
[]
# as a regular user, send messages to redact
for
_
in
range
(
20
):
b
=
self
.
helper
.
send
(
room_id
=
self
.
room_id
,
tok
=
self
.
other_access_token
)
message_ids
.
append
(
b
[
"
event_id
"
])
self
.
reactor
.
advance
(
10
)
# To get around ratelimits
# as the moderator, send a bunch of redactions redaction
for
msg_id
in
message_ids
:
# These should all succeed, even though this would be denied by
# standard message ratelimiter
self
.
_redact_event
(
self
.
mod_access_token
,
self
.
room_id
,
msg_id
)
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