Skip to content

Commit

Permalink
Fix TestParseJwksURI that relies on golang version (#16518)
Browse files Browse the repository at this point in the history
* Fix TestParseJwksURI that relies on golang version

* Fix lint
  • Loading branch information
howardjohn authored and istio-testing committed Aug 23, 2019
1 parent 7b1c2e6 commit 87ef53e
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions pkg/config/security/security_test.go
Expand Up @@ -23,21 +23,21 @@ import (

func TestParseJwksURI(t *testing.T) {
cases := []struct {
in string
expected security.JwksInfo
expectedErrorMessage string
in string
expected security.JwksInfo
expectedError bool
}{
{
in: "foo.bar.com",
expectedErrorMessage: `URI scheme "" is not supported`,
in: "foo.bar.com",
expectedError: true,
},
{
in: "tcp://foo.bar.com:abc",
expectedErrorMessage: `URI scheme "tcp" is not supported`,
in: "tcp://foo.bar.com:abc",
expectedError: true,
},
{
in: "http://foo.bar.com:abc",
expectedErrorMessage: `strconv.Atoi: parsing "abc": invalid syntax`,
in: "http://foo.bar.com:abc",
expectedError: true,
},
{
in: "http://foo.bar.com",
Expand Down Expand Up @@ -78,17 +78,11 @@ func TestParseJwksURI(t *testing.T) {
}
for _, c := range cases {
actual, err := security.ParseJwksURI(c.in)
if err != nil {
if c.expectedErrorMessage != err.Error() {
t.Errorf("ParseJwksURI(%s): expected error (%s), got (%v)", c.in, c.expectedErrorMessage, err)
}
} else {
if c.expectedErrorMessage != "" {
t.Errorf("ParseJwksURI(%s): expected error (%s), got no error", c.in, c.expectedErrorMessage)
}
if !reflect.DeepEqual(c.expected, actual) {
t.Errorf("expected %+v, got %+v", c.expected, actual)
}
if c.expectedError == (err == nil) {
t.Fatalf("ParseJwksURI(%s): expected error (%v), got (%v)", c.in, c.expectedError, err)
}
if !reflect.DeepEqual(c.expected, actual) {
t.Fatalf("expected %+v, got %+v", c.expected, actual)
}
}
}

0 comments on commit 87ef53e

Please sign in to comment.