Elimina el plugin Redmine Git Hosting

Finalmente se descarta por los problemas de configuración y potencial
brecha de seguridad al requerir acceso global al puerto ssh.
This commit is contained in:
Manuel Cillero 2020-12-06 11:46:44 +01:00
parent bdd66d941f
commit 0edadcfed8
494 changed files with 0 additions and 36768 deletions

View file

@ -1,217 +0,0 @@
module CrudControllerSpec
module Base
extend ActiveSupport::Concern
included do
include CrudControllerSpec::Helpers
before(:all) do
@project = create_project('git_project')
@repository = find_or_create_git_repository(project: @project, identifier: 'git_repository')
@repository2 = find_or_create_git_repository(project: @project, identifier: 'git_repository2')
@member_user = create_user_with_permissions(@project, member_user_options)
@anonymous_user = create_anonymous_user
@object = create_object
end
describe 'GET #index' do
context 'with sufficient permissions' do
before(:each) { set_session_user(@member_user) }
it 'renders the :index view' do
check_index_template
end
end
context 'with unsufficient permissions' do
it 'renders 403' do
set_session_user(@anonymous_user)
check_index_status(403)
end
end
end unless respond_to?(:skip_actions) && skip_actions.include?('index')
describe 'GET #show' do
before { Setting.rest_api_enabled = 1 }
context 'with sufficient permissions' do
it 'renders 200' do
check_api_response(200, id: @object.id, key: @member_user.api_key)
end
end
context 'with unsufficient permissions' do
it 'renders 403' do
check_api_response(403, id: @object.id, key: @anonymous_user.api_key)
end
end
end unless respond_to?(:skip_actions) && skip_actions.include?('show')
describe 'GET #new' do
context 'with sufficient permissions' do
before(:each) { set_session_user(@member_user) }
it 'assigns a new @object variable' do
check_new_variable(main_variable, tested_klass)
end
it 'renders the :new template' do
check_new_template
end
end
context 'with unsufficient permissions' do
it 'renders 403' do
set_session_user(@anonymous_user)
check_new_status(403)
end
end
end unless respond_to?(:skip_actions) && skip_actions.include?('new')
describe 'POST #create' do
context 'with sufficient permissions' do
before(:each) do
set_session_user(@member_user)
allow(controller).to receive(:call_use_case)
end
context 'with valid attributes' do
it 'saves the new object in the database' do
check_counter_incremented_on_create(tested_klass, valid_params_for_create)
end
it 'redirects to the repository page' do
check_create_status(200, valid_params_for_create)
end
end
context 'with invalid attributes' do
it 'does not save the new object in the database' do
check_counter_not_changed_on_create(tested_klass, invalid_params_for_create)
end
it 're-renders the :new template' do
check_create_template(:create, invalid_params_for_create)
end
end
end
context 'with unsufficient permissions' do
it 'renders 403' do
set_session_user(@anonymous_user)
check_create_status(403, valid_params_for_create)
end
end
end unless respond_to?(:skip_actions) && skip_actions.include?('create')
describe 'GET #edit' do
context 'with sufficient permissions' do
before(:each) { set_session_user(@member_user) }
context 'with existing object' do
it 'assigns the requested object to @object' do
check_edit_variable(main_variable, @object, id: @object.id)
end
it 'renders the :edit template' do
check_edit_template(id: @object.id)
end
end
context 'with non-existing object' do
it 'renders 404' do
check_edit_status(404, id: 100)
end
end
context 'with non-matching repository' do
it 'renders 404' do
check_edit_status(404, repository_id: @repository2.id, id: @object.id)
end
end
context 'with non-existing repository' do
it 'renders 404' do
check_edit_status(404, repository_id: 345, id: @object.id)
end
end
end
context 'with unsufficient permissions' do
it 'renders 403' do
set_session_user(@anonymous_user)
check_edit_status(403, id: @object.id)
end
end
end unless respond_to?(:skip_actions) && skip_actions.include?('edit')
describe 'PUT #update' do
context 'with sufficient permissions' do
before(:each) do
set_session_user(@member_user)
allow(controller).to receive(:call_use_case)
end
context 'with valid attributes' do
it 'located the requested @object' do
check_update_variable(main_variable, @object, valid_params_for_update)
end
it 'changes @object attributes' do
check_attribute_has_changed(updated_attribute, updated_attribute_value, valid_params_for_update)
end
it 'redirects to the repository page' do
check_update_status(200, valid_params_for_update)
end
end
context 'with invalid attributes' do
it 'located the requested @object' do
check_update_variable(main_variable, @object, invalid_params_for_update)
end
it 'does not change @object attributes' do
check_attribute_has_not_changed(updated_attribute, invalid_params_for_update)
end
it 're-renders the :edit template' do
check_update_template(invalid_params_for_update)
end
end
end
context 'with unsufficient permissions' do
it 'renders 403' do
set_session_user(@anonymous_user)
check_update_status(403, valid_params_for_update)
end
end
end unless respond_to?(:skip_actions) && skip_actions.include?('update')
describe 'DELETE #destroy' do
context 'with sufficient permissions' do
before(:each) do
set_session_user(@member_user)
allow(controller).to receive(:call_use_case)
end
it 'deletes the object' do
check_counter_decremented_on_delete(tested_klass, id: create_object.id)
end
it 'redirects to repositories#edit' do
check_delete_status(200, id: create_object.id)
end
end
context 'with unsufficient permissions' do
it 'renders 403' do
set_session_user(@anonymous_user)
check_delete_status(403, id: create_object.id)
end
end
end unless respond_to?(:skip_actions) && skip_actions.include?('destroy')
end
end
end

