From e861a6cf756d25598c32ee8531a4d8c7e54fbb8d Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Thu, 11 Aug 2016 10:47:53 +0200 Subject: [PATCH] Added test to ensure that XHR adapter does not read cookies if xsrfCookieName is null --- test/specs/xsrf.spec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/specs/xsrf.spec.js b/test/specs/xsrf.spec.js index f057a16..56cc0d2 100644 --- a/test/specs/xsrf.spec.js +++ b/test/specs/xsrf.spec.js @@ -1,3 +1,5 @@ +var cookies = require('../../lib/helpers/cookies'); + describe('xsrf', function () { beforeEach(function () { jasmine.Ajax.install(); @@ -41,6 +43,19 @@ describe('xsrf', function () { }); }); + it('should not read cookies at all if xsrfCookieName is null', function (done) { + spyOn(cookies, "read"); + + axios('/foo', { + xsrfCookieName: null + }); + + getAjaxRequest().then(function (request) { + expect(cookies.read).not.toHaveBeenCalled(); + done(); + }); + }); + it('should not set xsrf header for cross origin', function (done) { document.cookie = axios.defaults.xsrfCookieName + '=12345';