Skip to content
Snippets Groups Projects
Commit 2d899432 authored by DJ Mountney's avatar DJ Mountney
Browse files

Merge branch 'john_long-add-selinux-module-for-gitlab-shell' into 'master'

Add selinux module for gitlab-shell

Closes #5694

See merge request gitlab-org/omnibus-gitlab!4598
parents a48e48ee 35755fb6
Branches andrey-remove-group-caching
No related tags found
No related merge requests found
require 'chef_helper'
RSpec.describe GitlabWorkhorseHelper do
let(:node) { chef_run.node }
subject { described_class.new(node) }
before do
allow(Gitlab).to receive(:[]).and_call_original
end
context 'workhorse is listening on a tcp socket' do
cached(:chef_run) { converge_config }
let(:tcp_address) { '1.9.8.4' }
before do
stub_gitlab_rb(
gitlab_workhorse: {
listen_network: 'http',
listen_addr: tcp_address
}
)
end
describe '#unix_socket?' do
it 'returns false' do
expect(subject.unix_socket?).to be false
end
end
end
context 'workhorse is listening on a unix socket' do
cached(:chef_run) { converge_config }
before do
stub_gitlab_rb(
gitlab_workhorse: {
listen_network: 'unix'
}
)
end
describe '#unix_socket?' do
it 'returns true' do
expect(subject.unix_socket?).to be true
end
end
end
end
# This spec is to test the Workhorse library and whether the values parsed
# are the ones we expect
require 'chef_helper'
RSpec.describe 'GitlabWorkhorse' do
let(:node) { chef_run.node }
let(:user_socket) { '/where/is/my/ten/mm/socket_now' }
let(:user_sockets_directory) { '/where/is/my/ten/mm/sockets' }
let(:default_sockets_directory) { '/var/opt/gitlab/gitlab-workhorse/sockets' }
let(:default_socket) { '/var/opt/gitlab/gitlab-workhorse/sockets/socket' }
let(:tcp_listen_address) { '1.9.8.4' }
before do
allow(Gitlab).to receive(:[]).and_call_original
end
context '.parse_variables' do
context 'listening on a tcp socket' do
let(:chef_run) { converge_config }
before do
stub_gitlab_rb(
gitlab_workhorse: {
listen_network: 'http',
listen_addr: tcp_listen_address
}
)
end
it 'uses the user configured TCP listen address' do
expect(node['gitlab']['gitlab-workhorse']['listen_addr']).to eq(tcp_listen_address)
end
it 'keeps the sockets_directory as nil' do
expect(node['gitlab']['gitlab-workhorse']['sockets_directory']).to eq(nil)
end
end
context 'listening on a unix socket' do
context 'using default configuration' do
let(:chef_run) { converge_config }
before do
stub_gitlab_rb(
gitlab_workhorse: {
listen_network: 'unix'
}
)
end
it 'uses the default sockets directory' do
expect(node['gitlab']['gitlab-workhorse']['sockets_directory']).to eq(default_sockets_directory)
end
it 'uses the default socket file path' do
expect(node['gitlab']['gitlab-workhorse']['listen_addr']).to eq(default_socket)
end
end
context 'only listen_addr is set' do
let(:chef_run) { converge_config }
before do
stub_gitlab_rb(
gitlab_workhorse: {
listen_network: 'unix',
listen_addr: user_socket
}
)
end
it 'uses the user configured listen address' do
expect(node['gitlab']['gitlab-workhorse']['listen_addr']).to eq(user_socket)
end
it 'keeps the sockets_directory as nil' do
expect(node['gitlab']['gitlab-workhorse']['sockets_directory']).to eq(nil)
end
end
context 'only sockets_directory is set' do
let(:chef_run) { converge_config }
before do
stub_gitlab_rb(
gitlab_workhorse: {
listen_network: 'unix',
sockets_directory: user_sockets_directory
}
)
end
it 'uses the user configured sockets directory' do
expect(node['gitlab']['gitlab-workhorse']['sockets_directory']).to eq(user_sockets_directory)
end
it 'creates a socket named socket in the user configured sockets directory' do
expect(node['gitlab']['gitlab-workhorse']['listen_addr']).to eq("#{user_sockets_directory}/socket")
end
end
context 'listen_addr and sockets_directory are both set' do
let(:chef_run) { converge_config }
before do
stub_gitlab_rb(
gitlab_workhorse: {
listen_network: 'unix',
listen_addr: user_socket,
sockets_directory: user_sockets_directory
}
)
end
it 'uses the user configured sockets directory' do
expect(node['gitlab']['gitlab-workhorse']['sockets_directory']).to eq(user_sockets_directory)
end
it 'creates a socket matching the configured listen_addr' do
expect(node['gitlab']['gitlab-workhorse']['listen_addr']).to eq(user_socket)
end
end
end
end
end
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