mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Parse body
This commit is contained in:
parent
2f31cd77a6
commit
caa21ebf99
@ -9,9 +9,12 @@ RSpec.describe 'The /.well-known/host-meta request' do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_attributes(
|
||||
media_type: 'application/xrd+xml',
|
||||
body: host_meta_xml_template
|
||||
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
|
||||
@ -20,8 +23,15 @@ RSpec.describe 'The /.well-known/host-meta request' do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_attributes(
|
||||
media_type: 'application/json',
|
||||
body: host_meta_json_template
|
||||
media_type: 'application/json'
|
||||
)
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
links: [
|
||||
'rel' => 'lrdd',
|
||||
'template' => 'https://cb6e6126.ngrok.io/.well-known/webfinger?resource={uri}',
|
||||
]
|
||||
)
|
||||
end
|
||||
|
||||
@ -31,23 +41,7 @@ RSpec.describe 'The /.well-known/host-meta request' do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_attributes(
|
||||
media_type: 'application/json',
|
||||
body: host_meta_json_template
|
||||
media_type: 'application/json'
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def host_meta_xml_template
|
||||
<<~XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Link rel="lrdd" template="https://cb6e6126.ngrok.io/.well-known/webfinger?resource={uri}"/>
|
||||
</XRD>
|
||||
XML
|
||||
end
|
||||
|
||||
def host_meta_json_template
|
||||
'{"links":[{"rel":"lrdd","template":"https://cb6e6126.ngrok.io/.well-known/webfinger?resource={uri}"}]}'
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user