Skip to content

Commit

Permalink
FIx unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-ion committed Sep 18, 2023
1 parent d1fc7a2 commit 0e1d101
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
12 changes: 2 additions & 10 deletions trainingportal/test/challengeTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,7 @@ var lastChallengeId = "cwe862";

//calculate the hash
var mockSalt = "1234";
var masterSalt = "";
if(util.isNullOrUndefined(process.env.CHALLENGE_MASTER_SALT)){
util.log("WARNING. CHALLENGE_MASTER_SALT not set. Challenges may be bypassed.");
}
else{
masterSalt=process.env.CHALLENGE_MASTER_SALT;
}


masterSalt=process.env.CHALLENGE_MASTER_SALT;
var mockHash = crypto.createHash('sha256').update(lastChallengeId+mockSalt+masterSalt).digest('base64');

var mockRequest = {
Expand Down Expand Up @@ -183,7 +175,7 @@ describe('challengeTests', function() {

it('should verify correct badge code', () => {

let parsed = challenges.verifyBadgeCode("eyJiYWRnZUluZm8iOnsibGluZTEiOiJTZWN1cmUgQ29kaW5nIiwibGluZTIiOiJCbGFjayBCZWx0IiwiYmciOiJibGFjayJ9LCJnaXZlbk5hbWUiOiJGaXJzdExldmVsVXAiLCJmYW1pbHlOYW1lIjoiTGFzdExldmVsVXAiLCJjb21wbGV0aW9uIjoiVGh1IEZlYiAxMSAyMDIxIDIyOjQzOjMxIEdNVC0wNTAwIChFYXN0ZXJuIFN0YW5kYXJkIFRpbWUpIiwiaWRIYXNoIjoiOGQyN2JhMzdjNSJ9.309a1/l6E5rEE1IZ9P1Z/1MAUE+MbqbX19VIZ2+jp54=");
let parsed = challenges.verifyBadgeCode("eyJiYWRnZUluZm8iOnsibGluZTEiOiJTZWN1cmUgQ29kaW5nIiwibGluZTIiOiJCbGFjayBCZWx0IiwibGluZTMiOiIiLCJiZyI6ImJsYWNrIn0sImdpdmVuTmFtZSI6IkZpcnN0TGV2ZWxVcCIsImZhbWlseU5hbWUiOiJMYXN0TGV2ZWxVcCIsImNvbXBsZXRpb24iOiJUaHUgRmViIDExIDIwMjEgMjI6NDM6MzEgR01ULTA1MDAgKEVhc3Rlcm4gU3RhbmRhcmQgVGltZSkiLCJpZEhhc2giOiJlODNiYjJmNzI5In0%3D.rIyuJBgsIhdUi4Hq180vZUwBZhm9scj5CYonSVln7NY%3D");

assert.notEqual(null, parsed.badgeInfo, "code.info.badgeInfo should not be null")
assert.notEqual(null, parsed.givenName, "code.info.givenName should not be null")
Expand Down
3 changes: 3 additions & 0 deletions trainingportal/test/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
before(async () => {
process.env.CHALLENGE_MASTER_SALT = "5679"
})

0 comments on commit 0e1d101

Please sign in to comment.