Example #1
0
    return runTest(route, request).then((res) => {
      assert.equal(Object.keys(res).length, 6, 'response has correct number of keys')
      assert.equal(res.uid, request.auth.credentials.uid, 'response includes correctly-copied uid')
      assert.ok(res.sessionToken, 'response includes a sessionToken')
      assert.equal(res.authAt, request.auth.credentials.createdAt, 'response includes correctly-copied auth timestamp')
      assert.equal(res.verified, false, 'response includes correctly-copied verification flag')
      assert.equal(res.verificationMethod, 'email', 'response includes correct verification method')
      assert.equal(res.verificationReason, 'login', 'response includes correct verification reason')

      assert.equal(db.createSessionToken.callCount, 1, 'db.createSessionToken was called once')
      const sessionTokenOptions = db.createSessionToken.args[0][0]
      assert.equal(Object.keys(sessionTokenOptions).length, 17, 'was called with correct number of options')
      assert.equal(sessionTokenOptions.uid, 'foo', 'db.createSessionToken called with correct uid')
      assert.equal(sessionTokenOptions.createdAt, 234567, 'db.createSessionToken called with correct createdAt')
      assert.equal(sessionTokenOptions.email, '*****@*****.**', 'db.createSessionToken called with correct email')
      assert.equal(sessionTokenOptions.emailCode, 'abcdef', 'db.createSessionToken called with correct emailCode')
      assert.equal(sessionTokenOptions.emailVerified, true, 'db.createSessionToken called with correct emailverified')
      assert.equal(sessionTokenOptions.verifierSetAt, 123456, 'db.createSessionToken called with correct verifierSetAt')
      assert.equal(sessionTokenOptions.locale, 'en-AU', 'db.createSessionToken called with correct locale')
      assert.ok(! sessionTokenOptions.mustVerify, 'db.createSessionToken called with falsy mustVerify')
      assert.ok(sessionTokenOptions.tokenVerificationId, 'db.createSessionToken called with a truthy tokenVerificationId')
      assert.notEqual(sessionTokenOptions.tokenVerificationId, 'myCoolId', 'db.createSessionToken called with a new tokenVerificationId')
      assert.ok(sessionTokenOptions.tokenVerificationCode, 'db.createSessionToken called with a truthy tokenVerificationCode')
      assert.notEqual(sessionTokenOptions.tokenVerificationCode, 'myAwesomerCode', 'db.createSessionToken called with a new tokenVerificationCode')
      assert.equal(sessionTokenOptions.tokenVerificationCodeExpiresAt, 0, 'db.createSessionToken called with correct tokenVerificationCodeExpiresAt')
      assert.equal(sessionTokenOptions.uaBrowser, 'Chrome', 'db.createSessionToken called with correct uaBrowser')
      assert.equal(sessionTokenOptions.uaBrowserVersion, '12', 'db.createSessionToken called with correct uaBrowserVersion')
      assert.equal(sessionTokenOptions.uaOS, 'iOS', 'db.createSessionToken called with correct uaOS')
      assert.equal(sessionTokenOptions.uaOSVersion, '7', 'db.createSessionToken called with correct uaOSVersion')
      assert.equal(sessionTokenOptions.uaDeviceType, 'desktop', 'db.createSessionToken called with correct uaDeviceType')
      assert.equal(sessionTokenOptions.uaFormFactor, 'womble', 'db.createSessionToken called with correct uaFormFactor')
    })
Example #2
0
    'should create an Ed25519 keypair': function() {
      assert.equal(keys.pk.length, 32);
      assert.equal(keys.sk.length, 64);

      var keys2 = gryphon.keys();
      assert.notEqual(keys2.pk.toString(), keys.pk.toString());
      assert.notEqual(keys2.sk.toString(), keys.sk.toString());
    },
 function (keys) {
   assert.equal(typeof keys.wrapKb, 'string', 'yep, wrapKb')
   assert.notEqual(wrapKb, keys.wrapKb, 'wrapKb was reset')
   assert.equal(kA, keys.kA, 'kA was not reset')
   assert.equal(typeof client.kB, 'string')
   assert.equal(client.kB.length, 64, 'kB exists, has the right length')
 }
 .then(res => {
   const body = JSON.parse(res.payload);
   assert.equal(body.email, MOZILLA_EMAIL);
   assert.equal(body.avatar, avatarUrl);
   assert.ok(res.headers['last-modified']);
   lastModifiedFull = res.headers['last-modified'];
   assert.notEqual(lastModifiedFull, lastModifiedPartial);
 })
Example #5
0
 .then(token => {
   assert.equal(typeof token.lastAuthAt, 'function', 'lastAuthAt method is defined')
   assert.equal(typeof token.setUserAgentInfo, 'function', 'setUserAgentInfo method is defined')
   assert.equal(Object.getOwnPropertyDescriptor(token, 'state'), undefined, 'state property is undefined')
   assert.equal(
     typeof Object.getOwnPropertyDescriptor(Object.getPrototypeOf(token), 'state').get,
     'function',
     'state is a getter'
   )
   assert.notEqual(token.createdAt, TOKEN.createdAt, 'createdAt values are completely ignored')
 })
Example #6
0
      .then(code => {
        assert.equal(typeof code, 'string', 'db.createSigninCode should return a string')
        assert.notEqual(code, previousCode, 'db.createSigninCode should not return a duplicate code')
        assert.equal(Buffer.from(code, 'hex').length, config.signinCodeSize, 'db.createSigninCode should return the correct size code')

        // Consume both signinCodes
        return P.all([
          db.consumeSigninCode(previousCode),
          db.consumeSigninCode(code)
        ])
      })
