This commit is contained in:
lxp
2026-10-20 11:30:41 +08:00
parent 0631bd5ecc
commit a9a6ad6028
@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.web.servlet.MockMvc;
@@ -50,7 +51,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
"spring.datasource.url=jdbc:h2:mem:matching;MODE=MySQL;DB_CLOSE_DELAY=-1",
"spring.datasource.driver-class-name=org.h2.Driver", "spring.datasource.username=sa",
"spring.datasource.password=", "spring.sql.init.mode=never",
"app.storage.public-base-url=https://models.example.test", "logging.file.path=target/test-logs"
"app.storage.public-base-url=https://models.example.test", "logging.file.path=target/test-logs",
"app.oss.access-key-id=", "app.oss.access-key-secret="
})
@AutoConfigureMockMvc(print = org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrint.NONE)
class MatchingApiTest {
@@ -95,16 +97,18 @@ class MatchingApiTest {
}
@Test
void startsWithoutAdminOrOssBeansAndOnlyExposesUserRoutes() throws Exception {
void startsWithoutAdminBeansAndKeepsOssSdkLazyForMatching() throws Exception {
assertThat(context.getBeansOfType(AdminOperatorProvider.class)).isEmpty();
assertThat(context.getBeansOfType(ComponentUploadSessionTokenProvider.class)).isEmpty();
assertThat(context.getBeansOfType(ObjectStorageClient.class)).isEmpty();
assertThat(context.getBeansOfType(ObjectStorageClient.class)).hasSize(1);
assertThat(((ConfigurableApplicationContext) context).getBeanFactory().containsSingleton("ossClient")).isFalse();
mvc.perform(get("/admin-api/components")).andExpect(status().isNotFound());
mvc.perform(get("/api/components/CW-NO/assets/1/step")).andExpect(status().isNotFound());
JsonNode empty = match(request("TORSO_0"));
assertThat(empty.path("status").asText()).isEqualTo("NO_MATCH");
assertThat(empty.path("parts")).isEmpty();
assertThat(empty.path("missingParts").get(0).path("reason").asText()).isEqualTo("NO_COMPONENT");
assertThat(((ConfigurableApplicationContext) context).getBeanFactory().containsSingleton("ossClient")).isFalse();
}
@ParameterizedTest