Example #1
0
var user = function(i) {
  return {
    user_id: 'user_' + i,
    first_name: faker.name.firstName(),
    last_name: faker.name.lastName(),
    email: faker.internet.email() + faker.internet.email(),
    phone: faker.phone.phoneNumber()
  };
};
Example #2
0
    it('should be able to resend email(s) in test and development mode', function(done) {

        var email = {
            recipientName: faker.name.findName(),
            token: faker.random.uuid(),
            to: faker.internet.email(),
            baseUrl: faker.internet.url(),
            subject: 'Account confirmation',
            html: faker.lorem.sentence(),
            sender: faker.internet.email(),
            from: faker.internet.email(),
            type: 'confirm'
        };

        async.waterfall([

            function createMail(next) {
                Mail.queue(email, next);
            },

            function resend(mail, next) {
                Mail.resend(next);
            }

        ], function(error, response) {

            expect(error).to.not.exist;

            expect(response).to.exist;

            response = response[0];

            expect(response.type).to.exist;
            expect(response.type).to.be.equal('confirm');
            expect(response.type).to.be.a.String;

            expect(response.to).to.exist;
            expect(response.to).to.be.an.Array;
            expect(response.to).to.include(email.to);

            expect(response.sentAt).to.exist;
            expect(response.sentAt).to.be.a.Date;

            expect(response.html).to.exist;
            expect(response.html).to.be.a.String;

            expect(response.subject).to.exist;
            expect(response.subject).to.be.equal('Account confirmation');
            expect(response.subject).to.be.a.String;


            done(error, response);
        });

    });
Example #3
0
module.exports = function(done) {

    var data = [{
        username: faker.internet.userName(),
        email: faker.internet.email()
    }, {
        username: faker.internet.userName(),
        email: faker.internet.email()
    }];

    done(null, data);
};
Example #4
0
 var collection = Array.apply(null, {length: 50}).map(function(){
   return {
     title: faker.lorem.sentence(),
     location: faker.address.city(),
     description: faker.lorem.paragraphs(3),
     occupation: faker.lorem.words(1),
     type: faker.lorem.words(1),
     apply_to: faker.internet.email(),
     company: {
       name: faker.company.companyName(),
       email: faker.internet.email(),
       description: faker.lorem.paragraphs(2),
     }
   };
 });
Example #5
0
test('The fetchReleases on success', t => {

    t.plan(2);

    const action   = fetchReleases(),
          releases = [faker.internet.email()];

    const expectedActions = [
        {
            type: RELEASES_FETCHING
        },
        {
            type: RELEASES_FETCHED,
            data: releases
        }
    ];

    const dispatch = actual => {

        const expected = expectedActions.shift();
        t.deepEqual(actual, expected, `Should dispatch a ${ expected.type } action.`);
    };

    nock('https://api.spotify.com')
        .get('/v1/browse/new-releases')
        .reply(200, releases);

    action(dispatch);
});
Example #6
0
var addUsers = function (index, max) {
  var user = new User();

  user.firstName = faker.name.firstName();
  user.lastName = faker.name.lastName();
  user.displayName = user.firstName + ' ' + user.lastName;
  user.provider = 'local';
  user.public = true;
  user.avatarUploaded = false;
  user.avatarSource = 'none';
  user.email = index+faker.internet.email();
  user.password = faker.internet.password();
  user.username = index+user.firstName.toLowerCase().replace('\'', '');

  user.save(function(err) {
    if (err != null) console.log(err);
  });
  index++;
  addOffer(user._id, index, max);

  if (index <= max) {
    addUsers(index, max);
  }

};
 .map(id => Map({
   firstName: faker.name.firstName(),
   lastName: faker.name.lastName(),
   email: faker.internet.email(),
   fullTime: faker.random.boolean(),
   img: faker.image.avatar(),
 }))
