parent
110b3f6335
commit
2aeeffc3ec
2
Gemfile
2
Gemfile
|
@ -6,7 +6,7 @@ ruby '>= 2.3.0', '< 2.6.0'
|
||||||
gem 'pkg-config', '~> 1.3'
|
gem 'pkg-config', '~> 1.3'
|
||||||
|
|
||||||
gem 'puma', '~> 3.11'
|
gem 'puma', '~> 3.11'
|
||||||
gem 'rails', '~> 5.2.0'
|
gem 'rails', '~> 5.2.1'
|
||||||
|
|
||||||
gem 'hamlit-rails', '~> 0.2'
|
gem 'hamlit-rails', '~> 0.2'
|
||||||
gem 'pg', '~> 1.0'
|
gem 'pg', '~> 1.0'
|
||||||
|
|
88
Gemfile.lock
88
Gemfile.lock
|
@ -15,25 +15,25 @@ GIT
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
actioncable (5.2.0)
|
actioncable (5.2.1)
|
||||||
actionpack (= 5.2.0)
|
actionpack (= 5.2.1)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
websocket-driver (>= 0.6.1)
|
websocket-driver (>= 0.6.1)
|
||||||
actionmailer (5.2.0)
|
actionmailer (5.2.1)
|
||||||
actionpack (= 5.2.0)
|
actionpack (= 5.2.1)
|
||||||
actionview (= 5.2.0)
|
actionview (= 5.2.1)
|
||||||
activejob (= 5.2.0)
|
activejob (= 5.2.1)
|
||||||
mail (~> 2.5, >= 2.5.4)
|
mail (~> 2.5, >= 2.5.4)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
actionpack (5.2.0)
|
actionpack (5.2.1)
|
||||||
actionview (= 5.2.0)
|
actionview (= 5.2.1)
|
||||||
activesupport (= 5.2.0)
|
activesupport (= 5.2.1)
|
||||||
rack (~> 2.0)
|
rack (~> 2.0)
|
||||||
rack-test (>= 0.6.3)
|
rack-test (>= 0.6.3)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||||
actionview (5.2.0)
|
actionview (5.2.1)
|
||||||
activesupport (= 5.2.0)
|
activesupport (= 5.2.1)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
erubi (~> 1.4)
|
erubi (~> 1.4)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
|
@ -44,20 +44,20 @@ GEM
|
||||||
case_transform (>= 0.2)
|
case_transform (>= 0.2)
|
||||||
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
||||||
active_record_query_trace (1.5.4)
|
active_record_query_trace (1.5.4)
|
||||||
activejob (5.2.0)
|
activejob (5.2.1)
|
||||||
activesupport (= 5.2.0)
|
activesupport (= 5.2.1)
|
||||||
globalid (>= 0.3.6)
|
globalid (>= 0.3.6)
|
||||||
activemodel (5.2.0)
|
activemodel (5.2.1)
|
||||||
activesupport (= 5.2.0)
|
activesupport (= 5.2.1)
|
||||||
activerecord (5.2.0)
|
activerecord (5.2.1)
|
||||||
activemodel (= 5.2.0)
|
activemodel (= 5.2.1)
|
||||||
activesupport (= 5.2.0)
|
activesupport (= 5.2.1)
|
||||||
arel (>= 9.0)
|
arel (>= 9.0)
|
||||||
activestorage (5.2.0)
|
activestorage (5.2.1)
|
||||||
actionpack (= 5.2.0)
|
actionpack (= 5.2.1)
|
||||||
activerecord (= 5.2.0)
|
activerecord (= 5.2.1)
|
||||||
marcel (~> 0.3.1)
|
marcel (~> 0.3.1)
|
||||||
activesupport (5.2.0)
|
activesupport (5.2.1)
|
||||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||||
i18n (>= 0.7, < 2)
|
i18n (>= 0.7, < 2)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
|
@ -269,7 +269,7 @@ GEM
|
||||||
httplog (1.0.2)
|
httplog (1.0.2)
|
||||||
colorize (~> 0.8)
|
colorize (~> 0.8)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
i18n (1.0.1)
|
i18n (1.1.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
i18n-tasks (0.9.21)
|
i18n-tasks (0.9.21)
|
||||||
activesupport (>= 4.0.2)
|
activesupport (>= 4.0.2)
|
||||||
|
@ -346,8 +346,8 @@ GEM
|
||||||
net-scp (1.2.1)
|
net-scp (1.2.1)
|
||||||
net-ssh (>= 2.6.5)
|
net-ssh (>= 2.6.5)
|
||||||
net-ssh (4.2.0)
|
net-ssh (4.2.0)
|
||||||
nio4r (2.3.0)
|
nio4r (2.3.1)
|
||||||
nokogiri (1.8.2)
|
nokogiri (1.8.4)
|
||||||
mini_portile2 (~> 2.3.0)
|
mini_portile2 (~> 2.3.0)
|
||||||
nokogumbo (1.5.0)
|
nokogumbo (1.5.0)
|
||||||
nokogiri
|
nokogiri
|
||||||
|
@ -415,7 +415,7 @@ GEM
|
||||||
puma (3.11.4)
|
puma (3.11.4)
|
||||||
pundit (1.1.0)
|
pundit (1.1.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
rack (2.0.4)
|
rack (2.0.5)
|
||||||
rack-attack (5.2.0)
|
rack-attack (5.2.0)
|
||||||
rack
|
rack
|
||||||
rack-cors (1.0.2)
|
rack-cors (1.0.2)
|
||||||
|
@ -423,20 +423,20 @@ GEM
|
||||||
rack
|
rack
|
||||||
rack-proxy (0.6.4)
|
rack-proxy (0.6.4)
|
||||||
rack
|
rack
|
||||||
rack-test (1.0.0)
|
rack-test (1.1.0)
|
||||||
rack (>= 1.0, < 3)
|
rack (>= 1.0, < 3)
|
||||||
rails (5.2.0)
|
rails (5.2.1)
|
||||||
actioncable (= 5.2.0)
|
actioncable (= 5.2.1)
|
||||||
actionmailer (= 5.2.0)
|
actionmailer (= 5.2.1)
|
||||||
actionpack (= 5.2.0)
|
actionpack (= 5.2.1)
|
||||||
actionview (= 5.2.0)
|
actionview (= 5.2.1)
|
||||||
activejob (= 5.2.0)
|
activejob (= 5.2.1)
|
||||||
activemodel (= 5.2.0)
|
activemodel (= 5.2.1)
|
||||||
activerecord (= 5.2.0)
|
activerecord (= 5.2.1)
|
||||||
activestorage (= 5.2.0)
|
activestorage (= 5.2.1)
|
||||||
activesupport (= 5.2.0)
|
activesupport (= 5.2.1)
|
||||||
bundler (>= 1.3.0)
|
bundler (>= 1.3.0)
|
||||||
railties (= 5.2.0)
|
railties (= 5.2.1)
|
||||||
sprockets-rails (>= 2.0.0)
|
sprockets-rails (>= 2.0.0)
|
||||||
rails-controller-testing (1.0.2)
|
rails-controller-testing (1.0.2)
|
||||||
actionpack (~> 5.x, >= 5.0.1)
|
actionpack (~> 5.x, >= 5.0.1)
|
||||||
|
@ -452,12 +452,12 @@ GEM
|
||||||
railties (>= 5.0, < 6)
|
railties (>= 5.0, < 6)
|
||||||
rails-settings-cached (0.6.6)
|
rails-settings-cached (0.6.6)
|
||||||
rails (>= 4.2.0)
|
rails (>= 4.2.0)
|
||||||
railties (5.2.0)
|
railties (5.2.1)
|
||||||
actionpack (= 5.2.0)
|
actionpack (= 5.2.1)
|
||||||
activesupport (= 5.2.0)
|
activesupport (= 5.2.1)
|
||||||
method_source
|
method_source
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.18.1, < 2.0)
|
thor (>= 0.19.0, < 2.0)
|
||||||
rainbow (3.0.0)
|
rainbow (3.0.0)
|
||||||
rake (12.3.1)
|
rake (12.3.1)
|
||||||
rb-fsevent (0.10.3)
|
rb-fsevent (0.10.3)
|
||||||
|
@ -725,7 +725,7 @@ DEPENDENCIES
|
||||||
pundit (~> 1.1)
|
pundit (~> 1.1)
|
||||||
rack-attack (~> 5.2)
|
rack-attack (~> 5.2)
|
||||||
rack-cors (~> 1.0)
|
rack-cors (~> 1.0)
|
||||||
rails (~> 5.2.0)
|
rails (~> 5.2.1)
|
||||||
rails-controller-testing (~> 1.0)
|
rails-controller-testing (~> 1.0)
|
||||||
rails-i18n (~> 5.1)
|
rails-i18n (~> 5.1)
|
||||||
rails-settings-cached (~> 0.6)
|
rails-settings-cached (~> 0.6)
|
||||||
|
@ -764,4 +764,4 @@ RUBY VERSION
|
||||||
ruby 2.5.0p0
|
ruby 2.5.0p0
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.16.2
|
1.16.3
|
||||||
|
|
|
@ -15,8 +15,7 @@ RSpec.describe Api::SalmonController, type: :controller do
|
||||||
describe 'POST #update' do
|
describe 'POST #update' do
|
||||||
context 'with valid post data' do
|
context 'with valid post data' do
|
||||||
before do
|
before do
|
||||||
request.env['RAW_POST_DATA'] = File.read(File.join(Rails.root, 'spec', 'fixtures', 'salmon', 'mention.xml'))
|
post :update, params: { id: account.id }, body: File.read(File.join(Rails.root, 'spec', 'fixtures', 'salmon', 'mention.xml'))
|
||||||
post :update, params: { id: account.id }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'contains XML in the request body' do
|
it 'contains XML in the request body' do
|
||||||
|
@ -42,8 +41,7 @@ RSpec.describe Api::SalmonController, type: :controller do
|
||||||
|
|
||||||
context 'with empty post data' do
|
context 'with empty post data' do
|
||||||
before do
|
before do
|
||||||
request.env['RAW_POST_DATA'] = ''
|
post :update, params: { id: account.id }, body: ''
|
||||||
post :update, params: { id: account.id }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http client error' do
|
it 'returns http client error' do
|
||||||
|
@ -56,8 +54,7 @@ RSpec.describe Api::SalmonController, type: :controller do
|
||||||
service = double(call: false)
|
service = double(call: false)
|
||||||
allow(VerifySalmonService).to receive(:new).and_return(service)
|
allow(VerifySalmonService).to receive(:new).and_return(service)
|
||||||
|
|
||||||
request.env['RAW_POST_DATA'] = File.read(File.join(Rails.root, 'spec', 'fixtures', 'salmon', 'mention.xml'))
|
post :update, params: { id: account.id }, body: File.read(File.join(Rails.root, 'spec', 'fixtures', 'salmon', 'mention.xml'))
|
||||||
post :update, params: { id: account.id }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http client error' do
|
it 'returns http client error' do
|
||||||
|
|
|
@ -53,9 +53,8 @@ RSpec.describe Api::SubscriptionsController, type: :controller do
|
||||||
stub_request(:any, "https://mastodon.social/users/Gargron").to_return(status: 404)
|
stub_request(:any, "https://mastodon.social/users/Gargron").to_return(status: 404)
|
||||||
|
|
||||||
request.env['HTTP_X_HUB_SIGNATURE'] = "sha1=#{OpenSSL::HMAC.hexdigest('sha1', 'abc', feed)}"
|
request.env['HTTP_X_HUB_SIGNATURE'] = "sha1=#{OpenSSL::HMAC.hexdigest('sha1', 'abc', feed)}"
|
||||||
request.env['RAW_POST_DATA'] = feed
|
|
||||||
|
|
||||||
post :update, params: { id: account.id }
|
post :update, params: { id: account.id }, body: feed
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
|
|
|
@ -105,7 +105,7 @@ describe ApplicationController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns nil when body has been tampered' do
|
it 'returns nil when body has been tampered' do
|
||||||
request.headers['RAW_POST_DATA'] = 'doo doo doo'
|
post :success, body: 'doo doo doo'
|
||||||
expect(controller.signed_request_account).to be_nil
|
expect(controller.signed_request_account).to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Reference in New Issue