Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Commit bfbbad0

Browse files
committed
base test csrf
1 parent 7ed52d8 commit bfbbad0

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

test/bpmAuth.spec.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
/*global describe, it, beforeEach */
1+
/*global describe, it, beforeEach, afterEach */
22

33
var BpmAuth = require('../src/bpmAuth');
44
var AuthBpmMock = require('../test/mockObjects/mockAlfrescoApi').ActivitiMock.Auth;
55
var expect = require('chai').expect;
6+
var sinon = require('sinon');
67

78
describe('Bpm Auth test', function () {
89

@@ -159,5 +160,43 @@ describe('Bpm Auth test', function () {
159160
});
160161

161162
});
163+
164+
describe('CSRF Token', function () {
165+
166+
beforeEach(function() {
167+
this.setCsrfTokenStub = sinon.stub(BpmAuth.prototype, 'setCsrfToken');
168+
});
169+
170+
afterEach(function() {
171+
this.setCsrfTokenStub.restore();
172+
});
173+
174+
it('should be enabled by default', function (done) {
175+
this.authBpmMock.get200Response();
176+
177+
this.bpmAuth = new BpmAuth({
178+
hostBpm: this.hostBpm
179+
});
180+
181+
this.bpmAuth.login('admin', 'admin').then(() => {
182+
expect(this.setCsrfTokenStub.called).to.be.equal(true);
183+
done();
184+
});
185+
});
186+
187+
it('should be disabled if disableCsrf is true', function (done) {
188+
this.authBpmMock.get200Response();
189+
190+
this.bpmAuth = new BpmAuth({
191+
hostBpm: this.hostBpm,
192+
disableCsrf: true
193+
});
194+
195+
this.bpmAuth.login('admin', 'admin').then(() => {
196+
expect(this.setCsrfTokenStub.called).to.be.equal(false);
197+
done();
198+
});
199+
});
200+
});
162201
});
163202
});

0 commit comments

Comments
 (0)