diff --git a/provider/identityprovider/github.go b/provider/identityprovider/github.go index c315b6a6..f92337c3 100644 --- a/provider/identityprovider/github.go +++ b/provider/identityprovider/github.go @@ -3,7 +3,6 @@ package identityprovider import ( "context" "fmt" - "net/url" "strings" "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" @@ -91,9 +90,6 @@ func githubHostnameValidator() validator.String { // Validate hostname if !hostname.IsUnknown() && !hostname.IsNull() && len(hostname.ValueString()) > 0 { hostnameStr := hostname.ValueString() - if hostnameStr == "" { - return - } if hostnameStr == "github.com" || strings.HasSuffix(hostnameStr, ".github.com") { resp.Diagnostics.AddAttributeError(req.Path, "invalid hostname", fmt.Sprintf("'%s' hostname cannot be equal to [*.]github.com", hostnameStr), @@ -106,12 +102,6 @@ func githubHostnameValidator() validator.String { ) return } - _, err := url.ParseRequestURI(hostnameStr) - if err != nil { - resp.Diagnostics.AddAttributeError(req.Path, "invalid hostname", - fmt.Sprintf("Expected a valid GitHub hostname. Got %v", hostnameStr), - ) - } } }) } diff --git a/tests/e2e/idps_test.go b/tests/e2e/idps_test.go index 11edc151..71612608 100644 --- a/tests/e2e/idps_test.go +++ b/tests/e2e/idps_test.go @@ -566,6 +566,11 @@ var _ = Describe("Identity Providers", ci.Day2, ci.FeatureIDP, func() { } } + validateIDPArgAgainstNoError := func(svc exec.IDPService, idpArgs *exec.IDPArgs) { + _, err := svc.Apply(idpArgs) + Expect(err).ToNot(HaveOccurred()) + } + It("the mandatory idp's attributes must be set - [id:68939]", ci.Medium, func() { var err error idpServices.htpasswd, err = profileHandler.Services().GetIDPService(constants.IDPHTPassword) @@ -695,6 +700,16 @@ var _ = Describe("Identity Providers", ci.Day2, ci.FeatureIDP, func() { args.HostedDomain = helper.StringPointer(" invalid hostname ") validateIDPArgAgainstErrorSubstrings(idpServices.github, args, "hostname must be a valid DNS subdomain or IP address") + By("Create github idp with hostname myhost.com/aa") + args = getDefaultGitHubArgs(idpName) + args.HostedDomain = helper.StringPointer("myhost.com/aa") + validateIDPArgAgainstNoError(idpServices.github, args) + + By("Create github idp with hostname example.com") + args = getDefaultGitHubArgs(idpName) + args.HostedDomain = helper.StringPointer("example.com") + validateIDPArgAgainstNoError(idpServices.github, args) + By("Create github idp with empty hostname") args = getDefaultGitHubArgs(idpName) args.HostedDomain = helper.EmptyStringPointer