mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 05:43:44 +08:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
28 lines
1.1 KiB
Ruby
28 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe Webauthn::ChallengeGenerator do
|
|
it "generates a Webauthn::ChallengeGenerator::ChallengeSession with correct params" do
|
|
session = Webauthn::ChallengeGenerator.generate
|
|
expect(session).to be_a(Webauthn::ChallengeGenerator::ChallengeSession)
|
|
expect(session.challenge).not_to eq(nil)
|
|
expect(session.rp_id).to eq(Discourse.current_hostname)
|
|
expect(session.rp_name).to eq(SiteSetting.title)
|
|
end
|
|
|
|
describe "ChallengeSession" do
|
|
describe "#commit_to_session" do
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
it "stores the challenge, rp id, and rp name in the provided session object" do
|
|
secure_session = {}
|
|
generated_session = Webauthn::ChallengeGenerator.generate
|
|
generated_session.commit_to_session(secure_session, user)
|
|
|
|
expect(secure_session["staged-webauthn-challenge-#{user&.id}"]).to eq(generated_session.challenge)
|
|
expect(secure_session["staged-webauthn-rp-id-#{user&.id}"]).to eq(generated_session.rp_id)
|
|
expect(secure_session["staged-webauthn-rp-name-#{user&.id}"]).to eq(generated_session.rp_name)
|
|
end
|
|
end
|
|
end
|
|
end
|