Skip to content

Commit

Permalink
Stub out getRsaVerifier so that RSA verification always returns true (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Hobbs authored Mar 12, 2020
1 parent 5f4e982 commit b9ecfed
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/web-auth/web-auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,35 @@ describe('auth0.WebAuth', function() {
appState: null
});
sinon.spy(SSODataStorage.prototype, 'set');

sinon
.stub(IdTokenVerifier.prototype, 'validateAccessToken')
.callsFake(function(at, alg, atHash, cb) {
cb(null);
});

sinon
.stub(IdTokenVerifier.prototype, 'getRsaVerifier')
.callsFake(function(iss, kid, cb) {
cb(null, {
verify: function() {
return true;
}
});
});
});

afterEach(function() {
SSODataStorage.prototype.set.restore();

if (IdTokenVerifier.prototype.validateAccessToken.restore) {
IdTokenVerifier.prototype.validateAccessToken.restore();
}

if (IdTokenVerifier.prototype.getRsaVerifier.restore) {
IdTokenVerifier.prototype.getRsaVerifier.restore();
}

if (WebAuth.prototype.validateToken.restore) {
WebAuth.prototype.validateToken.restore();
}
Expand Down Expand Up @@ -360,7 +378,12 @@ describe('auth0.WebAuth', function() {
nonce: 'lFCnI8.crRTdHfdo5k.zMXfR31856gKz'
},
function(err, data) {
if (err) {
return done(err);
}

expect(err).to.be(null);

expect(data).to.be.eql({
accessToken: null,
idToken:
Expand Down Expand Up @@ -388,6 +411,7 @@ describe('auth0.WebAuth', function() {
tokenType: 'Bearer',
scope: null
});

done();
}
); // eslint-disable-line
Expand Down

0 comments on commit b9ecfed

Please sign in to comment.