mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-01-13 19:38:51 +08:00
c60373bbfe
* added new file to test git repo setup * remove test.txt Add api-tests-table.md file to keep track of api endpoints, method and their test count + test types (and their count) * add js script to parse files in the /lib/api folder and retrieve a map of apiPath -> apiMethod * delete parseApiFiles.js as it is unneeded * add global (per test run) beforeEach and after hooks to collect test data and create an overview table * update tests to conform to new test title structure * add expectations to tests * remove old api-tests-table.md that was handmade * add expectations to tests in the api-test.js file * add GET endpoint /api-methods/:arg to fetch all api endpoints for testing purposes only * add and fix and refactor _globals-test.js file in the api test/api folder. Use global beforeEach and after hook to generate test overview table in api-test-overview.md file * add missing newline at the end of file * fix with prettier * api.js fix style, remove unnecessary comments, remove :arg * make first post,put,delete,get regex case insensitive, fix call to /api-methods * _globals-test.js fixes * fix some test titles --------- Co-authored-by: Nikolai Ovtsinnikov <nikolai@zone.ee>
63 lines
2.9 KiB
JavaScript
63 lines
2.9 KiB
JavaScript
/*eslint no-unused-expressions: 0, prefer-arrow-callback: 0, no-console:0 */
|
|
|
|
'use strict';
|
|
|
|
const supertest = require('supertest');
|
|
const chai = require('chai');
|
|
|
|
const expect = chai.expect;
|
|
chai.config.includeStack = true;
|
|
const config = require('wild-config');
|
|
|
|
const server = supertest.agent(`http://127.0.0.1:${config.api.port}`);
|
|
|
|
describe('API DKIM', function () {
|
|
let dkim;
|
|
|
|
this.timeout(10000); // eslint-disable-line no-invalid-this
|
|
|
|
it('should POST /dkim expect success', async () => {
|
|
const response = await server
|
|
.post('/dkim')
|
|
.send({
|
|
domain: 'example.com',
|
|
selector: 'wildduck',
|
|
privateKey:
|
|
'-----BEGIN RSA PRIVATE KEY-----\nMIICXQIBAAKBgQDFCPszabID2MLAzzfja3/TboKp4dHUGSkl6hNSly7IRdAhfh6J\nh6vNa+2Y7pyNagX00ukycZ/03O/93X3UxjzX/NpLESo3GwSjp39R4AgdW91nKt7X\nzGoz4ZQELAao+AH1QhJ8vumXFLFc6sS9l7Eu3+cZcAdWij2TCPKrB56tMQIDAQAB\nAoGAAQNfz07e1Hg74CPwpKG74Yly8I6xtoZ+mKxQdx9B5VO+kz2DyK9C6eaBLUUk\n1vFRoIWpH1JIQUkVjtehuwNd8rgPacPZRjSJrGuvwtP/bjzA8m/z/lI0+rfQW7L7\nRfPoi2fl6MJ3KkjNypmVPPNvtJA42aPUDW6SFcXFvSv43gECQQD12RFLlZ5H3W6z\n2ncJXiZha508LoyABkYeb+veCFwicoNEreQrToDgC3GuBRkODsUgRZaVu2sa4tlv\nzO0rwkXRAkEAzSvmAxTvkSf/gMy5mO+sZKeUEtMHibF4LKxw7Men2oADgVTnS38r\nf8uYJteLt3lkfHfV5ezEOERvQutKnMfpYQJBAL7apceUvkyyBWfQWIrIMWl9vpHi\n3SXiOPsWDfjPap8/YNKnYDOSfQ/xMm5S/NFh+/yCqVVSKuKzavOVFiXbapECQQDC\nhWdK7rN/xRNaUz93/2xL9hHOkyNnacoNWOSrqVO8NnicSxoLmyNrw2SbFusRZdde\npuM2XfdffYqbQKd545OhAkBiCm/hUl5+hCJI6xl4wh3aR4h8j/TA6/u4ohPjqYco\nLUPpKBaWeKdwQRbkkpMsVz6lFtpyZlV6V8joGEd8OLMO\n-----END RSA PRIVATE KEY-----',
|
|
description: 'Some text about this DKIM certificate',
|
|
sess: '12345',
|
|
ip: '127.0.0.1'
|
|
})
|
|
.expect(200);
|
|
expect(response.body.success).to.be.true;
|
|
expect(/^[0-9a-f]{24}$/.test(response.body.id)).to.be.true;
|
|
dkim = response.body.id;
|
|
});
|
|
|
|
it('should GET /dkim/:dkim expect success', async () => {
|
|
const response = await server.get(`/dkim/${dkim}`).expect(200);
|
|
|
|
expect(response.body.success).to.be.true;
|
|
expect(response.body.id).to.equal(dkim);
|
|
});
|
|
|
|
it('should GET /dkim/resolve/:domain expect success', async () => {
|
|
const response = await server.get(`/dkim/resolve/example.com`).expect(200);
|
|
expect(response.body.success).to.be.true;
|
|
expect(response.body.id).to.equal(dkim);
|
|
});
|
|
|
|
it('should GET /dkim expect success', async () => {
|
|
const response = await server.get(`/dkim`).expect(200);
|
|
|
|
expect(response.body.success).to.be.true;
|
|
expect(response.body.results.length).to.equal(1);
|
|
expect(response.body.results.find(entry => entry.id === dkim)).to.exist;
|
|
});
|
|
|
|
it('should DELETE /dkim/:dkim expect success', async () => {
|
|
const response = await server.delete(`/dkim/${dkim}`).expect(200);
|
|
|
|
expect(response.body.success).to.be.true;
|
|
});
|
|
});
|