コード例 #1
0
afterEach((done) => {
    rp.get.restore();
    rp.post.restore();
    cacheSetSpy.restore();
    cacheGetSpy.restore();
    done();
});
コード例 #2
0
    it('fail if no response getting the key', (done) => {
        // Mock out the get call for fetching the key to give an error
        rp.get.restore();
        reqStub = sinon.stub(rp, 'get');
        reqStub.returns(Promise.reject());

        token_util.verify(token1_valid, trusted_issuers).then((decoded) => {
            done(new Error('Should fail no response getting the key'));
        }).catch(() => {
            // We expect an error here
            done();
        });
    });
コード例 #3
0
    it('fail signed with a different key', (done) => {
        // Mock out the get call for fetching the key to give an error
        rp.get.restore();
        reqStub = sinon.stub(rp, 'get');
        reqStub.returns(Promise.resolve(JSON.stringify({ value: key2 })));

        // Using a key from another server, verification should fail
        token_util.verify(token1_valid, trusted_issuers).then((decoded) => {
            done(new Error('Should fail if token and key mismatch'));
        }).catch((err) => {
            // We expect an error here
            try {
                expect(err.name).to.equal('JsonWebTokenError');
                expect(err.message).to.equal('invalid signature');
                done();
            } catch (e) {
                return done(e);
            }
        });
    });
コード例 #4
0
 after(function() {
   request.put.restore();
   request.get.restore();
 });
コード例 #5
0
 afterEach(() => {
   request.get.restore()
 })
コード例 #6
0
ファイル: serviceTest.js プロジェクト: rgrnwd/TheWheel
 return service.getCuisines().catch(function(error) {
     assert.isTrue(error.message === 'Something went wrong');
     requestPromise.get.restore();
 });
コード例 #7
0
ファイル: serviceTest.js プロジェクト: rgrnwd/TheWheel
 return service.getCuisines().then(function(result) {
     assert.isTrue(result === 'result');
     requestPromise.get.restore();
 });