Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
eb871d3a
Commit
eb871d3a
authored
Jan 05, 2021
by
Quang-Minh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine expect_rejection assertions
parent
b1c223d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
spec/support/helpers/rack_attack_spec_helpers.rb
spec/support/helpers/rack_attack_spec_helpers.rb
+17
-0
No files found.
spec/support/helpers/rack_attack_spec_helpers.rb
View file @
eb871d3a
...
...
@@ -26,18 +26,35 @@ module RackAttackSpecHelpers
{
'AUTHORIZATION'
=>
"Basic
#{
encoded_login
}
"
}
end
# rubocop:disable Metrics/AbcSize
def
expect_rejection
(
&
block
)
yield
expect
(
response
).
to
have_gitlab_http_status
(
:too_many_requests
)
expect
(
response
).
to
have_header
(
'Retry-After'
)
expect
(
response
.
headers
[
'Retry-After'
]).
to
match
(
/^\d+$/
)
expect
(
response
).
to
have_header
(
'RateLimit-Limit'
)
expect
(
response
.
headers
[
'RateLimit-Limit'
]).
to
match
(
/^\d+$/
)
expect
(
response
).
to
have_header
(
'RateLimit-Observed'
)
expect
(
response
.
headers
[
'RateLimit-Observed'
]).
to
match
(
/^\d+$/
)
expect
(
response
).
to
have_header
(
'RateLimit-Remaining'
)
expect
(
response
.
headers
[
'RateLimit-Remaining'
]).
to
match
(
/^\d+$/
)
expect
(
response
).
to
have_header
(
'RateLimit-Reset'
)
expect
(
response
.
headers
[
'RateLimit-Reset'
]).
to
match
(
/^\d+$/
)
expect
(
response
).
to
have_header
(
'RateLimit-ResetTime'
)
expect
do
Time
.
httpdate
(
response
.
headers
[
'RateLimit-ResetTime'
])
end
.
not_to
raise_error
expect
(
response
).
to
have_header
(
'Retry-After'
)
expect
(
response
.
headers
[
'Retry-After'
]).
to
match
(
/^\d+$/
)
end
# rubocop:enable Metrics/AbcSize
def
expect_ok
(
&
block
)
yield
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment