test(ci): OapiFlowTasksByBizTest 补来源主体/许可/开通桩
build / build-push (push) Successful in 1m37s

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 通过
This commit is contained in:
chenxing
2026-10-30 10:24:25 +08:00
parent d72128672f
commit 0f2883c1af
@@ -62,6 +62,45 @@ class OapiFlowTasksByBizTest extends FlowTestSupport {
public com.yunhai.flowcenter.stub.StubUserClient stubUserClient() { public com.yunhai.flowcenter.stub.StubUserClient stubUserClient() {
return new com.yunhai.flowcenter.stub.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 @BeforeEach
@@ -81,6 +120,8 @@ class OapiFlowTasksByBizTest extends FlowTestSupport {
} }
} }
cleanDb(); 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); client = new OapiSignedClient("http://localhost:" + port, APP_KEY, APP_SECRET);
} }