mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-09-10 15:14:40 +08:00
* 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>
62 lines
1.9 KiB
JavaScript
62 lines
1.9 KiB
JavaScript
/*eslint no-unused-expressions: 0, prefer-arrow-callback: 0, no-console:0 */
|
|
|
|
/* globals before: false, after: false */
|
|
|
|
'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('Storage tests', function () {
|
|
this.timeout(10000); // eslint-disable-line no-invalid-this
|
|
|
|
let user;
|
|
|
|
before(async () => {
|
|
// ensure that we have an existing user account
|
|
const response = await server
|
|
.post('/users')
|
|
.send({
|
|
username: 'storageuser',
|
|
password: 'secretvalue',
|
|
address: 'storageuser.addrtest@example.com',
|
|
name: 'storage user'
|
|
})
|
|
.expect(200);
|
|
expect(response.body.success).to.be.true;
|
|
expect(response.body.id).to.exist;
|
|
|
|
user = response.body.id;
|
|
});
|
|
|
|
after(async () => {
|
|
if (!user) {
|
|
return;
|
|
}
|
|
|
|
const response = await server.delete(`/users/${user}`).expect(200);
|
|
expect(response.body.success).to.be.true;
|
|
|
|
user = false;
|
|
});
|
|
|
|
it('should POST /users/{user}/storage expect success', async () => {
|
|
const response = await server
|
|
.post(`/users/${user}/storage`)
|
|
.send({
|
|
filename: 'image.gif',
|
|
contentType: 'image/gif',
|
|
encoding: 'base64',
|
|
content:
|
|
'R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7'
|
|
})
|
|
.expect(200);
|
|
expect(response.body.success).to.be.true;
|
|
});
|
|
});
|