module.exports = function() {
    var data = {
        users: [],
        albums: [],
        photos: []
    }


    // create 10 users
    for (var i = 0; i < 10; i++) {
        var albumIds = [];

        var r = Math.ceil(Math.random() * 10) + pid;
        r = r < 3 + pid ? 3 + pid : r;
        r = r > 20 + pid ? 20 + pid : r;

        for (var j = pid; j < r; j++) {
            var photoIds = [];

            var s = Math.ceil(Math.random() * 10);
            s = s < 3 ? 3 : s;
            s = s > 20 ? 20 : s;

            for (var k = 0; k < s; k++) {
                photoIds.push(pid);

                data.photos.push({
                    id: pid++,
                    albumId: aid,
                    photo: faker.image.imageUrl(),
                    tags : faker.lorem.words(),
                    description: faker.lorem.sentence()
                });

            }

            albumIds.push(aid);

            data.albums.push({
                id: aid++,
                userId: i,
                name: faker.lorem.words().join(' '),
                description: faker.lorem.paragraph(),
                photos: photoIds
            });
        }

        data.users.push({
            id: i,
            firstName: faker.name.firstName(),
            lastName: faker.name.lastName(),
            email: faker.internet.email(),
            company : faker.company.companyName(),
            avatar: faker.image.avatar(),
            albums: albumIds
        });

    }
    return data
}
Example #9
0
 invitation: attrs => {
   return new Invitation(merge({
     token: faker.random.alphaNumeric(36),
     email: faker.internet.email(),
     created_at: new Date()
   }, attrs))
 },
describe("Users endpoint", function () {
    beforeAll(() => {
        connectToDb()
    })
    const payload = {
        name: faker.name.firstName(),
        email: faker.internet.email(),
        timeZones: [],
        password: '1234567a'
    }
    let id 
    beforeAll((done) => {
        addNewUser(payload, 'regular').then(x => {
            expect(x.name).toBe(payload.name)
            expect(x.email).toBe(payload.email)
            id = x._id
            done()
        })
    })

    it("should remove user ", async function (done) {
        const user = await getUser(payload.email)
        expect(user).toBeTruthy()
        await removeUser(id)
        const deletedUser = await getUser(payload.email)
        expect(deletedUser).toBeFalsy()
        done()
    })





})
    it('should be able to update saved model', function(done) {
        var username = faker.internet.userName();
        var email = faker.internet.email();

        var instance = User.new({
            username: username,
            email: email
        });

        instance
            .save(function(error, user) {
                if (error) {
                    done(error);
                } else {
                    user.username = faker.internet.userName();

                    user
                        .save(function(error, nextUser) {
                            if (error) {
                                done(error);
                            } else {
                                expect(nextUser.updatedAt).to.not.be.null;
                                done();
                            }
                        });
                }
            });
    });
Example #12
0
 profile: function () {
   return {
     name: this.name,
     email: faker.internet.email(),
     profilePictureUrl: faker.image.imageUrl()
   };
 },
Example #13
0
 it('should create a user', async () => {
   const firstName= faker.name.firstName()
   const lastName = faker.name.lastName()
   const query = {
     operationName: 'Signup',
     variables: {
       newUserInput: {
         firstName,
         lastName,
         username: faker.internet.userName(firstName, lastName).toLowerCase(),
         email: faker.internet.email().toLowerCase(),
         password: faker.internet.password(),
       },
     },
     query: `mutation Signup($newUserInput: NewUserInput!) {
       signup(newUserInput: $newUserInput) {
         token
       }
     }`,
   }
   const injectOptions = {
     method: 'POST',
     url: '/graphql',
     payload: JSON.stringify(query),
   }
   const response = await server.inject(injectOptions)
   console.log('response', response.payload)
   const data = JSON.parse(response.payload).data
   console.log('data', data)
   expect(data.signup.token).not.toBeNull()
 })
Example #14
0
 emails: function () {
   const email = faker.internet.email();
   return [{
     address: email,
     verified: true
   }];
 },
Example #15
0
 beforeEach(() => {
   seeder(Meteor.users, {
     environments: ['development'],
     resetCollection: true,
     data: {
       static: [
         {
           email: faker.internet.email(),
           password: faker.internet.password(),
           profile: {
             fname: faker.name.firstName(),
             lname: faker.name.lastName(),
             address: {
               line1: faker.address.streetAddress(),
               line2: faker.random.boolean()
                 ? faker.address.secondaryAddress()
                 : null,
               city: faker.address.city(),
               state: faker.address.stateAbbr(),
               country: 'US',
               postal_code: faker.address.zipCode(),
             },
             phone: faker.phone.phoneNumber('(###) ###-####'),
             business_name: faker.random.boolean()
               ? faker.company.companyName()
               : null,
           },
           roles: ['admin'],
         },
       ],
     },
   });
 });
    it('should be able to save a model and return promise if no callback provided', function(done) {
        var username = faker.internet.userName();
        var email = faker.internet.email();

        var instance = User.new({
            username: username,
            email: email
        });

        instance
            .save()
            .then(function(user) {
                expect(user.id).to.exist;
                expect(user.id).to.not.be.null;

                expect(user.createdAt).to.exist;
                expect(user.createdAt).to.not.be.null;

                expect(user.updatedAt).to.exist;
                expect(user.updatedAt).to.not.be.null;
                done();
            })
            .catch(function(error) {
                done(error);
            });
    });
