diff options
Diffstat (limited to 'spec/lib/gitlab/fips_spec.rb')
-rw-r--r-- | spec/lib/gitlab/fips_spec.rb | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/spec/lib/gitlab/fips_spec.rb b/spec/lib/gitlab/fips_spec.rb index 2ede2e3adf3..4d19a44f617 100644 --- a/spec/lib/gitlab/fips_spec.rb +++ b/spec/lib/gitlab/fips_spec.rb @@ -6,16 +6,46 @@ RSpec.describe Gitlab::FIPS do describe ".enabled?" do subject { described_class.enabled? } - context "feature flag is enabled" do - it { is_expected.to be_truthy } + let(:openssl_fips_mode) { false } + let(:fips_mode_env_var) { nil } + + before do + expect(OpenSSL).to receive(:fips_mode).and_return(openssl_fips_mode) + stub_env("FIPS_MODE", fips_mode_env_var) + end + + describe "OpenSSL auto-detection" do + context "OpenSSL is in FIPS mode" do + let(:openssl_fips_mode) { true } + + it { is_expected.to be_truthy } + end + + context "OpenSSL is not in FIPS mode" do + let(:openssl_fips_mode) { false } + + it { is_expected.to be_falsey } + end end - context "feature flag is disabled" do - before do - stub_feature_flags(fips_mode: false) + describe "manual configuration via env var" do + context "env var is not set" do + let(:fips_mode_env_var) { nil } + + it { is_expected.to be_falsey } end - it { is_expected.to be_falsey } + context "env var is set to true" do + let(:fips_mode_env_var) { "true" } + + it { is_expected.to be_truthy } + end + + context "env var is set to false" do + let(:fips_mode_env_var) { "false" } + + it { is_expected.to be_falsey } + end end end end |