From a07ede4949ab6526ac69d9fc99ef691d6f7806c6 Mon Sep 17 00:00:00 2001 From: Marco Dinis Date: Thu, 28 Nov 2024 14:21:57 +0000 Subject: [PATCH] Hostname validation: document invalid hostnames --- docs/pages/admin-guides/management/guides/ec2-tags.mdx | 2 +- docs/pages/admin-guides/management/guides/gcp-tags.mdx | 2 +- lib/utils/utils_test.go | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/pages/admin-guides/management/guides/ec2-tags.mdx b/docs/pages/admin-guides/management/guides/ec2-tags.mdx index 409cc020efc31..93338221fd7b6 100644 --- a/docs/pages/admin-guides/management/guides/ec2-tags.mdx +++ b/docs/pages/admin-guides/management/guides/ec2-tags.mdx @@ -10,7 +10,7 @@ this way will have the `aws/` prefix. When the Teleport process starts, it fetch the instance metadata service and adds them as labels. The process will update the tags every hour, so newly created or deleted tags will be reflected in the labels. -If the tag `TeleportHostname` (case-sensitive) is present, its value will override the node's hostname. +If the tag `TeleportHostname` is present, its value (must be lower case) will override the node's hostname. ```code $ tsh ls diff --git a/docs/pages/admin-guides/management/guides/gcp-tags.mdx b/docs/pages/admin-guides/management/guides/gcp-tags.mdx index 80e9451716d10..031f8679b5bef 100644 --- a/docs/pages/admin-guides/management/guides/gcp-tags.mdx +++ b/docs/pages/admin-guides/management/guides/gcp-tags.mdx @@ -17,7 +17,7 @@ When the Teleport process starts, it fetches all tags and labels from the GCP API and adds them as labels. The process will update the tags every hour, so newly created or deleted tags will be reflected in the labels. -If the GCP label `TeleportHostname` (case-sensitive) is present, its value will override the node's hostname. This +If the GCP label `TeleportHostname` is present, its value (must be lower case) will override the node's hostname. This does not apply to GCP tags. ```code diff --git a/lib/utils/utils_test.go b/lib/utils/utils_test.go index e1625915bb204..075d99b3f9e98 100644 --- a/lib/utils/utils_test.go +++ b/lib/utils/utils_test.go @@ -234,6 +234,16 @@ func TestIsValidHostname(t *testing.T) { hostname: "some-host-1.example.com", assert: require.True, }, + { + name: "only lower case works", + hostname: "only-lower-case-works", + assert: require.True, + }, + { + name: "mixed upper case fails", + hostname: "mixed-UPPER-CASE-fails", + assert: require.False, + }, { name: "one component", hostname: "example",