Example #17
0
const userSeed = async () => {
  try {
    const UserData = [
      {
        firstName: 'team6',
        lastName: 'team6',
        email: 'team6@6.com',
        password: 'password',
        imageUrl:
          'https://pbs.twimg.com/profile_images/1431161157/guy-fawkes_400x400.jpeg',
        admin: true
      }
    ]

    // Create Silly Name Universities and Faker addresses
    for (let i = 0; i < 10; i++) {
      UserData.push({
        firstName: `${faker.name.firstName()}`,
        lastName: `${faker.name.lastName()}`,
        email: `${faker.internet.email()}`,
        password: `password`
      })
    }

    await User.bulkCreate(UserData, {returning: true})
    console.log('[SUCCESS]: Database synced successfully.')
  } catch (err) {
    console.log('[ERROR]: Database not synced successfully.')
    console.log(err)
  } finally {
    console.log('Shutting genre connection')
    console.log('Genre db closed')
  }
}
function generateMockData(options) {
	var data = []
	var i = 0
	for( ;i < options.len; i++ ) {
		data.push({
			id       : i,
			index    : i + 1,
			firstName: faker.name.firstName(),
			lastName : faker.name.lastName(),
			city     : faker.address.city(),
			email    : faker.internet.email()
		})
	}
	if(options.type === 'local') {
		return data
	}

	if(options.type === 'remote') {
		var dataPackage = { count: data.length }
		if(options.request) {
			var startIndex = options.request.skip
			dataPackage.data = data.splice(startIndex,options.request.pageSize)
		} else {
			dataPackage.data = data
		}

		return dataPackage
	}
}
Example #19
0
export function factory() {
  return {
    email: faker.internet.email(),
    username: faker.internet.userName(),
    password: faker.internet.password(),
  };
}
Example #20
0
 function user(index) {
   return {
     id: index + 1,
     name: faker.name.firstName() + ' ' + faker.name.lastName(),
     username: faker.internet.userName(),
     email: faker.internet.email(),
     address: {
       street: faker.address.streetName(),
       suite: faker.address.streetSuffix(),
       city: faker.address.city(),
       zipcode: faker.address.zipCode(),
       geo: {
         lat: faker.address.latitude(),
         lng: faker.address.longitude()
       }
     },
     phone: faker.phone.phoneNumber(),
     website: faker.internet.url(),
     company: {
       name: faker.company.companyName(),
       catchPhrase: faker.company.catchPhrase(),
       bs: faker.company.bs
     },
     role: faker.random.arrayElement(['admin', 'manager', 'guest'])
   };
 }
Example #21
0
 _.times(10, () => {
   return Customer.create({
     first_name: Faker.name.firstName(),
     last_name: Faker.name.lastName(),
     email: Faker.internet.email()
   }).catch(onError);
 });
Example #22
0
    it('should be able to check if account is locked', function(done) {
        var User = mongoose.model('LUser');

        var user = new User({
            email: faker.internet.email(),
            password: faker.internet.password(),
            failedAttempts: 5
        });

        expect(user.isLocked).to.be.a('function');

        async.waterfall([
            function(next) {
                user.lock(next);
            },
            function(lockable, next) {
                user.isLocked(next);
            }
        ], function(error /*, lockable*/ ) {
            expect(error).to.exist;
            expect(error.message)
                .to.equal('Account locked. Check unlock instructions sent to you.');

            done();
        });
    });
Example #23
0
    it('should be able to signup new credentials', function(done) {
        var user = {
            email: faker.internet.email(),
            password: faker.internet.password()
        };

        var request = new Request({
            body: user
        });

        var response = new Response({
            request: request,
            finish: function() {
                var _user = response._getJSON();

                //remember user
                _user_ = _user;

                expect(response.statusCode).to.equal(201);

                expect(_user.email).to.equal(user.email);

                done();
            }
        });

        signup(request, response);
    });
Example #24
0
 function(next) {
     User
         .register({
             email: faker.internet.email(),
             password: faker.internet.password()
         }, next);
 },
Example #25
0
 user: attrs => {
   return new User(merge({
     name: faker.name.findName(),
     active: true,
     email: faker.internet.email()
   }, attrs))
 },
