@@ -1561,7 +1561,7 @@ func TestDeleteApiCredentials_PoolGuardVsStoreFault(t *testing.T) {
15611561 t .Fatalf ("seed oauth cred %q: %v" , n , err )
15621562 }
15631563 }
1564- if err := st .CreatePoolWithMembers ("p" , "failover" , []string {"m" , "n" }); err != nil {
1564+ if err := st .CreatePoolWithMembers ("p" , "failover" , []string {"m" , "n" }, "" ); err != nil {
15651565 t .Fatalf ("create pool: %v" , err )
15661566 }
15671567
@@ -2801,7 +2801,7 @@ func TestPostApiPools_DuplicateName(t *testing.T) {
28012801 st := newTestStore (t )
28022802 enableHTTPChannel (t , st )
28032803 seedOAuthCred (t , st , "credA" , "credB" )
2804- if err := st .CreatePoolWithMembers ("dup_pool" , store .PoolStrategyFailover , []string {"credA" }); err != nil {
2804+ if err := st .CreatePoolWithMembers ("dup_pool" , store .PoolStrategyFailover , []string {"credA" }, "" ); err != nil {
28052805 t .Fatalf ("seed pool: %v" , err )
28062806 }
28072807 srv := api .NewServer (st , nil , nil , "" )
@@ -2851,7 +2851,7 @@ func TestPostApiPools_MemberAlreadyPooled(t *testing.T) {
28512851 st := newTestStore (t )
28522852 enableHTTPChannel (t , st )
28532853 seedOAuthCred (t , st , "credA" , "credB" )
2854- if err := st .CreatePoolWithMembers ("pool_one" , store .PoolStrategyFailover , []string {"credA" }); err != nil {
2854+ if err := st .CreatePoolWithMembers ("pool_one" , store .PoolStrategyFailover , []string {"credA" }, "" ); err != nil {
28552855 t .Fatalf ("seed pool: %v" , err )
28562856 }
28572857 srv := api .NewServer (st , nil , nil , "" )
@@ -2955,7 +2955,7 @@ func TestGetApiPoolsName_Status(t *testing.T) {
29552955 st := newTestStore (t )
29562956 enableHTTPChannel (t , st )
29572957 seedOAuthCred (t , st , "credA" , "credB" )
2958- if err := st .CreatePoolWithMembers ("pool1" , store .PoolStrategyFailover , []string {"credA" , "credB" }); err != nil {
2958+ if err := st .CreatePoolWithMembers ("pool1" , store .PoolStrategyFailover , []string {"credA" , "credB" }, "" ); err != nil {
29592959 t .Fatalf ("create pool: %v" , err )
29602960 }
29612961 srv := api .NewServer (st , nil , nil , "" )
@@ -3011,7 +3011,7 @@ func TestPostApiPoolsNameRotate_Success(t *testing.T) {
30113011 st := newTestStore (t )
30123012 enableHTTPChannel (t , st )
30133013 seedOAuthCred (t , st , "credA" , "credB" )
3014- if err := st .CreatePoolWithMembers ("pool1" , store .PoolStrategyFailover , []string {"credA" , "credB" }); err != nil {
3014+ if err := st .CreatePoolWithMembers ("pool1" , store .PoolStrategyFailover , []string {"credA" , "credB" }, "" ); err != nil {
30153015 t .Fatalf ("create pool: %v" , err )
30163016 }
30173017 srv := api .NewServer (st , nil , nil , "" )
@@ -3051,7 +3051,7 @@ func TestPostApiPoolsNameAuthResetTarget(t *testing.T) {
30513051 st := newTestStore (t )
30523052 enableHTTPChannel (t , st )
30533053 seedOAuthCred (t , st , "credA" , "credB" )
3054- if err := st .CreatePoolWithMembers ("pool1" , store .PoolStrategyFailover , []string {"credA" , "credB" }); err != nil {
3054+ if err := st .CreatePoolWithMembers ("pool1" , store .PoolStrategyFailover , []string {"credA" , "credB" }, "" ); err != nil {
30553055 t .Fatalf ("create pool: %v" , err )
30563056 }
30573057 srv := api .NewServer (st , nil , nil , "" )
@@ -3067,7 +3067,12 @@ func TestPostApiPoolsNameAuthResetTarget(t *testing.T) {
30673067 return rec
30683068 }
30693069
3070- // Set a target.
3070+ // Set a target. The 200 path returns the full, schema-complete pool via a
3071+ // read-back: name+strategy+members are all required by the OpenAPI Pool
3072+ // schema. (The read-back-failure fallback returns 204 No Content rather
3073+ // than a partial Pool that would violate that schema — Copilot #2 — but
3074+ // that path is not reachable here without failing the store mid-handler,
3075+ // which the concrete *store.Store gives no seam for.)
30713076 rec := post (`{"auth_reset_target": "openai-codex"}` )
30723077 if rec .Code != http .StatusOK {
30733078 t .Fatalf ("set: expected 200, got %d: %s" , rec .Code , rec .Body .String ())
@@ -3079,6 +3084,16 @@ func TestPostApiPoolsNameAuthResetTarget(t *testing.T) {
30793084 if p .AuthResetTarget == nil || * p .AuthResetTarget != "openai-codex" {
30803085 t .Fatalf ("response AuthResetTarget = %v, want openai-codex" , p .AuthResetTarget )
30813086 }
3087+ // Schema completeness: the OpenAPI Pool schema requires name+strategy+members.
3088+ if p .Name != "pool1" {
3089+ t .Errorf ("200 body name = %q, want pool1" , p .Name )
3090+ }
3091+ if p .Strategy != store .PoolStrategyFailover {
3092+ t .Errorf ("200 body strategy = %q, want %q" , p .Strategy , store .PoolStrategyFailover )
3093+ }
3094+ if len (p .Members ) != 2 {
3095+ t .Fatalf ("200 body members = %+v, want 2 (credA, credB)" , p .Members )
3096+ }
30823097 // Reached the store (no inline logic; routed through poolops).
30833098 got , err := st .GetPool ("pool1" )
30843099 if err != nil {
@@ -3147,6 +3162,16 @@ func TestPostApiPools_WithAuthResetTarget(t *testing.T) {
31473162 if rec .Code != http .StatusCreated {
31483163 t .Fatalf ("expected 201, got %d: %s" , rec .Code , rec .Body .String ())
31493164 }
3165+ // The 201 response body must reflect the configured target. The synthetic
3166+ // store.Pool the handler builds when the read-back is skipped/fails used to
3167+ // omit it (Copilot #1), so assert it round-trips through the JSON body.
3168+ var p api.Pool
3169+ if err := json .NewDecoder (rec .Body ).Decode (& p ); err != nil {
3170+ t .Fatalf ("decode 201 body: %v" , err )
3171+ }
3172+ if p .AuthResetTarget == nil || * p .AuthResetTarget != "openai-codex" {
3173+ t .Fatalf ("201 body AuthResetTarget = %v, want openai-codex" , p .AuthResetTarget )
3174+ }
31503175 got , err := st .GetPool ("codex" )
31513176 if err != nil {
31523177 t .Fatalf ("GetPool: %v" , err )
@@ -3178,7 +3203,7 @@ func TestDeleteApiPoolsName_Success(t *testing.T) {
31783203 st := newTestStore (t )
31793204 enableHTTPChannel (t , st )
31803205 seedOAuthCred (t , st , "credA" , "credB" )
3181- if err := st .CreatePoolWithMembers ("pool1" , store .PoolStrategyFailover , []string {"credA" , "credB" }); err != nil {
3206+ if err := st .CreatePoolWithMembers ("pool1" , store .PoolStrategyFailover , []string {"credA" , "credB" }, "" ); err != nil {
31823207 t .Fatalf ("create pool: %v" , err )
31833208 }
31843209 srv := api .NewServer (st , nil , nil , "" )
@@ -3225,7 +3250,7 @@ func TestDeleteApiPoolsName_ReferencedByBinding(t *testing.T) {
32253250 st := newTestStore (t )
32263251 enableHTTPChannel (t , st )
32273252 seedOAuthCred (t , st , "credA" , "credB" )
3228- if err := st .CreatePoolWithMembers ("pool1" , store .PoolStrategyFailover , []string {"credA" , "credB" }); err != nil {
3253+ if err := st .CreatePoolWithMembers ("pool1" , store .PoolStrategyFailover , []string {"credA" , "credB" }, "" ); err != nil {
32293254 t .Fatalf ("create pool: %v" , err )
32303255 }
32313256 // A binding referencing the pool by name keeps it from being removed.
0 commit comments