mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Apply syntax_tree formatting to spec/*
This commit is contained in:
@@ -47,9 +47,12 @@ class UserTestBookmarkable < BaseBookmarkable
|
||||
end
|
||||
|
||||
def self.list_query(user, guardian)
|
||||
user.bookmarks.joins(
|
||||
"INNER JOIN users ON users.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'User'"
|
||||
).where(bookmarkable_type: "User")
|
||||
user
|
||||
.bookmarks
|
||||
.joins(
|
||||
"INNER JOIN users ON users.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'User'",
|
||||
)
|
||||
.where(bookmarkable_type: "User")
|
||||
end
|
||||
|
||||
def self.search_query(bookmarks, query, ts_query, &bookmarkable_search)
|
||||
|
||||
@@ -32,9 +32,7 @@ shared_examples "basic reviewable attributes" do
|
||||
|
||||
describe "#flagger_username" do
|
||||
it "equals to the username of the user who created the reviewable" do
|
||||
reviewable.update!(
|
||||
created_by: Fabricate(:user, username: "gg.osama")
|
||||
)
|
||||
reviewable.update!(created_by: Fabricate(:user, username: "gg.osama"))
|
||||
expect(subject[:flagger_username]).to eq("gg.osama")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'fiber'
|
||||
require "fiber"
|
||||
|
||||
module Concurrency
|
||||
module Logic
|
||||
class DeadEnd < StandardError; end
|
||||
class DeadEnd < StandardError
|
||||
end
|
||||
|
||||
module Complete
|
||||
class Path
|
||||
@@ -169,9 +170,7 @@ module Concurrency
|
||||
until @tasks.empty?
|
||||
task = @path.choose(*@tasks)
|
||||
task.resume
|
||||
unless task.alive?
|
||||
@tasks.delete(task)
|
||||
end
|
||||
@tasks.delete(task) unless task.alive?
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -196,20 +195,14 @@ module Concurrency
|
||||
end
|
||||
|
||||
def multi(&blk)
|
||||
with_possible_failure do
|
||||
with_in_transaction do
|
||||
@redis.multi(&blk)
|
||||
end
|
||||
end
|
||||
with_possible_failure { with_in_transaction { @redis.multi(&blk) } }
|
||||
end
|
||||
|
||||
def method_missing(method, *args, &blk)
|
||||
if @in_transaction
|
||||
@redis.send(method, *args, &blk)
|
||||
else
|
||||
with_possible_failure do
|
||||
@redis.send(method, *args, &blk)
|
||||
end
|
||||
with_possible_failure { @redis.send(method, *args, &blk) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -227,25 +220,17 @@ module Concurrency
|
||||
|
||||
def with_possible_failure
|
||||
outcome =
|
||||
@execution.choose_with_weights(
|
||||
[:succeed, 0.96],
|
||||
[:fail_before, 0.02],
|
||||
[:fail_after, 0.02]
|
||||
)
|
||||
@execution.choose_with_weights([:succeed, 0.96], [:fail_before, 0.02], [:fail_after, 0.02])
|
||||
|
||||
@execution.yield
|
||||
|
||||
if outcome == :fail_before
|
||||
raise Redis::ConnectionError
|
||||
end
|
||||
raise Redis::ConnectionError if outcome == :fail_before
|
||||
|
||||
result = yield
|
||||
|
||||
@execution.yield
|
||||
|
||||
if outcome == :fail_after
|
||||
raise Redis::ConnectionError
|
||||
end
|
||||
raise Redis::ConnectionError if outcome == :fail_after
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
@@ -20,7 +20,6 @@ module MessageBus::DiagnosticsHelper
|
||||
ensure
|
||||
@tracking = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module MessageBus
|
||||
|
||||
@@ -16,11 +16,12 @@ module DiscourseEvent::TestHelper
|
||||
@events_trigger = nil
|
||||
|
||||
if event_name
|
||||
events_trigger = events_trigger.filter do |event|
|
||||
next if event[:event_name] != event_name
|
||||
next if args && event[:params] != args
|
||||
true
|
||||
end
|
||||
events_trigger =
|
||||
events_trigger.filter do |event|
|
||||
next if event[:event_name] != event_name
|
||||
next if args && event[:params] != args
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
events_trigger
|
||||
|
||||
@@ -6,7 +6,11 @@ class FakeS3
|
||||
def self.create
|
||||
s3 = self.new
|
||||
s3.stub_bucket(SiteSetting.s3_upload_bucket) if SiteSetting.s3_upload_bucket.present?
|
||||
s3.stub_bucket(File.join(SiteSetting.s3_backup_bucket, RailsMultisite::ConnectionManagement.current_db)) if SiteSetting.s3_backup_bucket.present?
|
||||
if SiteSetting.s3_backup_bucket.present?
|
||||
s3.stub_bucket(
|
||||
File.join(SiteSetting.s3_backup_bucket, RailsMultisite::ConnectionManagement.current_db),
|
||||
)
|
||||
end
|
||||
s3.stub_s3_helper
|
||||
s3
|
||||
end
|
||||
@@ -27,17 +31,25 @@ class FakeS3
|
||||
def stub_bucket(full_bucket_name)
|
||||
bucket_name, _prefix = full_bucket_name.split("/", 2)
|
||||
|
||||
s3_helper = S3Helper.new(
|
||||
full_bucket_name,
|
||||
Rails.configuration.multisite ? FileStore::S3Store.new.multisite_tombstone_prefix : FileStore::S3Store::TOMBSTONE_PREFIX,
|
||||
client: @s3_client
|
||||
)
|
||||
s3_helper =
|
||||
S3Helper.new(
|
||||
full_bucket_name,
|
||||
(
|
||||
if Rails.configuration.multisite
|
||||
FileStore::S3Store.new.multisite_tombstone_prefix
|
||||
else
|
||||
FileStore::S3Store::TOMBSTONE_PREFIX
|
||||
end
|
||||
),
|
||||
client: @s3_client,
|
||||
)
|
||||
@buckets[bucket_name] = FakeS3Bucket.new(full_bucket_name, s3_helper)
|
||||
end
|
||||
|
||||
def stub_s3_helper
|
||||
@buckets.each do |bucket_name, bucket|
|
||||
S3Helper.stubs(:new)
|
||||
S3Helper
|
||||
.stubs(:new)
|
||||
.with { |b| b == bucket_name || b == bucket.name }
|
||||
.returns(bucket.s3_helper)
|
||||
end
|
||||
@@ -61,10 +73,7 @@ class FakeS3
|
||||
end
|
||||
|
||||
def log_operation(context)
|
||||
@operations << {
|
||||
name: context.operation_name,
|
||||
params: context.params.dup
|
||||
}
|
||||
@operations << { name: context.operation_name, params: context.params.dup }
|
||||
end
|
||||
|
||||
def calculate_etag(context)
|
||||
@@ -73,64 +82,86 @@ class FakeS3
|
||||
end
|
||||
|
||||
def stub_methods
|
||||
@s3_client.stub_responses(:head_object, -> (context) do
|
||||
log_operation(context)
|
||||
@s3_client.stub_responses(
|
||||
:head_object,
|
||||
->(context) do
|
||||
log_operation(context)
|
||||
|
||||
if object = find_object(context.params)
|
||||
{ content_length: object[:size], last_modified: object[:last_modified], metadata: object[:metadata] }
|
||||
else
|
||||
{ status_code: 404, headers: {}, body: "" }
|
||||
end
|
||||
end)
|
||||
if object = find_object(context.params)
|
||||
{
|
||||
content_length: object[:size],
|
||||
last_modified: object[:last_modified],
|
||||
metadata: object[:metadata],
|
||||
}
|
||||
else
|
||||
{ status_code: 404, headers: {}, body: "" }
|
||||
end
|
||||
end,
|
||||
)
|
||||
|
||||
@s3_client.stub_responses(:get_object, -> (context) do
|
||||
log_operation(context)
|
||||
@s3_client.stub_responses(
|
||||
:get_object,
|
||||
->(context) do
|
||||
log_operation(context)
|
||||
|
||||
if object = find_object(context.params)
|
||||
{ content_length: object[:size], body: "" }
|
||||
else
|
||||
{ status_code: 404, headers: {}, body: "" }
|
||||
end
|
||||
end)
|
||||
if object = find_object(context.params)
|
||||
{ content_length: object[:size], body: "" }
|
||||
else
|
||||
{ status_code: 404, headers: {}, body: "" }
|
||||
end
|
||||
end,
|
||||
)
|
||||
|
||||
@s3_client.stub_responses(:delete_object, -> (context) do
|
||||
log_operation(context)
|
||||
@s3_client.stub_responses(
|
||||
:delete_object,
|
||||
->(context) do
|
||||
log_operation(context)
|
||||
|
||||
find_bucket(context.params)&.delete_object(context.params[:key])
|
||||
nil
|
||||
end)
|
||||
find_bucket(context.params)&.delete_object(context.params[:key])
|
||||
nil
|
||||
end,
|
||||
)
|
||||
|
||||
@s3_client.stub_responses(:copy_object, -> (context) do
|
||||
log_operation(context)
|
||||
@s3_client.stub_responses(
|
||||
:copy_object,
|
||||
->(context) do
|
||||
log_operation(context)
|
||||
|
||||
source_bucket_name, source_key = context.params[:copy_source].split("/", 2)
|
||||
copy_source = { bucket: source_bucket_name, key: source_key }
|
||||
source_bucket_name, source_key = context.params[:copy_source].split("/", 2)
|
||||
copy_source = { bucket: source_bucket_name, key: source_key }
|
||||
|
||||
if context.params[:metadata_directive] == "REPLACE"
|
||||
attribute_overrides = context.params.except(:copy_source, :metadata_directive)
|
||||
else
|
||||
attribute_overrides = context.params.slice(:key, :bucket)
|
||||
end
|
||||
if context.params[:metadata_directive] == "REPLACE"
|
||||
attribute_overrides = context.params.except(:copy_source, :metadata_directive)
|
||||
else
|
||||
attribute_overrides = context.params.slice(:key, :bucket)
|
||||
end
|
||||
|
||||
new_object = find_object(copy_source).dup.merge(attribute_overrides)
|
||||
find_bucket(new_object).put_object(new_object)
|
||||
new_object = find_object(copy_source).dup.merge(attribute_overrides)
|
||||
find_bucket(new_object).put_object(new_object)
|
||||
|
||||
{ copy_object_result: { etag: calculate_etag(context) } }
|
||||
end)
|
||||
{ copy_object_result: { etag: calculate_etag(context) } }
|
||||
end,
|
||||
)
|
||||
|
||||
@s3_client.stub_responses(:create_multipart_upload, -> (context) do
|
||||
log_operation(context)
|
||||
@s3_client.stub_responses(
|
||||
:create_multipart_upload,
|
||||
->(context) do
|
||||
log_operation(context)
|
||||
|
||||
find_bucket(context.params).put_object(context.params)
|
||||
{ upload_id: SecureRandom.hex }
|
||||
end)
|
||||
find_bucket(context.params).put_object(context.params)
|
||||
{ upload_id: SecureRandom.hex }
|
||||
end,
|
||||
)
|
||||
|
||||
@s3_client.stub_responses(:put_object, -> (context) do
|
||||
log_operation(context)
|
||||
@s3_client.stub_responses(
|
||||
:put_object,
|
||||
->(context) do
|
||||
log_operation(context)
|
||||
|
||||
find_bucket(context.params).put_object(context.params)
|
||||
{ etag: calculate_etag(context) }
|
||||
end)
|
||||
find_bucket(context.params).put_object(context.params)
|
||||
{ etag: calculate_etag(context) }
|
||||
end,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
GIT_INITIAL_BRANCH_SUPPORTED = Gem::Version.new(`git --version`.match(/[\d\.]+/)[0]) >= Gem::Version.new("2.28.0")
|
||||
GIT_INITIAL_BRANCH_SUPPORTED =
|
||||
Gem::Version.new(`git --version`.match(/[\d\.]+/)[0]) >= Gem::Version.new("2.28.0")
|
||||
|
||||
module Helpers
|
||||
extend ActiveSupport::Concern
|
||||
@@ -27,8 +28,8 @@ module Helpers
|
||||
end
|
||||
|
||||
def fixture_file(filename)
|
||||
return '' if filename.blank?
|
||||
file_path = File.expand_path(Rails.root + 'spec/fixtures/' + filename)
|
||||
return "" if filename.blank?
|
||||
file_path = File.expand_path(Rails.root + "spec/fixtures/" + filename)
|
||||
File.read(file_path)
|
||||
end
|
||||
|
||||
@@ -47,9 +48,7 @@ module Helpers
|
||||
def create_post(args = {})
|
||||
# Pretty much all the tests with `create_post` will fail without this
|
||||
# since allow_uncategorized_topics is now false by default
|
||||
unless args[:allow_uncategorized_topics] == false
|
||||
SiteSetting.allow_uncategorized_topics = true
|
||||
end
|
||||
SiteSetting.allow_uncategorized_topics = true unless args[:allow_uncategorized_topics] == false
|
||||
|
||||
args[:title] ||= "This is my title #{Helpers.next_seq}"
|
||||
args[:raw] ||= "This is the raw body of my post, it is cool #{Helpers.next_seq}"
|
||||
@@ -61,9 +60,7 @@ module Helpers
|
||||
creator = PostCreator.new(user, args)
|
||||
post = creator.create
|
||||
|
||||
if creator.errors.present?
|
||||
raise StandardError.new(creator.errors.full_messages.join(" "))
|
||||
end
|
||||
raise StandardError.new(creator.errors.full_messages.join(" ")) if creator.errors.present?
|
||||
|
||||
post
|
||||
end
|
||||
@@ -92,7 +89,7 @@ module Helpers
|
||||
end
|
||||
|
||||
def create_staff_only_tags(tag_names)
|
||||
create_limited_tags('Staff Tags', Group::AUTO_GROUPS[:staff], tag_names)
|
||||
create_limited_tags("Staff Tags", Group::AUTO_GROUPS[:staff], tag_names)
|
||||
end
|
||||
|
||||
def create_limited_tags(tag_group_name, group_id, tag_names)
|
||||
@@ -100,12 +97,12 @@ module Helpers
|
||||
TagGroupPermission.where(
|
||||
tag_group: tag_group,
|
||||
group_id: Group::AUTO_GROUPS[:everyone],
|
||||
permission_type: TagGroupPermission.permission_types[:full]
|
||||
permission_type: TagGroupPermission.permission_types[:full],
|
||||
).update(permission_type: TagGroupPermission.permission_types[:readonly])
|
||||
TagGroupPermission.create!(
|
||||
tag_group: tag_group,
|
||||
group_id: group_id,
|
||||
permission_type: TagGroupPermission.permission_types[:full]
|
||||
permission_type: TagGroupPermission.permission_types[:full],
|
||||
)
|
||||
tag_names.each do |name|
|
||||
tag_group.tags << (Tag.where(name: name).first || Fabricate(:tag, name: name))
|
||||
@@ -113,10 +110,7 @@ module Helpers
|
||||
end
|
||||
|
||||
def create_hidden_tags(tag_names)
|
||||
tag_group = Fabricate(:tag_group,
|
||||
name: 'Hidden Tags',
|
||||
permissions: { staff: :full }
|
||||
)
|
||||
tag_group = Fabricate(:tag_group, name: "Hidden Tags", permissions: { staff: :full })
|
||||
tag_names.each do |name|
|
||||
tag_group.tags << (Tag.where(name: name).first || Fabricate(:tag, name: name))
|
||||
end
|
||||
@@ -131,7 +125,7 @@ module Helpers
|
||||
end
|
||||
|
||||
def capture_output(output_name)
|
||||
if ENV['RAILS_ENABLE_TEST_STDOUT']
|
||||
if ENV["RAILS_ENABLE_TEST_STDOUT"]
|
||||
yield
|
||||
return
|
||||
end
|
||||
@@ -160,9 +154,7 @@ module Helpers
|
||||
old_root = ActionController::Base.config.relative_url_root
|
||||
ActionController::Base.config.relative_url_root = f
|
||||
|
||||
before_next_spec do
|
||||
ActionController::Base.config.relative_url_root = old_root
|
||||
end
|
||||
before_next_spec { ActionController::Base.config.relative_url_root = old_root }
|
||||
end
|
||||
|
||||
def setup_git_repo(files)
|
||||
@@ -192,14 +184,12 @@ module Helpers
|
||||
|
||||
def track_sql_queries
|
||||
queries = []
|
||||
callback = ->(*, payload) {
|
||||
queries << payload.fetch(:sql) unless ["CACHE", "SCHEMA"].include?(payload.fetch(:name))
|
||||
}
|
||||
|
||||
ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do
|
||||
yield
|
||||
callback = ->(*, payload) do
|
||||
queries << payload.fetch(:sql) unless %w[CACHE SCHEMA].include?(payload.fetch(:name))
|
||||
end
|
||||
|
||||
ActiveSupport::Notifications.subscribed(callback, "sql.active_record") { yield }
|
||||
|
||||
queries
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MockedImapProvider < Imap::Providers::Gmail
|
||||
def connect!; end
|
||||
def disconnect!; end
|
||||
def open_mailbox(mailbox_name, write: false); end
|
||||
def connect!
|
||||
end
|
||||
def disconnect!
|
||||
end
|
||||
def open_mailbox(mailbox_name, write: false)
|
||||
end
|
||||
|
||||
def labels
|
||||
['INBOX']
|
||||
["INBOX"]
|
||||
end
|
||||
end
|
||||
|
||||
def EmailFabricator(options)
|
||||
email = +''
|
||||
email = +""
|
||||
email += "Date: Sat, 31 Mar 2018 17:50:19 -0700\n"
|
||||
email += "From: #{options[:from] || "Dan <dan@discourse.org>"}\n"
|
||||
email += "To: #{options[:to] || "Joffrey <joffrey@discourse.org>"}\n"
|
||||
|
||||
@@ -11,13 +11,14 @@ module IntegrationHelpers
|
||||
challenge = body["challenge"]
|
||||
user = Fabricate.build(:user)
|
||||
|
||||
post "/u.json", params: {
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
password: 'asdasljdhaiosdjioaeiow',
|
||||
password_confirmation: honeypot,
|
||||
challenge: challenge.reverse
|
||||
}
|
||||
post "/u.json",
|
||||
params: {
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
password: "asdasljdhaiosdjioaeiow",
|
||||
password_confirmation: honeypot,
|
||||
challenge: challenge.reverse,
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
@@ -35,11 +36,12 @@ module IntegrationHelpers
|
||||
end
|
||||
|
||||
def read_secure_session
|
||||
id = begin
|
||||
session[:secure_session_id]
|
||||
rescue NoMethodError
|
||||
nil
|
||||
end
|
||||
id =
|
||||
begin
|
||||
session[:secure_session_id]
|
||||
rescue NoMethodError
|
||||
nil
|
||||
end
|
||||
|
||||
# This route will init the secure_session for us
|
||||
get "/session/hp.json" if id.nil?
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'nokogiri/xml/parse_options'
|
||||
require "nokogiri/xml/parse_options"
|
||||
RSpec::Matchers.define :match_html do |expected|
|
||||
match do |actual|
|
||||
make_canonical_html(expected).eql? make_canonical_html(actual)
|
||||
end
|
||||
match { |actual| make_canonical_html(expected).eql? make_canonical_html(actual) }
|
||||
|
||||
failure_message do |actual|
|
||||
"after sanitizing for extra white space and compactness, expected:\n#{actual}\n to match:\n#{expected}"
|
||||
@@ -15,17 +13,16 @@ RSpec::Matchers.define :match_html do |expected|
|
||||
end
|
||||
|
||||
def make_canonical_html(html)
|
||||
doc = Nokogiri::HTML5(html) do |config|
|
||||
config[:options] = Nokogiri::XML::ParseOptions::NOBLANKS | Nokogiri::XML::ParseOptions::COMPACT
|
||||
end
|
||||
doc =
|
||||
Nokogiri.HTML5(html) do |config|
|
||||
config[:options] = Nokogiri::XML::ParseOptions::NOBLANKS |
|
||||
Nokogiri::XML::ParseOptions::COMPACT
|
||||
end
|
||||
|
||||
doc.traverse do |node|
|
||||
if node.node_name&.downcase == "text"
|
||||
node.content = node.content.gsub(/\s+/, ' ').strip
|
||||
end
|
||||
node.content = node.content.gsub(/\s+/, " ").strip if node.node_name&.downcase == "text"
|
||||
end
|
||||
|
||||
doc.to_html
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ module OneboxHelpers
|
||||
File.exist?(file) ? File.read(file) : ""
|
||||
end
|
||||
|
||||
def inspect_html_fragment(raw_fragment, tag_name, attribute = 'src')
|
||||
def inspect_html_fragment(raw_fragment, tag_name, attribute = "src")
|
||||
preview = Nokogiri::HTML::DocumentFragment.parse(raw_fragment)
|
||||
preview.css(tag_name).first[attribute]
|
||||
end
|
||||
@@ -14,7 +14,10 @@ module OneboxHelpers
|
||||
RSpec.shared_context "with engines" do
|
||||
before do
|
||||
fixture = defined?(@onebox_fixture) ? @onebox_fixture : described_class.onebox_name
|
||||
stub_request(:get, defined?(@uri) ? @uri : @link).to_return(status: 200, body: onebox_response(fixture))
|
||||
stub_request(:get, defined?(@uri) ? @uri : @link).to_return(
|
||||
status: 200,
|
||||
body: onebox_response(fixture),
|
||||
)
|
||||
end
|
||||
|
||||
let(:onebox) { described_class.new(link) }
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec::Matchers.define :rate_limit do |attribute|
|
||||
match do |model|
|
||||
model.class.include? RateLimiter::OnCreateRecord
|
||||
end
|
||||
match { |model| model.class.include? RateLimiter::OnCreateRecord }
|
||||
end
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
|
||||
module SessionControllerExtension
|
||||
def self.included(base)
|
||||
base.skip_before_action :check_xhr, only: %i(test_second_factor_restricted_route)
|
||||
base.skip_before_action :check_xhr, only: %i[test_second_factor_restricted_route]
|
||||
end
|
||||
|
||||
def test_second_factor_restricted_route
|
||||
result = run_second_factor!(TestSecondFactorAction) do |manager|
|
||||
manager.allow_backup_codes! if params[:allow_backup_codes]
|
||||
end
|
||||
result =
|
||||
run_second_factor!(TestSecondFactorAction) do |manager|
|
||||
manager.allow_backup_codes! if params[:allow_backup_codes]
|
||||
end
|
||||
if result.no_second_factors_enabled?
|
||||
render json: { result: 'no_second_factors_enabled' }
|
||||
render json: { result: "no_second_factors_enabled" }
|
||||
else
|
||||
render json: { result: 'second_factor_auth_completed' }
|
||||
render json: { result: "second_factor_auth_completed" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.shared_examples_for 'stats cacheable' do
|
||||
describe 'fetch_cached_stats' do
|
||||
after do
|
||||
Discourse.redis.del(described_class.stats_cache_key)
|
||||
end
|
||||
RSpec.shared_examples_for "stats cacheable" do
|
||||
describe "fetch_cached_stats" do
|
||||
after { Discourse.redis.del(described_class.stats_cache_key) }
|
||||
|
||||
it 'returns the cached stats' do
|
||||
it "returns the cached stats" do
|
||||
stats = described_class.fetch_stats.to_json
|
||||
Discourse.redis.set(described_class.stats_cache_key, stats)
|
||||
expect(described_class.fetch_cached_stats).to eq(JSON.parse(stats))
|
||||
end
|
||||
|
||||
it 'returns fetches the stats if stats has not been cached' do
|
||||
it "returns fetches the stats if stats has not been cached" do
|
||||
freeze_time
|
||||
|
||||
Discourse.redis.del(described_class.stats_cache_key)
|
||||
expect(described_class.fetch_cached_stats).to eq(JSON.parse(described_class.fetch_stats.to_json))
|
||||
expect(described_class.fetch_cached_stats).to eq(
|
||||
JSON.parse(described_class.fetch_stats.to_json),
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'fetch_stats' do
|
||||
it 'has not been implemented' do
|
||||
describe "fetch_stats" do
|
||||
it "has not been implemented" do
|
||||
expect { described_class.fetch_stats }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,7 +30,13 @@ module SidekiqHelpers
|
||||
|
||||
expect(matched_job).to(
|
||||
eq(expectation),
|
||||
expectation ? "No enqueued job with #{expected} found" : "Enqueued job with #{expected} found"
|
||||
(
|
||||
if expectation
|
||||
"No enqueued job with #{expected} found"
|
||||
else
|
||||
"Enqueued job with #{expected} found"
|
||||
end
|
||||
),
|
||||
)
|
||||
end
|
||||
|
||||
@@ -46,9 +52,7 @@ module SidekiqHelpers
|
||||
# post.update!(raw: 'new raw')
|
||||
# end
|
||||
def expect_not_enqueued_with(job:, args: {}, at: nil)
|
||||
expect_enqueued_with(job: job, args: args, at: at, expectation: false) do
|
||||
yield if block_given?
|
||||
end
|
||||
expect_enqueued_with(job: job, args: args, at: at, expectation: false) { yield if block_given? }
|
||||
end
|
||||
|
||||
# Checks whether a job has been enqueued with the given arguments
|
||||
@@ -88,15 +92,16 @@ module SidekiqHelpers
|
||||
job_args.merge!(at: job["at"]) if job["at"]
|
||||
job_args.merge!(enqueued_at: job["enqueued_at"]) if job["enqueued_at"]
|
||||
|
||||
matched_job ||= args.all? do |key, value|
|
||||
value = value.to_s if value.is_a?(Symbol)
|
||||
matched_job ||=
|
||||
args.all? do |key, value|
|
||||
value = value.to_s if value.is_a?(Symbol)
|
||||
|
||||
if key == :at
|
||||
value.to_f == (job_args[:at] || job_args[:enqueued_at]).to_f
|
||||
else
|
||||
value == job_args[key]
|
||||
if key == :at
|
||||
value.to_f == (job_args[:at] || job_args[:enqueued_at]).to_f
|
||||
else
|
||||
value == job_args[key]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
matched_job
|
||||
|
||||
@@ -41,7 +41,10 @@ module SystemHelpers
|
||||
|
||||
def resize_window(width: nil, height: nil)
|
||||
original_size = page.driver.browser.manage.window.size
|
||||
page.driver.browser.manage.window.resize_to(width || original_size.width, height || original_size.height)
|
||||
page.driver.browser.manage.window.resize_to(
|
||||
width || original_size.width,
|
||||
height || original_size.height,
|
||||
)
|
||||
yield
|
||||
ensure
|
||||
page.driver.browser.manage.window.resize_to(original_size.width, original_size.height)
|
||||
@@ -52,9 +55,7 @@ module SystemHelpers
|
||||
|
||||
ENV["TZ"] = timezone
|
||||
|
||||
Capybara.using_session(timezone) do
|
||||
freeze_time(&example)
|
||||
end
|
||||
Capybara.using_session(timezone) { freeze_time(&example) }
|
||||
|
||||
ENV["TZ"] = previous_browser_timezone
|
||||
end
|
||||
|
||||
@@ -9,9 +9,9 @@ class TestSecondFactorAction < SecondFactor::Actions::Base
|
||||
redirect_url: params[:redirect_url],
|
||||
callback_params: {
|
||||
saved_param_1: params[:saved_param_1],
|
||||
saved_param_2: params[:saved_param_2]
|
||||
saved_param_2: params[:saved_param_2],
|
||||
},
|
||||
description: "this is description for test action"
|
||||
description: "this is description for test action",
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -1,30 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec::Matchers.define :be_within_one_second_of do |expected_time|
|
||||
match do |actual_time|
|
||||
(actual_time - expected_time).abs < 1
|
||||
end
|
||||
failure_message do |actual_time|
|
||||
"#{actual_time} is not within 1 second of #{expected_time}"
|
||||
end
|
||||
match { |actual_time| (actual_time - expected_time).abs < 1 }
|
||||
failure_message { |actual_time| "#{actual_time} is not within 1 second of #{expected_time}" }
|
||||
end
|
||||
|
||||
RSpec::Matchers.define :be_within_one_minute_of do |expected_time|
|
||||
match do |actual_time|
|
||||
(actual_time - expected_time).abs < 60
|
||||
end
|
||||
failure_message do |actual_time|
|
||||
"#{actual_time} is not within 1 minute of #{expected_time}"
|
||||
end
|
||||
match { |actual_time| (actual_time - expected_time).abs < 60 }
|
||||
failure_message { |actual_time| "#{actual_time} is not within 1 minute of #{expected_time}" }
|
||||
end
|
||||
|
||||
RSpec::Matchers.define :eq_time do |expected_time|
|
||||
match do |actual_time|
|
||||
(actual_time - expected_time).abs < 0.001
|
||||
end
|
||||
failure_message do |actual_time|
|
||||
"#{actual_time} is not within 1 millisecond of #{expected_time}"
|
||||
end
|
||||
match { |actual_time| (actual_time - expected_time).abs < 0.001 }
|
||||
failure_message { |actual_time| "#{actual_time} is not within 1 millisecond of #{expected_time}" }
|
||||
failure_message_when_negated do |actual_time|
|
||||
"#{actual_time} is within 1 millisecond of #{expected_time}"
|
||||
end
|
||||
|
||||
@@ -28,7 +28,8 @@ module TopicGuardianCanSeeConsistencyCheck
|
||||
result = super
|
||||
|
||||
if self.class.run_topic_can_see_consistency_check?
|
||||
new_result = self.can_see_topic_ids(topic_ids: [topic&.id], hide_deleted: hide_deleted).present?
|
||||
new_result =
|
||||
self.can_see_topic_ids(topic_ids: [topic&.id], hide_deleted: hide_deleted).present?
|
||||
|
||||
if result != new_result
|
||||
raise "result between TopicGuardian#can_see_topic? (#{result}) and TopicGuardian#can_see_topic_ids (#{new_result}) has drifted and returned different results for the same input"
|
||||
|
||||
@@ -4,13 +4,16 @@ module UploadsHelpers
|
||||
def setup_s3
|
||||
SiteSetting.enable_s3_uploads = true
|
||||
|
||||
SiteSetting.s3_region = 'us-west-1'
|
||||
SiteSetting.s3_region = "us-west-1"
|
||||
SiteSetting.s3_upload_bucket = "s3-upload-bucket"
|
||||
|
||||
SiteSetting.s3_access_key_id = "some key"
|
||||
SiteSetting.s3_secret_access_key = "some secrets3_region key"
|
||||
|
||||
stub_request(:head, "https://#{SiteSetting.s3_upload_bucket}.s3.#{SiteSetting.s3_region}.amazonaws.com/")
|
||||
stub_request(
|
||||
:head,
|
||||
"https://#{SiteSetting.s3_upload_bucket}.s3.#{SiteSetting.s3_region}.amazonaws.com/",
|
||||
)
|
||||
end
|
||||
|
||||
def enable_secure_uploads
|
||||
@@ -19,7 +22,8 @@ module UploadsHelpers
|
||||
end
|
||||
|
||||
def stub_upload(upload)
|
||||
url = %r{https://#{SiteSetting.s3_upload_bucket}.s3.#{SiteSetting.s3_region}.amazonaws.com/original/\d+X.*#{upload.sha1}.#{upload.extension}\?acl}
|
||||
url =
|
||||
%r{https://#{SiteSetting.s3_upload_bucket}.s3.#{SiteSetting.s3_region}.amazonaws.com/original/\d+X.*#{upload.sha1}.#{upload.extension}\?acl}
|
||||
stub_request(:put, url)
|
||||
end
|
||||
|
||||
|
||||
@@ -5,19 +5,19 @@ RSpec.shared_examples "User Sidebar Serializer Attributes" do |serializer_klass|
|
||||
|
||||
let(:serializer) { serializer_klass.new(user, scope: Guardian.new(user), root: false) }
|
||||
|
||||
before do
|
||||
SiteSetting.navigation_menu = "sidebar"
|
||||
end
|
||||
before { SiteSetting.navigation_menu = "sidebar" }
|
||||
|
||||
describe "#sidebar_list_destination" do
|
||||
it 'is not included when navigation menu is legacy' do
|
||||
it "is not included when navigation menu is legacy" do
|
||||
SiteSetting.navigation_menu = "legacy"
|
||||
|
||||
expect(serializer.as_json[:sidebar_list_destination]).to eq(nil)
|
||||
end
|
||||
|
||||
it "returns choosen value or default" do
|
||||
expect(serializer.as_json[:sidebar_list_destination]).to eq(SiteSetting.default_sidebar_list_destination)
|
||||
expect(serializer.as_json[:sidebar_list_destination]).to eq(
|
||||
SiteSetting.default_sidebar_list_destination,
|
||||
)
|
||||
|
||||
user.user_option.update!(sidebar_list_destination: "unread_new")
|
||||
|
||||
@@ -25,14 +25,20 @@ RSpec.shared_examples "User Sidebar Serializer Attributes" do |serializer_klass|
|
||||
end
|
||||
end
|
||||
|
||||
describe '#sidebar_category_ids' do
|
||||
describe "#sidebar_category_ids" do
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:category_2) { Fabricate(:category) }
|
||||
fab!(:private_category) { Fabricate(:private_category, group: group) }
|
||||
fab!(:category_sidebar_section_link) { Fabricate(:category_sidebar_section_link, user: user, linkable: category) }
|
||||
fab!(:category_sidebar_section_link_2) { Fabricate(:category_sidebar_section_link, user: user, linkable: category_2) }
|
||||
fab!(:category_sidebar_section_link_3) { Fabricate(:category_sidebar_section_link, user: user, linkable: private_category) }
|
||||
fab!(:category_sidebar_section_link) do
|
||||
Fabricate(:category_sidebar_section_link, user: user, linkable: category)
|
||||
end
|
||||
fab!(:category_sidebar_section_link_2) do
|
||||
Fabricate(:category_sidebar_section_link, user: user, linkable: category_2)
|
||||
end
|
||||
fab!(:category_sidebar_section_link_3) do
|
||||
Fabricate(:category_sidebar_section_link, user: user, linkable: private_category)
|
||||
end
|
||||
|
||||
it "is not included when navigation menu is legacy" do
|
||||
SiteSetting.navigation_menu = "legacy"
|
||||
@@ -47,31 +53,32 @@ RSpec.shared_examples "User Sidebar Serializer Attributes" do |serializer_klass|
|
||||
|
||||
json = serializer.as_json
|
||||
|
||||
expect(json[:sidebar_category_ids]).to eq([
|
||||
category.id,
|
||||
category_2.id
|
||||
])
|
||||
expect(json[:sidebar_category_ids]).to eq([category.id, category_2.id])
|
||||
|
||||
group.add(user)
|
||||
serializer = serializer_klass.new(user, scope: Guardian.new(user), root: false)
|
||||
json = serializer.as_json
|
||||
|
||||
expect(json[:sidebar_category_ids]).to eq([
|
||||
category.id,
|
||||
category_2.id,
|
||||
private_category.id
|
||||
])
|
||||
expect(json[:sidebar_category_ids]).to eq([category.id, category_2.id, private_category.id])
|
||||
end
|
||||
end
|
||||
|
||||
describe '#sidebar_tags' do
|
||||
describe "#sidebar_tags" do
|
||||
fab!(:tag) { Fabricate(:tag, name: "foo") }
|
||||
fab!(:pm_tag) { Fabricate(:tag, name: "bar", pm_topic_count: 5, topic_count: 0) }
|
||||
fab!(:hidden_tag) { Fabricate(:tag, name: "secret") }
|
||||
fab!(:staff_tag_group) { Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: ["secret"]) }
|
||||
fab!(:tag_sidebar_section_link) { Fabricate(:tag_sidebar_section_link, user: user, linkable: tag) }
|
||||
fab!(:tag_sidebar_section_link_2) { Fabricate(:tag_sidebar_section_link, user: user, linkable: pm_tag) }
|
||||
fab!(:tag_sidebar_section_link_3) { Fabricate(:tag_sidebar_section_link, user: user, linkable: hidden_tag) }
|
||||
fab!(:staff_tag_group) do
|
||||
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: ["secret"])
|
||||
end
|
||||
fab!(:tag_sidebar_section_link) do
|
||||
Fabricate(:tag_sidebar_section_link, user: user, linkable: tag)
|
||||
end
|
||||
fab!(:tag_sidebar_section_link_2) do
|
||||
Fabricate(:tag_sidebar_section_link, user: user, linkable: pm_tag)
|
||||
end
|
||||
fab!(:tag_sidebar_section_link_3) do
|
||||
Fabricate(:tag_sidebar_section_link, user: user, linkable: hidden_tag)
|
||||
end
|
||||
|
||||
it "is not included when navigation menu is legacy" do
|
||||
SiteSetting.navigation_menu = "legacy"
|
||||
@@ -99,7 +106,7 @@ RSpec.shared_examples "User Sidebar Serializer Attributes" do |serializer_klass|
|
||||
|
||||
expect(json[:sidebar_tags]).to contain_exactly(
|
||||
{ name: tag.name, pm_only: false },
|
||||
{ name: pm_tag.name, pm_only: true }
|
||||
{ name: pm_tag.name, pm_only: true },
|
||||
)
|
||||
|
||||
user.update!(admin: true)
|
||||
@@ -109,7 +116,7 @@ RSpec.shared_examples "User Sidebar Serializer Attributes" do |serializer_klass|
|
||||
expect(json[:sidebar_tags]).to contain_exactly(
|
||||
{ name: tag.name, pm_only: false },
|
||||
{ name: pm_tag.name, pm_only: true },
|
||||
{ name: hidden_tag.name, pm_only: false }
|
||||
{ name: hidden_tag.name, pm_only: false },
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -117,20 +124,20 @@ RSpec.shared_examples "User Sidebar Serializer Attributes" do |serializer_klass|
|
||||
describe "#display_sidebar_tags" do
|
||||
fab!(:tag) { Fabricate(:tag) }
|
||||
|
||||
it 'should not be included in serialised object when navigation menu is legacy' do
|
||||
it "should not be included in serialised object when navigation menu is legacy" do
|
||||
SiteSetting.tagging_enabled = true
|
||||
SiteSetting.navigation_menu = "legacy"
|
||||
|
||||
expect(serializer.as_json[:display_sidebar_tags]).to eq(nil)
|
||||
end
|
||||
|
||||
it 'should not be included in serialised object when tagging has been disabled' do
|
||||
it "should not be included in serialised object when tagging has been disabled" do
|
||||
SiteSetting.tagging_enabled = false
|
||||
|
||||
expect(serializer.as_json[:display_sidebar_tags]).to eq(nil)
|
||||
end
|
||||
|
||||
it 'should be true when user has visible tags' do
|
||||
it "should be true when user has visible tags" do
|
||||
SiteSetting.tagging_enabled = true
|
||||
|
||||
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [tag.name])
|
||||
@@ -139,7 +146,7 @@ RSpec.shared_examples "User Sidebar Serializer Attributes" do |serializer_klass|
|
||||
expect(serializer.as_json[:display_sidebar_tags]).to eq(true)
|
||||
end
|
||||
|
||||
it 'should be false when user has no visible tags' do
|
||||
it "should be false when user has no visible tags" do
|
||||
SiteSetting.tagging_enabled = true
|
||||
|
||||
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [tag.name])
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
RSpec.shared_examples_for "a versioned model" do
|
||||
let(:model) { Fabricate(described_class.to_s.downcase) }
|
||||
|
||||
it 'should be versioned' do
|
||||
it "should be versioned" do
|
||||
expect(model).to respond_to(:version)
|
||||
expect(model.version).to eq(1)
|
||||
end
|
||||
|
||||
@@ -19,42 +19,47 @@ module WebauthnIntegrationHelpers
|
||||
# simulate_localhost_webautn_challenge for a real example.
|
||||
def valid_security_key_data
|
||||
{
|
||||
credential_id: "9GiFosW50+s+juyJlyxKEVAsk3gZLo9XWIhX47eC4gHfDsldF3TWR43Tcl/+3gLTL5t1TjpmcbKA2DUV2eKrBw==",
|
||||
public_key: "pQECAyYgASFYIPMGM1OpSuCU5uks+BulAdfVxdlJiYcgGac5Y+LnLXC9Ilgghy0BKvRvptmQdtWz33Jjnf8Y6+HD85XdRiqmo1KMGPE="
|
||||
credential_id:
|
||||
"9GiFosW50+s+juyJlyxKEVAsk3gZLo9XWIhX47eC4gHfDsldF3TWR43Tcl/+3gLTL5t1TjpmcbKA2DUV2eKrBw==",
|
||||
public_key:
|
||||
"pQECAyYgASFYIPMGM1OpSuCU5uks+BulAdfVxdlJiYcgGac5Y+LnLXC9Ilgghy0BKvRvptmQdtWz33Jjnf8Y6+HD85XdRiqmo1KMGPE=",
|
||||
}
|
||||
end
|
||||
|
||||
def valid_security_key_auth_post_data
|
||||
{
|
||||
signature: "MEYCIQC5xyUQvF4qTPZ2yX7crp/IEs1E/4wqhXgxC1EVAumhfgIhAIC/7w4BVEy+ew6vMYISahtnnIqbqsPZosBeTUSI8Y4j",
|
||||
clientData: "eyJjaGFsbGVuZ2UiOiJOR1UzWW1Zek0yWTBNelkyWkdFM05EVTNZak5qWldVNFpUWTNOakJoTm1NMFlqVTVORFptTlRrd016Vm1ZMlZpTURVd01UZzJOemcxTW1RMSIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCIsInR5cGUiOiJ3ZWJhdXRobi5nZXQifQ==",
|
||||
signature:
|
||||
"MEYCIQC5xyUQvF4qTPZ2yX7crp/IEs1E/4wqhXgxC1EVAumhfgIhAIC/7w4BVEy+ew6vMYISahtnnIqbqsPZosBeTUSI8Y4j",
|
||||
clientData:
|
||||
"eyJjaGFsbGVuZ2UiOiJOR1UzWW1Zek0yWTBNelkyWkdFM05EVTNZak5qWldVNFpUWTNOakJoTm1NMFlqVTVORFptTlRrd016Vm1ZMlZpTURVd01UZzJOemcxTW1RMSIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCIsInR5cGUiOiJ3ZWJhdXRobi5nZXQifQ==",
|
||||
authenticatorData: "SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MBAAAA2Q==",
|
||||
credentialId: valid_security_key_data[:credential_id]
|
||||
credentialId: valid_security_key_data[:credential_id],
|
||||
}
|
||||
end
|
||||
|
||||
def valid_security_key_challenge_data
|
||||
{
|
||||
challenge: "4e7bf33f4366da7457b3cee8e6760a6c4b5946f59035fceb0501867852d5"
|
||||
}
|
||||
{ challenge: "4e7bf33f4366da7457b3cee8e6760a6c4b5946f59035fceb0501867852d5" }
|
||||
end
|
||||
|
||||
def valid_security_key_create_post_data
|
||||
{
|
||||
id: "hg7Ojg9H4urf9UlT99T2yr-FQtEGCWnRNdkI5QKEqDxlSjsLHhUcQxeTPelC26cy9XQ_qIg1Nq88PNVDlZvxHA",
|
||||
rawId: "hg7Ojg9H4urf9UlT99T2yr+FQtEGCWnRNdkI5QKEqDxlSjsLHhUcQxeTPelC26cy9XQ/qIg1Nq88PNVDlZvxHA==",
|
||||
rawId:
|
||||
"hg7Ojg9H4urf9UlT99T2yr+FQtEGCWnRNdkI5QKEqDxlSjsLHhUcQxeTPelC26cy9XQ/qIg1Nq88PNVDlZvxHA==",
|
||||
type: "public-key",
|
||||
attestation: "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjESZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2NBAAAAAAAAAAAAAAAAAAAAAAAAAAAAQIYOzo4PR+Lq3/VJU/fU9sq/hULRBglp0TXZCOUChKg8ZUo7Cx4VHEMXkz3pQtunMvV0P6iINTavPDzVQ5Wb8RylAQIDJiABIVggJI3i7Svv1+Hu8pGYIQ6XEIeWHxjr+qKVXPmXSQswGysiWCDs0ZRoPXkajl+Mpvc16BPVFrKRxl06V+XTKdKffiMzZQ==",
|
||||
clientData: "eyJjaGFsbGVuZ2UiOiJOR1UzWW1Zek0yWTBNelkyWkdFM05EVTNZak5qWldVNFpUWTNOakJoTm1NMFlqVTVORFptTlRrd016Vm1ZMlZpTURVd01UZzJOemcxTW1RMSIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCIsInR5cGUiOiJ3ZWJhdXRobi5jcmVhdGUifQ==",
|
||||
name: "My Security Key"
|
||||
attestation:
|
||||
"o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjESZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2NBAAAAAAAAAAAAAAAAAAAAAAAAAAAAQIYOzo4PR+Lq3/VJU/fU9sq/hULRBglp0TXZCOUChKg8ZUo7Cx4VHEMXkz3pQtunMvV0P6iINTavPDzVQ5Wb8RylAQIDJiABIVggJI3i7Svv1+Hu8pGYIQ6XEIeWHxjr+qKVXPmXSQswGysiWCDs0ZRoPXkajl+Mpvc16BPVFrKRxl06V+XTKdKffiMzZQ==",
|
||||
clientData:
|
||||
"eyJjaGFsbGVuZ2UiOiJOR1UzWW1Zek0yWTBNelkyWkdFM05EVTNZak5qWldVNFpUWTNOakJoTm1NMFlqVTVORFptTlRrd016Vm1ZMlZpTURVd01UZzJOemcxTW1RMSIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCIsInR5cGUiOiJ3ZWJhdXRobi5jcmVhdGUifQ==",
|
||||
name: "My Security Key",
|
||||
}
|
||||
end
|
||||
|
||||
# all of the valid security key data is sourced from a localhost
|
||||
# login, if this is not set the specs for webauthn WILL NOT WORK
|
||||
def stub_as_dev_localhost
|
||||
Discourse.stubs(:current_hostname).returns('localhost')
|
||||
Discourse.stubs(:base_url).returns('http://localhost:3000')
|
||||
Discourse.stubs(:current_hostname).returns("localhost")
|
||||
Discourse.stubs(:base_url).returns("http://localhost:3000")
|
||||
end
|
||||
|
||||
def simulate_localhost_webauthn_challenge
|
||||
@@ -62,8 +67,8 @@ module WebauthnIntegrationHelpers
|
||||
Webauthn::ChallengeGenerator.stubs(:generate).returns(
|
||||
Webauthn::ChallengeGenerator::ChallengeSession.new(
|
||||
challenge: valid_security_key_challenge_data[:challenge],
|
||||
rp_id: Discourse.current_hostname
|
||||
)
|
||||
rp_id: Discourse.current_hostname,
|
||||
),
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user