Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Willem van der Meer <mail@jewilmeer.nl>2014-08-29 19:29:42 +0400
committerJan-Willem van der Meer <mail@jewilmeer.nl>2014-08-29 19:30:42 +0400
commit0d5ae2802e887dcd95fe537a59450a2c0f548382 (patch)
tree5b65aaf99fe126f6361f36083261789b0143330f /spec/lib/gitlab
parent97547428bd481b984a4c5513931617db0d890ee5 (diff)
Move and rename ldap / oauth specs
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/auth_spec.rb28
-rw-r--r--spec/lib/gitlab/ldap/user_spec.rb2
-rw-r--r--spec/lib/gitlab/oauth/user_spec.rb45
3 files changed, 74 insertions, 1 deletions
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