Last active
March 18, 2018 19:07
-
-
Save WaleedAshraf/ebd0bfa752b7496faed134b01a338382 to your computer and use it in GitHub Desktop.
Mock Express Session
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
// name = "my-session" -> base64 value of required object (cookie) | |
// name.sig = "my-session.sig" -> signed value of cookie using Keygrip | |
let cookie = Buffer.from(JSON.stringify({"count":2})).toString('base64'); // base64 converted value of cookie | |
let kg = Keygrip(['testKey']) // same key as I'm using in my app | |
let hash = kg.sign('my-session=' + cookie); | |
await request(app).get('api/image/submit').set("Accept", "text/html") | |
.set('cookie', ['my-session=' + cookie + '; ' + 'my-session.sig=' + hash + ';']) | |
.expect(200); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment