Backfill test cases

This commit is contained in:
Joshua Casey 2023-06-07 21:33:54 -05:00
parent 10c3e482b4
commit 5004925444
2 changed files with 15 additions and 1 deletions

View File

@ -44,6 +44,10 @@ func (p *FederationDomainIssuer) validate() error {
return constable.Error(`issuer must have "https" scheme`) return constable.Error(`issuer must have "https" scheme`)
} }
if issuerURL.Hostname() == "" {
return constable.Error(`issuer must have a hostname`)
}
if issuerURL.User != nil { if issuerURL.User != nil {
return constable.Error(`issuer must not have username or password`) return constable.Error(`issuer must not have username or password`)
} }

View File

@ -1,4 +1,4 @@
// Copyright 2020 the Pinniped contributors. All Rights Reserved. // Copyright 2020-2023 the Pinniped contributors. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
package provider package provider
@ -20,6 +20,16 @@ func TestFederationDomainIssuerValidations(t *testing.T) {
issuer: "", issuer: "",
wantError: "federation domain must have an issuer", wantError: "federation domain must have an issuer",
}, },
{
name: "returns url.Parse errors",
issuer: "https://example.com" + string(byte(0x7f)),
wantError: "could not parse issuer as URL: parse \"https://example.com\\x7f\": net/url: invalid control character in URL",
},
{
name: "no hostname",
issuer: "https://",
wantError: `issuer must have a hostname`,
},
{ {
name: "no scheme", name: "no scheme",
issuer: "tuna.com", issuer: "tuna.com",