mirror of
https://github.com/komari-monitor/komari.git
synced 2026-11-20 23:08:46 +00:00
29 lines
615 B
Go
29 lines
615 B
Go
package cloudflared_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/komari-monitor/komari/utils/cloudflared"
|
|
)
|
|
|
|
func TestStatusDoesNotExposeToken(t *testing.T) {
|
|
const token = "test-cloudflare-token"
|
|
t.Setenv("KOMARI_CLOUDFLARED_TOKEN", token)
|
|
|
|
status := cloudflared.Status()
|
|
if !status.EnvTokenPresent {
|
|
t.Fatalf("expected environment token to be detected")
|
|
}
|
|
|
|
payload, err := json.Marshal(status)
|
|
if err != nil {
|
|
t.Fatalf("failed to marshal status: %v", err)
|
|
}
|
|
|
|
if strings.Contains(string(payload), token) {
|
|
t.Fatalf("expected status payload not to contain the raw token")
|
|
}
|
|
}
|