feat: package Beijing test deployment with HTTPS and preflight checks
This commit is contained in:
1 parent
ae749a1fe9
commit
c7278c00a6
33 files changed
+1153
-54
No files matched your search
+49
@@ -0,0 +1,49 @@
|
||||
package com.moyi.controlplane.gateway;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.moyi.controlplane.auth.AuthService;
|
||||
import com.moyi.controlplane.catalog.CatalogService;
|
||||
import com.moyi.controlplane.security.SecretCipher;
|
||||
import com.moyi.controlplane.usage.UsageAuditService;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class PostgresBindingTest {
|
||||
@Test
|
||||
void keyIdUsesNativeUuidBinding() {
|
||||
JdbcTemplate jdbc = mock(JdbcTemplate.class);
|
||||
AuthService auth = mock(AuthService.class);
|
||||
when(auth.requireUser("session")).thenReturn(new AuthService.UserView(UUID.randomUUID(), "admin", "username", "Admin", "admin", "active", null, null));
|
||||
doAnswer(call -> {
|
||||
Object[] bindings = (Object[]) call.getRawArguments()[1];
|
||||
assertInstanceOf(UUID.class, bindings[0]);
|
||||
return 1;
|
||||
}).when(jdbc).update(startsWith("INSERT INTO platform_api_keys"), any(Object[].class));
|
||||
doReturn(Map.of("name", "test")).when(jdbc).queryForObject(anyString(), any(RowMapper.class), any(Object[].class));
|
||||
new CatalogService(jdbc, new ObjectMapper(), mock(SecretCipher.class)).createKey("session", Map.of("name", "test"), auth);
|
||||
verify(jdbc).update(startsWith("INSERT INTO platform_api_keys"), any(Object[].class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void oversizedAuditPayloadIsStillValidJsonb() {
|
||||
JdbcTemplate jdbc = mock(JdbcTemplate.class);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
doAnswer(call -> {
|
||||
Object[] bindings = (Object[]) call.getRawArguments()[1];
|
||||
String payload = (String) bindings[11];
|
||||
assertTrue(payload.length() <= 32000);
|
||||
assertTrue(mapper.readTree(payload).get("_truncated").asBoolean());
|
||||
return 1;
|
||||
}).when(jdbc).update(startsWith("INSERT INTO usage_events"), any(Object[].class));
|
||||
new UsageAuditService(jdbc, mapper).recordCall(UUID.randomUUID(), UUID.randomUUID(), "model", "provider", "succeeded", 5, 0, 0,
|
||||
List.of("x".repeat(8000), "y".repeat(8000), "z".repeat(8000), "w".repeat(8000), "v".repeat(8000)), null, null, null);
|
||||
verify(jdbc).update(startsWith("INSERT INTO usage_events"), any(Object[].class));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user