forked from kubernetes/minikube
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(util): Move maskProxyPassword to pkg/util, update references…
… & tests, introduced MaskProxyPasswordWithKey refactor(util): Move maskProxyPassword to pkg/util, update references & tests, introduced MaskProxyPasswordWithKey
- Loading branch information
1 parent
ed5eb17
commit 89f58c8
Showing
5 changed files
with
145 additions
and
109 deletions.
There are no files selected for viewing
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 was deleted.
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 |
---|---|---|
|
@@ -208,3 +208,105 @@ func TestRemoveDuplicateStrings(t *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
func TestMaskProxyPassword(t *testing.T) { | ||
type dockerOptTest struct { | ||
input string | ||
output string | ||
} | ||
var tests = []dockerOptTest{ | ||
{ | ||
input: "cats", | ||
output: "cats", | ||
}, | ||
{ | ||
input: "myDockerOption=value", | ||
output: "myDockerOption=value", | ||
}, | ||
{ | ||
input: "http://minikube.sigs.k8s.io", | ||
output: "http://minikube.sigs.k8s.io", | ||
}, | ||
{ | ||
input: "http://[email protected]:8080", | ||
output: "http://[email protected]:8080", | ||
}, | ||
{ | ||
input: "https://mary:[email protected]:8080", | ||
output: "https://mary:*****@minikube.sigs.k8s.io:8080", | ||
}, | ||
{ | ||
input: "http://jdoe:%n0tRe@al:[email protected]:8080", | ||
output: "http://jdoe:*****@minikube.sigs.k8s.io:8080", | ||
}, | ||
{ | ||
input: "http://jo@han:n0tRe@al:&[email protected]:8080", | ||
output: "http://jo@han:*****@minikube.sigs.k8s.io:8080", | ||
}, | ||
{ | ||
input: "http://k@r3n!:an0th3erF@akeP@[email protected]", | ||
output: "http://k@r3n!:*****@minikube.sigs.k8s.io", | ||
}, | ||
{ | ||
input: "https://fr@ank5t3in:an0th3erF@akeP@[email protected]", | ||
output: "https://fr@ank5t3in:*****@minikube.sigs.k8s.io", | ||
}, | ||
} | ||
for _, test := range tests { | ||
got := MaskProxyPassword(test.input) | ||
if got != test.output { | ||
t.Errorf("MaskProxyPassword(\"%v\"): got %v, expected %v", test.input, got, test.output) | ||
} | ||
} | ||
} | ||
|
||
func TestMaskProxyPasswordWithKey(t *testing.T) { | ||
type dockerOptTest struct { | ||
input string | ||
output string | ||
} | ||
var tests = []dockerOptTest{ | ||
{ | ||
input: "cats", | ||
output: "cats", | ||
}, | ||
{ | ||
input: "myDockerOption=value", | ||
output: "myDockerOption=value", | ||
}, | ||
{ | ||
input: "http_proxy=http://minikube.sigs.k8s.io", | ||
output: "HTTP_PROXY=http://minikube.sigs.k8s.io", | ||
}, | ||
{ | ||
input: "https_proxy=http://[email protected]:8080", | ||
output: "HTTPS_PROXY=http://[email protected]:8080", | ||
}, | ||
{ | ||
input: "https_proxy=https://mary:[email protected]:8080", | ||
output: "HTTPS_PROXY=https://mary:*****@minikube.sigs.k8s.io:8080", | ||
}, | ||
{ | ||
input: "http_proxy=http://jdoe:%n0tRe@al:[email protected]:8080", | ||
output: "HTTP_PROXY=http://jdoe:*****@minikube.sigs.k8s.io:8080", | ||
}, | ||
{ | ||
input: "http_proxy=http://jo@han:n0tRe@al:&[email protected]:8080", | ||
output: "HTTP_PROXY=http://jo@han:*****@minikube.sigs.k8s.io:8080", | ||
}, | ||
{ | ||
input: "http_proxy=http://k@r3n!:an0th3erF@akeP@[email protected]", | ||
output: "HTTP_PROXY=http://k@r3n!:*****@minikube.sigs.k8s.io", | ||
}, | ||
{ | ||
input: "https_proxy=https://fr@ank5t3in:an0th3erF@akeP@[email protected]", | ||
output: "HTTPS_PROXY=https://fr@ank5t3in:*****@minikube.sigs.k8s.io", | ||
}, | ||
} | ||
for _, test := range tests { | ||
got := MaskProxyPasswordWithKey(test.input) | ||
if got != test.output { | ||
t.Errorf("MaskProxyPasswordWithKey(\"%v\"): got %v, expected %v", test.input, got, test.output) | ||
} | ||
} | ||
} |