Bläddra i källkod

Clarify tests.

Jared Hanson 3 år sedan
förälder
incheckning
8780974ab7
2 ändrade filer med 4 tillägg och 4 borttagningar
  1. 1 1
      lib/strategy.js
  2. 3 3
      test/strategy.test.js

+ 1 - 1
lib/strategy.js

@@ -38,7 +38,7 @@ Strategy.prototype.authenticate = function(req, options) {
   try {
   try {
     var siweMessage = new siwe.SiweMessage(message);
     var siweMessage = new siwe.SiweMessage(message);
   } catch(ex) {
   } catch(ex) {
-    return self.fail({ message: 'Invalid message.' }, 403);
+    return self.fail({ message: 'Malformed message.' }, 403);
   }
   }
   
   
   var origin = utils.originalOrigin(req);
   var origin = utils.originalOrigin(req);

+ 3 - 3
test/strategy.test.js

@@ -210,7 +210,7 @@ describe('Strategy', function() {
       .authenticate();
       .authenticate();
   }); // should fail when signature is invalid
   }); // should fail when signature is invalid
   
   
-  it('should fail when message is malformed (missing message)', function(done) {
+  it('should fail when message is malformed (missing address)', function(done) {
     chai.passport.use(new Strategy(function(address, cb) {
     chai.passport.use(new Strategy(function(address, cb) {
       expect(address).to.equal('0xCC6F4DF4B758C4DE3203e8842E2d8CAc564D7758');
       expect(address).to.equal('0xCC6F4DF4B758C4DE3203e8842E2d8CAc564D7758');
       return cb(null, { id: '248289761001' });
       return cb(null, { id: '248289761001' });
@@ -238,13 +238,13 @@ describe('Strategy', function() {
         };
         };
       })
       })
       .fail(function(challenge, status) {
       .fail(function(challenge, status) {
-        expect(challenge).to.deep.equal({ message: 'Invalid message.' });
+        expect(challenge).to.deep.equal({ message: 'Malformed message.' });
         expect(status).to.equal(403);
         expect(status).to.equal(403);
         done();
         done();
       })
       })
       .error(done)
       .error(done)
       .authenticate();
       .authenticate();
-  }); // should fail when message is malformed (missing message)
+  }); // should fail when message is malformed (missing address)
   
   
   it('should fail when missing message', function(done) {
   it('should fail when missing message', function(done) {
     chai.passport.use(new Strategy(function(address, cb) {
     chai.passport.use(new Strategy(function(address, cb) {