Skip to content

Commit 27a9375

Browse files
committed
test
1 parent 183be22 commit 27a9375

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,55 @@ describe('Certificate', () => {
332332
expect(certificateWithMismatch.certifier).toBe(certifierPubKey)
333333
expect(await certificateWithMismatch.verify()).toBe(true)
334334
})
335+
336+
it('should create a Certificate from an object using fromObject()', () => {
337+
const certificateObject = {
338+
type: 'Q29tbW9uU291cmNlIGlkZW50aXR5',
339+
subject: '028e2e075e1e57ba4c62c90125468109f9b4e2a7741da3dd76ccd0c73b2a8a37ad',
340+
serialNumber: 'UegX3uufsqHsbEKeBSxUd9AziLSyru86TnwfhPoZJYE=',
341+
certifier: '03c644fe2fd97673a5d86555a58587e7936390be6582ece262bc387014bcff6fe4',
342+
revocationOutpoint: '0245242bd144a85053b4c1e4a0ed5467c79a4d172680ca77a970ebabd682d564.0',
343+
signature: '304402202c86ef816c469fe657289ddea12d2c444f006ef5ab5851f00107c7724eb67ea602202786244c077567c8f3ec5da78bd61ce0c35bf1eeac0488e026c03b21c403b0fd',
344+
fields: {
345+
displayName: 'eqsSpUgTKk891y1EkyCPPg+C4YoVZJvB0EQ4iore7VofkM5TB9Ctj7x2PgBaWI0A9tfATDO9',
346+
email: 'n6HVUvyHkIDMvB4ERxVGxmX6lgRBM+e7kbbC5DiRCKe5a60BJeXr05g4POq6OHYO9Wl/b1Xxe+JKsejl',
347+
phoneNumber: '5yWyN9kOGaZs5G6yvXUWnWj4rm7kDAug4YIsn4BQLKGYRzDx8s1dytb43ega6BnSp0gUTnskcjiM8ekqul2a',
348+
lat: 'lc3u6SFKQ5Mpxp5vc+6s4aXe7lOyQQLfN+CbOu4XlBYsj7Jlc78gt4sGCwDSxbzvA41eElCjlc2Our5bpLcsg1I6',
349+
lng: 'FmY3iM/2/LDfYNEeXpcj7Epn933tRHz50WoBkBrqYv6jmZ6dXE6RRYId9TcaxIvB0D7Y14aD5vjSV6Bx48hdic5g'
350+
}
351+
}
352+
353+
const certificate = Certificate.fromObject(certificateObject)
354+
355+
expect(certificate.type).toEqual(certificateObject.type)
356+
expect(certificate.serialNumber).toEqual(certificateObject.serialNumber)
357+
expect(certificate.subject).toEqual(certificateObject.subject)
358+
expect(certificate.certifier).toEqual(certificateObject.certifier)
359+
expect(certificate.revocationOutpoint).toEqual(certificateObject.revocationOutpoint)
360+
expect(certificate.signature).toEqual(certificateObject.signature)
361+
expect(certificate.fields).toEqual(certificateObject.fields)
362+
})
363+
364+
it('should create a Certificate from an object without signature using fromObject()', () => {
365+
const certificateObject = {
366+
type: 'Q29tbW9uU291cmNlIGlkZW50aXR5',
367+
subject: '028e2e075e1e57ba4c62c90125468109f9b4e2a7741da3dd76ccd0c73b2a8a37ad',
368+
serialNumber: 'UegX3uufsqHsbEKeBSxUd9AziLSyru86TnwfhPoZJYE=',
369+
certifier: '03c644fe2fd97673a5d86555a58587e7936390be6582ece262bc387014bcff6fe4',
370+
revocationOutpoint: '0245242bd144a85053b4c1e4a0ed5467c79a4d172680ca77a970ebabd682d564.0',
371+
fields: {
372+
displayName: 'eqsSpUgTKk891y1EkyCPPg+C4YoVZJvB0EQ4iore7VofkM5TB9Ctj7x2PgBaWI0A9tfATDO9'
373+
}
374+
}
375+
376+
const certificate = Certificate.fromObject(certificateObject)
377+
378+
expect(certificate.type).toEqual(certificateObject.type)
379+
expect(certificate.serialNumber).toEqual(certificateObject.serialNumber)
380+
expect(certificate.subject).toEqual(certificateObject.subject)
381+
expect(certificate.certifier).toEqual(certificateObject.certifier)
382+
expect(certificate.revocationOutpoint).toEqual(certificateObject.revocationOutpoint)
383+
expect(certificate.signature).toBeUndefined()
384+
expect(certificate.fields).toEqual(certificateObject.fields)
385+
})
335386
})

0 commit comments

Comments
 (0)