Merge pull request 'WebFinger endpoint' (#118) from feature/webfinger into master
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #118 Reviewed-by: raucao <raucao@noreply.kosmos.org>
This commit was merged in pull request #118.
This commit is contained in:
49
spec/requests/webfinger_spec.rb
Normal file
49
spec/requests/webfinger_spec.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "WebFinger", type: :request do
|
||||
describe "remoteStorage link relation" do
|
||||
context "user exists" do
|
||||
before do
|
||||
create :user, cn: 'tony', ou: 'kosmos.org'
|
||||
end
|
||||
|
||||
context "remoteStorage enabled globally" do
|
||||
it "includes the remoteStorage link for the user" do
|
||||
get "/.well-known/webfinger?resource=acct%3Atony%40kosmos.org"
|
||||
expect(response).to have_http_status(:ok)
|
||||
|
||||
res = JSON.parse(response.body)
|
||||
rs_link = res["links"].find {|l| l["rel"] == "http://tools.ietf.org/id/draft-dejong-remotestorage"}
|
||||
|
||||
expect(rs_link["href"]).to eql("https://storage.kosmos.org/tony@kosmos.org")
|
||||
|
||||
oauth_url = rs_link["properties"]["http://tools.ietf.org/html/rfc6749#section-4.2"]
|
||||
expect(oauth_url).to eql("https://example.com/rs/oauth")
|
||||
end
|
||||
end
|
||||
|
||||
context "remoteStorage not available" do
|
||||
before do
|
||||
Setting.remotestorage_enabled = false
|
||||
end
|
||||
|
||||
it "does not include the remoteStorage link" do
|
||||
get "/.well-known/webfinger?resource=acct%3Atony%40kosmos.org"
|
||||
expect(response).to have_http_status(:ok)
|
||||
|
||||
res = JSON.parse(response.body)
|
||||
rs_link = res["links"].find {|l| l["rel"] == "http://tools.ietf.org/id/draft-dejong-remotestorage"}
|
||||
|
||||
expect(rs_link).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "user does not exist" do
|
||||
it "does return a 404 status" do
|
||||
get "/.well-known/webfinger?resource=acct%3Ajane.doe%40kosmos.org"
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user