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

@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"sync"
"time"
"github.com/ory/dockertest/v3"
@ -29,14 +30,36 @@ func ExecuteCommandTimeout(timeout time.Duration) ExecuteCommandOption {
})
}
// buffer is a goroutine safe bytes.buffer
type buffer struct {
store bytes.Buffer
mutex sync.Mutex
}
// Write appends the contents of p to the buffer, growing the buffer as needed. It returns
// the number of bytes written.
func (b *buffer) Write(p []byte) (n int, err error) {
b.mutex.Lock()
defer b.mutex.Unlock()
return b.store.Write(p)
}
// String returns the contents of the unread portion of the buffer
// as a string.
func (b *buffer) String() string {
b.mutex.Lock()
defer b.mutex.Unlock()
return b.store.String()
}
func ExecuteCommand(
resource *dockertest.Resource,
cmd []string,
env []string,
options ...ExecuteCommandOption,
) (string, string, error) {
var stdout bytes.Buffer
var stderr bytes.Buffer
var stdout = buffer{}
var stderr = buffer{}
execConfig := ExecuteCommandConfig{
timeout: dockerExecuteTimeout,