Merge remote-tracking branch 'parent/main' into upstream-20241006
This commit is contained in:
commit
66bed31dbe
226 changed files with 2688 additions and 1846 deletions
|
@ -6,7 +6,7 @@ require 'webauthn/fake_client'
|
|||
RSpec.describe 'Security Key Options' do
|
||||
describe 'GET /auth/sessions/security_key_options' do
|
||||
let!(:user) do
|
||||
Fabricate(:user, email: 'x@y.com', password: 'abcdefgh', otp_required_for_login: true, otp_secret: User.generate_otp_secret(32))
|
||||
Fabricate(:user, email: 'x@y.com', password: 'abcdefgh', otp_required_for_login: true, otp_secret: User.generate_otp_secret)
|
||||
end
|
||||
|
||||
context 'with WebAuthn and OTP enabled as second factor' do
|
||||
|
|
|
@ -3,25 +3,62 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'The /.well-known/host-meta request' do
|
||||
it 'returns http success with valid XML response' do
|
||||
get '/.well-known/host-meta'
|
||||
context 'without extension format or accept header' do
|
||||
it 'returns http success with expected XML' do
|
||||
get '/.well-known/host-meta'
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_attributes(
|
||||
media_type: 'application/xrd+xml',
|
||||
body: host_meta_xml_template
|
||||
)
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_attributes(
|
||||
media_type: 'application/xrd+xml'
|
||||
)
|
||||
|
||||
expect(xrd_link_template_value)
|
||||
.to eq 'https://cb6e6126.ngrok.io/.well-known/webfinger?resource={uri}'
|
||||
end
|
||||
|
||||
def xrd_link_template_value
|
||||
response
|
||||
.parsed_body
|
||||
.at_xpath('/xrd:XRD/xrd:Link[@rel="lrdd"]/@template', 'xrd' => 'http://docs.oasis-open.org/ns/xri/xrd-1.0')
|
||||
.value
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
context 'with a .json format extension' do
|
||||
it 'returns http success with expected JSON' do
|
||||
get '/.well-known/host-meta.json'
|
||||
|
||||
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
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_attributes(
|
||||
media_type: 'application/json'
|
||||
)
|
||||
expect(response.parsed_body)
|
||||
.to include(expected_json_template)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a JSON `Accept` header' do
|
||||
it 'returns http success with expected JSON' do
|
||||
get '/.well-known/host-meta', headers: { 'Accept' => 'application/json' }
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_attributes(
|
||||
media_type: 'application/json'
|
||||
)
|
||||
expect(response.parsed_body)
|
||||
.to include(expected_json_template)
|
||||
end
|
||||
end
|
||||
|
||||
def expected_json_template
|
||||
{
|
||||
links: [
|
||||
'rel' => 'lrdd',
|
||||
'template' => 'https://cb6e6126.ngrok.io/.well-known/webfinger?resource={uri}',
|
||||
],
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue