mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Add tests for ENV#clear_sensitive_environment!
This commit is contained in:
parent
43c658a8fa
commit
84dda31e82
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user