Add tests for ENV#clear_sensitive_environment!

This commit is contained in:
Alyssa Ross 2018-03-01 17:48:08 +00:00
parent 43c658a8fa
commit 84dda31e82
No known key found for this signature in database
GPG Key ID: 6CF064D149E3ABDB
2 changed files with 16 additions and 2 deletions

View File

@ -28,9 +28,9 @@ module EnvActivation
end
def clear_sensitive_environment!
ENV.each_key do |key|
each_key do |key|
next unless /(cookie|key|token|password)/i =~ key
ENV.delete key
delete key
end
end
end

View File

@ -141,6 +141,20 @@ shared_examples EnvActivation do
expect(subject["MAKEFLAGS"]).to eq("-j4")
end
describe "#clear_sensitive_environment!" do
it "removes sensitive environment variables" do
subject["SECRET_TOKEN"] = "password"
subject.clear_sensitive_environment!
expect(subject).not_to include("SECRET_TOKEN")
end
it "leaves non-sensitive environment variables alone" do
subject["FOO"] = "bar"
subject.clear_sensitive_environment!
expect(subject["FOO"]).to eq "bar"
end
end
end
describe Stdenv do