package feature_test import ( "testing" "go.laravel.com/auth/social" "go.laravel.com/laraveltest" "app/tests" ) func TestDexLoginRequiresAnAllowedVerifiedOperator(t *testing.T) { t.Setenv("OPSPROOF_OPERATOR_EMAILS", "operator@example.test") client := tests.New(t, laraveltest.Env(map[string]string{ "OPSPROOF_DEX_ISSUER": "https://auth.example.test", "OPSPROOF_DEX_CLIENT_SECRET": "test-secret", "OPSPROOF_OPERATOR_EMAILS": "operator@example.test", })) client.WithoutRedirects().Get("/incidents/cluster/n8n").AssertRedirect("/login") allowed := client.FakeSocial("dex", &social.Profile{ ID: "dex-operator", Name: "Homelab Operator", Email: "operator@example.test", EmailVerified: true, }) allowed.WithoutRedirects().Get("/auth/dex/callback").AssertRedirect("/") allowed.Get("/").AssertOK().AssertInertia("Welcome").AssertProp("operator.authenticated", true) } func TestDexLoginRejectsAnUnlistedIdentity(t *testing.T) { t.Setenv("OPSPROOF_OPERATOR_EMAILS", "operator@example.test") client := tests.New(t, laraveltest.Env(map[string]string{ "OPSPROOF_DEX_ISSUER": "https://auth.example.test", "OPSPROOF_DEX_CLIENT_SECRET": "test-secret", "OPSPROOF_OPERATOR_EMAILS": "operator@example.test", })).FakeSocial("dex", &social.Profile{ ID: "dex-other", Name: "Other User", Email: "other@example.test", EmailVerified: true, }) client.Get("/auth/dex/callback").AssertForbidden() }