From 85ae9ee7ce53f32485d93b7c53f0d484c452d68d Mon Sep 17 00:00:00 2001 From: Thorarinn Sigurdsson <thorarinnsigurdsson@gmail.com> Date: Wed, 12 Aug 2020 09:36:50 +0200 Subject: [PATCH] fix(enterprise): validate domain as URI This prevents the user from accidentally using an invalid URI for the `domain` field (e.g. a domain that's missing the protocol prefix). --- garden-service/src/config/project.ts | 3 ++- garden-service/test/unit/src/commands/login.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/garden-service/src/config/project.ts b/garden-service/src/config/project.ts index 36801d7f2a..a74269e9c6 100644 --- a/garden-service/src/config/project.ts +++ b/garden-service/src/config/project.ts @@ -333,8 +333,9 @@ export const projectDocsSchema = () => // TODO: Refer to enterprise documentation for more details. domain: joi .string() + .uri() .meta({ internal: true }) - .description("The domain to use for cloud features. Should point to the API/backend base URL."), + .description("The domain to use for cloud features. Should be the full API/backend URL."), // Note: We provide a different schema below for actual validation, but need to define it this way for docs // because joi.alternatives() isn't handled well in the doc generation. environments: joi diff --git a/garden-service/test/unit/src/commands/login.ts b/garden-service/test/unit/src/commands/login.ts index 7e33a2f5df..bf527a928a 100644 --- a/garden-service/test/unit/src/commands/login.ts +++ b/garden-service/test/unit/src/commands/login.ts @@ -32,7 +32,7 @@ function makeCommandParams(garden: TestGarden) { describe("LoginCommand", () => { let tmpDir: tmp.DirectoryResult let projectConfig: ProjectConfig - const dummyDomain = "dummy-domain" + const dummyDomain = "http://dummy-domain.com" before(async () => { tmpDir = await tmp.dir({ unsafeCleanup: true })