diff --git a/openspec/changes/add-zh-cn-messages/tasks.md b/openspec/changes/add-zh-cn-messages/tasks.md index 82870ef..6c3823f 100644 --- a/openspec/changes/add-zh-cn-messages/tasks.md +++ b/openspec/changes/add-zh-cn-messages/tasks.md @@ -25,6 +25,7 @@ Verify commands: ## 3. Gateway - [x] 3.1 Narrow the token bypass from any `/message/` URL to the exact read paths in use (grep the callers first), plus `/locale/findAllEnabled`. Tests cover open reads and token-gated writes. Security code: read the whole diff. + - Found in the live check: the gateway had no `/locale/**` route, so the registry answered 404. Added the route with a test. - Verify: `mvn -T 1C -B -q -pl solvway-api-gateway -am verify` ## 4. mobile-api @@ -48,7 +49,7 @@ Verify commands: ## 6. Chinese - [x] 6.1 `zh_CN.seed.json` for every `defaultMessages.ts` key, following the glossary in design decision 7. Guard tests: full coverage, equal placeholders, no extra keys. -- [ ] 6.2 Generator `npm run i18n:sql` writing `sql/03-zh-cn-messages.sql`. It upserts zh_CN, inserts missing rows with English, aligns the four English rows and bumps the version. A test checks the committed SQL matches the generator. Mirror it into `local/seed/04-zh-cn-messages.sql`. +- [x] 6.2 Generator `npm run i18n:sql` writing `sql/03-zh-cn-messages.sql`. It upserts zh_CN, inserts missing rows with English, aligns the four English rows and bumps the version. A test checks the committed SQL matches the generator. Mirror it into `local/seed/04-zh-cn-messages.sql`. - Verify: portal verify, then apply the SQL to the local DB and confirm the catalog endpoint returns Chinese for a sample of keys. ## 7. Release diff --git a/solvway-api-gateway/src/main/resources/application.yml b/solvway-api-gateway/src/main/resources/application.yml index 8e336df..81c5e40 100644 --- a/solvway-api-gateway/src/main/resources/application.yml +++ b/solvway-api-gateway/src/main/resources/application.yml @@ -53,6 +53,10 @@ spring: uri: http://${app.services.name.system} predicates: - Path=/message/** + - id: locale + uri: http://${app.services.name.system} + predicates: + - Path=/locale/** - id: module uri: http://${app.services.name.system} predicates: diff --git a/solvway-api-gateway/src/test/java/com/solvway/gateway/LocaleRouteTest.java b/solvway-api-gateway/src/test/java/com/solvway/gateway/LocaleRouteTest.java new file mode 100644 index 0000000..8346d7a --- /dev/null +++ b/solvway-api-gateway/src/test/java/com/solvway/gateway/LocaleRouteTest.java @@ -0,0 +1,28 @@ +package com.solvway.gateway; + +import org.junit.jupiter.api.Test; +import org.yaml.snakeyaml.Yaml; + +import java.io.InputStream; +import java.util.List; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +/** add-zh-cn-messages: mobile-api reaches services-system's /locale/* language registry through the gateway. */ +class LocaleRouteTest { + + @Test + @SuppressWarnings("unchecked") + void localePathsRouteToServicesSystem() throws Exception { + try (InputStream in = getClass().getResourceAsStream("/application.yml")) { + Map yml = new Yaml().load(in); + Map gateway = (Map) ((Map) ((Map) yml.get("spring")).get("cloud")).get("gateway"); + List> routes = (List>) gateway.get("routes"); + assertThat(routes).anySatisfy(r -> { + assertThat(r.get("uri")).isEqualTo("http://${app.services.name.system}"); + assertThat((List) r.get("predicates")).contains("Path=/locale/**"); + }); + } + } +}