fix: enforce application limits and signature format
This commit is contained in:
@@ -323,6 +323,7 @@ describe('SmsConfigService', () => {
|
||||
interfaceEnabled: false,
|
||||
interfaceType: 'cmpp20',
|
||||
queuePriority: 'priority',
|
||||
dailyLimit: 100000,
|
||||
downstreamReceiptRetryEnabled: true,
|
||||
downstreamUplinkRetryEnabled: true,
|
||||
ipAllowlist: { create: [{ ipCidr: '10.0.0.1/32' }] },
|
||||
@@ -955,20 +956,41 @@ describe('SmsConfigService', () => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new SmsConfigService(prisma as never);
|
||||
|
||||
await service.createSignature({ tenantId: 'tenant-1', name: '运营新建签名' }, { initialAuditStatus: 'approved' });
|
||||
await service.createSignature({ tenantId: 'tenant-1', name: '【运营新建签名】' }, { initialAuditStatus: 'approved' });
|
||||
|
||||
expect(prisma.smsSignature.create).toHaveBeenCalledWith({
|
||||
data: expect.objectContaining({ auditStatus: 'approved', name: '运营新建签名' }),
|
||||
data: expect.objectContaining({ auditStatus: 'approved', name: '【运营新建签名】' }),
|
||||
});
|
||||
expect(prisma.auditRecord.create).toHaveBeenCalledWith({ data: expect.objectContaining({ action: 'admin_create_approved', statusAfter: 'approved' }) });
|
||||
});
|
||||
|
||||
it.each(['未带括号', '[英文括号]', '【【重复括号】】', '【 】'])(
|
||||
'rejects a signature name without exactly one complete Chinese black bracket pair: %s',
|
||||
async (name) => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new SmsConfigService(prisma as never);
|
||||
|
||||
await expect(service.createSignature({ tenantId: 'tenant-1', name }))
|
||||
.rejects.toThrow('短信签名必须包含完整中文黑括号,例如:【某某科技】');
|
||||
expect(prisma.smsSignature.create).not.toHaveBeenCalled();
|
||||
},
|
||||
);
|
||||
|
||||
it('rejects editing a signature to a name without complete Chinese black brackets', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new SmsConfigService(prisma as never);
|
||||
|
||||
await expect(service.updateSignature('sig-1', { name: '编辑无括号' }))
|
||||
.rejects.toThrow('短信签名必须包含完整中文黑括号,例如:【某某科技】');
|
||||
expect(prisma.smsSignature.update).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('updates enterprise signature drainage info through the admin API path', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new SmsConfigService(prisma as never);
|
||||
|
||||
await expect(service.updateSignature('sig-1', {
|
||||
name: '签名B',
|
||||
name: '【签名B】',
|
||||
auditStatus: 'approved',
|
||||
drainageInfo: {
|
||||
carrierStatus: { mobile: 'approved', unicom: 'approved', telecom: 'approved' },
|
||||
@@ -976,14 +998,14 @@ describe('SmsConfigService', () => {
|
||||
},
|
||||
})).resolves.toEqual(expect.objectContaining({
|
||||
id: 'sig-1',
|
||||
name: '签名B',
|
||||
name: '【签名B】',
|
||||
auditStatus: 'approved',
|
||||
}));
|
||||
|
||||
expect(prisma.smsSignature.update).toHaveBeenCalledWith({
|
||||
where: { id: 'sig-1' },
|
||||
data: expect.objectContaining({
|
||||
name: '签名B',
|
||||
name: '【签名B】',
|
||||
auditStatus: 'approved',
|
||||
drainageInfo: expect.objectContaining({
|
||||
carrierStatus: expect.objectContaining({ mobile: 'approved' }),
|
||||
|
||||
Reference in New Issue
Block a user