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/support/shared_examples/redis/redis_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/redis/redis_shared_examples.rb64
1 files changed, 64 insertions, 0 deletions
diff --git a/spec/support/shared_examples/redis/redis_shared_examples.rb b/spec/support/shared_examples/redis/redis_shared_examples.rb
index 23ec4a632b7..1270efd4701 100644
--- a/spec/support/shared_examples/redis/redis_shared_examples.rb
+++ b/spec/support/shared_examples/redis/redis_shared_examples.rb
@@ -379,6 +379,24 @@ RSpec.shared_examples "redis_shared_examples" do
}
end
+ let(:resque_yaml_config_with_only_cert) do
+ {
+ url: 'rediss://localhost:6380',
+ ssl_params: {
+ cert_file: '/tmp/client.crt'
+ }
+ }
+ end
+
+ let(:resque_yaml_config_with_only_key) do
+ {
+ url: 'rediss://localhost:6380',
+ ssl_params: {
+ key_file: '/tmp/client.key'
+ }
+ }
+ end
+
let(:parsed_config_with_tls) do
{
url: 'rediss://localhost:6380',
@@ -389,6 +407,24 @@ RSpec.shared_examples "redis_shared_examples" do
}
end
+ let(:parsed_config_with_only_cert) do
+ {
+ url: 'rediss://localhost:6380',
+ ssl_params: {
+ cert: dummy_certificate
+ }
+ }
+ end
+
+ let(:parsed_config_with_only_key) do
+ {
+ url: 'rediss://localhost:6380',
+ ssl_params: {
+ key: dummy_key
+ }
+ }
+ end
+
before do
allow(::File).to receive(:exist?).and_call_original
allow(::File).to receive(:read).and_call_original
@@ -433,6 +469,34 @@ RSpec.shared_examples "redis_shared_examples" do
end
end
+ context 'when only certificate file is specified' do
+ before do
+ allow(::File).to receive(:exist?).with("/tmp/client.crt").and_return(true)
+ allow(::File).to receive(:read).with("/tmp/client.crt").and_return("DUMMY_CERTIFICATE")
+ allow(OpenSSL::X509::Certificate).to receive(:new).with("DUMMY_CERTIFICATE").and_return(dummy_certificate)
+ allow(::File).to receive(:exist?).with("/tmp/client.key").and_return(false)
+ end
+
+ it 'renders resque.yml correctly' do
+ expect(subject.send(:parse_client_tls_options,
+ resque_yaml_config_with_only_cert)).to eq(parsed_config_with_only_cert)
+ end
+ end
+
+ context 'when only key file is specified' do
+ before do
+ allow(::File).to receive(:exist?).with("/tmp/client.crt").and_return(false)
+ allow(::File).to receive(:exist?).with("/tmp/client.key").and_return(true)
+ allow(::File).to receive(:read).with("/tmp/client.key").and_return("DUMMY_KEY")
+ allow(OpenSSL::PKey).to receive(:read).with("DUMMY_KEY").and_return(dummy_key)
+ end
+
+ it 'renders resque.yml correctly' do
+ expect(subject.send(:parse_client_tls_options,
+ resque_yaml_config_with_only_key)).to eq(parsed_config_with_only_key)
+ end
+ end
+
context 'when configuration valid TLS related options' do
before do
allow(::File).to receive(:exist?).with("/tmp/client.crt").and_return(true)