Skip to content

Commit

Permalink
Merge pull request #235 from forio/EPICENTER-4433
Browse files Browse the repository at this point in the history
EPICENTER-4433 delete keyed scenario cookie; 2.13.4
  • Loading branch information
lukwallace authored Oct 8, 2020
2 parents ce1b552 + 3470b04 commit b6a069d
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 39 deletions.
2 changes: 1 addition & 1 deletion build/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = function (grunt) {
reporters: ['mocha'],
singleRun: true,
browserConsoleLogOptions: {
terminal: false
terminal: false,
},
// logLevel: 'debug',
mochaReporter: {
Expand Down
6 changes: 3 additions & 3 deletions dist/components/assignment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://forio.com/tools/js-libs/2.13.3/components/assignment/assignment.css">
<link rel="stylesheet" href="https://forio.com/tools/js-libs/2.13.4/components/assignment/assignment.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>
</head>
Expand Down Expand Up @@ -73,8 +73,8 @@
</div>
</div>
<!-- make sure to include jquery, epicenter.js and assignment.js -->
<script src="https://forio.com/tools/js-libs/2.13.3/epicenter.min.js"></script>
<script src="https://forio.com/tools/js-libs/2.13.3/components/assignment/assignment.js"></script>
<script src="https://forio.com/tools/js-libs/2.13.4/epicenter.min.js"></script>
<script src="https://forio.com/tools/js-libs/2.13.4/components/assignment/assignment.js"></script>
<script>
new window.forio.MultiplayerAssignmentComponent({
el: '#assignment-component',
Expand Down
6 changes: 3 additions & 3 deletions dist/components/login/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">

<!-- login.css provides styling for the group selector pop over dialog -->
<link rel="stylesheet" href="https://forio.com/tools/js-libs/2.13.3/components/login/login.css">
<link rel="stylesheet" href="https://forio.com/tools/js-libs/2.13.4/components/login/login.css">

<!-- make sure to include jquery, epicenter.js and login.js -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://forio.com/tools/js-libs/2.13.3/epicenter.min.js"></script>
<script src="https://forio.com/tools/js-libs/2.13.3/components/login/login.js"></script>
<script src="https://forio.com/tools/js-libs/2.13.4/epicenter.min.js"></script>
<script src="https://forio.com/tools/js-libs/2.13.4/components/login/login.js"></script>
</head>
<body>
<!--
Expand Down
2 changes: 1 addition & 1 deletion dist/components/login/login.js.map

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions dist/epicenter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/epicenter.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/epicenter.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/epicenter.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "epicenter-js",
"version": "2.13.3",
"version": "2.13.4",
"repository": {
"type": "git",
"url": "https://github.com/forio/epicenter-js-libs"
Expand Down
48 changes: 24 additions & 24 deletions src/managers/auth-manager/tests/test-auth-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Auth Manager', function () {
active: true
}
];

function getResponse() {
var singleGroup = [
{
Expand Down Expand Up @@ -154,11 +154,11 @@ describe('Auth Manager', function () {

it('should fail when the user has multiple groups', function () {
multipleGroupsResponse = true;
var sucessSpy = sinon.spy(function (p) {
return $.Deferred().resolve(p).promise();
var sucessSpy = sinon.spy(function (p) {
return $.Deferred().resolve(p).promise();
});
var failSpy = sinon.spy(function (p) {
return $.Deferred().resolve(p).promise();
var failSpy = sinon.spy(function (p) {
return $.Deferred().resolve(p).promise();
});
return am.login({ userName: 'test', password: 'test' }).then(sucessSpy, failSpy).then(function () {
sucessSpy.should.not.have.been.called;
Expand All @@ -172,11 +172,11 @@ describe('Auth Manager', function () {
});
it('should fail when the user belongs to no groups', function () {
noGroupResponse = true;
var sucessSpy = sinon.spy(function (p) {
return $.Deferred().resolve(p).promise();
var sucessSpy = sinon.spy(function (p) {
return $.Deferred().resolve(p).promise();
});
var failSpy = sinon.spy(function (p) {
return $.Deferred().resolve(p).promise();
var failSpy = sinon.spy(function (p) {
return $.Deferred().resolve(p).promise();
});
return am.login({ userName: 'test', password: 'test' }).then(sucessSpy, failSpy).then(function () {
sucessSpy.should.not.have.been.called;
Expand All @@ -202,11 +202,11 @@ describe('Auth Manager', function () {

// it('should not work when a wrong group is used', function () {
// multipleGroupsResponse = true;
// var sucessSpy = sinon.spy(function (p) {
// return $.Deferred().resolve(p).promise();
// var sucessSpy = sinon.spy(function (p) {
// return $.Deferred().resolve(p).promise();
// });
// var failSpy = sinon.spy(function (p) {
// return $.Deferred().resolve(p).promise();
// var failSpy = sinon.spy(function (p) {
// return $.Deferred().resolve(p).promise();
// });
// return am.login({ userName: 'test', password: 'test', groupId: 'wrong-id' }).then(sucessSpy, failSpy).then(function (data) {
// sucessSpy.should.not.have.been.called;
Expand All @@ -227,24 +227,24 @@ describe('Auth Manager', function () {
var session = am.getCurrentUserSessionInfo();
session.groupName.should.equal('rv-test');
});

});

it('should fail with the list of groups on a team member login with no group', function () {
multipleGroupsResponse = true;
teamMemberResponse = true;

var sucessSpy = sinon.spy(function (p) {
return $.Deferred().resolve(p).promise();
var sucessSpy = sinon.spy(function (p) {
return $.Deferred().resolve(p).promise();
});
var failSpy = sinon.spy(function (p) {
return $.Deferred().resolve(p).promise();
var failSpy = sinon.spy(function (p) {
return $.Deferred().resolve(p).promise();
});

return am.login({ userName: 'test', password: 'test' }).then(sucessSpy, failSpy).then(function (data) {
sucessSpy.should.not.have.been.called;
failSpy.should.have.been.calledOnce;

var req = server.requests.pop();
req.method.toUpperCase().should.equal('GET');
req.url.should.match(/https:\/\/(.*)\/(.*)\/group\/local\/?/);
Expand All @@ -265,7 +265,7 @@ describe('Auth Manager', function () {
am.isLoggedIn().should.equal(true);
});
});
it('should return true after logging out', function () {
it('should return false after logging out', function () {
return am.logout().then(function () {
am.isLoggedIn().should.equal(false);
});
Expand All @@ -290,7 +290,7 @@ describe('Auth Manager', function () {
spyCall = cookie.set.getCall(1);
spyCall.args[0].should.match(/epicenter-scenario=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=\.forio\.com; path=\/app\/accountName\/projectName/);
done();
}).fail(function () {
}).fail(function (e) {
done(new Error('Login should not fail'));
});
});
Expand Down Expand Up @@ -372,7 +372,7 @@ describe('Auth Manager', function () {
session.groups['test-project'].groupName.should.equal('rv-test2');
session.groups['test-project'].groupId.should.equal('groupId');
session.groups['test-project'].isFac.should.be.false;

am.sessionManager.removeSession();
done();
}).fail(function () {
Expand Down Expand Up @@ -400,7 +400,7 @@ describe('Auth Manager', function () {
session.groups['test-project2'].groupName.should.equal('rv-test2');
session.groups['test-project2'].groupId.should.equal('groupId');
session.groups['test-project2'].isFac.should.be.true;

am.sessionManager.removeSession();
done();
}).fail(function () {
Expand All @@ -423,7 +423,7 @@ describe('Auth Manager', function () {
session.groups.projectName.groupName.should.equal('rv-test2');
session.groups.projectName.groupId.should.equal('groupId');
session.groups.projectName.isFac.should.be.false;

am.sessionManager.removeSession();
done();
}).fail(function () {
Expand Down
4 changes: 4 additions & 0 deletions src/store/session-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ var SessionManager = function (managerOptions) {
Object.keys(keyNames).forEach(function (cookieKey) {
var cookieName = keyNames[cookieKey];
store.remove(cookieName);
document.cookie.split('; ')
.map((c)=> c.split('=')[0] || '')
.filter((c)=> c.indexOf(cookieName) === 0)
.forEach((cookieName)=> store.remove(cookieName));
});
return true;
},
Expand Down

0 comments on commit b6a069d

Please sign in to comment.