mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 19:16:51 +08:00
0af6c5efdc
This is part 1 of 3, split up of PR #23529. This PR refactors the webauthn code to support passkey authentication/registration. Passkeys aren't used yet, that is coming in PRs 2 and 3. Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
26 lines
881 B
Ruby
26 lines
881 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe DiscourseWebauthn::ChallengeGenerator do
|
|
it "generates a DiscourseWebauthn::ChallengeGenerator::ChallengeSession with a challenge" do
|
|
session = DiscourseWebauthn::ChallengeGenerator.generate
|
|
expect(session).to be_a(DiscourseWebauthn::ChallengeGenerator::ChallengeSession)
|
|
expect(session.challenge).not_to eq(nil)
|
|
end
|
|
|
|
describe "ChallengeSession" do
|
|
describe "#commit_to_session" do
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
it "stores the challenge in the provided session object" do
|
|
secure_session = {}
|
|
generated_session = DiscourseWebauthn::ChallengeGenerator.generate
|
|
generated_session.commit_to_session(secure_session, user)
|
|
|
|
expect(secure_session["staged-webauthn-challenge-#{user&.id}"]).to eq(
|
|
generated_session.challenge,
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end
|