ensure final dot on node name (#2503)

* ensure final dot on node name

This ensures that nodes which have a base domain set, will have a dot appended to their FQDN.

Resolves: https://github.com/juanfont/headscale/issues/2501

* improve OIDC TTL expire test

Waiting a bit more than the TTL of the OIDC token seems to remove some flakiness of this test. This furthermore makes use of a go func safe buffer which should avoid race conditions.
This commit is contained in:
Nick 2025-04-11 12:39:08 +02:00 committed by GitHub
parent 0d3134720b
commit 109989005d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 67 additions and 13 deletions

View file

@ -364,7 +364,7 @@ func (node *Node) GetFQDN(baseDomain string) (string, error) {
if baseDomain != "" {
hostname = fmt.Sprintf(
"%s.%s",
"%s.%s.",
node.GivenName,
baseDomain,
)

View file

@ -142,7 +142,7 @@ func TestNodeFQDN(t *testing.T) {
},
},
domain: "example.com",
want: "test.example.com",
want: "test.example.com.",
},
{
name: "all-set",
@ -153,7 +153,7 @@ func TestNodeFQDN(t *testing.T) {
},
},
domain: "example.com",
want: "test.example.com",
want: "test.example.com.",
},
{
name: "no-given-name",
@ -171,7 +171,7 @@ func TestNodeFQDN(t *testing.T) {
GivenName: strings.Repeat("a", 256),
},
domain: "example.com",
wantErr: fmt.Sprintf("failed to create valid FQDN (%s.example.com): hostname too long, cannot except 255 ASCII chars", strings.Repeat("a", 256)),
wantErr: fmt.Sprintf("failed to create valid FQDN (%s.example.com.): hostname too long, cannot except 255 ASCII chars", strings.Repeat("a", 256)),
},
{
name: "no-dnsconfig",
@ -182,7 +182,7 @@ func TestNodeFQDN(t *testing.T) {
},
},
domain: "example.com",
want: "test.example.com",
want: "test.example.com.",
},
}