Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Pierre Boudes
mastodon
Commits
1eb51bd7
Unverified
Commit
1eb51bd7
authored
1 year ago
by
Claire
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add request specs for caching behavior (#24592)
parent
88d33f36
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spec/rails_helper.rb
+22
-0
22 additions, 0 deletions
spec/rails_helper.rb
spec/requests/cache_spec.rb
+685
-0
685 additions, 0 deletions
spec/requests/cache_spec.rb
with
707 additions
and
0 deletions
spec/rails_helper.rb
+
22
−
0
View file @
1eb51bd7
...
...
@@ -35,6 +35,26 @@ Devise::Test::ControllerHelpers.module_eval do
end
end
module
SignedRequestHelpers
def
get
(
path
,
headers:
nil
,
sign_with:
nil
,
**
args
)
return
super
path
,
headers:
headers
,
**
args
if
sign_with
.
nil?
headers
||=
{}
headers
[
'Date'
]
=
Time
.
now
.
utc
.
httpdate
headers
[
'Host'
]
=
ENV
.
fetch
(
'LOCAL_DOMAIN'
)
signed_headers
=
headers
.
merge
(
'(request-target)'
=>
"get
#{
path
}
"
).
slice
(
'(request-target)'
,
'Host'
,
'Date'
)
key_id
=
ActivityPub
::
TagManager
.
instance
.
key_uri_for
(
sign_with
)
keypair
=
sign_with
.
keypair
signed_string
=
signed_headers
.
map
{
|
key
,
value
|
"
#{
key
.
downcase
}
:
#{
value
}
"
}.
join
(
"
\n
"
)
signature
=
Base64
.
strict_encode64
(
keypair
.
sign
(
OpenSSL
::
Digest
.
new
(
'SHA256'
),
signed_string
))
headers
[
'Signature'
]
=
"keyId=
\"
#{
key_id
}
\"
,algorithm=
\"
rsa-sha256
\"
,headers=
\"
#{
signed_headers
.
keys
.
join
(
' '
).
downcase
}
\"
,signature=
\"
#{
signature
}
\"
"
super
path
,
headers:
headers
,
**
args
end
end
RSpec
.
configure
do
|
config
|
config
.
fixture_path
=
"
#{
Rails
.
root
}
/spec/fixtures"
config
.
use_transactional_fixtures
=
true
...
...
@@ -46,10 +66,12 @@ RSpec.configure do |config|
config
.
include
Devise
::
Test
::
ControllerHelpers
,
type: :helper
config
.
include
Devise
::
Test
::
ControllerHelpers
,
type: :view
config
.
include
Devise
::
Test
::
IntegrationHelpers
,
type: :feature
config
.
include
Devise
::
Test
::
IntegrationHelpers
,
type: :request
config
.
include
Paperclip
::
Shoulda
::
Matchers
config
.
include
ActiveSupport
::
Testing
::
TimeHelpers
config
.
include
Chewy
::
Rspec
::
Helpers
config
.
include
Redisable
config
.
include
SignedRequestHelpers
,
type: :request
config
.
before
:each
,
type: :feature
do
https
=
ENV
[
'LOCAL_HTTPS'
]
==
'true'
...
...
This diff is collapsed.
Click to expand it.
spec/requests/cache_spec.rb
0 → 100644
+
685
−
0
View file @
1eb51bd7
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