Merge pull request #3854 from alyssais/test_clear_sensitive_environment

Add tests for ENV#clear_sensitive_environment!
This commit is contained in:
Alyssa Ross 2018-03-02 08:31:19 +00:00 committed by GitHub
commit db7f0734c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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