mirror of https://github.com/mastodon/mastodon
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
Ruby
38 lines
1.1 KiB
Ruby
5 years ago
|
# frozen_string_literal: true
|
||
|
|
||
|
require 'rails_helper'
|
||
|
|
||
4 days ago
|
RSpec.describe 'Auth Challenges' do
|
||
5 years ago
|
let(:password) { 'foobar12345' }
|
||
|
let(:user) { Fabricate(:user, password: password) }
|
||
|
|
||
2 months ago
|
before { sign_in user }
|
||
5 years ago
|
|
||
|
describe 'POST #create' do
|
||
|
let(:return_to) { edit_user_registration_path }
|
||
|
|
||
|
context 'with correct password' do
|
||
2 months ago
|
it 'redirects back and sets challenge passed at in session' do
|
||
4 days ago
|
post '/auth/challenge', params: { form_challenge: { return_to: return_to, current_password: password } }
|
||
|
|
||
2 months ago
|
expect(response)
|
||
|
.to redirect_to(return_to)
|
||
|
expect(session[:challenge_passed_at])
|
||
|
.to_not be_nil
|
||
5 years ago
|
end
|
||
|
end
|
||
|
|
||
|
context 'with incorrect password' do
|
||
2 months ago
|
it 'renders challenge, displays error, does not set session' do
|
||
4 days ago
|
post '/auth/challenge', params: { form_challenge: { return_to: return_to, current_password: 'hhfggjjd562' } }
|
||
|
|
||
2 months ago
|
expect(response.body)
|
||
4 days ago
|
.to include(I18n.t('challenge.prompt'))
|
||
|
.and include('Invalid password')
|
||
2 months ago
|
expect(session[:challenge_passed_at])
|
||
|
.to be_nil
|
||
5 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|