Example #1
0
        it('should fail login with invalid password on POST /api/auth/login', function (done) {
            User.authenticate.restore();
            sinon.stub(User, 'authenticate')
                .withArgs('b@b', '123123')
                .callsArgWith(2, null, null, codes.AUTH_PWD_MISMATCH); //<--

            request(app)
                .post('/api/auth/login')
                .send({email: 'b@b', password: '******'})
                .set(typeAcceptHeaders)
                .expect(200)
                .expect({error: 'Wrong email or password'}, done);
        });
Example #2
0
        it('should fail login with unverified email on POST /api/auth/login & re-send email', function (done) {
            User.authenticate.restore();
            sinon.stub(User, 'authenticate')
                .withArgs('b@b', '123123')
                .callsArgWith(2, null, {email: 'b@b', name: {full: 'John Snow'}}, codes.AUTH_NOT_VERIFIED); //<--

            // TODO - doesn't work!
            /*sinon.stub(mailer, 'send')
                .withArgs('b@b')
                .calledOnce.should.equal(true);*/

            request(app)
                .post('/api/auth/login')
                .send({email: 'b@b', password: '******'})
                .set(typeAcceptHeaders)
                .expect(200)
                .expect({error: 'verify-email'}, done);
        });
Example #3
0
 after(function () {
     User.authenticate.restore();
 });