From 0d5ae2802e887dcd95fe537a59450a2c0f548382 Mon Sep 17 00:00:00 2001 From: Jan-Willem van der Meer Date: Fri, 29 Aug 2014 17:29:42 +0200 Subject: Move and rename ldap / oauth specs --- lib/gitlab/ldap/adapter.rb | 3 ++- spec/lib/auth_spec.rb | 28 ------------------------ spec/lib/gitlab/auth_spec.rb | 28 ++++++++++++++++++++++++ spec/lib/gitlab/ldap/user_spec.rb | 2 +- spec/lib/gitlab/oauth/user_spec.rb | 45 ++++++++++++++++++++++++++++++++++++++ spec/lib/oauth_spec.rb | 45 -------------------------------------- 6 files changed, 76 insertions(+), 75 deletions(-) delete mode 100644 spec/lib/auth_spec.rb create mode 100644 spec/lib/gitlab/auth_spec.rb create mode 100644 spec/lib/gitlab/oauth/user_spec.rb delete mode 100644 spec/lib/oauth_spec.rb diff --git a/lib/gitlab/ldap/adapter.rb b/lib/gitlab/ldap/adapter.rb index ca239bea884..68ac1b22909 100644 --- a/lib/gitlab/ldap/adapter.rb +++ b/lib/gitlab/ldap/adapter.rb @@ -86,7 +86,8 @@ module Gitlab end def dn_matches_filter?(dn, filter) - ldap_search(base: dn, filter: filter, scope: Net::LDAP::SearchScope_BaseObject, attributes: %w{dn}).any? + ldap_search(base: dn, filter: filter, + scope: Net::LDAP::SearchScope_BaseObject, attributes: %w{dn}).any? end def ldap_search(*args) diff --git a/spec/lib/auth_spec.rb b/spec/lib/auth_spec.rb deleted file mode 100644 index 073b811c3fb..00000000000 --- a/spec/lib/auth_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe Gitlab::Auth do - let(:gl_auth) { Gitlab::Auth.new } - - describe :find do - before do - @user = create( - :user, - username: 'john', - password: '88877711', - password_confirmation: '88877711' - ) - end - - it "should find user by valid login/password" do - gl_auth.find('john', '88877711').should == @user - end - - it "should not find user with invalid password" do - gl_auth.find('john', 'invalid11').should_not == @user - end - - it "should not find user with invalid login and password" do - gl_auth.find('jon', 'invalid11').should_not == @user - end - end -end diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb new file mode 100644 index 00000000000..073b811c3fb --- /dev/null +++ b/spec/lib/gitlab/auth_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +describe Gitlab::Auth do + let(:gl_auth) { Gitlab::Auth.new } + + describe :find do + before do + @user = create( + :user, + username: 'john', + password: '88877711', + password_confirmation: '88877711' + ) + end + + it "should find user by valid login/password" do + gl_auth.find('john', '88877711').should == @user + end + + it "should not find user with invalid password" do + gl_auth.find('john', 'invalid11').should_not == @user + end + + it "should not find user with invalid login and password" do + gl_auth.find('jon', 'invalid11').should_not == @user + end + end +end diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb index 501642dca79..71b316bee2f 100644 --- a/spec/lib/gitlab/ldap/user_spec.rb +++ b/spec/lib/gitlab/ldap/user_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::LDAP do +describe Gitlab::LDAP::User do let(:gl_auth) { Gitlab::LDAP::User } before do diff --git a/spec/lib/gitlab/oauth/user_spec.rb b/spec/lib/gitlab/oauth/user_spec.rb new file mode 100644 index 00000000000..2f15b5e0349 --- /dev/null +++ b/spec/lib/gitlab/oauth/user_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe Gitlab::OAuth::User do + let(:gl_auth) { Gitlab::OAuth::User } + + before do + Gitlab.config.stub(omniauth: {}) + + @info = double( + uid: '12djsak321', + nickname: 'john', + name: 'John', + email: 'john@mail.com' + ) + end + + describe :create do + it "should create user from LDAP" do + @auth = double(info: @info, provider: 'ldap') + user = gl_auth.create(@auth) + + user.should be_valid + user.extern_uid.should == @info.uid + user.provider.should == 'ldap' + end + + it "should create user from Omniauth" do + @auth = double(info: @info, provider: 'twitter') + user = gl_auth.create(@auth) + + user.should be_valid + user.extern_uid.should == @info.uid + user.provider.should == 'twitter' + end + + it "should apply defaults to user" do + @auth = double(info: @info, provider: 'ldap') + user = gl_auth.create(@auth) + + user.should be_valid + user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit + user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group + end + end +end diff --git a/spec/lib/oauth_spec.rb b/spec/lib/oauth_spec.rb deleted file mode 100644 index 2f15b5e0349..00000000000 --- a/spec/lib/oauth_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'spec_helper' - -describe Gitlab::OAuth::User do - let(:gl_auth) { Gitlab::OAuth::User } - - before do - Gitlab.config.stub(omniauth: {}) - - @info = double( - uid: '12djsak321', - nickname: 'john', - name: 'John', - email: 'john@mail.com' - ) - end - - describe :create do - it "should create user from LDAP" do - @auth = double(info: @info, provider: 'ldap') - user = gl_auth.create(@auth) - - user.should be_valid - user.extern_uid.should == @info.uid - user.provider.should == 'ldap' - end - - it "should create user from Omniauth" do - @auth = double(info: @info, provider: 'twitter') - user = gl_auth.create(@auth) - - user.should be_valid - user.extern_uid.should == @info.uid - user.provider.should == 'twitter' - end - - it "should apply defaults to user" do - @auth = double(info: @info, provider: 'ldap') - user = gl_auth.create(@auth) - - user.should be_valid - user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit - user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group - end - end -end -- cgit v1.2.1