summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortakayamaki <fsgiko@gmail.com>2018-10-21 00:28:04 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-10-20 17:28:04 +0200
commit33976c8ecc6bd5e75b918737b224c9d4388f6516 (patch)
treedbcbfd0194ca3948e02082830be0ca0aaacce483
parentfd5285658f477c5b6a9c7af0935b5c889729b2e0 (diff)
fix: Execute PAM authentication tests on CircleCI (#9029)
and use 'if' option of context block
-rw-r--r--.circleci/config.yml3
-rw-r--r--spec/controllers/auth/sessions_controller_spec.rb74
2 files changed, 39 insertions, 38 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 20688b8e9a7..674d1b02dca 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -13,6 +13,9 @@ aliases:
ALLOW_NOPAM: true
CONTINUOUS_INTEGRATION: true
DISABLE_SIMPLECOV: true
+ PAM_ENABLED: true
+ PAM_DEFAULT_SERVICE: pam_test
+ PAM_CONTROLLED_SERVICE: pam_test_controlled
working_directory: ~/projects/mastodon/
- &attach_workspace
diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb
index 86fed7b8bb1..71fcc1a6e3d 100644
--- a/spec/controllers/auth/sessions_controller_spec.rb
+++ b/spec/controllers/auth/sessions_controller_spec.rb
@@ -55,55 +55,53 @@ RSpec.describe Auth::SessionsController, type: :controller do
request.env['devise.mapping'] = Devise.mappings[:user]
end
- if ENV['PAM_ENABLED'] == 'true'
- context 'using PAM authentication' do
- context 'using a valid password' do
- before do
- post :create, params: { user: { email: "pam_user1", password: '123456' } }
- end
+ context 'using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do
+ context 'using a valid password' do
+ before do
+ post :create, params: { user: { email: "pam_user1", password: '123456' } }
+ end
- it 'redirects to home' do
- expect(response).to redirect_to(root_path)
- end
+ it 'redirects to home' do
+ expect(response).to redirect_to(root_path)
+ end
- it 'logs the user in' do
- expect(controller.current_user).to be_instance_of(User)
- end
+ it 'logs the user in' do
+ expect(controller.current_user).to be_instance_of(User)
end
+ end
- context 'using an invalid password' do
- before do
- post :create, params: { user: { email: "pam_user1", password: 'WRONGPW' } }
- end
+ context 'using an invalid password' do
+ before do
+ post :create, params: { user: { email: "pam_user1", password: 'WRONGPW' } }
+ end
- it 'shows a login error' do
- expect(flash[:alert]).to match I18n.t('devise.failure.invalid', authentication_keys: 'Email')
- end
+ it 'shows a login error' do
+ expect(flash[:alert]).to match I18n.t('devise.failure.invalid', authentication_keys: 'Email')
+ end
- it "doesn't log the user in" do
- expect(controller.current_user).to be_nil
- end
+ it "doesn't log the user in" do
+ expect(controller.current_user).to be_nil
end
+ end
- context 'using a valid email and existing user' do
- let(:user) do
- account = Fabricate.build(:account, username: 'pam_user1')
- account.save!(validate: false)
- user = Fabricate(:user, email: 'pam@example.com', password: nil, account: account)
- user
- end
+ context 'using a valid email and existing user' do
+ let(:user) do
+ account = Fabricate.build(:account, username: 'pam_user1')
+ account.save!(validate: false)
+ user = Fabricate(:user, email: 'pam@example.com', password: nil, account: account)
+ user
+ end
- before do
- post :create, params: { user: { email: user.email, password: '123456' } }
- end
+ before do
+ post :create, params: { user: { email: user.email, password: '123456' } }
+ end
- it 'redirects to home' do
- expect(response).to redirect_to(root_path)
- end
+ it 'redirects to home' do
+ expect(response).to redirect_to(root_path)
+ end
- it 'logs the user in' do
- expect(controller.current_user).to eq user
- end
+ it 'logs the user in' do
+ expect(controller.current_user).to eq user
end
end
end