feat: extend enterprise gateway policies billing protocols and operations
This commit is contained in:
1 parent
1528b71882
commit
af43947b5d
67 files changed
+1822
-69
No files matched your search
+5
-1
@@ -82,6 +82,7 @@ class PlatformAdminPostgresTest {
|
||||
context.registerBean(DataSource.class, () -> source);
|
||||
context.registerBean(DataSourceTransactionManager.class, () -> new DataSourceTransactionManager(source));
|
||||
context.registerBean(AuthService.class, () -> new AuthService(jdbc, new PasswordHasher("test-pepper"), json, 168));
|
||||
context.registerBean(TotpService.class, () -> new TotpService(jdbc,new SecretCipher("test-mfa")));
|
||||
context.registerBean(CatalogService.class, () -> new CatalogService(jdbc, json, new SecretCipher("test-encryption")));
|
||||
context.registerBean(WalletService.class, () -> new WalletService(jdbc, context.getBean(AuthService.class)));
|
||||
context.registerBean(UsageAuditService.class, () -> new UsageAuditService(jdbc,json));
|
||||
@@ -371,6 +372,7 @@ class PlatformAdminPostgresTest {
|
||||
ChatFixture chatFixture() {
|
||||
var model=new LinkedHashMap<>(catalog.listModels(false).stream().filter(m -> "provider-deepseek".equals(m.get("providerId"))).findFirst().orElseThrow());
|
||||
model.put("pricing",Map.of("input",2,"output",4,"cachedInput",1,"unit","CNY / 1M tokens"));
|
||||
jdbc.update("UPDATE model_catalog SET pricing='{"+"\"input\":2,\"output\":4,\"cachedInput\":1,\"unit\":\"CNY / 1M tokens\"}'::jsonb WHERE id=?",model.get("id"));
|
||||
var created=catalog.createKey(memberToken,Map.of("name","Local billing test","modelIds",List.of(model.get("id"))),auth);
|
||||
var key=catalog.authenticateKey(created.get("key").toString());
|
||||
var input=ChatMeter.request(Map.of("model",model.get("id"),"messages",List.of(Map.of("role","user","content","你好")),"max_tokens",16),json);
|
||||
@@ -444,9 +446,11 @@ class PlatformAdminPostgresTest {
|
||||
var f=chatFixture();
|
||||
assertEquals("INSUFFICIENT_BALANCE",assertThrows(ApiException.class,()->f.reserve(null)).getCode());
|
||||
f.model().remove("pricing");
|
||||
jdbc.update("UPDATE model_catalog SET pricing=NULL WHERE id=?",f.model().get("id"));
|
||||
assertEquals("MODEL_NOT_PRICED",assertThrows(ApiException.class,()->f.reserve(null)).getCode());
|
||||
f.model().put("pricing",Map.of("input",1,"output",2,"unit","USD / 1M tokens"));
|
||||
assertEquals("MODEL_NOT_PRICED",assertThrows(ApiException.class,()->f.reserve(null)).getCode());
|
||||
jdbc.update("UPDATE model_catalog SET pricing='{"+"\"input\":1,\"output\":2,\"unit\":\"USD / 1M tokens\"}'::jsonb WHERE id=?",f.model().get("id"));
|
||||
assertEquals("BILLING_UNIT_UNSUPPORTED",assertThrows(ApiException.class,()->f.reserve(null)).getCode());
|
||||
assertEquals(0,jdbc.queryForObject("SELECT count(*) FROM chat_billing_requests",Integer.class));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user