-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00d30b5
commit 31b4cb6
Showing
2 changed files
with
60 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,62 @@ | ||
var expect =require('chai').expect; | ||
var LazyCrypto=require('./index.js'); | ||
|
||
var lazyCrypto=new LazyCrypto(); | ||
describe("lazy-crypto",function(){ | ||
it('dummy test', function(){ | ||
expect(true).to.be.true; | ||
it('Dummy Test', function(){ | ||
expect(lazyCrypto!=null||lazyCrypto!=undefined).to.be.true; | ||
}); | ||
|
||
}); | ||
|
||
//LazyCrypto | ||
|
||
//generateEmailVerificationToken | ||
var token=lazyCrypto.generateVerificationToken(4,10); | ||
describe("Generate Verification Token Test",function(){ | ||
it("Token contains an expiration date",function(){ | ||
expect(token.expires instanceof Date).to.be.true; | ||
}) | ||
it("Token contains token string",function(){ | ||
expect(token.token!=undefined && token.token!=null); | ||
}); | ||
}); | ||
|
||
//validateSha512HashAndSalt | ||
var salt=lazyCrypto.generateSalt(20); | ||
describe("Generate Salt with length 20 Test",function(){ | ||
it("Salt was generated",function(){ | ||
expect(salt!=undefined&&salt!=null).to.be.true; | ||
}) | ||
it("Salt length is valid",function(){ | ||
expect(salt.length==20).to.be.true; | ||
}) | ||
}); | ||
var hash=lazyCrypto.generateSha512Hash('password',salt); | ||
describe("Generate SHA512 Hash with Salt",function(){ | ||
it("Hash was generated",function(){ | ||
expect(hash!=undefined&&hash!=null).to.be.true; | ||
}) | ||
it("Hash and Salt are present on the result",function(){ | ||
expect(hash.passwordSalt!=undefined&&hash.passwordHash!=null); | ||
}) | ||
it("Hash and salt are valid!",function(){ | ||
expect(lazyCrypto.validateSha512HashAndSalt("password",salt,hash)); | ||
}) | ||
}) | ||
describe('Validation of SHA512 Hash with Salt',function(){ | ||
it("Hash and salt are valid!",function(){ | ||
expect(lazyCrypto.validateSha512HashAndSalt("password",salt,hash)); | ||
}) | ||
}) | ||
var res=lazyCrypto.generateSha512HashAndSalt('password',20); | ||
describe("Generation of SHA 512 Hash along with a Unique Salt",function(){ | ||
it('Hash and Salt Generated',function(){ | ||
expect(res.passwordSalt!=undefined && res.passwordSalt!=null); | ||
}) | ||
it('Salt generated has correct length',function(){ | ||
expect(res.passwordSalt.length==20) | ||
}) | ||
it("Hash and salt are valid!",function(){ | ||
expect(lazyCrypto.validateSha512HashAndSalt("password",res.passwordSalt,res.passwordHash)); | ||
}) | ||
}) | ||
|
||
//generateSha512HashAndSalt | ||
|
||
//generateSha512Hash | ||
|
||
//generateSalt | ||
//passwordSalt:passwordData.salt, | ||
// passwordHash:passwordData.passwordHash |