Skip to content
Snippets Groups Projects
Commit dc889678 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent cd52759e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -5,7 +5,6 @@ require 'spec_helper'
describe Projects::TransferService do
include GitHelpers
 
let(:gitlab_shell) { Gitlab::Shell.new }
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, :repository, :legacy_storage, namespace: user.namespace) }
Loading
Loading
@@ -104,7 +103,7 @@ describe Projects::TransferService do
it 'rolls back repo location' do
attempt_project_transfer
 
expect(gitlab_shell.repository_exists?(project.repository_storage, "#{project.disk_path}.git")).to be(true)
expect(project.repository.raw.exists?).to be(true)
expect(original_path).to eq current_path
end
 
Loading
Loading
@@ -172,21 +171,18 @@ describe Projects::TransferService do
end
 
context 'namespace which contains orphan repository with same projects path name' do
let(:repository_storage) { 'default' }
let(:repository_storage_path) { Gitlab.config.repositories.storages[repository_storage].legacy_disk_path }
let(:fake_repo_path) { File.join(TestEnv.repos_path, group.full_path, "#{project.path}.git") }
 
before do
group.add_owner(user)
 
unless gitlab_shell.create_repository(repository_storage, "#{group.full_path}/#{project.path}", project.full_path)
raise 'failed to add repository'
end
TestEnv.create_bare_repository(fake_repo_path)
 
@result = transfer_project(project, user, group)
end
 
after do
gitlab_shell.remove_repository(repository_storage, "#{group.full_path}/#{project.path}")
FileUtils.rm_rf(fake_repo_path)
end
 
it { expect(@result).to eq false }
Loading
Loading
Loading
Loading
@@ -12,7 +12,6 @@ describe Projects::UpdateService do
end
 
describe '#execute' do
let(:gitlab_shell) { Gitlab::Shell.new }
let(:admin) { create(:admin) }
 
context 'when changing visibility level' do
Loading
Loading
@@ -303,18 +302,17 @@ describe Projects::UpdateService do
end
 
context 'when renaming a project' do
let(:repository_storage) { 'default' }
let(:repository_storage_path) { Gitlab.config.repositories.storages[repository_storage].legacy_disk_path }
let(:fake_repo_path) { File.join(TestEnv.repos_path, user.namespace.full_path, 'existing.git') }
 
context 'with legacy storage' do
let(:project) { create(:project, :legacy_storage, :repository, creator: user, namespace: user.namespace) }
 
before do
gitlab_shell.create_repository(repository_storage, "#{user.namespace.full_path}/existing", user.namespace.full_path)
TestEnv.create_bare_repository(fake_repo_path)
end
 
after do
gitlab_shell.remove_repository(repository_storage, "#{user.namespace.full_path}/existing")
FileUtils.rm_rf(fake_repo_path)
end
 
it 'does not allow renaming when new path matches existing repository on disk' do
Loading
Loading
Loading
Loading
@@ -2,14 +2,14 @@
 
module LdapHelpers
def ldap_adapter(provider = 'ldapmain', ldap = double(:ldap))
::Gitlab::Auth::LDAP::Adapter.new(provider, ldap)
::Gitlab::Auth::Ldap::Adapter.new(provider, ldap)
end
 
def user_dn(uid)
"uid=#{uid},ou=users,dc=example,dc=com"
end
 
# Accepts a hash of Gitlab::Auth::LDAP::Config keys and values.
# Accepts a hash of Gitlab::Auth::Ldap::Config keys and values.
#
# Example:
# stub_ldap_config(
Loading
Loading
@@ -17,7 +17,7 @@ module LdapHelpers
# admin_group: 'my-admin-group'
# )
def stub_ldap_config(messages)
allow_any_instance_of(::Gitlab::Auth::LDAP::Config).to receive_messages(messages)
allow_any_instance_of(::Gitlab::Auth::Ldap::Config).to receive_messages(messages)
end
 