View file

@ -1,143 +0,0 @@
module CrudControllerSpec
module Helpers
##### INDEX
def check_index_template
get :index, params: base_options
assert_response :success
end
def check_index_status(status)
get :index, params: base_options
check_status(status)
end
##### SHOW
def check_api_response(status, opts = {})
get :show, params: merge_options(opts).merge(format: 'json')
check_status(status)
end
##### NEW
def check_new_variable(variable, klass)
get :new, params: base_options
assert_response :success
end
def check_new_template
get :new, params: base_options
assert_response :success
end
def check_new_status(status)
get :new, params: base_options
check_status(status)
end
##### CREATE
def check_create_template(template, opts = {})
xhr_post merge_options(opts)
end
def check_create_status(status, opts = {})
xhr_post merge_options(opts)
check_status(status)
end
def check_counter_incremented_on_create(klass, opts = {})
expect { xhr_post merge_options(opts) }.to change(klass, :count).by(1)
end
def check_counter_not_changed_on_create(klass, opts = {})
expect { xhr_post merge_options(opts) }.not_to change(klass, :count)
end
##### EDIT
def check_edit_variable(variable, value, opts = {})
get :edit, params: merge_options(opts)
end
def check_edit_template(opts = {})
get :edit, params: merge_options(opts)
assert_response :success
end
def check_edit_status(status, opts = {})
get :edit, params: merge_options(opts)
check_status(status)
end
##### UPDATE
def check_update_variable(variable, value, opts = {})
xhr_put merge_options(opts)
@object.reload
end
def check_attribute_has_changed(method, value, opts = {})
xhr_put merge_options(opts)
@object.reload
check_equality(@object.send(method), value)
end
def check_attribute_has_not_changed(method, opts = {})
old_value = @object.send(method)
xhr_put merge_options(opts)
@object.reload
check_equality(@object.send(method), old_value)
end
def check_update_template(opts = {})
xhr_put merge_options(opts)
end
def check_update_status(status, opts = {})
xhr_put merge_options(opts)
check_status(status)
end
##### DELETE
def check_counter_decremented_on_delete(klass, opts = {})
expect { delete :destroy, params: merge_options(opts).merge(format: 'js') }.to change(klass, :count).by(-1)
end
def check_delete_status(status, opts = {})
delete :destroy, params: merge_options(opts).merge(format: 'js')
check_status(status)
end
private
def base_options
{ repository_id: @repository.id }.clone
end
def merge_options(opts = {})
base_options.merge(opts)
end
def member_user_options
{ permissions: permissions }
end
def check_status(status)
expect(response.status).to eq status
end
def check_equality(variable, value)
expect(variable).to eq value
end
def xhr_post(opts = {})
post :create, params: opts, xhr: true
end
def xhr_put(opts = {})
put :update, params: opts, xhr: true
end
end
end

