Merge git://github.com/tootsuite/mastodon into tootsuite-master
This commit is contained in:
@@ -9,7 +9,7 @@ describe Api::Web::PushSubscriptionsController do
|
||||
|
||||
let(:create_payload) do
|
||||
{
|
||||
data: {
|
||||
subscription: {
|
||||
endpoint: 'https://fcm.googleapis.com/fcm/send/fiuH06a27qE:APA91bHnSiGcLwdaxdyqVXNDR9w1NlztsHb6lyt5WDKOC_Z_Q8BlFxQoR8tWFSXUIDdkyw0EdvxTu63iqamSaqVSevW5LfoFwojws8XYDXv_NRRLH6vo2CdgiN4jgHv5VLt2A8ah6lUX',
|
||||
keys: {
|
||||
p256dh: 'BEm_a0bdPDhf0SOsrnB2-ategf1hHoCnpXgQsFj5JCkcoMrMt2WHoPfEYOYPzOIs9mZE8ZUaD7VA5vouy0kEkr8=',
|
||||
@@ -36,25 +36,17 @@ describe Api::Web::PushSubscriptionsController do
|
||||
it 'saves push subscriptions' do
|
||||
sign_in(user)
|
||||
|
||||
stub_request(:post, create_payload[:data][:endpoint]).to_return(status: 200)
|
||||
stub_request(:post, create_payload[:subscription][:endpoint]).to_return(status: 200)
|
||||
|
||||
post :create, format: :json, params: create_payload
|
||||
|
||||
user.reload
|
||||
|
||||
push_subscription = Web::PushSubscription.find_by(endpoint: create_payload[:data][:endpoint])
|
||||
push_subscription = Web::PushSubscription.find_by(endpoint: create_payload[:subscription][:endpoint])
|
||||
|
||||
expect(push_subscription['endpoint']).to eq(create_payload[:data][:endpoint])
|
||||
expect(push_subscription['key_p256dh']).to eq(create_payload[:data][:keys][:p256dh])
|
||||
expect(push_subscription['key_auth']).to eq(create_payload[:data][:keys][:auth])
|
||||
end
|
||||
|
||||
it 'sends welcome notification' do
|
||||
sign_in(user)
|
||||
|
||||
stub_request(:post, create_payload[:data][:endpoint]).to_return(status: 200)
|
||||
|
||||
post :create, format: :json, params: create_payload
|
||||
expect(push_subscription['endpoint']).to eq(create_payload[:subscription][:endpoint])
|
||||
expect(push_subscription['key_p256dh']).to eq(create_payload[:subscription][:keys][:p256dh])
|
||||
expect(push_subscription['key_auth']).to eq(create_payload[:subscription][:keys][:auth])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,15 +54,15 @@ describe Api::Web::PushSubscriptionsController do
|
||||
it 'changes alert settings' do
|
||||
sign_in(user)
|
||||
|
||||
stub_request(:post, create_payload[:data][:endpoint]).to_return(status: 200)
|
||||
stub_request(:post, create_payload[:subscription][:endpoint]).to_return(status: 200)
|
||||
|
||||
post :create, format: :json, params: create_payload
|
||||
|
||||
alerts_payload[:id] = Web::PushSubscription.find_by(endpoint: create_payload[:data][:endpoint]).id
|
||||
alerts_payload[:id] = Web::PushSubscription.find_by(endpoint: create_payload[:subscription][:endpoint]).id
|
||||
|
||||
put :update, format: :json, params: alerts_payload
|
||||
|
||||
push_subscription = Web::PushSubscription.find_by(endpoint: create_payload[:data][:endpoint])
|
||||
push_subscription = Web::PushSubscription.find_by(endpoint: create_payload[:subscription][:endpoint])
|
||||
|
||||
expect(push_subscription.data['follow']).to eq(alerts_payload[:data][:follow])
|
||||
expect(push_subscription.data['favourite']).to eq(alerts_payload[:data][:favourite])
|
||||
|
@@ -31,12 +31,5 @@ describe 'about/_contact.html.haml' do
|
||||
|
||||
expect(rendered).to have_content('admin@example.com')
|
||||
end
|
||||
|
||||
it 'does not show info when email is missing' do
|
||||
contact = double(site_contact_email: nil, contact_account: nil)
|
||||
render 'about/contact', contact: contact
|
||||
|
||||
expect(rendered).not_to have_content(I18n.t('about.business_email'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -1,38 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'about/_links.html.haml' do
|
||||
context 'when signed in' do
|
||||
before do
|
||||
allow(view).to receive(:user_signed_in?).and_return(true)
|
||||
end
|
||||
|
||||
it 'does not show sign in link' do
|
||||
render 'about/links', instance: InstancePresenter.new
|
||||
|
||||
expect(rendered).to have_content(I18n.t('about.get_started'))
|
||||
expect(rendered).not_to have_content(I18n.t('auth.login'))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when signed out' do
|
||||
before do
|
||||
allow(view).to receive(:user_signed_in?).and_return(false)
|
||||
end
|
||||
|
||||
it 'shows get started link when registrations are allowed' do
|
||||
render 'about/links', instance: double(open_registrations: true)
|
||||
|
||||
expect(rendered).to have_content(I18n.t('about.get_started'))
|
||||
expect(rendered).to have_content(I18n.t('auth.login'))
|
||||
end
|
||||
|
||||
it 'hides get started link when registrations are closed' do
|
||||
render 'about/links', instance: double(open_registrations: false)
|
||||
|
||||
expect(rendered).not_to have_content(I18n.t('about.get_started'))
|
||||
expect(rendered).to have_content(I18n.t('auth.login'))
|
||||
end
|
||||
end
|
||||
end
|
@@ -83,6 +83,6 @@ describe Pubsubhubbub::ConfirmationWorker do
|
||||
end
|
||||
|
||||
def http_headers
|
||||
{ 'Connection' => 'close', 'Host' => 'example.com', 'User-Agent' => 'http.rb/2.2.2 (Mastodon/1.4.7; +https://cb6e6126.ngrok.io/)' }
|
||||
{ 'Connection' => 'close', 'Host' => 'example.com' }
|
||||
end
|
||||
end
|
||||
|
@@ -59,7 +59,6 @@ describe Pubsubhubbub::DeliveryWorker do
|
||||
'Content-Type' => 'application/atom+xml',
|
||||
'Host' => 'example.com',
|
||||
'Link' => "<https://#{Rails.configuration.x.local_domain}/api/push>; rel=\"hub\", <https://#{Rails.configuration.x.local_domain}/users/#{subscription.account.username}.atom>; rel=\"self\"",
|
||||
'User-Agent' => 'http.rb/2.2.2 (Mastodon/1.4.7; +https://cb6e6126.ngrok.io/)',
|
||||
}.tap do |basic|
|
||||
known_digest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), subscription.secret.to_s, payload)
|
||||
basic.merge('X-Hub-Signature' => "sha1=#{known_digest}") if subscription.secret?
|
||||
|
Reference in New Issue
Block a user