From 0f2883c1af13d22edb48a88ef65df328a02c8d68 Mon Sep 17 00:00:00 2001 From: chenxing Date: Fri, 30 Oct 2026 10:24:25 +0800 Subject: [PATCH] =?UTF-8?q?test(ci):=20OapiFlowTasksByBizTest=20=E8=A1=A5?= =?UTF-8?q?=E6=9D=A5=E6=BA=90=E4=B8=BB=E4=BD=93/=E8=AE=B8=E5=8F=AF/?= =?UTF-8?q?=E5=BC=80=E9=80=9A=E6=A1=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI 门禁用例在无 UserBase 的容器内被 fail-closed 拒绝(code=4 调用应用主体解析不可用)。 本类靶子是 by-biz 的 0/1/N 与"不探测他人办件"语义,主体解析与授权链由 FlUsageGrantTest / OapiFlowContractIT 覆盖,故: - @Primary FlowSourcePrincipalResolver 桩:固定 ub-app:100001 - 发布即补绑定来源的 grant;@MockBean UserBaseActivationClient 固定已开通 本地以 CI 同款 schema(flowcenter_ci_local + ddl-auto=validate)复跑 11/11 通过 --- .../oapi/OapiFlowTasksByBizTest.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/test/java/com/yunhai/flowcenter/oapi/OapiFlowTasksByBizTest.java b/src/test/java/com/yunhai/flowcenter/oapi/OapiFlowTasksByBizTest.java index 8ad9bd5..48b8389 100644 --- a/src/test/java/com/yunhai/flowcenter/oapi/OapiFlowTasksByBizTest.java +++ b/src/test/java/com/yunhai/flowcenter/oapi/OapiFlowTasksByBizTest.java @@ -62,6 +62,45 @@ class OapiFlowTasksByBizTest extends FlowTestSupport { public com.yunhai.flowcenter.stub.StubUserClient stubUserClient() { return new com.yunhai.flowcenter.stub.StubUserClient(); } + + /** + * 来源主体解析桩:真实实现要出站查 UserBase 应用注册表,CI 容器内不可达即 fail-closed。 + * 本类靶子是 by-biz 的 0/1/N 与"不探测他人办件"语义,主体解析由 FlUsageGrantTest 覆盖。 + */ + @Bean + @Primary + public com.yunhai.flowcenter.service.FlowSourcePrincipalResolver stubSourceResolver() { + return new com.yunhai.flowcenter.service.FlowSourcePrincipalResolver(null) { + @Override + public com.yunhai.flowcenter.service.FlowSourcePrincipalResolver.Principal resolve(String appKey) { + return new com.yunhai.flowcenter.service.FlowSourcePrincipalResolver.Principal( + "ub-app:100001", 100001, appKey, "flow-test"); + } + }; + } + } + + @Autowired + private com.yunhai.flowcenter.repository.FlwUsageGrantRepository grantRepository; + + @org.springframework.boot.test.mock.mockito.MockBean + private com.yunhai.flowcenter.service.UserBaseActivationClient activationClient; + + /** + * 许可闸前置(C03):本类每条流程线都要能发起,故发布即补一条绑定来源的生效 grant; + * 开通校验(第二道闸)真实实现出网,这里固定为已开通。 + */ + @Override + protected FlwDef saveAndPublishDef(String code, String name, String contentJson) { + FlwDef def = super.saveAndPublishDef(code, name, contentJson); + com.yunhai.flowcenter.entity.FlwUsageGrant grant = new com.yunhai.flowcenter.entity.FlwUsageGrant(); + grant.setSchId(SCH); + grant.setFlowGuid(def.getFlowGuid()); + grant.setAppId(100001); + grant.setSourcePrincipalId("ub-app:100001"); + grant.setEnabled(1); + grantRepository.saveAndFlush(grant); + return def; } @BeforeEach @@ -81,6 +120,8 @@ class OapiFlowTasksByBizTest extends FlowTestSupport { } } cleanDb(); + org.mockito.Mockito.when(activationClient.isAppActivatedStrict( + org.mockito.ArgumentMatchers.anyInt(), org.mockito.ArgumentMatchers.anyLong())).thenReturn(true); client = new OapiSignedClient("http://localhost:" + port, APP_KEY, APP_SECRET); }