View file

@ -1,190 +0,0 @@
RSpec.shared_context 'flat_organisation' do
##################################################
# #
# FLAT ORGANISATION / UNIQUE REPOSITORIES TESTS #
# #
##################################################
UNIQUE_REPOSITORIES_MATRIX = {
repository_1: {
is_default: true,
identifier: '',
url: 'repositories/redmine/project-child.git',
root_url: 'repositories/redmine/project-child.git',
git_cache_id: 'project-child',
redmine_name: 'project-child',
gitolite_repository_path: 'repositories/redmine/project-child.git',
gitolite_full_repository_path: '/home/git/repositories/redmine/project-child.git',
gitolite_repository_name: 'redmine/project-child',
redmine_repository_path: 'project-child',
new_repository_name: 'redmine/project-child',
old_repository_name: 'redmine/project-child',
http_user_login: '',
git_access_path: 'redmine/project-child.git',
http_access_path: 'git/project-child.git',
ssh_url: "ssh://#{GIT_USER}@localhost/redmine/project-child.git",
git_url: 'git://localhost/redmine/project-child.git',
http_url: 'http://localhost/git/project-child.git',
https_url: 'https://localhost/git/project-child.git',
},
repository_2: {
is_default: false,
identifier: 'repo1-test',
url: 'repositories/redmine/repo1-test.git',
root_url: 'repositories/redmine/repo1-test.git',
git_cache_id: 'repo1-test',
redmine_name: 'repo1-test',
gitolite_repository_path: 'repositories/redmine/repo1-test.git',
gitolite_full_repository_path: '/home/git/repositories/redmine/repo1-test.git',
gitolite_repository_name: 'redmine/repo1-test',
redmine_repository_path: 'repo1-test',
new_repository_name: 'redmine/repo1-test',
old_repository_name: 'redmine/repo1-test',
http_user_login: '',
git_access_path: 'redmine/repo1-test.git',
http_access_path: 'git/repo1-test.git',
ssh_url: "ssh://#{GIT_USER}@localhost/redmine/repo1-test.git",
git_url: 'git://localhost/redmine/repo1-test.git',
http_url: 'http://localhost/git/repo1-test.git',
https_url: 'https://localhost/git/repo1-test.git',
},
repository_3: {
is_default: true,
identifier: '',
url: 'repositories/redmine/project-parent.git',
root_url: 'repositories/redmine/project-parent.git',
git_cache_id: 'project-parent',
redmine_name: 'project-parent',
gitolite_repository_path: 'repositories/redmine/project-parent.git',
gitolite_full_repository_path: '/home/git/repositories/redmine/project-parent.git',
gitolite_repository_name: 'redmine/project-parent',
redmine_repository_path: 'project-parent',
new_repository_name: 'redmine/project-parent',
old_repository_name: 'redmine/project-parent',
http_user_login: '',
git_access_path: 'redmine/project-parent.git',
http_access_path: 'git/project-parent.git',
ssh_url: "ssh://#{GIT_USER}@localhost/redmine/project-parent.git",
git_url: 'git://localhost/redmine/project-parent.git',
http_url: 'http://localhost/git/project-parent.git',
https_url: 'https://localhost/git/project-parent.git',
},
repository_4: {
is_default: false,
identifier: 'repo2-test',
url: 'repositories/redmine/repo2-test.git',
root_url: 'repositories/redmine/repo2-test.git',
git_cache_id: 'repo2-test',
redmine_name: 'repo2-test',
gitolite_repository_path: 'repositories/redmine/repo2-test.git',
gitolite_full_repository_path: '/home/git/repositories/redmine/repo2-test.git',
gitolite_repository_name: 'redmine/repo2-test',
redmine_repository_path: 'repo2-test',
new_repository_name: 'redmine/repo2-test',
old_repository_name: 'redmine/repo2-test',
http_user_login: '',
git_access_path: 'redmine/repo2-test.git',
http_access_path: 'git/repo2-test.git',
ssh_url: "ssh://#{GIT_USER}@localhost/redmine/repo2-test.git",
git_url: 'git://localhost/redmine/repo2-test.git',
http_url: 'http://localhost/git/repo2-test.git',
https_url: 'https://localhost/git/repo2-test.git',
},
}
def build_collection_of_unique_repositories
@repository_1 = build_git_repository(project: @project_child, is_default: true)
@repository_1.valid?
@repository_2 = build_git_repository(project: @project_child, identifier: 'repo1-test')
@repository_2.valid?
@repository_3 = build_git_repository(project: @project_parent, is_default: true)
@repository_3.valid?
@repository_4 = build_git_repository(project: @project_parent, identifier: 'repo2-test')
@repository_4.valid?
end
def create_collection_of_unique_repositories
@repository_1 = create_git_repository(project: @project_child, is_default: true)
@repository_2 = create_git_repository(project: @project_child, identifier: 'repo1-test')
@repository_3 = create_git_repository(project: @project_parent, is_default: true)
@repository_4 = create_git_repository(project: @project_parent, identifier: 'repo2-test')
end
context 'when flat_organisation with unique_identifier: fast tests' do
before(:all) do
Setting.plugin_redmine_git_hosting[:hierarchical_organisation] = 'false'
Setting.plugin_redmine_git_hosting[:unique_repo_identifier] = 'true'
build_collection_of_unique_repositories
end
UNIQUE_REPOSITORIES_MATRIX.each do |repo, attributes|
describe repo do
attributes.each do |key, value|
if value == true || value == false
it { expect(instance_variable_get("@#{repo}").send(key)).to be value }
else
it { expect(instance_variable_get("@#{repo}").send(key)).to eq value }
end
end
end
end
end
context 'when flat_organisation with unique_identifier: long tests' do
describe '.repo_ident_unique?' do
it 'should be true' do
Setting.plugin_redmine_git_hosting[:hierarchical_organisation] = 'false'
Setting.plugin_redmine_git_hosting[:unique_repo_identifier] = 'true'
expect(Repository::Xitolite.repo_ident_unique?).to be true
end
end
describe '.have_duplicated_identifier?' do
it 'should be false' do
Setting.plugin_redmine_git_hosting[:hierarchical_organisation] = 'false'
Setting.plugin_redmine_git_hosting[:unique_repo_identifier] = 'true'
create_collection_of_unique_repositories
expect(Repository::Xitolite.have_duplicated_identifier?).to be false
end
end
describe '.repo_path_to_git_cache_id' do
before do
Setting.plugin_redmine_git_hosting[:hierarchical_organisation] = 'false'
Setting.plugin_redmine_git_hosting[:unique_repo_identifier] = 'true'
create_collection_of_unique_repositories
end
let(:repo1) { Repository::Xitolite.find_by_path(@repository_1.url, loose: true) }
let(:repo2) { Repository::Xitolite.find_by_path(@repository_2.url, loose: true) }
let(:repo3) { Repository::Xitolite.find_by_path(@repository_3.url, loose: true) }
let(:repo4) { Repository::Xitolite.find_by_path(@repository_4.url, loose: true) }
let(:git_cache_id1) { Repository::Xitolite.repo_path_to_git_cache_id(@repository_1.url) }
let(:git_cache_id2) { Repository::Xitolite.repo_path_to_git_cache_id(@repository_2.url) }
let(:git_cache_id3) { Repository::Xitolite.repo_path_to_git_cache_id(@repository_3.url) }
let(:git_cache_id4) { Repository::Xitolite.repo_path_to_git_cache_id(@repository_4.url) }
describe 'repositories should match' do
it { expect(repo1).to eq @repository_1 }
it { expect(repo2).to eq @repository_2 }
it { expect(repo3).to eq @repository_3 }
it { expect(repo4).to eq @repository_4 }
it { expect(git_cache_id1).to eq 'project-child' }
it { expect(git_cache_id2).to eq 'repo1-test' }
it { expect(git_cache_id3).to eq 'project-parent' }
it { expect(git_cache_id4).to eq 'repo2-test' }
end
end
end
end

View file

@ -1,106 +0,0 @@
module GlobalHelpers
def create_user_with_permissions(project, permissions: [], login: nil)
role = Role.find_by_name('Manager')
role = FactoryBot.create(:role, name: 'Manager') if role.nil?
role.permissions += permissions
role.save!
if login.nil?
user = FactoryBot.create(:user)
else
user = FactoryBot.create(:user, login: login)
end
member = Member.new(role_ids: [role.id], user_id: user.id)
project.members << member
user
end
def create_project(identifier = nil)
if identifier.nil?
FactoryBot.create(:project)
else
project = Project.find_by_identifier(identifier)
project = FactoryBot.create(:project, identifier: identifier) if project.nil?
project
end
end
def set_session_user(user)
request.session[:user_id] = user.id
end
def create_anonymous_user
create_user('git_anonymous')
end
def create_admin_user
create_user('git_admin', admin: true)
end
def create_user(login, admin: false)
user = User.find_by_login(login)
user = FactoryBot.create(:user, login: login, admin: admin) if user.nil?
user
end
def create_ssh_key(opts = {})
FactoryBot.create(:gitolite_public_key, opts)
end
def build_ssh_key(opts = {})
FactoryBot.build(:gitolite_public_key, opts)
end
def build_git_repository(opts = {})
FactoryBot.build(:repository_gitolite, opts)
end
def find_or_create_git_repository(opts = {})
repository = Repository::Xitolite.find_by_identifier(opts[:identifier])
if repository.nil?
repository = FactoryBot.create(:repository_gitolite, opts)
build_extra(repository)
end
repository
end
def create_git_repository(opts = {})
repository = FactoryBot.create(:repository_gitolite, opts)
build_extra(repository)
repository
end
def build_extra(repository)
extra = repository.build_extra(default_branch: 'master', key: RedmineGitHosting::Utils::Crypto.generate_secret(64))
extra.save!
end
def create_svn_repository(opts = {})
FactoryBot.create(:repository_svn, opts)
end
def load_yaml_fixture(fixture)
YAML::load(load_fixture(fixture))
end
def load_fixture(fixture)
File.read(RedmineGitHosting.plugin_spec_dir('fixtures', fixture))
end
end

