Skip to content
Snippets Groups Projects
Commit d92ef39d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Fixed test and travis

parent f038dd85
No related branches found
No related tags found
No related merge requests found
branches:
only:
- 'master'
rvm:
- 1.9.2
script: "bundle exec rspec spec"
Loading
Loading
@@ -3,9 +3,8 @@ source 'http://rubygems.org'
gemspec
 
group :development, :test do
gem 'guard'
gem 'guard-rspec'
gem 'guard-bundler'
gem 'growl'
gem 'rb-fsevent'
gem 'rspec'
gem 'pry'
gem 'rake'
gem 'rack-test'
end
PATH
remote: .
specs:
omniauth-ldap (1.0.2)
gitlab_omniauth-ldap (1.0.2)
net-ldap (~> 0.2.2)
omniauth (~> 1.0)
pyu-ruby-sasl (~> 0.0.3.1)
Loading
Loading
@@ -10,70 +10,40 @@ PATH
GEM
remote: http://rubygems.org/
specs:
archive-tar-minitar (0.5.2)
columnize (0.3.4)
coderay (1.0.8)
diff-lcs (1.1.3)
ffi (1.0.9)
growl (1.0.3)
guard (0.8.8)
thor (~> 0.14.6)
guard-bundler (0.1.3)
bundler (>= 1.0.0)
guard (>= 0.2.2)
guard-rspec (0.5.0)
guard (>= 0.8.4)
hashie (1.2.0)
libnotify (0.5.7)
ffi (= 1.0.9)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
multi_json (1.0.3)
method_source (0.8.1)
net-ldap (0.2.2)
omniauth (1.0.1)
omniauth (1.1.1)
hashie (~> 1.2)
rack
pry (0.9.10)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.3.1)
pyu-ruby-sasl (0.0.3.3)
rack (1.3.5)
rack-test (0.6.1)
rack (1.4.1)
rack-test (0.6.2)
rack (>= 1.0)
rb-fsevent (0.4.3.1)
rspec (2.7.0)
rspec-core (~> 2.7.0)
rspec-expectations (~> 2.7.0)
rspec-mocks (~> 2.7.0)
rspec-core (2.7.1)
rspec-expectations (2.7.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.7.0)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
rake (10.0.3)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.12.1)
rubyntlm (0.1.1)
simplecov (0.5.4)
multi_json (~> 1.0.3)
simplecov-html (~> 0.5.3)
simplecov-html (0.5.3)
thor (0.14.6)
slop (3.3.3)
 
PLATFORMS
ruby
 
