summaryrefslogtreecommitdiff
path: root/internal/config/config_test.go
diff options
context:
space:
mode:
authorChia <Chia@93.nz>2026-08-05 00:26:25 +1200
committerChia <Chia@93.nz>2026-08-05 00:33:31 +1200
commit1a3d7f9a8a181df48f0e911cbe17a3fad3ab9ac9 (patch)
tree8c92e1e7326fc67ed077a0a878697f1be14b43da /internal/config/config_test.go
parent5b651488b081b65fda8a323f228e139adb79a35d (diff)
add some scriptsmain
Diffstat (limited to 'internal/config/config_test.go')
-rw-r--r--internal/config/config_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index e681508..2331b0f 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -85,6 +85,31 @@ func TestLoadRejectsAdminWithoutControlPlane(t *testing.T) {
}
}
+func TestLoadResolvesStripeSecrets(t *testing.T) {
+ t.Setenv("AIGW_DATABASE_URL", "postgres://aigw:aigw@postgres/aigw")
+ t.Setenv("AIGW_CREDENTIAL_KEY", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")
+ t.Setenv("TEST_STRIPE_KEY", "rk_test_example")
+ t.Setenv("TEST_STRIPE_WEBHOOK", "whsec_example")
+ path := writeConfig(t, `{
+ "control_plane":{"enabled":true},
+ "billing":{"enabled":true,"stripe":{"enabled":true,"api_key_env":"TEST_STRIPE_KEY","webhook_secret_env":"TEST_STRIPE_WEBHOOK","success_url":"http://localhost/admin/?topup=success","cancel_url":"http://localhost/admin/?topup=cancel"}}
+}`)
+ cfg, err := Load(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if cfg.Billing.Stripe.APIKey != "rk_test_example" || cfg.Billing.Stripe.WebhookSecret != "whsec_example" {
+ t.Fatal("Stripe secrets were not resolved")
+ }
+}
+
+func TestLoadRejectsBillingWithoutControlPlane(t *testing.T) {
+ path := writeConfig(t, `{"billing":{"enabled":true}}`)
+ if _, err := Load(path); err == nil {
+ t.Fatal("expected billing without control plane to be rejected")
+ }
+}
+
func writeConfig(t *testing.T, content string) string {
t.Helper()
path := filepath.Join(t.TempDir(), "config.json")