mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Merge commit '2254f47702368938bdfd0d997f2487fb2950d676' into glitch-soc/merge-upstream
This commit is contained in:
@@ -16,22 +16,30 @@ RSpec.describe Settings::TwoFactorAuthentication::ConfirmationsController do
|
||||
end
|
||||
|
||||
def qr_code_markup
|
||||
RQRCode::QRCode.new(
|
||||
'otpauth://totp/cb6e6126.ngrok.io:local-part%40domain?secret=thisisasecretforthespecofnewview&issuer=cb6e6126.ngrok.io'
|
||||
).as_svg(padding: 0, module_size: 4, use_path: true)
|
||||
RQRCode::QRCode
|
||||
.new(totp_provisioning_uri)
|
||||
.as_svg(padding: 0, module_size: 4, use_path: true)
|
||||
end
|
||||
|
||||
def totp_provisioning_uri
|
||||
ROTP::TOTP
|
||||
.new(otp_secret_value, issuer: Rails.configuration.x.local_domain)
|
||||
.provisioning_uri(user.email)
|
||||
end
|
||||
end
|
||||
|
||||
[true, false].each do |with_otp_secret|
|
||||
let(:user) { Fabricate(:user, email: 'local-part@domain', otp_secret: with_otp_secret ? 'oldotpsecret' : nil) }
|
||||
|
||||
let(:otp_secret_value) { 'thisisasecretforthespecofnewview' }
|
||||
|
||||
context 'when signed in' do
|
||||
before { sign_in user, scope: :user }
|
||||
|
||||
describe 'GET #new' do
|
||||
context 'when a new otp secret has been set in the session' do
|
||||
subject do
|
||||
get :new, session: { challenge_passed_at: Time.now.utc, new_otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
get :new, session: { challenge_passed_at: Time.now.utc, new_otp_secret: otp_secret_value }
|
||||
end
|
||||
|
||||
it_behaves_like 'renders expected page'
|
||||
@@ -47,7 +55,7 @@ RSpec.describe Settings::TwoFactorAuthentication::ConfirmationsController do
|
||||
describe 'POST #create' do
|
||||
describe 'when form_two_factor_confirmation parameter is not provided' do
|
||||
it 'raises ActionController::ParameterMissing' do
|
||||
post :create, params: {}, session: { challenge_passed_at: Time.now.utc, new_otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
post :create, params: {}, session: { challenge_passed_at: Time.now.utc, new_otp_secret: otp_secret_value }
|
||||
|
||||
expect(response).to have_http_status(400)
|
||||
end
|
||||
@@ -64,7 +72,7 @@ RSpec.describe Settings::TwoFactorAuthentication::ConfirmationsController do
|
||||
|
||||
it 'renders page with success' do
|
||||
expect { post_create_with_options }
|
||||
.to change { user.reload.otp_secret }.to 'thisisasecretforthespecofnewview'
|
||||
.to change { user.reload.otp_secret }.to otp_secret_value
|
||||
|
||||
expect(flash[:notice])
|
||||
.to eq(I18n.t('two_factor_authentication.enabled_success'))
|
||||
@@ -102,7 +110,7 @@ RSpec.describe Settings::TwoFactorAuthentication::ConfirmationsController do
|
||||
def post_create_with_options
|
||||
post :create,
|
||||
params: { form_two_factor_confirmation: { otp_attempt: '123456' } },
|
||||
session: { challenge_passed_at: Time.now.utc, new_otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
session: { challenge_passed_at: Time.now.utc, new_otp_secret: otp_secret_value }
|
||||
end
|
||||
|
||||
def prepare_user_otp_generation
|
||||
@@ -112,7 +120,7 @@ RSpec.describe Settings::TwoFactorAuthentication::ConfirmationsController do
|
||||
end
|
||||
|
||||
def prepare_user_otp_consumption_response(result)
|
||||
options = { otp_secret: 'thisisasecretforthespecofnewview' }
|
||||
options = { otp_secret: otp_secret_value }
|
||||
allow(user)
|
||||
.to receive(:validate_and_consume_otp!)
|
||||
.with('123456', options)
|
||||
|
||||
@@ -18,8 +18,8 @@ RSpec.describe AdminMailer do
|
||||
.to be_present
|
||||
.and(deliver_to(recipient.user_email))
|
||||
.and(deliver_from('notifications@localhost'))
|
||||
.and(have_subject("New report for cb6e6126.ngrok.io (##{report.id})"))
|
||||
.and(have_body_text("Mike,\r\n\r\nJohn has reported Mike\r\n\r\nView: https://cb6e6126.ngrok.io/admin/reports/#{report.id}\r\n"))
|
||||
.and(have_subject(I18n.t('admin_mailer.new_report.subject', instance: Rails.configuration.x.local_domain, id: report.id)))
|
||||
.and(have_body_text("Mike,\r\n\r\nJohn has reported Mike\r\n\r\nView: #{admin_report_url(report)}\r\n"))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,7 +37,7 @@ RSpec.describe AdminMailer do
|
||||
.to be_present
|
||||
.and(deliver_to(recipient.user_email))
|
||||
.and(deliver_from('notifications@localhost'))
|
||||
.and(have_subject("#{appeal.account.username} is appealing a moderation decision on cb6e6126.ngrok.io"))
|
||||
.and(have_subject(I18n.t('admin_mailer.new_appeal.subject', instance: Rails.configuration.x.local_domain, username: appeal.account.username)))
|
||||
.and(have_body_text("#{appeal.account.username} is appealing a moderation decision by #{appeal.strike.account.username}"))
|
||||
end
|
||||
end
|
||||
@@ -56,7 +56,7 @@ RSpec.describe AdminMailer do
|
||||
.to be_present
|
||||
.and(deliver_to(recipient.user_email))
|
||||
.and(deliver_from('notifications@localhost'))
|
||||
.and(have_subject("New account up for review on cb6e6126.ngrok.io (#{user.account.username})"))
|
||||
.and(have_subject(I18n.t('admin_mailer.new_pending_account.subject', instance: Rails.configuration.x.local_domain, username: user.account.username)))
|
||||
.and(have_body_text('The details of the new account are below. You can approve or reject this application.'))
|
||||
end
|
||||
end
|
||||
@@ -80,7 +80,7 @@ RSpec.describe AdminMailer do
|
||||
.to be_present
|
||||
.and(deliver_to(recipient.user_email))
|
||||
.and(deliver_from('notifications@localhost'))
|
||||
.and(have_subject('New trends up for review on cb6e6126.ngrok.io'))
|
||||
.and(have_subject(I18n.t('admin_mailer.new_trends.subject', instance: Rails.configuration.x.local_domain)))
|
||||
.and(have_body_text('The following items need a review before they can be displayed publicly'))
|
||||
.and(have_body_text(ActivityPub::TagManager.instance.url_for(status)))
|
||||
.and(have_body_text(link.title))
|
||||
@@ -101,7 +101,7 @@ RSpec.describe AdminMailer do
|
||||
.to be_present
|
||||
.and(deliver_to(recipient.user_email))
|
||||
.and(deliver_from('notifications@localhost'))
|
||||
.and(have_subject('New Mastodon versions are available for cb6e6126.ngrok.io!'))
|
||||
.and(have_subject(I18n.t('admin_mailer.new_software_updates.subject', instance: Rails.configuration.x.local_domain)))
|
||||
.and(have_body_text('New Mastodon versions have been released, you may want to update!'))
|
||||
end
|
||||
end
|
||||
@@ -119,7 +119,7 @@ RSpec.describe AdminMailer do
|
||||
.to be_present
|
||||
.and(deliver_to(recipient.user_email))
|
||||
.and(deliver_from('notifications@localhost'))
|
||||
.and(have_subject('Critical Mastodon updates are available for cb6e6126.ngrok.io!'))
|
||||
.and(have_subject(I18n.t('admin_mailer.new_critical_software_updates.subject', instance: Rails.configuration.x.local_domain)))
|
||||
.and(have_body_text('New critical versions of Mastodon have been released, you may want to update as soon as possible!'))
|
||||
.and(have_header('Importance', 'high'))
|
||||
.and(have_header('Priority', 'urgent'))
|
||||
@@ -140,7 +140,7 @@ RSpec.describe AdminMailer do
|
||||
.to be_present
|
||||
.and(deliver_to(recipient.user_email))
|
||||
.and(deliver_from('notifications@localhost'))
|
||||
.and(have_subject('Registrations for cb6e6126.ngrok.io have been automatically switched to requiring approval'))
|
||||
.and(have_subject(I18n.t('admin_mailer.auto_close_registrations.subject', instance: Rails.configuration.x.local_domain)))
|
||||
.and(have_body_text('have been automatically switched'))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user