summaryrefslogtreecommitdiff
path: root/internal/config/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-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")