Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install semgrep #46

Open
wants to merge 6 commits into
base: f24
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ coverage
test/files/normalise.jpg.png
test/files/normalise-resized.jpg
package-lock.json
/package.json
*.mongodb
link-plugins.sh
test.sh
Expand Down
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"useTabs": true,
"arrowParens": "always",
"endOfLine": "auto",
"singleQuote": true,
"tabWidth": 1,
"requirePragma": false,
"insertPragma": false
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"semgrep": "^0.0.1"
}
}
75 changes: 75 additions & 0 deletions test/posts/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'use strict';

const assert = require('assert');
const db = require('../mocks/databasemock');
const plugins = require('../../src/plugins');
const user = require('../../src/user');
const topics = require('../../src/topics');
const categories = require('../../src/categories');
const groups = require('../../src/groups');
const privileges = require('../../src/privileges');
const meta = require('../../src/meta');

const Posts = {};

describe('create post', () => {
let pid;
let purgePid;
let cid;
let uid;
let endorsed;

before(async () => {
// Create a user
uid = await user.create({
username: 'uploads user',
password: 'abracadabra',
gdpr_consent: 1,
});

// Create a test category
({ cid } = await categories.create({
name: 'Test Category',
description: 'Test category created by testing script',
}));
});

it('create a post where endorsed is automatically false', async () => {
try {
// Create a post within the category
const topicPostData = await topics.post({
uid,
cid,
title: 'topic with some images',
content:
'here is an image [alt text](/assets/uploads/files/abracadabra.png) and another [alt text](/assets/uploads/files/shazam.jpg)',
});

// Check if 'endorsed' is false
endorsed = topicPostData.postData.endorsed;
assert.strictEqual(endorsed, false);
} catch (error) {
console.log(error);
}
});

it('create a post where endorsed is initialized to be true', async () => {
try {
// Create a post within the category
const topicPostData = await topics.post({
uid,
cid,
title: 'topic with some images',
content:
'here is an image [alt text](/assets/uploads/files/abracadabra.png) and another [alt text](/assets/uploads/files/shazam.jpg)',
endorsed: true,
});

// Check if 'endorsed' is true
endorsed = topicPostData.postData.endorsed;
assert.strictEqual(endorsed, true);
} catch (error) {
console.log(error);
}
});
});
Loading