package rest

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestNewServerUsesEphemeralJWTSecretWhenUnset(t *testing.T) {
	t.Setenv("JWT_SECRET", "")

	first := NewServer(nil, 138)
	second := NewServer(nil, 138)

	require.NotEmpty(t, first.jwtSecret)
	require.NotEmpty(t, second.jwtSecret)
	require.NotEqual(t, []byte("change-me-in-production-use-strong-random-secret"), first.jwtSecret)
	require.NotEqual(t, string(first.jwtSecret), string(second.jwtSecret))
}
