From fd328cf6e8fac0af2b3ec7f755a734f0fe2385c7 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Tue, 30 May 2017 01:04:37 +0900 Subject: Cover WellKnown::WebfingerController more (#3385) --- .../well_known/webfinger_controller_spec.rb | 63 ++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-) (limited to 'spec/controllers') diff --git a/spec/controllers/well_known/webfinger_controller_spec.rb b/spec/controllers/well_known/webfinger_controller_spec.rb index 4d588bf4e..252c786d4 100644 --- a/spec/controllers/well_known/webfinger_controller_spec.rb +++ b/spec/controllers/well_known/webfinger_controller_spec.rb @@ -4,7 +4,40 @@ describe WellKnown::WebfingerController, type: :controller do render_views describe 'GET #show' do - let(:alice) { Fabricate(:account, username: 'alice') } + let(:alice) do + Fabricate(:account, username: 'alice') + end + + before do + alice.private_key = < + + acct:alice@cb6e6126.ngrok.io + https://cb6e6126.ngrok.io/@alice + https://cb6e6126.ngrok.io/users/alice + + + + + + +XML end it 'returns http not found when account cannot be found' do @@ -24,13 +79,15 @@ describe WellKnown::WebfingerController, type: :controller do expect(response).to have_http_status(:not_found) end - it 'returns http success when account can be found with alternate domains' do + it 'returns JSON when account can be found with alternate domains' do Rails.configuration.x.alternate_domains = ["foo.org"] username, domain = alice.to_webfinger_s.split("@") get :show, params: { resource: "#{username}@foo.org" }, format: :json expect(response).to have_http_status(:success) + expect(response.content_type).to eq 'application/jrd+json' + expect(response.body).to eq "{\"subject\":\"acct:alice@cb6e6126.ngrok.io\",\"aliases\":[\"https://cb6e6126.ngrok.io/@alice\",\"https://cb6e6126.ngrok.io/users/alice\"],\"links\":[{\"rel\":\"http://webfinger.net/rel/profile-page\",\"type\":\"text/html\",\"href\":\"https://cb6e6126.ngrok.io/@alice\"},{\"rel\":\"http://schemas.google.com/g/2010#updates-from\",\"type\":\"application/atom+xml\",\"href\":\"http://test.host/users/alice.atom\"},{\"rel\":\"self\",\"type\":\"application/activity+json\",\"href\":\"https://cb6e6126.ngrok.io/@alice\"},{\"rel\":\"salmon\",\"href\":\"#{api_salmon_url(alice.id)}\"},{\"rel\":\"magic-public-key\",\"href\":\"data:application/magic-public-key,RSA.x4D6DyZa3zGa1XLhd_VG1bLGvK-Dmyz93WJfWNezIKeSuJkmA0f2NmoOfLUoumq9szN2Xt0GLDX06tDajdYPPXgLtDG0o1qqTrIJ7UTyYhbo94Wotl9iJvEwa5IjP1Mn00YJ_KvFrzKCm15PC7up6r-NtHsqoYS8X1KAqcbnptU=.AQAB\"},{\"rel\":\"http://ostatus.org/schema/1.0/subscribe\",\"template\":\"http://test.host/authorize_follow?acct={uri}\"}]}" end it 'returns http not found when account can not be found with alternate domains' do -- cgit