Skip to content

Node.js based forum software built for the modern web

test: fix tests

Barış Soner Uşaklı5abbe512c0cc
diff --git a/test/activitypub/signatures.js b/test/activitypub/signatures.js
index 09b24a6606..d913dc97ec 100644
--- a/test/activitypub/signatures.js
+++ b/test/activitypub/signatures.js
@@ -124,14 +124,19 @@ describe('http signature signing and verification', () => {
it('should return true when a digest is also passed in', async () => {
const endpoint = `${nconf.get('url')}/user/${username}/inbox`;
const path = `/user/${username}/inbox`;
+ const payload = { foo: 'bar' };
const keyData = await activitypub.getPrivateKey('uid', uid);
- const signature = await activitypub.sign(keyData, endpoint, { foo: 'bar' });
+ const hash = createHash('sha256');
+ hash.update(JSON.stringify(payload));
+ const checksum = `SHA-256=${hash.digest('base64')}`;
+ const signature = await activitypub.sign(keyData, endpoint, checksum);
const { host } = nconf.get('url_parsed');
const req = {
...mockReqBase,
...{
method: 'POST',
path,
+ body: payload,
headers: { ...signature, host },
},
};
diff --git a/test/socket.io.js b/test/socket.io.js
index 209f8dc056..add66afe2e 100644
--- a/test/socket.io.js
+++ b/test/socket.io.js
@@ -459,7 +459,7 @@ describe('socket.io', () => {
socketAdmin.plugins.upgrade({
uid: adminUid,
}, {
- id: 'nodebb-plugin-location-to-map',
+ id: 'nodebb-plugin-markdown',
version: 'latest',
}, (err) => {
assert.ifError(err);
@@ -467,6 +467,31 @@ describe('socket.io', () => {
done();
});
});
+
+ it('should fail to upgrade plugin if it is not installed', function (done) {
+ this.timeout(0);
+ const oldValue = process.env.NODE_ENV;
+ process.env.NODE_ENV = 'development';
+ socketAdmin.plugins.toggleInstall({
+ uid: adminUid,
+ }, {
+ id: 'nodebb-plugin-location-to-map',
+ version: 'latest',
+ }, function (err) {
+ assert.ifError(err);
+ socketAdmin.plugins.upgrade({
+ uid: adminUid,
+ }, {
+ id: 'nodebb-plugin-location-to-map',
+ version: 'latest',
+ }, (err) => {
+ console.log(err);
+ assert.strictEqual(err.message, '[[error:plugin-not-installed]]');
+ process.env.NODE_ENV = oldValue;
+ done();
+ });
+ });
+ });
});
it('should get list of active plugins', (done) => {