ensl_gathers/spec/client.js

29 lines
1 KiB
JavaScript
Raw Normal View History

2015-08-17 13:50:59 +00:00
"use strict";
var helper = require("./helpers/index.js");
var EnslClient = helper.EnslClient;
var assert = require("chai").assert;
var fs = require("fs");
var path = require("path");
var sessionString = (new Buffer(fs.readFileSync(path.join(__dirname, "helpers/data/session.txt"))).toString('ascii'));
describe("ENSL Client", function () {
describe (".decodeSession", function () {
it ("decodes an ENSL session", function () {
var output = EnslClient.decodeSession(sessionString);
2015-08-18 09:56:35 +00:00
assert.isNotNull(output);
assert.isDefined(output.session_id);
2015-08-17 13:50:59 +00:00
});
it ("returns null if invalid cookie format", function () {
assert.isNull(EnslClient.decodeSession("foo"));
});
it ("returns null if invalid JSON", function () {
var invalidSession = "Zm9v%0A--b4794ad68b095b5ee06381e58e97a9c0cb243ede";
assert.isNull(EnslClient.decodeSession(invalidSession));
});
it ("returns null if signature is invalid", function () {
var invalidSessionString = sessionString + "foo";
assert.isNull(EnslClient.decodeSession(invalidSessionString));
});
});
});