DEPENDENCIES
growl
guard
guard-bundler
guard-rspec
libnotify
omniauth-ldap!
gitlab_omniauth-ldap!
pry
rack-test
rb-fsevent
rspec (~> 2.7)
ruby-debug19
simplecov
rake
rspec
Loading
Loading
@@ -49,10 +49,10 @@ module OmniAuth
:base => @base
}
@uri = construct_uri(@host, @port, @method != :plain)
@bind_method = @try_sasl ? :sasl : (@allow_anonymous||!@bind_dn||!@password ? :anonymous : :simple)
@auth = sasl_auths({:username => @bind_dn, :password => @password}).first if @bind_method == :sasl
@auth ||= { :method => @bind_method,
:username => @bind_dn,
Loading
Loading
@@ -61,11 +61,11 @@ module OmniAuth
config[:auth] = @auth
@connection = Net::LDAP.new(config)
end
#:base => "dc=yourcompany, dc=com",
# :filter => "(mail=#{user})",
# :password => psw
def bind_as(args = {})
def bind_as(args = {})
result = false
@connection.open do |me|
rs = me.search args
Loading
Loading
Loading
Loading
@@ -6,22 +6,17 @@ Gem::Specification.new do |gem|
gem.email = ["ping@intridea.com"]
gem.description = %q{A LDAP strategy for OmniAuth.}
gem.summary = %q{A LDAP strategy for OmniAuth.}
gem.homepage = "https://github.com/intridea/omniauth-ldap"
gem.homepage = "https://github.com/gitlabhq/omniauth-ldap"
 
gem.add_runtime_dependency 'omniauth', '~> 1.0'
gem.add_runtime_dependency 'net-ldap', '~> 0.2.2'
gem.add_runtime_dependency 'pyu-ruby-sasl', '~> 0.0.3.1'
gem.add_runtime_dependency 'rubyntlm', '~> 0.1.1'
gem.add_development_dependency 'rspec', '~> 2.7'
gem.add_development_dependency 'simplecov'
gem.add_development_dependency 'rack-test'
gem.add_development_dependency 'libnotify'
gem.add_development_dependency 'ruby-debug19'
gem.add_runtime_dependency 'rubyntlm', '~> 0.1.1'
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.name = "omniauth-ldap"
gem.name = "gitlab_omniauth-ldap"
gem.require_paths = ["lib"]
gem.version = OmniAuth::LDAP::VERSION
end
require 'spec_helper'
describe "OmniAuth::Strategies::LDAP" do
# :title => "My LDAP",
# :title => "My LDAP",
# :host => '10.101.10.1',
# :port => 389,
# :method => :plain,
Loading
Loading
@@ -8,12 +9,13 @@ describe "OmniAuth::Strategies::LDAP" do
# :uid => 'sAMAccountName',
# :name_proc => Proc.new {|name| name.gsub(/@.*$/,'')}
# :bind_dn => 'default_bind_dn'
# :password => 'password'
class MyLdapProvider < OmniAuth::Strategies::LDAP; end
# :password => 'password'
class MyLdapProvider < OmniAuth::Strategies::LDAP; end
def app
Rack::Builder.new {
use OmniAuth::Test::PhonySession
use MyLdapProvider, :name => 'ldap', :title => 'MyLdap Form', :host => '192.168.1.145', :base => 'dc=score, dc=local', :name_proc => Proc.new {|name| name.gsub(/@.*$/,'')}
use MyLdapProvider, :name => 'ldap', :title => 'MyLdap Form', :host => '192.168.1.145', :base => 'dc=score, dc=local', :name_proc => Proc.new {|name| name.gsub(/@.*$/,'')}
run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
}.to_app
end
Loading
Loading
@@ -52,36 +54,42 @@ describe "OmniAuth::Strategies::LDAP" do
@adaptor = mock(OmniAuth::LDAP::Adaptor, {:uid => 'ping'})
OmniAuth::LDAP::Adaptor.stub(:new).and_return(@adaptor)
end
context 'failure' do
before(:each) do
@adaptor.stub(:bind_as).and_return(false)
end
before(:each) do
@adaptor.stub(:bind_as).and_return(false)
end
it 'should raise MissingCredentialsError' do
lambda{post('/auth/ldap/callback', {})}.should raise_error OmniAuth::Strategies::LDAP::MissingCredentialsError
post('/auth/ldap/callback', {})
last_response.should be_redirect
last_response.headers['Location'].should =~ %r{ldap_error}
end
it 'should redirect to error page' do
it 'should redirect to error page' do
post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
last_response.should be_redirect
last_response.headers['Location'].should =~ %r{invalid_credentials}
end
it 'should redirect to error page when there is exception' do
it 'should redirect to error page when there is exception' do
@adaptor.stub(:bind_as).and_throw(Exception.new('connection_error'))
post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
last_response.should be_redirect
last_response.headers['Location'].should =~ %r{ldap_error}
end
end
context 'success' do
let(:auth_hash){ last_request.env['omniauth.auth'] }
before(:each) do
@adaptor.stub(:bind_as).and_return({:dn => ['cn=ping, dc=intridea, dc=com'], :mail => ['ping@intridea.com'], :givenname => ['Ping'], :sn => ['Yu'],
:telephonenumber => ['555-555-5555'], :mobile => ['444-444-4444'], :uid => ['ping'], :title => ['dev'], :address =>[ 'k street'],
:l => ['Washington'], :st => ['DC'], :co => ["U.S.A"], :postofficebox => ['20001'], :wwwhomepage => ['www.intridea.com'],
:jpegphoto => ['http://www.intridea.com/ping.jpg'], :description => ['omniauth-ldap']})
@adaptor.stub(:bind_as).and_return({:dn => ['cn=ping, dc=intridea, dc=com'], :mail => ['ping@intridea.com'], :givenname => ['Ping'], :sn => ['Yu'],
:telephonenumber => ['555-555-5555'], :mobile => ['444-444-4444'], :uid => ['ping'], :title => ['dev'], :address =>[ 'k street'],
:l => ['Washington'], :st => ['DC'], :co => ["U.S.A"], :postofficebox => ['20001'], :wwwhomepage => ['www.intridea.com'],
:jpegphoto => ['http://www.intridea.com/ping.jpg'], :description => ['omniauth-ldap']})
post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
end
it 'should raise MissingCredentialsError' do
should_not raise_error OmniAuth::Strategies::LDAP::MissingCredentialsError
end
Loading
Loading
$:.unshift File.expand_path('..', __FILE__)
$:.unshift File.expand_path('../../lib', __FILE__)
require 'simplecov'
SimpleCov.start
require 'rspec'
require 'rack/test'
require 'omniauth'
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment