diff --git a/README.md b/README.md index 0787f857b..1cd6312aa 100644 --- a/README.md +++ b/README.md @@ -112,10 +112,10 @@ include_v3 #### The full set of config parameters is explained below: ##### Required parameters: -* `api`: Cloud Controller API endpoint. +* `api`: Cloud Controller API endpoint, without scheme (HTTP/S) specified. * `admin_user`: Name of a user in your CF instance with admin credentials. This admin user must have the `doppler.firehose` scope. * `admin_password`: Password of the admin user above. -* `apps_domain`: A shared domain that tests can use to create subdomains that will route to applications also created in the tests. +* `apps_domain`: A shared domain that tests can use to create subdomains that will route to applications also created in the tests, without scheme (HTTP/S) specified. * `skip_ssl_validation`: Set to true if using an invalid (e.g. self-signed) cert for traffic routed to your CF instance; this is generally always true for BOSH-Lite deployments of CF. ##### Optional parameters: diff --git a/helpers/config/config_struct.go b/helpers/config/config_struct.go index 48a84cc9d..687888df1 100644 --- a/helpers/config/config_struct.go +++ b/helpers/config/config_struct.go @@ -467,9 +467,13 @@ func validateApiEndpoint(config *config) error { return fmt.Errorf("* Invalid configuration: 'api' must be a valid Cloud Controller endpoint but was blank") } + // Use URL parse to check endpoint, but we do not want users to provide a scheme/protocol u, err := url.Parse(config.GetApiEndpoint()) if err != nil { - return fmt.Errorf("* Invalid configuration: 'api' must be a valid URL but was set to '%s'", config.GetApiEndpoint()) + return fmt.Errorf("* Invalid configuration: 'api' must be a valid domain but was set to '%s'", config.GetApiEndpoint()) + } + if u.Scheme != "" { + return fmt.Errorf("* Invalid configuration: 'api' must not contain a scheme/protocol but was set to '%s' in '%s'", u.Scheme, config.GetApiEndpoint()) } host := u.Host diff --git a/helpers/config/config_test.go b/helpers/config/config_test.go index 68627e1a8..8d073e73b 100644 --- a/helpers/config/config_test.go +++ b/helpers/config/config_test.go @@ -689,7 +689,19 @@ var _ = Describe("Config", func() { It("returns an error", func() { _, err := cfg.NewCatsConfig(tmpFilePath) Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError("* Invalid configuration: 'api' must be a valid URL but was set to '_bogus%%%'")) + Expect(err).To(MatchError("* Invalid configuration: 'api' must be a valid domain but was set to '_bogus%%%'")) + }) + }) + + Context("when the url contains https://", func() { + BeforeEach(func() { + testCfg.ApiEndpoint = ptrToString("https://api.bosh-lite.com") + }) + + It("returns an error", func() { + _, err := cfg.NewCatsConfig(tmpFilePath) + Expect(err).To(HaveOccurred()) + Expect(err).To(MatchError("* Invalid configuration: 'api' must not contain a scheme/protocol but was set to 'https' in 'https://api.bosh-lite.com'")) }) })