Skip to content

Commit

Permalink
Merge pull request #162 from OWASP/dec-2024-fix-dependencies-and-tests
Browse files Browse the repository at this point in the history
Dec 2024 - Fix dependencies and tests
  • Loading branch information
paul-ion authored Dec 22, 2024
2 parents 56f86c3 + 7b00af4 commit 71f2a7d
Show file tree
Hide file tree
Showing 7 changed files with 7,689 additions and 6,158 deletions.
13,313 changes: 7,411 additions & 5,902 deletions trainingportal/package-lock.json

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions trainingportal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"url": "git@github.com:trendmicro/SecureCodingDojo.git"
},
"scripts": {
"test": "mocha"
"test": "jest"
},
"jest": {
"verbose": true
},
"author": "Paul Ionescu",
"license": "Apache-2.0",
Expand All @@ -31,14 +34,14 @@
"highlightjs": "^9.16.2",
"jquery": "^3.6.0",
"markdown": "^0.5.0",
"mysql2": "^1.7.0",
"mysql2": "^3.11.5",
"node-truncate": "^0.1.0",
"open-iconic": "^1.1.1",
"passport": "^0.7.0",
"passport-google-oauth20": "^2.0.0",
"passport-ldapauth": "^2.1.4",
"passport-local": "^1.0.0",
"passport-saml": "^2.2.0",
"passport-saml": "^3.1.2",
"passport-slack": "0.0.7",
"passport-slack-oauth2": "^1.2.0",
"popper": "^1.0.1",
Expand All @@ -47,7 +50,6 @@
"validator": "^13.6.0"
},
"devDependencies": {
"chai": "^4.3.4",
"mocha": "^6.2.2"
"jest": "^29.7.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,25 @@ config.allowedAccountPattern = "authTest.*";
describe('authTests', () => {


before(async () => {
beforeAll(async () => {
await db.getConn().queryPromise("DELETE FROM users WHERE accountId LIKE ?",["authTest%"]);
await db.getConn().queryPromise("DELETE FROM teams WHERE name LIKE ?",["authTest%"]);
});

describe('#processAuthCallback', async () => {
describe('#processAuthCallback', () => {

var teamOwner = null;
var team = null;

before(async () => {

beforeAll(async () => {

await db.getPromise(db.insertUser,{accountId:"authTestTeamOwner",familyName:"Owner", givenName:"Team"});
teamOwner = await db.getPromise(db.getUser,"authTestTeamOwner");
await db.getPromise(db.insertTeam,[teamOwner,{name:"authTestTeam"}]);
team = await db.getPromise(db.getTeamWithMembersByName,"authTestTeam");
});

it('should create a new user without a team', async () => {
test('should create a new user without a team', async () => {
await db.getConn().queryPromise("DELETE FROM users WHERE accountId = ?",["authTestUser"]);

config.defaultTeam = null;
Expand All @@ -50,7 +49,7 @@ describe('authTests', () => {
return promise;
});

it('should create a new user and assign it to the default team', async () => {
test('should create a new user and assign it to the default team', async () => {
await db.getConn().queryPromise("DELETE FROM users WHERE accountId = ?",["authTestUser"]);
config.defaultTeam = "authTestTeam";
var promise = new Promise((resolve,reject)=>{
Expand All @@ -66,7 +65,7 @@ describe('authTests', () => {
return promise;
});

it('should retrieve and return an existing user', async () => {
test('should retrieve and return an existing user', async () => {
await db.getConn().queryPromise("DELETE FROM users WHERE accountId = ?",["authTestUser"]);
config.defaultTeam = "someOtherTeam";
var promise = new Promise((resolve,reject)=>{
Expand All @@ -82,7 +81,7 @@ describe('authTests', () => {
return promise;
});

it('should reject a profileId if is not allowed', async () => {
test('should reject a profileId if is not allowed', async () => {
var promise = new Promise((resolve,reject)=>{
auth.processAuthCallback("userNotMatchingAllowedPattern","A","B","c@email.local", (e, u) => {
resolve(e);
Expand All @@ -95,7 +94,7 @@ describe('authTests', () => {
return promise;
});

after(async () => {
afterAll(async () => {
await db.getPromise(db.deleteTeam,[teamOwner,team.id]);
await db.getPromise(db.deleteUser,"authTestNewUser");
await db.getPromise(db.deleteUser,"authTestTeamOwner");
Expand All @@ -105,7 +104,7 @@ describe('authTests', () => {
});


after(async()=>{
afterAll(async () => {
//cleanup
await db.getConn().queryPromise("DELETE FROM users WHERE accountId LIKE ?",["authTest%"]);
await db.getConn().queryPromise("DELETE FROM teams WHERE name LIKE ?",["authTest%"]);
Expand Down
Loading

0 comments on commit 71f2a7d

Please sign in to comment.