mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-16 16:16:43 +10:00
Cleanup provider validation
This commit is contained in:
@@ -17,8 +17,8 @@ module Gitlab
|
||||
end
|
||||
|
||||
def initialize(provider)
|
||||
raise "Unknown provider (#{provider}). Available providers: #{self.class.providers}"
|
||||
@provider = provider
|
||||
invalid_provider unless valid_provider?
|
||||
@options = config_for(provider)
|
||||
end
|
||||
|
||||
@@ -89,6 +89,14 @@ module Gitlab
|
||||
end
|
||||
end
|
||||
|
||||
def valid_provider?
|
||||
self.class.providers.include?(provider)
|
||||
end
|
||||
|
||||
def invalid_provider
|
||||
raise "Unknown provider (#{provider}). Available providers: #{self.class.providers}"
|
||||
end
|
||||
|
||||
def auth_options
|
||||
{
|
||||
auth: {
|
||||
|
||||
@@ -12,5 +12,9 @@ describe Gitlab::LDAP::Config do
|
||||
it "works" do
|
||||
expect(config).to be_a described_class
|
||||
end
|
||||
|
||||
it "raises an error if a unknow provider is used" do
|
||||
expect{ Gitlab::LDAP::Config.new 'unknown' }.to raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user