Example #7
0
    'can ignore paths': function() {
      intel.console({ ignore: 'test.util' });

      console.log('quux');
      assert.equal(spy._lastRecord.message, 'quux');

      consoleUtil('baz');
      assert.notEqual(spy._lastRecord.message, 'baz');
      assert.equal(lastMock[0], 'baz');

      intel.console();
    },
Example #8
0
 .then(function (token) {
   token.lastAccessTime = 'foo'
   token.setUserAgentInfo({
     uaBrowser: 'foo',
     uaBrowserVersion: 'bar',
     uaOS: 'baz',
     uaOSVersion: 'qux',
     uaDeviceType: 'wibble',
     uaFormFactor: 'blee'
   })
   assert.notEqual(token.lastAccessTime, undefined, 'lastAccessTime was not clobbered')
 })
Example #9
0
      return runTest(route, mockRequest, function (response) {
        assert.equal(mockMailer.sendVerifyCode.callCount, 1, 'mailer.sendVerifyCode was called')

        // Verify that the email code was sent
        var verifyCallArgs = mockMailer.sendVerifyCode.getCall(0).args
        assert.notEqual(verifyCallArgs[1], emailCode, 'mailer.sendVerifyCode was called with a fresh verification code')
        assert.equal(mockLog.flowEvent.callCount, 2, 'log.flowEvent was called twice')
        assert.equal(mockLog.flowEvent.args[0][0].event, 'account.login', 'first event was login')
        assert.equal(mockLog.flowEvent.args[1][0].event, 'email.verification.sent', 'second event was sent')
        assert.equal(mockMailer.sendVerifyLoginEmail.callCount, 0, 'mailer.sendVerifyLoginEmail was not called')
        assert.equal(mockMailer.sendNewDeviceLoginNotification.callCount, 0, 'mailer.sendNewDeviceLoginNotification was not called')
        assert.equal(response.verified, false, 'response indicates account is unverified')
        assert.equal(response.verificationMethod, 'email', 'verificationMethod is email')
        assert.equal(response.verificationReason, 'signup', 'verificationReason is signup')
        assert.equal(response.emailSent, true, 'email sent')
      })
 function (response) {
   assert(! response.sessionToken, 'no session token returned')
   assert(! response.keyFetchToken, 'no key fetch token returned')
   assert.notEqual(client.authPW.toString('hex'), firstAuthPW, 'password has changed')
 }
 function (response) {
   // Verify correct change password response
   assert.notEqual(response.sessionToken, originalSessionToken, 'session token has changed')
   assert.ok(response.keyFetchToken, 'key fetch token returned')
   assert.notEqual(client.authPW.toString('hex'), firstAuthPW, 'password has changed')
 }
Example #12
0
 }).then((x) => {
   client2 = x
   assert.notEqual(client1.sessionToken, client2.sessionToken, 'generated a new sessionToken')
   return client1.api.sessionDestroy(client1.sessionToken)
 }).then(() => {
Example #13
0
 return Token.createNewToken(Token, { createdAt: now }).then(token => {
   assert.notEqual(token.createdAt, now, 'token.createdAt is new')
 })
Example #14
0
 .then(function (token) {
   token.setUserAgentInfo({
     data: 'foo',
     id: 'foo',
     authKey: 'foo',
     bundleKey: 'foo',
     algorithm: 'foo',
     uid: 'foo',
     lifetime: 'foo',
     createdAt: 'foo',
     email: 'foo',
     emailCode: 'foo',
     emailVerified: 'foo',
     verifierSetAt: 'foo',
     locale: 'foo',
     uaBrowser: 'foo',
     uaBrowserVersion: 'bar',
     uaOS: 'baz',
     uaOSVersion: 'qux',
     uaDeviceType: 'wibble',
     uaFormFactor: 'blee',
     lastAccessTime: 'mnngh'
   })
   assert.notEqual(token.data, 'foo', 'data was not updated')
   assert.notEqual(token.id, 'foo', 'id was not updated')
   assert.notEqual(token.authKey, 'foo', 'authKey was not updated')
   assert.notEqual(token.bundleKey, 'foo', 'bundleKey was not updated')
   assert.notEqual(token.algorithm, 'foo', 'algorithm was not updated')
   assert.notEqual(token.uid, 'foo', 'uid was not updated')
   assert.notEqual(token.lifetime, 'foo', 'lifetime was not updated')
   assert.notEqual(token.createdAt, 'foo', 'createdAt was not updated')
   assert.notEqual(token.email, 'foo', 'email was not updated')
   assert.notEqual(token.emailVerified, 'foo', 'emailVerified was not updated')
   assert.notEqual(token.verifierSetAt, 'foo', 'verifierSetAt was not updated')
   assert.notEqual(token.locale, 'foo', 'locale was not updated')
   assert.equal(token.uaBrowser, 'foo', 'uaBrowser was updated')
   assert.equal(token.uaBrowserVersion, 'bar', 'uaBrowserVersion was updated')
   assert.equal(token.uaOS, 'baz', 'uaOS was updated')
   assert.equal(token.uaOSVersion, 'qux', 'uaOSVersion was updated')
   assert.equal(token.uaDeviceType, 'wibble', 'uaDeviceType was updated')
   assert.equal(token.uaFormFactor, 'blee', 'uaFormFactor was updated')
   assert.equal(token.lastAccessTime, 'mnngh', 'lastAccessTime was updated')
 })
Example #15
0
 .then((res) => {
   assert.ok(res.headers['last-modified']);
   assert.notEqual(res.headers['last-modified'], lastModified);
   done();
 });
Example #16
0
        }).then(function() {
          assert.notEqual(lastRecord.name, 'foobar');

          h.removeFilter(filter);
          return h.handle({ name: 'foobar' });
        }).then(function() {