summaryrefslogtreecommitdiff
path: root/spec/tasks
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2018-11-27 16:08:31 -0800
committerMichael Kozono <mkozono@gmail.com>2018-12-03 13:51:46 -0800
commit6855e6b5864abcf01689720424a4bea4c3b9fec2 (patch)
tree627226eee254d76b41d16cfd99f07be3f7c3f6b5 /spec/tasks
parentc3c25174e3397ca3f301b539477e6568c676d264 (diff)
downloadgitlab-ce-6855e6b5864abcf01689720424a4bea4c3b9fec2.tar.gz
Extract system check rake task logic
These changes make the code more reusable, testable, and most importantly, overrideable.
Diffstat (limited to 'spec/tasks')
-rw-r--r--spec/tasks/gitlab/check_rake_spec.rb108
1 files changed, 79 insertions, 29 deletions
diff --git a/spec/tasks/gitlab/check_rake_spec.rb b/spec/tasks/gitlab/check_rake_spec.rb
index 4eda618b6d6..06525e3c771 100644
--- a/spec/tasks/gitlab/check_rake_spec.rb
+++ b/spec/tasks/gitlab/check_rake_spec.rb
@@ -1,51 +1,101 @@
require 'rake_helper'
-describe 'gitlab:ldap:check rake task' do
- include LdapHelpers
-
+describe 'check.rake' do
before do
Rake.application.rake_require 'tasks/gitlab/check'
stub_warn_user_is_not_gitlab
end
- context 'when LDAP is not enabled' do
- it 'does not attempt to bind or search for users' do
- expect(Gitlab::Auth::LDAP::Config).not_to receive(:providers)
- expect(Gitlab::Auth::LDAP::Adapter).not_to receive(:open)
-
- run_rake_task('gitlab:ldap:check')
+ shared_examples_for 'system check rake task' do
+ it 'runs the check' do
+ expect do
+ subject
+ end.to output(/Checking #{name} ... Finished/).to_stdout
end
end
- context 'when LDAP is enabled' do
- let(:ldap) { double(:ldap) }
- let(:adapter) { ldap_adapter('ldapmain', ldap) }
+ describe 'gitlab:check rake task' do
+ subject { run_rake_task('gitlab:check') }
+ let(:name) { 'GitLab subtasks' }
- before do
- allow(Gitlab::Auth::LDAP::Config)
- .to receive_messages(
- enabled?: true,
- providers: ['ldapmain']
- )
- allow(Gitlab::Auth::LDAP::Adapter).to receive(:open).and_yield(adapter)
- allow(adapter).to receive(:users).and_return([])
- end
+ it_behaves_like 'system check rake task'
+ end
+
+ describe 'gitlab:gitlab_shell:check rake task' do
+ subject { run_rake_task('gitlab:gitlab_shell:check') }
+ let(:name) { 'GitLab Shell' }
+
+ it_behaves_like 'system check rake task'
+ end
+
+ describe 'gitlab:gitaly:check rake task' do
+ subject { run_rake_task('gitlab:gitaly:check') }
+ let(:name) { 'Gitaly' }
+
+ it_behaves_like 'system check rake task'
+ end
+
+ describe 'gitlab:sidekiq:check rake task' do
+ subject { run_rake_task('gitlab:sidekiq:check') }
+ let(:name) { 'Sidekiq' }
- it 'attempts to bind using credentials' do
- stub_ldap_config(has_auth?: true)
+ it_behaves_like 'system check rake task'
+ end
- expect(ldap).to receive(:bind)
+ describe 'gitlab:incoming_email:check rake task' do
+ subject { run_rake_task('gitlab:incoming_email:check') }
+ let(:name) { 'Incoming Email' }
- run_rake_task('gitlab:ldap:check')
+ it_behaves_like 'system check rake task'
+ end
+
+ describe 'gitlab:ldap:check rake task' do
+ include LdapHelpers
+
+ subject { run_rake_task('gitlab:ldap:check') }
+ let(:name) { 'LDAP' }
+
+ it_behaves_like 'system check rake task'
+
+ context 'when LDAP is not enabled' do
+ it 'does not attempt to bind or search for users' do
+ expect(Gitlab::Auth::LDAP::Config).not_to receive(:providers)
+ expect(Gitlab::Auth::LDAP::Adapter).not_to receive(:open)
+
+ subject
+ end
end
- it 'searches for 100 LDAP users' do
- stub_ldap_config(uid: 'uid')
+ context 'when LDAP is enabled' do
+ let(:ldap) { double(:ldap) }
+ let(:adapter) { ldap_adapter('ldapmain', ldap) }
+
+ before do
+ allow(Gitlab::Auth::LDAP::Config)
+ .to receive_messages(
+ enabled?: true,
+ providers: ['ldapmain']
+ )
+ allow(Gitlab::Auth::LDAP::Adapter).to receive(:open).and_yield(adapter)
+ allow(adapter).to receive(:users).and_return([])
+ end
+
+ it 'attempts to bind using credentials' do
+ stub_ldap_config(has_auth?: true)
+
+ expect(ldap).to receive(:bind)
+
+ subject
+ end
+
+ it 'searches for 100 LDAP users' do
+ stub_ldap_config(uid: 'uid')
- expect(adapter).to receive(:users).with('uid', '*', 100)
+ expect(adapter).to receive(:users).with('uid', '*', 100)
- run_rake_task('gitlab:ldap:check')
+ subject
+ end
end
end
end