fix: default tenant PNVS secrets to sms scope

This commit is contained in:
Codex
2026-07-03 22:54:36 +08:00
parent 9f4fd6530a
commit cd0f465689
3 changed files with 39 additions and 1 deletions

View File

@@ -7996,6 +7996,31 @@ async function testTenantAdminOps() {
assert.equal(authProvider.item?.secret?.hasSecretValue, true, 'auth provider should report masked secret status');
assert.ok(!JSON.stringify(authProvider).includes('wechat-app-secret-smoke'), 'auth provider response must not include secret plaintext');
const pnvsAuthProvider = await request('/api/tenant-admin/auth-providers', {
userId: TENANT_ADMIN_USER_ID,
method: 'PUT',
body: {
provider: 'aliyun-pnvs',
displayName: '阿里云短信认证',
status: 'testing',
configPublic: {
signName: '短信签名',
templateCode: 'SMS_123456789',
endpoint: 'https://dypnsapi.aliyuncs.com',
},
secret: {
secretJson: {
accessKeyId: 'pnvs-access-key-id',
accessKeySecret: 'pnvs-access-key-secret',
},
},
},
});
assert.equal(pnvsAuthProvider.item?.provider, 'aliyun-pnvs', 'tenant admin should upsert PNVS auth provider');
assert.equal(pnvsAuthProvider.item?.configPublic?.secretRef, 'app_private.tenant_secrets:sms:aliyun-pnvs', 'PNVS auth provider should default secrets to sms scope');
assert.equal(pnvsAuthProvider.item?.secret?.hasSecretJson, true, 'PNVS auth provider should report masked JSON secret status');
assert.ok(!JSON.stringify(pnvsAuthProvider).includes('pnvs-access-key-secret'), 'PNVS auth provider response must not include secret plaintext');
const miniappLogin = await request('/api/auth/oauth/wechat-miniapp', {
userId: false,
method: 'POST',