mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Merge commit '71d4ce1c228bab470fa9d3bcb5a130cf53665103' into glitch-soc/merge-upstream
This commit is contained in:
@@ -13,6 +13,7 @@ RSpec.describe AccountControllerConcern do
|
||||
|
||||
before do
|
||||
routes.draw { get 'success' => 'anonymous#success' }
|
||||
request.host = Rails.configuration.x.local_domain
|
||||
end
|
||||
|
||||
context 'when account is unconfirmed' do
|
||||
@@ -56,8 +57,8 @@ RSpec.describe AccountControllerConcern do
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_http_link_header('http://test.host/.well-known/webfinger?resource=acct%3Ausername%40cb6e6126.ngrok.io').for(rel: 'lrdd', type: 'application/jrd+json')
|
||||
.and have_http_link_header('https://cb6e6126.ngrok.io/users/username').for(rel: 'alternate', type: 'application/activity+json')
|
||||
.and 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, protocol: :https)).for(rel: 'alternate', type: 'application/activity+json')
|
||||
expect(response.body)
|
||||
.to include(account.username)
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ RSpec.describe UserTrackingConcern do
|
||||
get :show
|
||||
|
||||
expect_updated_sign_in_at(user)
|
||||
expect(redis.get("account:#{user.account_id}:regeneration")).to eq 'true'
|
||||
expect(redis.exists?("account:#{user.account_id}:regeneration")).to be true
|
||||
expect(RegenerationWorker).to have_received(:perform_async)
|
||||
end
|
||||
|
||||
@@ -80,7 +80,7 @@ RSpec.describe UserTrackingConcern do
|
||||
|
||||
expect_updated_sign_in_at(user)
|
||||
expect(redis.zcard(FeedManager.instance.key(:home, user.account_id))).to eq 3
|
||||
expect(redis.get("account:#{user.account_id}:regeneration")).to be_nil
|
||||
expect(redis.hget("account:#{user.account_id}:regeneration", 'status')).to eq 'finished'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ RSpec.describe HomeHelper do
|
||||
allow(helper).to receive(:closed_registrations?).and_return(true)
|
||||
result = helper.sign_up_message
|
||||
|
||||
expect(result).to eq t('auth.registration_closed', instance: 'cb6e6126.ngrok.io')
|
||||
expect(result).to eq t('auth.registration_closed', instance: Rails.configuration.x.local_domain)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ RSpec.describe Admin::SystemCheck::MediaPrivacyCheck do
|
||||
describe 'pass?' do
|
||||
context 'when the media cannot be listed' do
|
||||
before do
|
||||
stub_request(:get, /ngrok.io/).to_return(status: 200, body: 'a list of no files')
|
||||
stub_request(:get, /#{Regexp.quote(Rails.configuration.x.local_domain)}/).to_return(status: 200, body: 'a list of no files')
|
||||
end
|
||||
|
||||
it 'returns true' do
|
||||
|
||||
@@ -3,15 +3,25 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe OStatus::TagManager do
|
||||
around do |example|
|
||||
original = Rails.configuration.x.local_domain
|
||||
example.run
|
||||
Rails.configuration.x.local_domain = original
|
||||
end
|
||||
|
||||
describe '#unique_tag' do
|
||||
before { Rails.configuration.x.local_domain = 'mastodon.example' }
|
||||
|
||||
it 'returns a unique tag' do
|
||||
expect(described_class.instance.unique_tag(Time.utc(2000), 12, 'Status')).to eq 'tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Status'
|
||||
expect(described_class.instance.unique_tag(Time.utc(2000), 12, 'Status')).to eq 'tag:mastodon.example,2000-01-01:objectId=12:objectType=Status'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#unique_tag_to_local_id' do
|
||||
before { Rails.configuration.x.local_domain = 'mastodon.example' }
|
||||
|
||||
it 'returns the ID part' do
|
||||
expect(described_class.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Status', 'Status')).to eql '12'
|
||||
expect(described_class.instance.unique_tag_to_local_id('tag:mastodon.example,2000-01-01:objectId=12:objectType=Status', 'Status')).to eql '12'
|
||||
end
|
||||
|
||||
it 'returns nil if it is not local id' do
|
||||
@@ -19,17 +29,19 @@ RSpec.describe OStatus::TagManager do
|
||||
end
|
||||
|
||||
it 'returns nil if it is not expected type' do
|
||||
expect(described_class.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Block', 'Status')).to be_nil
|
||||
expect(described_class.instance.unique_tag_to_local_id('tag:mastodon.example,2000-01-01:objectId=12:objectType=Block', 'Status')).to be_nil
|
||||
end
|
||||
|
||||
it 'returns nil if it does not have object ID' do
|
||||
expect(described_class.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectType=Status', 'Status')).to be_nil
|
||||
expect(described_class.instance.unique_tag_to_local_id('tag:mastodon.example,2000-01-01:objectType=Status', 'Status')).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe '#local_id?' do
|
||||
before { Rails.configuration.x.local_domain = 'mastodon.example' }
|
||||
|
||||
it 'returns true for a local ID' do
|
||||
expect(described_class.instance.local_id?('tag:cb6e6126.ngrok.io;objectId=12:objectType=Status')).to be true
|
||||
expect(described_class.instance.local_id?('tag:mastodon.example;objectId=12:objectType=Status')).to be true
|
||||
end
|
||||
|
||||
it 'returns false for a foreign ID' do
|
||||
@@ -63,7 +75,7 @@ RSpec.describe OStatus::TagManager do
|
||||
|
||||
it 'returns the URL for account' do
|
||||
expect(target.object_type).to eq :person
|
||||
expect(subject).to eq 'https://cb6e6126.ngrok.io/users/alice'
|
||||
expect(subject).to eq "https://#{Rails.configuration.x.local_domain}/users/alice"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,7 +29,10 @@ RSpec.describe TextFormatter do
|
||||
let(:text) { '@alice' }
|
||||
|
||||
it 'creates a mention link' do
|
||||
expect(subject).to include '<a href="https://cb6e6126.ngrok.io/@alice" class="u-url mention">@<span>alice</span></a></span>'
|
||||
expect(subject)
|
||||
.to include(<<~LINK.squish)
|
||||
<a href="https://#{Rails.configuration.x.local_domain}/@alice" class="u-url mention">@<span>alice</span></a>
|
||||
LINK
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
174
spec/models/async_refresh_spec.rb
Normal file
174
spec/models/async_refresh_spec.rb
Normal file
@@ -0,0 +1,174 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AsyncRefresh do
|
||||
subject { described_class.new(redis_key) }
|
||||
|
||||
let(:redis_key) { 'testjob:key' }
|
||||
let(:status) { 'running' }
|
||||
let(:job_hash) { { 'status' => status, 'result_count' => 23 } }
|
||||
|
||||
describe '::find' do
|
||||
context 'when a matching job in redis exists' do
|
||||
before do
|
||||
redis.hset(redis_key, job_hash)
|
||||
end
|
||||
|
||||
it 'returns a new instance' do
|
||||
id = Rails.application.message_verifier('async_refreshes').generate(redis_key)
|
||||
async_refresh = described_class.find(id)
|
||||
|
||||
expect(async_refresh).to be_a described_class
|
||||
end
|
||||
end
|
||||
|
||||
context 'when no matching job in redis exists' do
|
||||
it 'returns `nil`' do
|
||||
id = Rails.application.message_verifier('async_refreshes').generate('non_existent')
|
||||
expect(described_class.find(id)).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '::create' do
|
||||
it 'inserts the given key into redis' do
|
||||
described_class.create(redis_key)
|
||||
|
||||
expect(redis.exists?(redis_key)).to be true
|
||||
end
|
||||
|
||||
it 'sets the status to `running`' do
|
||||
async_refresh = described_class.create(redis_key)
|
||||
|
||||
expect(async_refresh.status).to eq 'running'
|
||||
end
|
||||
|
||||
context 'with `count_results`' do
|
||||
it 'set `result_count` to 0' do
|
||||
async_refresh = described_class.create(redis_key, count_results: true)
|
||||
|
||||
expect(async_refresh.result_count).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
context 'without `count_results`' do
|
||||
it 'does not set `result_count`' do
|
||||
async_refresh = described_class.create(redis_key)
|
||||
|
||||
expect(async_refresh.result_count).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#id' do
|
||||
before do
|
||||
redis.hset(redis_key, job_hash)
|
||||
end
|
||||
|
||||
it "returns a signed version of the job's redis key" do
|
||||
id = subject.id
|
||||
key_name = Base64.decode64(id.split('-').first)
|
||||
|
||||
expect(key_name).to include redis_key
|
||||
end
|
||||
end
|
||||
|
||||
describe '#status' do
|
||||
before do
|
||||
redis.hset(redis_key, job_hash)
|
||||
end
|
||||
|
||||
context 'when the job is running' do
|
||||
it "returns 'running'" do
|
||||
expect(subject.status).to eq 'running'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the job is finished' do
|
||||
let(:status) { 'finished' }
|
||||
|
||||
it "returns 'finished'" do
|
||||
expect(subject.status).to eq 'finished'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#running?' do
|
||||
before do
|
||||
redis.hset(redis_key, job_hash)
|
||||
end
|
||||
|
||||
context 'when the job is running' do
|
||||
it 'returns `true`' do
|
||||
expect(subject.running?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the job is finished' do
|
||||
let(:status) { 'finished' }
|
||||
|
||||
it 'returns `false`' do
|
||||
expect(subject.running?).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#finished?' do
|
||||
before do
|
||||
redis.hset(redis_key, job_hash)
|
||||
end
|
||||
|
||||
context 'when the job is running' do
|
||||
it 'returns `false`' do
|
||||
expect(subject.finished?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the job is finished' do
|
||||
let(:status) { 'finished' }
|
||||
|
||||
it 'returns `true`' do
|
||||
expect(subject.finished?).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#finish!' do
|
||||
before do
|
||||
redis.hset(redis_key, job_hash)
|
||||
end
|
||||
|
||||
it 'sets the status to `finished`' do
|
||||
subject.finish!
|
||||
|
||||
expect(subject).to be_finished
|
||||
end
|
||||
end
|
||||
|
||||
describe '#result_count' do
|
||||
before do
|
||||
redis.hset(redis_key, job_hash)
|
||||
end
|
||||
|
||||
it 'returns the result count from redis' do
|
||||
expect(subject.result_count).to eq 23
|
||||
end
|
||||
end
|
||||
|
||||
describe '#reload' do
|
||||
before do
|
||||
redis.hset(redis_key, job_hash)
|
||||
end
|
||||
|
||||
it 'reloads the current data from redis and returns itself' do
|
||||
expect(subject).to be_running
|
||||
redis.hset(redis_key, { 'status' => 'finished' })
|
||||
expect(subject).to be_running
|
||||
|
||||
expect(subject.reload).to eq subject
|
||||
|
||||
expect(subject).to be_finished
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -32,7 +32,7 @@ RSpec.describe HomeFeed do
|
||||
|
||||
context 'when feed is being generated' do
|
||||
before do
|
||||
redis.set("account:#{account.id}:regeneration", true)
|
||||
redis.hset("account:#{account.id}:regeneration", { 'status' => 'running' })
|
||||
end
|
||||
|
||||
it 'returns nothing' do
|
||||
@@ -44,9 +44,19 @@ RSpec.describe HomeFeed do
|
||||
end
|
||||
|
||||
describe '#regenerating?' do
|
||||
context 'when an old-style string key is still in use' do
|
||||
it 'upgrades the key to a hash' do
|
||||
redis.set("account:#{account.id}:regeneration", true)
|
||||
|
||||
expect(subject.regenerating?).to be true
|
||||
|
||||
expect(redis.type("account:#{account.id}:regeneration")).to eq 'hash'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when feed is being generated' do
|
||||
before do
|
||||
redis.set("account:#{account.id}:regeneration", true)
|
||||
redis.hset("account:#{account.id}:regeneration", { 'status' => 'running' })
|
||||
end
|
||||
|
||||
it 'returns `true`' do
|
||||
@@ -55,13 +65,35 @@ RSpec.describe HomeFeed do
|
||||
end
|
||||
|
||||
context 'when feed is not being generated' do
|
||||
it 'returns `false`' do
|
||||
expect(subject.regenerating?).to be false
|
||||
context 'when the job is marked as finished' do
|
||||
before do
|
||||
redis.hset("account:#{account.id}:regeneration", { 'status' => 'finished' })
|
||||
end
|
||||
|
||||
it 'returns `false`' do
|
||||
expect(subject.regenerating?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the job key is missing' do
|
||||
it 'returns `false`' do
|
||||
expect(subject.regenerating?).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#regeneration_in_progress!' do
|
||||
context 'when an old-style string key is still in use' do
|
||||
it 'upgrades the key to a hash' do
|
||||
redis.set("account:#{account.id}:regeneration", true)
|
||||
|
||||
subject.regeneration_in_progress!
|
||||
|
||||
expect(redis.type("account:#{account.id}:regeneration")).to eq 'hash'
|
||||
end
|
||||
end
|
||||
|
||||
it 'sets the corresponding key in redis' do
|
||||
expect(redis.exists?("account:#{account.id}:regeneration")).to be false
|
||||
|
||||
@@ -72,12 +104,22 @@ RSpec.describe HomeFeed do
|
||||
end
|
||||
|
||||
describe '#regeneration_finished!' do
|
||||
it 'removes the corresponding key from redis' do
|
||||
redis.set("account:#{account.id}:regeneration", true)
|
||||
context 'when an old-style string key is still in use' do
|
||||
it 'upgrades the key to a hash' do
|
||||
redis.set("account:#{account.id}:regeneration", true)
|
||||
|
||||
subject.regeneration_finished!
|
||||
|
||||
expect(redis.type("account:#{account.id}:regeneration")).to eq 'hash'
|
||||
end
|
||||
end
|
||||
|
||||
it "sets the corresponding key's status to 'finished'" do
|
||||
redis.hset("account:#{account.id}:regeneration", { 'status' => 'running' })
|
||||
|
||||
subject.regeneration_finished!
|
||||
|
||||
expect(redis.exists?("account:#{account.id}:regeneration")).to be false
|
||||
expect(redis.hget("account:#{account.id}:regeneration", 'status')).to eq 'finished'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,7 +61,7 @@ RSpec.describe RemoteFollow do
|
||||
let(:account) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
it 'returns subscribe address' do
|
||||
expect(subject).to eq 'https://quitter.no/main/ostatussub?profile=https%3A%2F%2Fcb6e6126.ngrok.io%2Fusers%2Falice'
|
||||
expect(subject).to eq "https://quitter.no/main/ostatussub?profile=https%3A%2F%2F#{Rails.configuration.x.local_domain}%2Fusers%2Falice"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -66,7 +66,8 @@ RSpec.describe 'Home', :inline_jobs do
|
||||
end
|
||||
|
||||
context 'when the timeline is regenerating' do
|
||||
let(:timeline) { instance_double(HomeFeed, regenerating?: true, get: []) }
|
||||
let(:async_refresh) { AsyncRefresh.create("account:#{user.account_id}:regeneration") }
|
||||
let(:timeline) { instance_double(HomeFeed, regenerating?: true, get: [], async_refresh:) }
|
||||
|
||||
before do
|
||||
allow(HomeFeed).to receive(:new).and_return(timeline)
|
||||
@@ -76,6 +77,7 @@ RSpec.describe 'Home', :inline_jobs do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(206)
|
||||
expect(response.headers['Mastodon-Async-Refresh']).to eq "id=\"#{async_refresh.id}\", retry=5"
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
70
spec/requests/api/v1_alpha/async_refreshes_spec.rb
Normal file
70
spec/requests/api/v1_alpha/async_refreshes_spec.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'AsyncRefreshes' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:job) { AsyncRefresh.new('test_job') }
|
||||
|
||||
describe 'GET /api/v1_alpha/async_refreshes/:id' do
|
||||
context 'when not authorized' do
|
||||
it 'returns http unauthorized' do
|
||||
get api_v1_alpha_async_refresh_path(job.id)
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(401)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with wrong scope' do
|
||||
before do
|
||||
get api_v1_alpha_async_refresh_path(job.id), headers: headers
|
||||
end
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write write:accounts'
|
||||
end
|
||||
|
||||
context 'with correct scope' do
|
||||
let(:scopes) { 'read' }
|
||||
|
||||
context 'when job exists' do
|
||||
before do
|
||||
redis.hset('test_job', { 'status' => 'running', 'result_count' => 10 })
|
||||
end
|
||||
|
||||
after do
|
||||
redis.del('test_job')
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
get api_v1_alpha_async_refresh_path(job.id), headers: headers
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
parsed_response = response.parsed_body
|
||||
expect(parsed_response)
|
||||
.to be_present
|
||||
expect(parsed_response['async_refresh'])
|
||||
.to include('status' => 'running', 'result_count' => 10)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when job does not exist' do
|
||||
it 'returns not found' do
|
||||
get api_v1_alpha_async_refresh_path(job.id), headers: headers
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
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
|
||||
|
||||
@@ -21,7 +21,7 @@ RSpec::Matchers.define :have_thread_headers do
|
||||
.and(have_header('References', conversation_header_regex))
|
||||
end
|
||||
|
||||
def conversation_header_regex = /<conversation-\d+.\d\d\d\d-\d\d-\d\d@cb6e6126.ngrok.io>/
|
||||
def conversation_header_regex = /<conversation-\d+.\d\d\d\d-\d\d-\d\d@#{Regexp.quote(Rails.configuration.x.local_domain)}>/
|
||||
end
|
||||
|
||||
RSpec::Matchers.define :have_standard_headers do |type|
|
||||
|
||||
@@ -31,7 +31,7 @@ RSpec.describe 'email confirmation flow when captcha is enabled' do
|
||||
|
||||
# It presents a page with a link to the app callback
|
||||
expect(page)
|
||||
.to have_content(I18n.t('auth.confirmations.registration_complete', domain: 'cb6e6126.ngrok.io'))
|
||||
.to have_content(I18n.t('auth.confirmations.registration_complete', domain: Rails.configuration.x.local_domain))
|
||||
.and have_link(I18n.t('auth.confirmations.clicking_this_link'), href: client_app.confirmation_redirect_uri)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,6 +31,6 @@ RSpec.describe 'redirection confirmations' do
|
||||
end
|
||||
|
||||
def redirect_title
|
||||
I18n.t('redirects.title', instance: 'cb6e6126.ngrok.io')
|
||||
I18n.t('redirects.title', instance: Rails.configuration.x.local_domain)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user