testcase for POST certs

This commit is contained in:
Andris Reinman 2021-05-19 19:43:13 +03:00
parent a03c97a943
commit 2d381db260
2 changed files with 19 additions and 2 deletions

View file

@ -101,6 +101,7 @@ class CertHandler {
try {
const parsedCert = forge.pki.certificateFromPem(primaryCert);
certData.expires = new Date(parsedCert.validity.notAfter.toISOString());
certData.altNames = this.getAltNames(parsedCert);

View file

@ -501,8 +501,7 @@ describe('API tests', function () {
},
subject: 'hello world',
text: 'Hello hello world!',
html:
'<p>Hello hello world! <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" /></p>'
html: '<p>Hello hello world! <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" /></p>'
};
const response = await server.post(`/users/${userId}/mailboxes/${inbox}/messages`).send(message);
@ -571,4 +570,21 @@ describe('API tests', function () {
expect(response.body.results[0].name).to.equal('test töster');
});
});
describe('certs', () => {
it('should POST certs', async () => {
const response1 = await server
.post(`/certs`)
.send({
privateKey:
'-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDKC9G9BJlpJdKI\nMNsjLTgCthKBrtQy3TI4AC5FooqyMIxcpNllI5Mu63IPHRaBGE9+O07oHtYhPq/E\nq3SVBk0+lK346nHofZqVDWeWuiHFL2ilfhP1bFKbr5GtTWr3ctg5K1VVn/CTTPvv\nhvDlIEEaqa125jRVGabdQ53Wu6scY4IgrgFC6qnMZLuYTrmjnVCAehWxtQhPXH+R\n3nszHhUMcgKnDSv331p4AnPDZinv5SixbhizdOoFPFBDAdX4CXmwi3MiBz9FwMgA\nz6fGboW0DDxmm3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6EvoWjOOhFd1M9hy6XemAVTTix5ff7GzOx+ylwcoaNhW\nTEtB3hWRJmbmqBgojUL2/iHQYpkQiBoxIa7tXgy2eFaEHix/Qt3ivEPte7kOSz53\nAsIaoM78oZNm5A3EgzsFyJbjWv/JNgmeKN4E0PoS\n-----END CERTIFICATE-----',
description: 'test key',
servername: 'mydomain.com'
})
.expect(200);
expect(response1.body.fingerprint).to.equal('6a:bc:80:54:22:30:d2:4e:20:74:e1:11:df:f0:bb:6d:93:4a:f8:82:ee:48:79:8e:17:2e:ad:80:83:06:62:97');
expect(response1.body.altNames).to.deep.equal(['www.mydomain.com', 'mydomain.com', '*.mydomain.com', 'another.com']);
});
});
});