-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13751 from bparees/clear_proxy
Merged by openshift-bot
- Loading branch information
Showing
42 changed files
with
704 additions
and
5,058 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import ( | |
"strings" | ||
"testing" | ||
|
||
"github.com/fsouza/go-dockerclient" | ||
docker "github.com/fsouza/go-dockerclient" | ||
) | ||
|
||
type FakeDocker struct { | ||
|
@@ -522,3 +522,44 @@ func TestSimpleProgress(t *testing.T) { | |
} | ||
} | ||
} | ||
|
||
var credsRegex = regexp.MustCompile("user:password") | ||
var redactedRegex = regexp.MustCompile("redacted") | ||
|
||
func TestSafeForLoggingDockerCreateOptions(t *testing.T) { | ||
opts := &docker.CreateContainerOptions{ | ||
Config: &docker.Config{ | ||
|
||
Env: []string{ | ||
"http_proxy=http://user:[email protected]", | ||
"ignore=http://user:[email protected]", | ||
}, | ||
}, | ||
} | ||
stripped := SafeForLoggingDockerCreateOptions(opts) | ||
if credsRegex.MatchString(stripped.Config.Env[0]) { | ||
t.Errorf("stripped proxy variable %s should not contain credentials", stripped.Config.Env[0]) | ||
} | ||
if !redactedRegex.MatchString(stripped.Config.Env[0]) { | ||
t.Errorf("stripped proxy variable %s should contain redacted", stripped.Config.Env[0]) | ||
} | ||
if !credsRegex.MatchString(stripped.Config.Env[1]) { | ||
t.Errorf("stripped other variable %s should contain credentials", stripped.Config.Env[1]) | ||
} | ||
if redactedRegex.MatchString(stripped.Config.Env[1]) { | ||
t.Errorf("stripped other variable %s should not contain redacted", stripped.Config.Env[1]) | ||
} | ||
|
||
if !credsRegex.MatchString(opts.Config.Env[0]) { | ||
t.Errorf("original proxy variable %s should contain credentials", opts.Config.Env[0]) | ||
} | ||
if redactedRegex.MatchString(opts.Config.Env[0]) { | ||
t.Errorf("original proxy variable %s should not contain redacted", opts.Config.Env[0]) | ||
} | ||
if !credsRegex.MatchString(opts.Config.Env[1]) { | ||
t.Errorf("original other variable %s should contain credentials", opts.Config.Env[1]) | ||
} | ||
if redactedRegex.MatchString(opts.Config.Env[1]) { | ||
t.Errorf("original other variable %s should not contain redacted", opts.Config.Env[1]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.