Example #26
0
    it('should not be able to authenticate locked account', function(done) {
        var User = mongoose.model('LUser');
        var credentials = {
            email: faker.internet.email(),
            password: faker.internet.password(),
            failedAttempts: 5
        };

        async
            .waterfall(
                [
                    function(next) {
                        next(null, new User(credentials));
                    },
                    function(lockable, next) {
                        lockable.lock(next);
                    },
                    function(lockable, next) {
                        lockable.authenticate(credentials.password, next);
                    }
                ],
                function(error /*, lockable*/ ) {

                    expect(error).to.exist;
                    expect(error.message)
                        .to.equal('Account locked. Check unlock instructions sent to you.');

                    done();
                });
    });
Example #27
0
    it('should be able to reset failed attempts', function(done) {
        var User = mongoose.model('LUser');

        var user = new User({
            email: faker.internet.email(),
            password: faker.internet.password(),
            failedAttempts: 5
        });

        expect(user.resetFailedAttempts).to.be.a('function');

        async
            .waterfall([
                function save(next) {
                    user.save(function(error) {
                        if (error) {
                            next(error);
                        } else {
                            next(null, user);
                        }
                    });
                },
                function resetFailedAttempts(user, next) {
                    user.resetFailedAttempts(next);
                }
            ], function(error, lockable) {
                if (error) {
                    done(error);
                } else {
                    expect(lockable.failedAttempts).to.be.equal(0);
                    done();
                }
            });
    });
Example #28
0
 before(done => {
   app = require('../src/app')
   app.use(morgan('dev'))
   app.listen(3000, done)
   fixture = {
     username: faker.internet.userName(),
     password: faker.internet.password(),
     phone: faker.phone.phoneNumber('13#########'),
     email: faker.internet.email(),
     turbineUserId: faker.internet.userName(),
     spareUsername: faker.internet.userName(),
     sparePassword: faker.internet.password(),
     sparePhone: faker.phone.phoneNumber('13#########'),
     spareEmail: faker.internet.email()
   }
 })
export function fake_cp() {
  var dummy_event =
    [
      '2014-07-14T21:38:52+0000 6Mar2014 14:07:24 redirect ' + faker.internet.ip() + ' <eth1 alert web_client_type: Microsoft IE 8.0;',
      'resource: ' + faker.internet.url() + ';',
      'src: ' + faker.internet.ip() + ';',
      'dst: ' + faker.internet.ip() + ';',
      'proto: ' + fake_proto() + ';',
      'session_id: [' + fake_session_id() + '];',
      'Protection name: Check Point - Testing Bot;',
      'malware_family: Check Point;',
      'Source OS: ' + fake_os() + ';',
      'Confidence Level: ' + faker.random.number({ min: 0, max: 5}) + ';',
      'severity: ' + faker.random.number({ min: 0, max: 5}) + ';',
      'malware_action: Communication with C&C site;',
      'rule_uid: {' + faker.random.uuid() + '};',
      'Protection Type: URL reputation;',
      'malware_rule_id: {' + fake_malware_rule_id() + '};',
      'protection_id: 00233CFEE;',
      'refid: ' + faker.random.number({ min: 0, max: 5}) + ';',
      'log_id: ' + faker.random.number({ min: 0, max: 5}) + ';',
      'proxy_src_ip: ' + faker.internet.ip() + ';',
      'scope: ' + faker.internet.ip() + ';',
      'user: ' + fake_user_name() + ';',
      'src_user_name: ' + fake_user_name() + ';',
      'src_machine_name: ' + faker.internet.email() + ';',
      'snid: ' + fake_snid() + ';',
      'product: Anti Malware;',
      'service: ' + faker.internet.protocol() + ';',
      's_port: ' + faker.random.number({ min: 22, max: 8080}) + ';',
      'device_version: This is Check Points software version R77.10 - Build 243;'
    ];

  return dummy_event.join(' ');
}
describe("Users endpoint", function () {
    beforeAll(() => {
        connectToDb()
    })
    const payload = {
        name: faker.name.firstName(),
        email: faker.internet.email(),
        timeZones: [],
        password: '1234567a'
    }
    let id 
    beforeAll((done) => {
        addNewUser(payload, 'regular').then(x => {
            expect(x.name).toBe(payload.name)
            expect(x.email).toBe(payload.email)
            id = x._id
            done()
        })
    })

    it("should Update User info ", function (done) {
        const newEmail = faker.internet.email()
        const newName =  faker.name.firstName()
        updateUserInfo(id, newEmail, newName ).then(x=>{
            expect(x.name).toBe(newName)
            expect(x.email).toBe(newEmail)
            done()
        })
    })





})