Harden composite group product surfaces

This commit is contained in:
Heatherm Huang
2026-07-23 09:19:25 +08:00
parent ebc1028771
commit c8d1e2e16f
20 changed files with 570 additions and 45 deletions
@@ -40,3 +40,23 @@ func TestCompositeTargetPlatformAllowedRejectsWrongOrUnknownModel(t *testing.T)
})
}
}
func TestCompositeTargetPlatformResolvedRejectsUnknownModel(t *testing.T) {
gin.SetMode(gin.TestMode)
c, _ := gin.CreateTestContext(httptest.NewRecorder())
c.Request = httptest.NewRequest("POST", "/v1/messages", nil)
apiKey := &service.APIKey{Group: &service.Group{Platform: service.PlatformComposite}}
require.False(t, compositeTargetPlatformResolved(c, apiKey, "llama-4-maverick"))
_, ok := service.ResolvedTargetPlatformFromContext(c.Request.Context())
require.False(t, ok)
}
func TestCompositeTargetPlatformResolvedAllowsConcreteGroupWithoutResolution(t *testing.T) {
gin.SetMode(gin.TestMode)
c, _ := gin.CreateTestContext(httptest.NewRecorder())
c.Request = httptest.NewRequest("POST", "/v1/messages", nil)
apiKey := &service.APIKey{Group: &service.Group{Platform: service.PlatformAnthropic}}
require.True(t, compositeTargetPlatformResolved(c, apiKey, "llama-4-maverick"))
}