Cleanup provider validation

parent 824aeacd
...@@ -17,8 +17,8 @@ module Gitlab ...@@ -17,8 +17,8 @@ module Gitlab
end end
def initialize(provider) def initialize(provider)
raise "Unknown provider (#{provider}). Available providers: #{self.class.providers}"
@provider = provider @provider = provider
invalid_provider unless valid_provider?
@options = config_for(provider) @options = config_for(provider)
end end
...@@ -89,6 +89,14 @@ module Gitlab ...@@ -89,6 +89,14 @@ module Gitlab
end end
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 def auth_options
{ {
auth: { auth: {
......
...@@ -12,5 +12,9 @@ describe Gitlab::LDAP::Config do ...@@ -12,5 +12,9 @@ describe Gitlab::LDAP::Config do
it "works" do it "works" do
expect(config).to be_a described_class expect(config).to be_a described_class
end end
it "raises an error if a unknow provider is used" do
expect{ Gitlab::LDAP::Config.new 'unknown' }.to raise_error
end
end end
end end
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment