60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
//go:build integration
|
|
|
|
package admin_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ultisuite/ulti-backend/internal/integrationtest"
|
|
)
|
|
|
|
func TestAdminOrgSettings(t *testing.T) {
|
|
h := integrationtest.RequireHarness(t)
|
|
adminClient, _ := integrationtest.RequireAdminClient(t, h)
|
|
|
|
getResp, err := adminClient.Get("/api/v1/admin/org/settings")
|
|
integrationtest.FailIf(err, t, "get org settings")
|
|
integrationtest.FailUnlessStatus(t, getResp, 200)
|
|
|
|
var initial map[string]any
|
|
integrationtest.DecodeJSON(t, getResp, &initial)
|
|
policy, ok := initial["policy"].(map[string]any)
|
|
if !ok {
|
|
t.Fatalf("missing policy: %#v", initial)
|
|
}
|
|
storage, ok := policy["storage_quotas"].(map[string]any)
|
|
if !ok {
|
|
t.Fatalf("missing storage_quotas: %#v", policy)
|
|
}
|
|
if storage["default_mail_gib"] == nil {
|
|
t.Fatalf("expected default_mail_gib in policy")
|
|
}
|
|
|
|
putResp, err := adminClient.Put("/api/v1/admin/org/settings", map[string]any{
|
|
"policy": map[string]any{
|
|
"storage_quotas": map[string]any{
|
|
"default_mail_gib": 10,
|
|
},
|
|
"usage_quotas": map[string]any{
|
|
"llm_requests_per_day": 200,
|
|
},
|
|
},
|
|
})
|
|
integrationtest.FailIf(err, t, "put org settings")
|
|
integrationtest.FailUnlessStatus(t, putResp, 200)
|
|
|
|
var updated map[string]any
|
|
integrationtest.DecodeJSON(t, putResp, &updated)
|
|
updatedPolicy, ok := updated["policy"].(map[string]any)
|
|
if !ok {
|
|
t.Fatalf("missing policy after update: %#v", updated)
|
|
}
|
|
updatedStorage, ok := updatedPolicy["storage_quotas"].(map[string]any)
|
|
if !ok {
|
|
t.Fatalf("missing storage_quotas after update")
|
|
}
|
|
if updatedStorage["default_mail_gib"] != float64(10) {
|
|
t.Fatalf("default_mail_gib = %v, want 10", updatedStorage["default_mail_gib"])
|
|
}
|
|
}
|