[DRE-commits] [ruby-omniauth-ldap] 02/05: Add rspec3-port patch

Balasankar C balasankarc-guest at moszumanska.debian.org
Sun Jan 10 07:58:01 UTC 2016


This is an automated email from the git hooks/post-receive script.

balasankarc-guest pushed a commit to branch master
in repository ruby-omniauth-ldap.

commit cbcb54921579279475ba321a28148eff4b2b210c
Author: Balasankar C <balasankarc at autistici.org>
Date:   Sun Jan 10 13:14:43 2016 +0530

    Add rspec3-port patch
---
 debian/patches/port-tests-rspec3.patch | 281 +++++++++++++++++++++++++++++++++
 debian/patches/series                  |   1 +
 2 files changed, 282 insertions(+)

diff --git a/debian/patches/port-tests-rspec3.patch b/debian/patches/port-tests-rspec3.patch
new file mode 100644
index 0000000..bd5b662
--- /dev/null
+++ b/debian/patches/port-tests-rspec3.patch
@@ -0,0 +1,281 @@
+Description: Port tests to new RSpec3 syntax
+Author: Balasankar C <balasankarc at autistici.org>
+Forwarded: https://github.com/intridea/omniauth-ldap/pull/64
+Last-Update: 2016-01-10
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/spec/omniauth-ldap/adaptor_spec.rb
++++ b/spec/omniauth-ldap/adaptor_spec.rb
+@@ -4,53 +4,53 @@
+   describe 'initialize' do
+     it 'should throw exception when must have field is not set' do
+       #[:host, :port, :method, :bind_dn]
+-      lambda { OmniAuth::LDAP::Adaptor.new({host: "192.168.1.145", method: 'plain'})}.should raise_error(ArgumentError)
++      expect { OmniAuth::LDAP::Adaptor.new({host: "192.168.1.145", method: 'plain'})}.to raise_error(ArgumentError)
+     end
+ 
+     it 'should throw exception when method is not supported' do
+-      lambda { OmniAuth::LDAP::Adaptor.new({host: "192.168.1.145", method: 'myplain', uid: 'uid', port: 389, base: 'dc=com'})}.should raise_error(OmniAuth::LDAP::Adaptor::ConfigurationError)
++      expect { OmniAuth::LDAP::Adaptor.new({host: "192.168.1.145", method: 'myplain', uid: 'uid', port: 389, base: 'dc=com'})}.to raise_error(OmniAuth::LDAP::Adaptor::ConfigurationError)
+     end
+ 
+     it 'should setup ldap connection with anonymous' do
+       adaptor = OmniAuth::LDAP::Adaptor.new({host: "192.168.1.145", method: 'plain', base: 'dc=intridea, dc=com', port: 389, uid: 'sAMAccountName'})
+-      adaptor.connection.should_not == nil
+-      adaptor.connection.host.should == '192.168.1.145'
+-      adaptor.connection.port.should == 389
+-      adaptor.connection.base.should == 'dc=intridea, dc=com'
+-      adaptor.connection.instance_variable_get('@auth').should == {:method => :anonymous, :username => nil, :password => nil}
++      expect(adaptor.connection).not_to eq(nil)
++      expect(adaptor.connection.host).to eq('192.168.1.145')
++      expect(adaptor.connection.port).to eq(389)
++      expect(adaptor.connection.base).to eq('dc=intridea, dc=com')
++      expect(adaptor.connection.instance_variable_get('@auth')).to eq({:method => :anonymous, :username => nil, :password => nil})
+     end
+ 
+     it 'should setup ldap connection with simple' do
+       adaptor = OmniAuth::LDAP::Adaptor.new({host: "192.168.1.145", method: 'plain', base: 'dc=intridea, dc=com', port: 389, uid: 'sAMAccountName', bind_dn: 'bind_dn', password: 'password'})
+-      adaptor.connection.should_not == nil
+-      adaptor.connection.host.should == '192.168.1.145'
+-      adaptor.connection.port.should == 389
+-      adaptor.connection.base.should == 'dc=intridea, dc=com'
+-      adaptor.connection.instance_variable_get('@auth').should == {:method => :simple, :username => 'bind_dn', :password => 'password'}
++      expect(adaptor.connection).not_to eq(nil)
++      expect(adaptor.connection.host).to eq('192.168.1.145')
++      expect(adaptor.connection.port).to eq(389)
++      expect(adaptor.connection.base).to eq('dc=intridea, dc=com')
++      expect(adaptor.connection.instance_variable_get('@auth')).to eq({:method => :simple, :username => 'bind_dn', :password => 'password'})
+     end
+ 
+     it 'should setup ldap connection with sasl-md5' do
+       adaptor = OmniAuth::LDAP::Adaptor.new({host: "192.168.1.145", method: 'plain', base: 'dc=intridea, dc=com', port: 389, uid: 'sAMAccountName', try_sasl: true, sasl_mechanisms: ["DIGEST-MD5"], bind_dn: 'bind_dn', password: 'password'})
+-      adaptor.connection.should_not == nil
+-      adaptor.connection.host.should == '192.168.1.145'
+-      adaptor.connection.port.should == 389
+-      adaptor.connection.base.should == 'dc=intridea, dc=com'
+-      adaptor.connection.instance_variable_get('@auth')[:method].should == :sasl
+-      adaptor.connection.instance_variable_get('@auth')[:mechanism].should == 'DIGEST-MD5'
+-      adaptor.connection.instance_variable_get('@auth')[:initial_credential].should == ''
+-      adaptor.connection.instance_variable_get('@auth')[:challenge_response].should_not be_nil
++      expect(adaptor.connection).not_to eq(nil)
++      expect(adaptor.connection.host).to eq('192.168.1.145')
++      expect(adaptor.connection.port).to eq(389)
++      expect(adaptor.connection.base).to eq('dc=intridea, dc=com')
++      expect(adaptor.connection.instance_variable_get('@auth')[:method]).to eq(:sasl)
++      expect(adaptor.connection.instance_variable_get('@auth')[:mechanism]).to eq('DIGEST-MD5')
++      expect(adaptor.connection.instance_variable_get('@auth')[:initial_credential]).to eq('')
++      expect(adaptor.connection.instance_variable_get('@auth')[:challenge_response]).not_to be_nil
+     end
+ 
+     it 'should setup ldap connection with sasl-gss' do
+       adaptor = OmniAuth::LDAP::Adaptor.new({host: "192.168.1.145", method: 'plain', base: 'dc=intridea, dc=com', port: 389, uid: 'sAMAccountName', try_sasl: true, sasl_mechanisms: ["GSS-SPNEGO"], bind_dn: 'bind_dn', password: 'password'})
+-      adaptor.connection.should_not == nil
+-      adaptor.connection.host.should == '192.168.1.145'
+-      adaptor.connection.port.should == 389
+-      adaptor.connection.base.should == 'dc=intridea, dc=com'
+-      adaptor.connection.instance_variable_get('@auth')[:method].should == :sasl
+-      adaptor.connection.instance_variable_get('@auth')[:mechanism].should == 'GSS-SPNEGO'
+-      adaptor.connection.instance_variable_get('@auth')[:initial_credential].should =~ /^NTLMSSP/
+-      adaptor.connection.instance_variable_get('@auth')[:challenge_response].should_not be_nil
++      expect(adaptor.connection).not_to eq(nil)
++      expect(adaptor.connection.host).to eq('192.168.1.145')
++      expect(adaptor.connection.port).to eq(389)
++      expect(adaptor.connection.base).to eq('dc=intridea, dc=com')
++      expect(adaptor.connection.instance_variable_get('@auth')[:method]).to eq(:sasl)
++      expect(adaptor.connection.instance_variable_get('@auth')[:mechanism]).to eq('GSS-SPNEGO')
++      expect(adaptor.connection.instance_variable_get('@auth')[:initial_credential]).to match(/^NTLMSSP/)
++      expect(adaptor.connection.instance_variable_get('@auth')[:challenge_response]).not_to be_nil
+     end
+   end
+ 
+@@ -60,18 +60,18 @@
+ 
+     it 'should bind simple' do
+       adaptor = OmniAuth::LDAP::Adaptor.new({host: "192.168.1.126", method: 'plain', base: 'dc=score, dc=local', port: 389, uid: 'sAMAccountName', bind_dn: 'bind_dn', password: 'password'})
+-      adaptor.connection.should_receive(:open).and_yield(adaptor.connection)
+-      adaptor.connection.should_receive(:search).with(args).and_return([rs])
+-      adaptor.connection.should_receive(:bind).with({:username => 'new dn', :password => args[:password], :method => :simple}).and_return(true)
+-      adaptor.bind_as(args).should == rs
++      expect(adaptor.connection).to receive(:open).and_yield(adaptor.connection)
++      expect(adaptor.connection).to receive(:search).with(args).and_return([rs])
++      expect(adaptor.connection).to receive(:bind).with({:username => 'new dn', :password => args[:password], :method => :simple}).and_return(true)
++      expect(adaptor.bind_as(args)).to eq(rs)
+     end
+ 
+     it 'should bind sasl' do
+       adaptor = OmniAuth::LDAP::Adaptor.new({host: "192.168.1.145", method: 'plain', base: 'dc=intridea, dc=com', port: 389, uid: 'sAMAccountName', try_sasl: true, sasl_mechanisms: ["GSS-SPNEGO"], bind_dn: 'bind_dn', password: 'password'})
+-      adaptor.connection.should_receive(:open).and_yield(adaptor.connection)
+-      adaptor.connection.should_receive(:search).with(args).and_return([rs])
+-      adaptor.connection.should_receive(:bind).and_return(true)
+-      adaptor.bind_as(args).should == rs
++      expect(adaptor.connection).to receive(:open).and_yield(adaptor.connection)
++      expect(adaptor.connection).to receive(:search).with(args).and_return([rs])
++      expect(adaptor.connection).to receive(:bind).and_return(true)
++      expect(adaptor.bind_as(args)).to eq(rs)
+     end
+   end
+ end
+--- a/spec/omniauth/strategies/ldap_spec.rb
++++ b/spec/omniauth/strategies/ldap_spec.rb
+@@ -24,46 +24,46 @@
+   end
+ 
+   it 'should add a camelization for itself' do
+-    OmniAuth::Utils.camelize('ldap').should == 'LDAP'
++    expect(OmniAuth::Utils.camelize('ldap')).to eq('LDAP')
+   end
+ 
+   describe '/auth/ldap' do
+     before(:each){ get '/auth/ldap' }
+ 
+     it 'should display a form' do
+-      last_response.status.should == 200
+-      last_response.body.should be_include("<form")
++      expect(last_response.status).to eq(200)
++      expect(last_response.body).to be_include("<form")
+     end
+ 
+     it 'should have the callback as the action for the form' do
+-      last_response.body.should be_include("action='/auth/ldap/callback'")
++      expect(last_response.body).to be_include("action='/auth/ldap/callback'")
+     end
+ 
+     it 'should have a text field for each of the fields' do
+-      last_response.body.scan('<input').size.should == 2
++      expect(last_response.body.scan('<input').size).to eq(2)
+     end
+     it 'should have a label of the form title' do
+-      last_response.body.scan('MyLdap Form').size.should > 1
++      expect(last_response.body.scan('MyLdap Form').size).to be > 1
+     end
+   end
+ 
+   describe 'post /auth/ldap/callback' do
+     before(:each) do
+       @adaptor = double(OmniAuth::LDAP::Adaptor, {:uid => 'ping'})
+-      OmniAuth::LDAP::Adaptor.stub(:new).and_return(@adaptor)
++      allow(OmniAuth::LDAP::Adaptor).to receive(:new).and_return(@adaptor)
+     end
+ 
+     context 'failure' do
+       before(:each) do
+-        @adaptor.stub(:bind_as).and_return(false)
++        allow(@adaptor).to receive(:bind_as).and_return(false)
+       end
+ 
+       context "when username is not preset" do
+         it 'should redirect to error page' do
+           post('/auth/ldap/callback', {})
+ 
+-          last_response.should be_redirect
+-          last_response.headers['Location'].should =~ %r{missing_credentials}
++          expect(last_response).to be_redirect
++          expect(last_response.headers['Location']).to match(%r{missing_credentials})
+         end
+       end
+ 
+@@ -71,8 +71,8 @@
+         it 'should redirect to error page' do
+           post('/auth/ldap/callback', {:username => ""})
+ 
+-          last_response.should be_redirect
+-          last_response.headers['Location'].should =~ %r{missing_credentials}
++          expect(last_response).to be_redirect
++          expect(last_response.headers['Location']).to match(%r{missing_credentials})
+         end
+       end
+ 
+@@ -81,8 +81,8 @@
+           it 'should redirect to error page' do
+             post('/auth/ldap/callback', {:username => "ping"})
+ 
+-            last_response.should be_redirect
+-            last_response.headers['Location'].should =~ %r{missing_credentials}
++            expect(last_response).to be_redirect
++            expect(last_response.headers['Location']).to match(%r{missing_credentials})
+           end
+         end
+ 
+@@ -90,8 +90,8 @@
+           it 'should redirect to error page' do
+             post('/auth/ldap/callback', {:username => "ping", :password => ""})
+ 
+-            last_response.should be_redirect
+-            last_response.headers['Location'].should =~ %r{missing_credentials}
++            expect(last_response).to be_redirect
++            expect(last_response.headers['Location']).to match(%r{missing_credentials})
+           end
+         end
+       end
+@@ -101,21 +101,21 @@
+           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}
++            expect(last_response).to be_redirect
++            expect(last_response.headers['Location']).to match(%r{invalid_credentials})
+           end
+         end
+ 
+         context "and communication with LDAP server caused an exception" do
+           before :each do
+-            @adaptor.stub(:bind_as).and_throw(Exception.new('connection_error'))
++            allow(@adaptor).to receive(:bind_as).and_throw(Exception.new('connection_error'))
+           end
+ 
+           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{ldap_error}
++            expect(last_response).to be_redirect
++            expect(last_response.headers['Location']).to match(%r{ldap_error})
+           end
+         end
+       end
+@@ -125,7 +125,7 @@
+       let(:auth_hash){ last_request.env['omniauth.auth'] }
+ 
+       before(:each) do
+-        @adaptor.stub(:bind_as).and_return(Net::LDAP::Entry.from_single_ldif_string(
++        allow(@adaptor).to receive(:bind_as).and_return(Net::LDAP::Entry.from_single_ldif_string(
+       %Q{dn: cn=ping, dc=intridea, dc=com
+ mail: ping at intridea.com
+ givenname: Ping
+@@ -148,22 +148,22 @@
+       end
+ 
+       it 'should not redirect to error page' do
+-        last_response.should_not be_redirect
++        expect(last_response).not_to be_redirect
+       end
+ 
+       it 'should map user info to Auth Hash' do
+-        auth_hash.uid.should == 'cn=ping, dc=intridea, dc=com'
+-        auth_hash.info.email.should == 'ping at intridea.com'
+-        auth_hash.info.first_name.should == 'Ping'
+-        auth_hash.info.last_name.should == 'Yu'
+-        auth_hash.info.phone.should == '555-555-5555'
+-        auth_hash.info.mobile.should == '444-444-4444'
+-        auth_hash.info.nickname.should == 'ping'
+-        auth_hash.info.title.should == 'dev'
+-        auth_hash.info.location.should == 'k street, Washington, DC, U.S.A 20001'
+-        auth_hash.info.url.should == 'www.intridea.com'
+-        auth_hash.info.image.should == 'http://www.intridea.com/ping.jpg'
+-        auth_hash.info.description.should == 'omniauth-ldap'
++        expect(auth_hash.uid).to eq('cn=ping, dc=intridea, dc=com')
++        expect(auth_hash.info.email).to eq('ping at intridea.com')
++        expect(auth_hash.info.first_name).to eq('Ping')
++        expect(auth_hash.info.last_name).to eq('Yu')
++        expect(auth_hash.info.phone).to eq('555-555-5555')
++        expect(auth_hash.info.mobile).to eq('444-444-4444')
++        expect(auth_hash.info.nickname).to eq('ping')
++        expect(auth_hash.info.title).to eq('dev')
++        expect(auth_hash.info.location).to eq('k street, Washington, DC, U.S.A 20001')
++        expect(auth_hash.info.url).to eq('www.intridea.com')
++        expect(auth_hash.info.image).to eq('http://www.intridea.com/ping.jpg')
++        expect(auth_hash.info.description).to eq('omniauth-ldap')
+       end
+     end
+   end
diff --git a/debian/patches/series b/debian/patches/series
index 5f736eb..1b6f8bf 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,4 @@ gitlab.patch
 get-rid-of-simplecov.patch
 relax-net-ldap-version.patch
 relax-ntlm.patch
+port-tests-rspec3.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-omniauth-ldap.git



More information about the Pkg-ruby-extras-commits mailing list