diff --git a/src/services/api/authentication.js b/src/services/api/authentication.js index 63e846c..6ab890f 100644 --- a/src/services/api/authentication.js +++ b/src/services/api/authentication.js @@ -9,7 +9,8 @@ const authentication = { }) { return request.post( '/api/authentication/login', - {login, password, rememberMe} + {login, password, rememberMe}, + {token: null} ); }, diff --git a/src/services/api/signup.js b/src/services/api/signup.js index 7a521bf..b0d0340 100644 --- a/src/services/api/signup.js +++ b/src/services/api/signup.js @@ -12,14 +12,16 @@ export default { }) { return request.post( '/api/signup', - {email, username, password, rePassword, rulesAgreement, lang, captcha} + {email, username, password, rePassword, rulesAgreement, lang, captcha}, + {token: null} ); }, activate({key = ''}) { return request.post( '/api/signup/confirm', - {key} + {key}, + {token: null} ); }, diff --git a/tests/services/api/activate.test.js b/tests/services/api/activate.test.js new file mode 100644 index 0000000..5881666 --- /dev/null +++ b/tests/services/api/activate.test.js @@ -0,0 +1,73 @@ +import expect from 'unexpected'; +import sinon from 'sinon'; + +import request from 'services/request'; +import signup from 'services/api/signup'; + +describe('signup api', () => { + describe('#register', () => { + const params = { + email: 'email', + username: 'username', + password: 'password', + rePassword: 'rePassword', + rulesAgreement: false, + lang: 'lang', + captcha: 'captcha' + }; + + beforeEach(() => { + sinon.stub(request, 'post').named('request.post'); + }); + + afterEach(() => { + request.post.restore(); + }); + + it('should post to register api', () => { + signup.register(params); + + expect(request.post, 'to have a call satisfying', [ + '/api/signup', params, {} + ]); + }); + + it('should disable any token', () => { + signup.register(params); + + expect(request.post, 'to have a call satisfying', [ + '/api/signup', params, {token: null} + ]); + }); + }); + + describe('#activate', () => { + const params = { + key: 'key' + }; + + beforeEach(() => { + sinon.stub(request, 'post').named('request.post'); + }); + + afterEach(() => { + request.post.restore(); + }); + + it('should post to confirmation api', () => { + signup.activate(params); + + expect(request.post, 'to have a call satisfying', [ + '/api/signup/confirm', params, {} + ]); + }); + + it('should disable any token', () => { + signup.activate(params); + + expect(request.post, 'to have a call satisfying', [ + '/api/signup/confirm', params, {token: null} + ]); + }); + }); +}); diff --git a/tests/services/api/authentication.test.js b/tests/services/api/authentication.test.js index 1b7a56d..1866351 100644 --- a/tests/services/api/authentication.test.js +++ b/tests/services/api/authentication.test.js @@ -6,6 +6,38 @@ import authentication from 'services/api/authentication'; import accounts from 'services/api/accounts'; describe('authentication api', () => { + describe('#login', () => { + const params = { + login: 'foo', + password: 'secret', + rememberMe: false + }; + + beforeEach(() => { + sinon.stub(request, 'post').named('request.post'); + }); + + afterEach(() => { + request.post.restore(); + }); + + it('should post to login api', () => { + authentication.login(params); + + expect(request.post, 'to have a call satisfying', [ + '/api/authentication/login', params, {} + ]); + }); + + it('should disable any token', () => { + authentication.login(params); + + expect(request.post, 'to have a call satisfying', [ + '/api/authentication/login', params, {token: null} + ]); + }); + }); + describe('#validateToken()', () => { const validTokens = {token: 'foo', refreshToken: 'bar'};