def stub_ldap_setting(messages)
Loading
Loading
@@ -28,29 +28,29 @@ module LdapHelpers
# `entry` to simulate when an LDAP person is not found
#
# Example:
# adapter = ::Gitlab::Auth::LDAP::Adapter.new('ldapmain', double(:ldap))
# adapter = ::Gitlab::Auth::Ldap::Adapter.new('ldapmain', double(:ldap))
# ldap_user_entry = ldap_user_entry('john_doe')
#
# stub_ldap_person_find_by_uid('john_doe', ldap_user_entry, adapter)
def stub_ldap_person_find_by_uid(uid, entry, provider = 'ldapmain')
return_value = ::Gitlab::Auth::LDAP::Person.new(entry, provider) if entry.present?
return_value = ::Gitlab::Auth::Ldap::Person.new(entry, provider) if entry.present?
 
allow(::Gitlab::Auth::LDAP::Person)
allow(::Gitlab::Auth::Ldap::Person)
.to receive(:find_by_uid).with(uid, any_args).and_return(return_value)
end
 
def stub_ldap_person_find_by_dn(entry, provider = 'ldapmain')
person = ::Gitlab::Auth::LDAP::Person.new(entry, provider) if entry.present?
person = ::Gitlab::Auth::Ldap::Person.new(entry, provider) if entry.present?
 
allow(::Gitlab::Auth::LDAP::Person)
allow(::Gitlab::Auth::Ldap::Person)
.to receive(:find_by_dn)
.and_return(person)
end
 
def stub_ldap_person_find_by_email(email, entry, provider = 'ldapmain')
person = ::Gitlab::Auth::LDAP::Person.new(entry, provider) if entry.present?
person = ::Gitlab::Auth::Ldap::Person.new(entry, provider) if entry.present?
 
allow(::Gitlab::Auth::LDAP::Person)
allow(::Gitlab::Auth::Ldap::Person)
.to receive(:find_by_email)
.with(email, anything)
.and_return(person)
Loading
Loading
@@ -66,8 +66,8 @@ module LdapHelpers
end
 
def raise_ldap_connection_error
allow_any_instance_of(Gitlab::Auth::LDAP::Adapter)
.to receive(:ldap_search).and_raise(Gitlab::Auth::LDAP::LDAPConnectionError)
allow_any_instance_of(Gitlab::Auth::Ldap::Adapter)
.to receive(:ldap_search).and_raise(Gitlab::Auth::Ldap::LdapConnectionError)
end
end
 
Loading
Loading
Loading
Loading
@@ -30,7 +30,7 @@ RSpec.shared_context 'Ldap::OmniauthCallbacksController' do
@original_env_config_omniauth_auth = mock_auth_hash(provider.to_s, uid, user.email)
stub_omniauth_provider(provider, context: request)
 
allow(Gitlab::Auth::LDAP::Access).to receive(:allowed?).and_return(valid_login?)
allow(Gitlab::Auth::Ldap::Access).to receive(:allowed?).and_return(valid_login?)
end
 
after do
Loading
Loading
Loading
Loading
@@ -68,8 +68,8 @@ describe 'check.rake' do
 
context 'when LDAP is not enabled' do
it 'does not attempt to bind or search for users' do
expect(Gitlab::Auth::LDAP::Config).not_to receive(:providers)
expect(Gitlab::Auth::LDAP::Adapter).not_to receive(:open)
expect(Gitlab::Auth::Ldap::Config).not_to receive(:providers)
expect(Gitlab::Auth::Ldap::Adapter).not_to receive(:open)
 
subject
end
Loading
Loading
@@ -80,12 +80,12 @@ describe 'check.rake' do
let(:adapter) { ldap_adapter('ldapmain', ldap) }
 
before do
allow(Gitlab::Auth::LDAP::Config)
allow(Gitlab::Auth::Ldap::Config)
.to receive_messages(
enabled?: true,
providers: ['ldapmain']
)
allow(Gitlab::Auth::LDAP::Adapter).to receive(:open).and_yield(adapter)
allow(Gitlab::Auth::Ldap::Adapter).to receive(:open).and_yield(adapter)
allow(adapter).to receive(:users).and_return([])
end
 
Loading
Loading
Loading
Loading
@@ -421,24 +421,6 @@ describe PostReceive do
perform
end
end
it 'updates the snippet db information' do
blob = snippet.blobs.first
expect(snippet).to receive(:update).with(file_name: blob.path, content: blob.data)
perform
end
context 'when snippet does not have any blob' do
it 'does not update snippet db information' do
allow(snippet).to receive(:blobs).and_return([])
expect(snippet).not_to receive(:update)
perform
end
end
end
end
 
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