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:
Diffstat (limited to 'spec/lib/gitlab/o_auth')
-rw-r--r--spec/lib/gitlab/o_auth/auth_hash_spec.rb55
-rw-r--r--spec/lib/gitlab/o_auth/user_spec.rb109
2 files changed, 0 insertions, 164 deletions
diff --git a/spec/lib/gitlab/o_auth/auth_hash_spec.rb b/spec/lib/gitlab/o_auth/auth_hash_spec.rb
deleted file mode 100644
index 5eb77b492b2..00000000000
--- a/spec/lib/gitlab/o_auth/auth_hash_spec.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-require 'spec_helper'
-
-describe Gitlab::OAuth::AuthHash do
- let(:auth_hash) do
- Gitlab::OAuth::AuthHash.new(double({
- provider: 'twitter',
- uid: uid,
- info: double(info_hash)
- }))
- end
- let(:uid) { 'my-uid' }
- let(:email) { 'my-email@example.com' }
- let(:nickname) { 'my-nickname' }
- let(:info_hash) {
- {
- email: email,
- nickname: nickname,
- name: 'John',
- first_name: "John",
- last_name: "Who"
- }
- }
-
- context "defaults" do
- it { expect(auth_hash.provider).to eql 'twitter' }
- it { expect(auth_hash.uid).to eql uid }
- it { expect(auth_hash.email).to eql email }
- it { expect(auth_hash.username).to eql nickname }
- it { expect(auth_hash.name).to eql "John" }
- it { expect(auth_hash.password).to_not be_empty }
- end
-
- context "email not provided" do
- before { info_hash.delete(:email) }
- it "generates a temp email" do
- expect( auth_hash.email).to start_with('temp-email-for-oauth')
- end
- end
-
- context "username not provided" do
- before { info_hash.delete(:nickname) }
-
- it "takes the first part of the email as username" do
- expect( auth_hash.username ).to eql "my-email"
- end
- end
-
- context "name not provided" do
- before { info_hash.delete(:name) }
-
- it "concats first and lastname as the name" do
- expect( auth_hash.name ).to eql "John Who"
- end
- end
-end \ No newline at end of file
diff --git a/spec/lib/gitlab/o_auth/user_spec.rb b/spec/lib/gitlab/o_auth/user_spec.rb
deleted file mode 100644
index 44cdd1e4fab..00000000000
--- a/spec/lib/gitlab/o_auth/user_spec.rb
+++ /dev/null
@@ -1,109 +0,0 @@
-require 'spec_helper'
-
-describe Gitlab::OAuth::User do
- let(:oauth_user) { Gitlab::OAuth::User.new(auth_hash) }
- let(:gl_user) { oauth_user.gl_user }
- let(:uid) { 'my-uid' }
- let(:provider) { 'my-provider' }
- let(:auth_hash) { double(uid: uid, provider: provider, info: double(info_hash)) }
- let(:info_hash) do
- {
- nickname: '-john+gitlab-ETC%.git@gmail.com',
- name: 'John',
- email: 'john@mail.com'
- }
- end
-
- describe :persisted? do
- let!(:existing_user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'my-provider') }
-
- it "finds an existing user based on uid and provider (facebook)" do
- auth = double(info: double(name: 'John'), uid: 'my-uid', provider: 'my-provider')
- expect( oauth_user.persisted? ).to be_truthy
- end
-
- it "returns false if use is not found in database" do
- auth_hash.stub(uid: 'non-existing')
- expect( oauth_user.persisted? ).to be_falsey
- end
- end
-
- describe :save do
- let(:provider) { 'twitter' }
-
- describe 'signup' do
- context "with allow_single_sign_on enabled" do
- before { Gitlab.config.omniauth.stub allow_single_sign_on: true }
-
- it "creates a user from Omniauth" do
- oauth_user.save
-
- expect(gl_user).to be_valid
- identity = gl_user.identities.first
- expect(identity.extern_uid).to eql uid
- expect(identity.provider).to eql 'twitter'
- end
- end
-
- context "with allow_single_sign_on disabled (Default)" do
- it "throws an error" do
- expect{ oauth_user.save }.to raise_error StandardError
- end
- end
- end
-
- describe 'blocking' do
- let(:provider) { 'twitter' }
- before { Gitlab.config.omniauth.stub allow_single_sign_on: true }
-
- context 'signup' do
- context 'dont block on create' do
- before { Gitlab.config.omniauth.stub block_auto_created_users: false }
-
- it do
- oauth_user.save
- expect(gl_user).to be_valid
- expect(gl_user).not_to be_blocked
- end
- end
-
- context 'block on create' do
- before { Gitlab.config.omniauth.stub block_auto_created_users: true }
-
- it do
- oauth_user.save
- expect(gl_user).to be_valid
- expect(gl_user).to be_blocked
- end
- end
- end
-
- context 'sign-in' do
- before do
- oauth_user.save
- oauth_user.gl_user.activate
- end
-
- context 'dont block on create' do
- before { Gitlab.config.omniauth.stub block_auto_created_users: false }
-
- it do
- oauth_user.save
- expect(gl_user).to be_valid
- expect(gl_user).not_to be_blocked
- end
- end
-
- context 'block on create' do
- before { Gitlab.config.omniauth.stub block_auto_created_users: true }
-
- it do
- oauth_user.save
- expect(gl_user).to be_valid
- expect(gl_user).not_to be_blocked
- end
- end
- end
- end
- end
-end