Skip to content

Commit 869c90b

Browse files
Test coverage update
1 parent a3da3f3 commit 869c90b

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

src/auth/certificates/__tests/MasterCertificate.test.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ describe('MasterCertificate', () => {
364364
organization: 'SelfCo'
365365
}
366366

367-
// ✅ FIX: resolve the subject's identity key as proper hex
368367
const subjectIdentityKey = (
369368
await subjectWallet.getPublicKey({ identityKey: true })
370369
).publicKey
@@ -382,10 +381,43 @@ describe('MasterCertificate', () => {
382381
subjectWallet,
383382
selfSignedCert.masterKeyring,
384383
selfSignedCert.fields,
385-
'self' // still fine here if decryptFields treats 'self' specially
384+
'self' // still fine here if decryptFields treats 'self' specially
386385
)
387386

388387
expect(decrypted).toEqual(selfSignedFields)
389388
})
390389
})
391-
})
390+
391+
describe('issueCertificateForSubject subject identity resolution', () => {
392+
it('resolves subject === "self" to the certifier wallet identity key', async () => {
393+
const certifierIdentity = (
394+
await certifierWallet.getPublicKey({ identityKey: true })
395+
).publicKey
396+
397+
const fields = { foo: 'bar' }
398+
399+
const cert = await MasterCertificate.issueCertificateForSubject(
400+
certifierWallet,
401+
'self',
402+
fields,
403+
'TEST_CERT'
404+
)
405+
406+
expect(cert.subject).toBe(certifierIdentity)
407+
})
408+
409+
it('uses provided subjectIdentityKey when subject is a valid hex string', async () => {
410+
const providedSubject = 'a'.repeat(64); // valid 32-byte hex
411+
412+
const fields = { foo: 'bar' }
413+
414+
const cert = await MasterCertificate.issueCertificateForSubject(
415+
certifierWallet,
416+
providedSubject,
417+
fields,
418+
'TEST_CERT'
419+
)
420+
421+
expect(cert.subject).toBe(providedSubject)
422+
})
423+
})

0 commit comments

Comments
 (0)