View file

@ -1,190 +0,0 @@
RSpec.shared_context 'hierarchical_organisation' do
##############################################################
# #
# HIERARCHICAL ORGANISATION / NON-UNIQUE REPOSITORIES TESTS #
# #
##############################################################
NON_UNIQUE_REPOSITORIES_MATRIX = {
repository_1: {
is_default: true,
identifier: '',
url: 'repositories/redmine/project-parent/project-child.git',
root_url: 'repositories/redmine/project-parent/project-child.git',
git_cache_id: 'project-child',
redmine_name: 'project-child',
gitolite_repository_path: 'repositories/redmine/project-parent/project-child.git',
gitolite_full_repository_path: '/home/git/repositories/redmine/project-parent/project-child.git',
gitolite_repository_name: 'redmine/project-parent/project-child',
redmine_repository_path: 'project-parent/project-child',
new_repository_name: 'redmine/project-parent/project-child',
old_repository_name: 'redmine/project-parent/project-child',
http_user_login: '',
git_access_path: 'redmine/project-parent/project-child.git',
http_access_path: 'git/project-parent/project-child.git',
ssh_url: "ssh://#{GIT_USER}@localhost/redmine/project-parent/project-child.git",
git_url: 'git://localhost/redmine/project-parent/project-child.git',
http_url: 'http://localhost/git/project-parent/project-child.git',
https_url: 'https://localhost/git/project-parent/project-child.git',
},
repository_2: {
is_default: false,
identifier: 'repo-test',
url: 'repositories/redmine/project-parent/project-child/repo-test.git',
root_url: 'repositories/redmine/project-parent/project-child/repo-test.git',
git_cache_id: 'project-child/repo-test',
redmine_name: 'repo-test',
gitolite_repository_path: 'repositories/redmine/project-parent/project-child/repo-test.git',
gitolite_full_repository_path: '/home/git/repositories/redmine/project-parent/project-child/repo-test.git',
gitolite_repository_name: 'redmine/project-parent/project-child/repo-test',
redmine_repository_path: 'project-parent/project-child/repo-test',
new_repository_name: 'redmine/project-parent/project-child/repo-test',
old_repository_name: 'redmine/project-parent/project-child/repo-test',
http_user_login: '',
git_access_path: 'redmine/project-parent/project-child/repo-test.git',
http_access_path: 'git/project-parent/project-child/repo-test.git',
ssh_url: "ssh://#{GIT_USER}@localhost/redmine/project-parent/project-child/repo-test.git",
git_url: 'git://localhost/redmine/project-parent/project-child/repo-test.git',
http_url: 'http://localhost/git/project-parent/project-child/repo-test.git',
https_url: 'https://localhost/git/project-parent/project-child/repo-test.git',
},
repository_3: {
is_default: true,
identifier: '',
url: 'repositories/redmine/project-parent.git',
root_url: 'repositories/redmine/project-parent.git',
git_cache_id: 'project-parent',
redmine_name: 'project-parent',
gitolite_repository_path: 'repositories/redmine/project-parent.git',
gitolite_full_repository_path: '/home/git/repositories/redmine/project-parent.git',
gitolite_repository_name: 'redmine/project-parent',
redmine_repository_path: 'project-parent',
new_repository_name: 'redmine/project-parent',
old_repository_name: 'redmine/project-parent',
http_user_login: '',
git_access_path: 'redmine/project-parent.git',
http_access_path: 'git/project-parent.git',
ssh_url: "ssh://#{GIT_USER}@localhost/redmine/project-parent.git",
git_url: 'git://localhost/redmine/project-parent.git',
http_url: 'http://localhost/git/project-parent.git',
https_url: 'https://localhost/git/project-parent.git',
},
repository_4: {
is_default: false,
identifier: 'repo-test',
url: 'repositories/redmine/project-parent/repo-test.git',
root_url: 'repositories/redmine/project-parent/repo-test.git',
git_cache_id: 'project-parent/repo-test',
redmine_name: 'repo-test',
gitolite_repository_path: 'repositories/redmine/project-parent/repo-test.git',
gitolite_full_repository_path: '/home/git/repositories/redmine/project-parent/repo-test.git',
gitolite_repository_name: 'redmine/project-parent/repo-test',
redmine_repository_path: 'project-parent/repo-test',
new_repository_name: 'redmine/project-parent/repo-test',
old_repository_name: 'redmine/project-parent/repo-test',
http_user_login: '',
git_access_path: 'redmine/project-parent/repo-test.git',
http_access_path: 'git/project-parent/repo-test.git',
ssh_url: "ssh://#{GIT_USER}@localhost/redmine/project-parent/repo-test.git",
git_url: 'git://localhost/redmine/project-parent/repo-test.git',
http_url: 'http://localhost/git/project-parent/repo-test.git',
https_url: 'https://localhost/git/project-parent/repo-test.git',
}
}
def build_collection_of_non_unique_repositories
@repository_1 = build_git_repository(project: @project_child, is_default: true)
@repository_1.valid?
@repository_2 = build_git_repository(project: @project_child, identifier: 'repo-test')
@repository_2.valid?
@repository_3 = build_git_repository(project: @project_parent, is_default: true)
@repository_3.valid?
@repository_4 = build_git_repository(project: @project_parent, identifier: 'repo-test')
@repository_4.valid?
end
def create_collection_of_non_unique_repositories
@repository_1 = create_git_repository(project: @project_child, is_default: true)
@repository_2 = create_git_repository(project: @project_child, identifier: 'repo-test')
@repository_3 = create_git_repository(project: @project_parent, is_default: true)
@repository_4 = create_git_repository(project: @project_parent, identifier: 'repo-test')
end
context 'when hierarchical_organisation with non_unique_identifier: fast tests' do
before(:all) do
Setting.plugin_redmine_git_hosting[:hierarchical_organisation] = 'true'
Setting.plugin_redmine_git_hosting[:unique_repo_identifier] = 'false'
build_collection_of_non_unique_repositories
end
NON_UNIQUE_REPOSITORIES_MATRIX.each do |repo, attributes|
describe repo do
attributes.each do |key, value|
if value == true || value == false
it { expect(instance_variable_get("@#{repo}").send(key)).to be value }
else
it { expect(instance_variable_get("@#{repo}").send(key)).to eq value }
end
end
end
end
end
context 'when hierarchical_organisation with non_unique_identifier: long tests' do
describe '.repo_ident_unique?' do
it 'should be false' do
Setting.plugin_redmine_git_hosting[:hierarchical_organisation] = 'true'
Setting.plugin_redmine_git_hosting[:unique_repo_identifier] = 'false'
expect(Repository::Xitolite.repo_ident_unique?).to be false
end
end
describe '.have_duplicated_identifier?' do
it 'should be true' do
Setting.plugin_redmine_git_hosting[:hierarchical_organisation] = 'true'
Setting.plugin_redmine_git_hosting[:unique_repo_identifier] = 'false'
create_collection_of_non_unique_repositories
expect(Repository::Xitolite.have_duplicated_identifier?).to be true
end
end
describe '.repo_path_to_git_cache_id' do
before do
Setting.plugin_redmine_git_hosting[:hierarchical_organisation] = 'true'
Setting.plugin_redmine_git_hosting[:unique_repo_identifier] = 'false'
create_collection_of_non_unique_repositories
end
let(:repo1) { Repository::Xitolite.find_by_path(@repository_1.url, loose: true) }
let(:repo2) { Repository::Xitolite.find_by_path(@repository_2.url, loose: true) }
let(:repo3) { Repository::Xitolite.find_by_path(@repository_3.url, loose: true) }
let(:repo4) { Repository::Xitolite.find_by_path(@repository_4.url, loose: true) }
let(:git_cache_id1) { Repository::Xitolite.repo_path_to_git_cache_id(@repository_1.url) }
let(:git_cache_id2) { Repository::Xitolite.repo_path_to_git_cache_id(@repository_2.url) }
let(:git_cache_id3) { Repository::Xitolite.repo_path_to_git_cache_id(@repository_3.url) }
let(:git_cache_id4) { Repository::Xitolite.repo_path_to_git_cache_id(@repository_4.url) }
describe 'repositories should match' do
it { expect(repo1).to eq @repository_1 }
it { expect(repo2).to eq @repository_2 }
it { expect(repo3).to eq @repository_3 }
it { expect(repo4).to eq @repository_4 }
it { expect(git_cache_id1).to eq 'project-child' }
it { expect(git_cache_id2).to eq 'project-child/repo-test' }
it { expect(git_cache_id3).to eq 'project-parent' }
it { expect(git_cache_id4).to eq 'project-parent/repo-test' }
end
end
end
end