mirror of
https://github.com/yingziwu/mastodon.git
synced 2026-02-25 19:52:41 +00:00
Reduce hard coding of LOCAL_DOMAIN env value throughout tests (#35025)
This commit is contained in:
parent
f92ff6d699
commit
ab7f50ce4e
15 changed files with 69 additions and 37 deletions
|
|
@ -27,10 +27,10 @@ RSpec.describe 'account featured tags API' do
|
|||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to contain_exactly(a_hash_including({
|
||||
name: 'bar',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.username}/tagged/bar",
|
||||
url: short_account_tag_url(username: account.username, tag: 'bar'),
|
||||
}), a_hash_including({
|
||||
name: 'foo',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.username}/tagged/foo",
|
||||
url: short_account_tag_url(username: account.username, tag: 'foo'),
|
||||
}))
|
||||
end
|
||||
|
||||
|
|
@ -43,10 +43,10 @@ RSpec.describe 'account featured tags API' do
|
|||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to contain_exactly(a_hash_including({
|
||||
name: 'bar',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.pretty_acct}/tagged/bar",
|
||||
url: short_account_tag_url(username: account.pretty_acct, tag: 'bar'),
|
||||
}), a_hash_including({
|
||||
name: 'foo',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.pretty_acct}/tagged/foo",
|
||||
url: short_account_tag_url(username: account.pretty_acct, tag: 'foo'),
|
||||
}))
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -22,19 +22,23 @@ RSpec.describe 'Content-Security-Policy' do
|
|||
def expected_csp_headers
|
||||
<<~CSP.split("\n").map(&:strip)
|
||||
base-uri 'none'
|
||||
child-src 'self' blob: https://cb6e6126.ngrok.io
|
||||
connect-src 'self' data: blob: https://cb6e6126.ngrok.io #{Rails.configuration.x.streaming_api_base_url}
|
||||
child-src 'self' blob: #{local_domain}
|
||||
connect-src 'self' data: blob: #{local_domain} #{Rails.configuration.x.streaming_api_base_url}
|
||||
default-src 'none'
|
||||
font-src 'self' https://cb6e6126.ngrok.io
|
||||
font-src 'self' #{local_domain}
|
||||
form-action 'none'
|
||||
frame-ancestors 'none'
|
||||
frame-src 'self' https:
|
||||
img-src 'self' data: blob: https://cb6e6126.ngrok.io
|
||||
manifest-src 'self' https://cb6e6126.ngrok.io
|
||||
media-src 'self' data: https://cb6e6126.ngrok.io
|
||||
script-src 'self' https://cb6e6126.ngrok.io 'wasm-unsafe-eval'
|
||||
style-src 'self' https://cb6e6126.ngrok.io 'nonce-ZbA+JmE7+bK8F5qvADZHuQ=='
|
||||
worker-src 'self' blob: https://cb6e6126.ngrok.io
|
||||
img-src 'self' data: blob: #{local_domain}
|
||||
manifest-src 'self' #{local_domain}
|
||||
media-src 'self' data: #{local_domain}
|
||||
script-src 'self' #{local_domain} 'wasm-unsafe-eval'
|
||||
style-src 'self' #{local_domain} 'nonce-ZbA+JmE7+bK8F5qvADZHuQ=='
|
||||
worker-src 'self' blob: #{local_domain}
|
||||
CSP
|
||||
end
|
||||
|
||||
def local_domain
|
||||
root_url(host: Rails.configuration.x.local_domain).chop
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ RSpec.describe 'Link headers' do
|
|||
get short_account_path(username: account)
|
||||
|
||||
expect(response)
|
||||
.to have_http_link_header('https://cb6e6126.ngrok.io/.well-known/webfinger?resource=acct%3Atest%40cb6e6126.ngrok.io').for(rel: 'lrdd', type: 'application/jrd+json')
|
||||
.and have_http_link_header('https://cb6e6126.ngrok.io/users/test').for(rel: 'alternate', type: 'application/activity+json')
|
||||
.to have_http_link_header(webfinger_url(resource: account.to_webfinger_s)).for(rel: 'lrdd', type: 'application/jrd+json')
|
||||
.and have_http_link_header(account_url(account)).for(rel: 'alternate', type: 'application/activity+json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,7 +25,15 @@ RSpec.describe 'Remote Interaction Helper' do
|
|||
|
||||
def expected_csp_headers
|
||||
<<~CSP.squish
|
||||
default-src 'none'; frame-ancestors 'self'; form-action 'none'; script-src 'self' https://cb6e6126.ngrok.io 'wasm-unsafe-eval'; connect-src https:
|
||||
default-src 'none';
|
||||
frame-ancestors 'self';
|
||||
form-action 'none';
|
||||
script-src 'self' #{local_domain} 'wasm-unsafe-eval';
|
||||
connect-src https:
|
||||
CSP
|
||||
end
|
||||
|
||||
def local_domain
|
||||
root_url(host: Rails.configuration.x.local_domain).chop
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ RSpec.describe 'The /.well-known/host-meta request' do
|
|||
)
|
||||
|
||||
expect(xrd_link_template_value)
|
||||
.to eq 'https://cb6e6126.ngrok.io/.well-known/webfinger?resource={uri}'
|
||||
.to eq "https://#{Rails.configuration.x.local_domain}/.well-known/webfinger?resource={uri}"
|
||||
end
|
||||
|
||||
def xrd_link_template_value
|
||||
|
|
@ -57,7 +57,7 @@ RSpec.describe 'The /.well-known/host-meta request' do
|
|||
{
|
||||
links: [
|
||||
'rel' => 'lrdd',
|
||||
'template' => 'https://cb6e6126.ngrok.io/.well-known/webfinger?resource={uri}',
|
||||
'template' => "https://#{Rails.configuration.x.local_domain}/.well-known/webfinger?resource={uri}",
|
||||
],
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
|
|||
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
subject: eq('acct:alice@cb6e6126.ngrok.io'),
|
||||
aliases: include('https://cb6e6126.ngrok.io/@alice', 'https://cb6e6126.ngrok.io/users/alice')
|
||||
subject: eq(alice.to_webfinger_s),
|
||||
aliases: include("https://#{Rails.configuration.x.local_domain}/@alice", "https://#{Rails.configuration.x.local_domain}/users/alice")
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
@ -125,10 +125,14 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
|
|||
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
subject: 'acct:mastodon.internal@cb6e6126.ngrok.io',
|
||||
aliases: ['https://cb6e6126.ngrok.io/actor']
|
||||
subject: instance_actor.to_webfinger_s,
|
||||
aliases: [instance_actor_url]
|
||||
)
|
||||
end
|
||||
|
||||
def instance_actor
|
||||
Account.where(id: Account::INSTANCE_ACTOR_ID).first
|
||||
end
|
||||
end
|
||||
|
||||
context 'with no resource parameter' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue