2023-11-16 06:12:02 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 15:12:25 +10:00
|
|
|
RSpec.describe 'The /.well-known/host-meta request' do
|
2023-11-16 06:12:02 +11:00
|
|
|
it 'returns http success with valid XML response' do
|
|
|
|
get '/.well-known/host-meta'
|
|
|
|
|
|
|
|
expect(response)
|
|
|
|
.to have_http_status(200)
|
|
|
|
.and have_attributes(
|
2024-10-02 19:23:44 +10:00
|
|
|
media_type: 'application/xrd+xml'
|
|
|
|
)
|
|
|
|
|
|
|
|
doc = Nokogiri::XML(response.parsed_body)
|
|
|
|
expect(doc.at_xpath('/xrd:XRD/xrd:Link[@rel="lrdd"]/@template', 'xrd' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0').value)
|
|
|
|
.to eq 'https://cb6e6126.ngrok.io/.well-known/webfinger?resource={uri}'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http success with valid JSON response with .json extension' do
|
|
|
|
get '/.well-known/host-meta.json'
|
|
|
|
|
|
|
|
expect(response)
|
|
|
|
.to have_http_status(200)
|
|
|
|
.and have_attributes(
|
|
|
|
media_type: 'application/json'
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(response.parsed_body)
|
|
|
|
.to include(
|
|
|
|
links: [
|
|
|
|
'rel' => 'lrdd',
|
|
|
|
'template' => 'https://cb6e6126.ngrok.io/.well-known/webfinger?resource={uri}',
|
|
|
|
]
|
2023-11-16 06:12:02 +11:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2024-10-02 19:23:44 +10:00
|
|
|
it 'returns http success with valid JSON response with Accept header' do
|
|
|
|
get '/.well-known/host-meta', headers: { 'Accept' => 'application/json' }
|
2023-11-16 06:12:02 +11:00
|
|
|
|
2024-10-02 19:23:44 +10:00
|
|
|
expect(response)
|
|
|
|
.to have_http_status(200)
|
|
|
|
.and have_attributes(
|
|
|
|
media_type: 'application/json'
|
|
|
|
)
|
2023-11-16 06:12:02 +11:00
|
|
|
end
|
|
|
|
end
|