Example #1
0
// Use Faker to generate a unique App Object
function genSeedApp(input) {
  var appSeed = {
    title: faker.commerce.productName(),
    description: faker.company.catchPhrase(),
    user_id: input.user_id || users[0].id,
    readme: faker.internet.url(),
    sourceLink: faker.internet.url(),
    exeLink: faker.internet.url(),
    iOSAppStoreLink: faker.internet.url(),
    releaseDate: faker.date.future(),
  };
  return appSeed;
}
Example #2
0
function generateCustomFieldValue(field) {
    // https://github.com/marak/Faker.js/#api-methods
    switch (field.type) {
        case 'text':
            return faker.lorem.words();
        case 'website':
            return faker.internet.url();
        case 'gpg':
            return '';
        case 'longtext':
            return faker.lorem.lines();
        case 'json':
            return `{"say":"${faker.lorem.word()}"}`;
        case 'number':
            return faker.random.number().toString();
        case 'option':
            return Math.round(Math.random());
        case 'date-us':
            return '10/20/2017';
        case 'date-eur':
            return '20/10/2017';
        case 'birthday-us':
            return '10/20';
        case 'birthday-eur':
            return '20/10';
        default:
            return '';
    }
}
Example #3
0
    it('<a> with `href` prop', () => {
      const url = faker.internet.url()
      const wrapper = shallow(<Step href={url} />)

      wrapper.should.have.tagName('a')
      wrapper.should.have.attr('href', url)
    })
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(' ');
}
 test('should rejects when navigates redirect', async () => {
     let childEmitter = new TestEmitter(),
         window = {
             loadURL: jest.fn(),
             webContents: childEmitter,
             show: jest.fn()
         },
         authUrl = faker.internet.url(),
         err = faker.random.uuid(),
         mockOauth = { 
             redirectUrl: authUrl,
             getAuthUrl: jest.fn(),
             getTokens: jest.fn(() => Promise.reject(err)) 
         }
     Oauth.mockImplementation(() => mockOauth)
     try {
         let result = login({
             redirectUrl: authUrl
         }, window, session)
         session.defaultSession.webRequest.emit('Completed', { url: authUrl })
         result = await result
         expect(true).toBeFalsy()
         
     } catch (error) {
         expect(error).toEqual(err)
     }
 })
Example #6
0
    it('renders as `a` when defined', () => {
      const url = faker.internet.url()
      const wrapper = shallow(<Step href={url} />)

      wrapper.should.have.tagName('a')
      wrapper.should.have.attr('href', url)
    })
    test('should rejects when no code in url redirect', async () => {
        let childEmitter = new TestEmitter(),
        window = {
            loadURL: jest.fn(),
            webContents: childEmitter,
            show: jest.fn()
        },
        authUrl = faker.internet.url(),
        mockOauth = { 
            redirectUrl: authUrl,
            getAuthUrl: jest.fn(),
        },
        parsed = {
            query: {
                error: faker.random.uuid()
            }
        }
        Oauth.mockImplementation(() => mockOauth)
        url.parse.mockReturnValue(parsed)

        try {
            let result = login({
                redirectUrl: authUrl
            }, window, session)
            session.defaultSession.webRequest.emit('Completed', { url: authUrl })
            result = await result
            expect(true).toBeFalsy()
            
        } catch (error) {
            expect(error).toEqual(`URL response is not correct, parameters are ${JSON.stringify(parsed.query)}`)
        }
    })
var dataDescription = a.map(function(i, idx) {
    // Restaurant top level description
    i.id = i.idx
    i.API = i.apiKey;
    i.star = Math.floor(Math.random() * 5);
    i.reviewCount = Math.floor(Math.random() * 600);
    i.priceLevel = Math.floor(Math.random() * 5);
    i.cuisine = i.foodTypes.filter(i => (i !== ''))[
        0
    ];
    i.topTags = topTags.filter((i) => (Math.random() < 0.13));
    i.description = faker.lorem.paragraphs();

    // Restaurant sidePanel description (LEFT)
    i.diningStyle = diningStyleTags[Math.floor((Math.random() * diningStyleTags_l))];
    i.website = faker.internet.url();
    i.paymentOptions = paymentOptionsTags.filter((i, idx) => (Math.random() < 0.66));;
    i.dressCode = i.diningStyle;
    i.chef = faker.name.findName();
    i.catering = (Math.random() < 0.4) ? faker.lorem.paragraphs() : 'No catering';
    i.privatePartyContact = faker.name.findName() + ': ' + faker.phone.phoneNumberFormat().slice(0,
        12);
    i.neighborhood = zipCodeNeighbor[i.zip] === undefined ? i.city : zipCodeNeighbor[i.zip];
    i.crossStreet = i.streetAddress.split(' ').filter(i => !Number(i) > 0).join(' ');
    return i;
})
Example #9
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'])
   };
 }
    it('renders an <a> with an href attr', () => {
      const url = faker.internet.url()
      const wrapper = shallow(<Card href={url} />)

      wrapper.should.have.tagName('a')
      wrapper.should.have.attr('href', url)
    })
Example #11
0
 media: attrs => {
   return new Media(merge({
     position: 0,
     type: 'image',
     url: faker.internet.url()
   }, attrs))
 },
    test('should get oauth tokens when navigates redirect', async () => {
        let childEmitter = new TestEmitter(),
            window = {
                loadURL: jest.fn(),
                webContents: childEmitter,
                show: jest.fn()
            },
            authUrl = faker.internet.url(),
            tokens = faker.random.uuid(),
            mockOauth = { 
                redirectUrl: authUrl,
                getAuthUrl: jest.fn(),
                getTokens: jest.fn(() => Promise.resolve(tokens)) 
            },
            parsed = {
                query: {
                    code: faker.random.uuid()
                }
            }
        Oauth.mockImplementation(() => mockOauth)
        url.parse.mockReturnValue(parsed)

        let result = login({
            redirectUrl: authUrl
        }, window, session)
        session.defaultSession.webRequest.emit('Completed', { url: authUrl })
        result = await result
        expect(url.parse).toBeCalledWith(authUrl, true)
        expect(mockOauth.getTokens).toBeCalledWith(parsed.query.code)
        expect(result).toEqual(tokens)
    })
Example #13
0
exports.getThirdPartyUser = function () {
    const thirdPartyUser = _.clone(exports.getLocalUser());
    thirdPartyUser.authType = 'vkontakte';
    thirdPartyUser.thirdPartyProfileUrl = faker.internet.url();
    thirdPartyUser.thirdPartyId = faker.random.number().toString();
    delete thirdPartyUser.passwordHash;
    return thirdPartyUser;
};
Example #14
0
 beforeEach(function () {
   author = {
     name: faker.name.firstName(),
     description: faker.lorem.paragraph(),
     books: [],
     webSite: faker.internet.url(),
     avatar: faker.internet.avatar()
   }
 })
Example #15
0
export default function createHistory({
  title = faker.name.title(),
  url   = faker.internet.url()
} = {}) {
  return {
    title,
    url
  };
}
Example #16
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 #17
0
 .then(([ users, networks ]) => ({
   name,
   avatar_url: faker.internet.avatar(),
   background_url: faker.image.imageUrl(),
   beta_access_code: faker.random.uuid(),
   description: faker.lorem.paragraph(),
   slug: faker.helpers.slugify(name).toLowerCase(),
   daily_digest: faker.random.boolean(),
   membership_fee: faker.random.number(),
   plan_guid: faker.random.uuid(),
   banner_url: faker.internet.url(),
   category: faker.random.uuid(),
   created_at: faker.date.past(),
   created_by_id: users[0].id,
   leader_id: users[0].id,
   welcome_message: faker.lorem.paragraph(),
   network_id: networks[0].id,
   location: faker.address.country(),
   slack_hook_url: faker.internet.url(),
   slack_team: faker.internet.url(),
   slack_configure_url: faker.internet.url()
 }))
Example #18
0
function fakeUser (_, Promise) {
  return Promise.resolve({
    email: faker.internet.email(),
    name: `${faker.name.firstName()} ${faker.name.lastName()}`,
    avatar_url: faker.internet.avatar(),
    first_name: faker.name.firstName(),
    last_name: faker.name.lastName(),
    last_login_at: faker.date.past(),
    active: true,
    email_validated: true,
    created_at: faker.date.past(),
    bio: faker.lorem.paragraph(),
    banner_url: faker.image.imageUrl(),
    twitter_name: faker.internet.userName(),
    linkedin_url: faker.internet.url(),
    facebook_url: faker.internet.url(),
    work: faker.lorem.paragraph(),
    intention: faker.lorem.paragraph(),
    extra_info: faker.lorem.paragraph(),
    updated_at: faker.date.past(),
    location: faker.address.country(),
    url: faker.internet.url()
  })
}
Example #19
0
exports.getPassportUser = function () {
    return {
        id: faker.random.number().toString(),
        username: faker.internet.userName(),
        name: {
            givenName: faker.name.firstName(),
            familyName: faker.name.lastName()
        },
        photos: [
            { value: faker.internet.avatar() }
        ],
        provider: 'vkontakte',
        profileUrl: faker.internet.url()
    }
};
Example #20
0
setInterval(function(argument) {
    
    //queue email for send
    Mail.queue({
        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'
    });

}, 4000);
Example #21
0
 return _.times(10, (i) => {
   return User.create({
     username: faker.internet.userName(),
     email: faker.internet.email(),
     pictureUrl: faker.image.avatar(),
     website: faker.internet.url(),
     location: faker.address.city()
   }).then((person) => {
     return person.createAuthoredArticle({
       title: faker.company.catchPhrase(),
       content: faker.lorem.paragraphs()
     }).then(() => {
       if (i === 9) {
         resolve();
       }
     });
   });
 });
Example #22
0
    it('should be able to queue email in test and development mode for later send', function(done) {

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

        Mail.on('mail:queued', function(response) {

            expect(response).to.exist;

            expect(response._id).to.exist;

            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.not.exist;

            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(null, response);

        });

        //queue email
        Mail.queue(email);

    });
app.get('/api/fake/internet', function(req, res) {
	res.json([
		{
			avatar: faker.internet.avatar(),
			email: faker.internet.email(),
			exampleEmail: faker.internet.exampleEmail(),
			userName: faker.internet.userName(),
			protocol: faker.internet.protocol(),
			url: faker.internet.url(),
			domainName: faker.internet.domainName(),
			domainSuffix: faker.internet.domainSuffix(),
			domainWord: faker.internet.domainWord(),
			ip: faker.internet.ip(),
			userAgent: faker.internet.userAgent(),
			color: faker.internet.color(),
			mac: faker.internet.mac(),
			password: faker.internet.password()
		}
	])
});
Example #24
0
exports.category = function(app, count) {
  console.info('RUN FAKER CATEGORY');
  var helper = faker.helpers;

  for(var i = count; i >= 0; i--){

      var name = faker.commerce.productName();
      var description = faker.lorem.sentences();

      var prod = {
        _id: (i+1).toString(),
        active: faker.random.boolean(),
        name: name,
        description: description,
        url: faker.internet.url() + '/' + faker.helpers.slugify(name),
        image: faker.image.fashion(),
        locales: [
          {lang:'ES', title:name, description: faker.lorem.sentences()}
        ],
        images: [
          {
            href: 'https://www.medic-world.com/skin/frontend/ultimo/mw/images/flags/mwd.png',
            // href: faker.image.fashion(),
            title: faker.random.words(),
            description: faker.random.words(),
            mediaType: 'jpg',
          }
        ],
        createdAt:'2016-12-18',
        updatedAt:'2016-12-18',
    };

    app.service('categories').create(prod, {}).then(function(data) {
      // console.log('Created categories data', 'data');
    });
    if(i==1)
    console.log('FAKER categories',prod);
    // post('http://localhost:3030/cms', prod);

  };
}
Example #25
0
    it('should be able to send email 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',
            type: 'confirm'
        };

        Mail
            .send(email, function(error, response) {

                expect(error).to.not.exist;

                expect(response).to.exist;

                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 #26
0
          (function addNextTribe(tribeIndex) {
            var tribe = new Tribe();

            tribe.label = faker.lorem.word() + '_' + (tribes.length + tribeIndex);
            tribe.labelHistory = faker.random.words();
            tribe.slugHistory = faker.random.words();
            tribe.synonyms = faker.random.words();
            tribe.color = faker.internet.color().slice(1);
            tribe.count = 0;
            tribe.created = Date.now();
            tribe.modified = Date.now();
            tribe.public = true;
            tribe.image_UUID = _.sample(tribeImageUUIDs);
            tribe.attribution = faker.name.findName();
            tribe.attribution_url = faker.internet.url();
            tribe.description = faker.lorem.sentences();

            tribe.save(function (err) {
              if (err != null) {
                console.log(err);
              }
              else {
                process.stdout.write('.');
                savedTribes += 1;
                if ((limit && (savedTribes + tribes.length >= max))
                    || !limit && ((savedTribes >= max))) {
                  console.log('');
                  console.log(chalk.green(tribes.length + ' tribes existed in the database.'));
                  console.log(chalk.green(savedTribes + ' tribes successfully added.'));
                  console.log(chalk.green('Database now contains ' + (tribes.length + savedTribes) + ' tribes.'));
                  console.log(chalk.white('')); // Reset to white
                  process.exit(0);
                }
              }
            });
          }(index));
 authUrl: () => faker.internet.url()
Example #28
0
var app = require('../index');
var chai = require('chai');
var faker = require('faker');
var expect = chai.expect;

var cheerio = require('cheerio');

chai.use(require('chai-http'));

var input_url = faker.internet.url();
var output_url = "";

describe('Get Home Page', function () {
    it('should return 200 on home page', function (done) {
        chai.request(app)
            .get('/')
            .end(function (err, res) {
                expect(res.statusCode).to.equal(200);
                done();
            });
    });
});

describe('Post empty url to shorten', function () {
    it('should return 200 on home page', function (done) {
        chai.request(app)
            .post('/shorten')
            .send({ url: "" })
            .end(function (err, res) {
                expect(res.statusCode).to.equal(200);
                done();
describe('Bullets', () => {
  const projects = new List([
    new Map({
      id: faker.random.number(),
      attributes: new Map({
        title: faker.random.word(),
        github_page_url: faker.internet.url(),
        web_page_url: faker.internet.url(),
        body: faker.lorem.sentences(),
        description: faker.lorem.sentence(),
        date_deployed: '2016-03-13 20:45:16'
      })
    }),
    new Map({
      id: faker.random.number(),
      attributes: new Map({
        title: faker.random.word(),
        github_page_url: faker.internet.url(),
        web_page_url: faker.internet.url(),
        body: faker.lorem.sentences(),
        description: faker.lorem.sentence(),
        date_deployed: '2016-03-13 20:45:16'
      })
    })
  ]);
  const project = projects.last();
  let bullets;

  beforeEach(() => {
    bullets = new Bullets();
    bullets.props = {
      isActiveProject: (currentProject, activeProject) => {
        return activeProject.get('id') === currentProject.get('id');
      },
      activeProject: project
    };
  });

  describe('bulletClassName', () => {
    let bulletClassName;

    beforeEach(() => {
      bulletClassName = bullets.bulletClassName(projects.last());
    });

    it('returns active if true', () => {
      expect(bulletClassName).to.equal('side-bar__bullet side-bar__bullet--active');
    });
  });

  describe('bulletStyles', () => {
    let getColor;
    const colorSets = new List([]);

    beforeEach(() => {
      getColor = spy(ProjectHelpers, 'getColor');

      bullets.props = {
        isActiveProject: (currentProject, activeProject) => {
          return activeProject.get('id') === currentProject.get('id');
        },
        activeProject: project,
        colorSets: colorSets
      };
    });

    it('calls getColor if the project is the activeProject', () => {
      bullets.bulletStyles(project);
      expect(getColor.calledOnce).to.be.true;
    });
  });

  describe('bulletIsToBeHighlighted', () => {
    let isActiveProject;

    it('returns true if state.hover is the project in question', () => {
      isActiveProject = stub(bullets.props, 'isActiveProject').returns(false);
      bullets.state = {
        hover: project
      };

      expect(bullets.bulletIsToBeHighlighted(project)).to.be.true;
    });

    it('returns true if state.hover is not the project in question but the project is active', () => {
      isActiveProject = stub(bullets.props, 'isActiveProject').returns(true);
      bullets.state = {
        hover: null
      };

      expect(bullets.bulletIsToBeHighlighted(project)).to.be.true;
    });

    it('returns false if state.hover is not the project in question and the project is not active', () => {
      isActiveProject = stub(bullets.props, 'isActiveProject').returns(false);
      bullets.state = {
        hover: null
      };

      expect(bullets.bulletIsToBeHighlighted(project)).to.be.false;
    });

    afterEach(() => {
      isActiveProject.restore();
    });
  });
});
Example #30
0
describe('the current user', function () {
    var user = {};
    
    before(function(done){
	session
	    .get('/users/me')
            .set('Accept', 'application/json')
	    .expect(200, function(err, res) {
		user = res.body;
		done();
	    });
    });
    
    it('should include an id', function () {
	user.should.have.property('_id');
    });

    it('is available at /users/:id', function (done) {
	session
	    .get('/users/' + user['_id'])
	    .expect(200, done);
    });

    // These are really integration tests, so fuzz testing is
    // acceptable
    
    var updatedData = {
	email: faker.internet.email(),
	birthday: faker.date.past(),
	website: faker.internet.url(),
	biography: faker.lorem.text(),
	displayName: faker.name.firstName()
    };

    it('can be updated at /users/:id', function (done) {
	session
	    .post('/users/' + user['_id'])
	    .send(updatedData)
	    .expect(200, done);
    });

    it('can not be updated at by another person', function (done) {
	otherSession
	    .post('/users/' + user['_id'])
	    .send(updatedData)
	    .expect(403, done);
    });    

    it('can be retrieved a second time', function (done) {
	session
	    .get('/users/me')
            .set('Accept', 'application/json')		
	    .expect(200, function(err, res) {
		user = res.body;
		done();
	    });	
    });

    it('should include new email', function () {
	user.should.have.property('email');
	validator.normalizeEmail(user.email).should.equal( validator.normalizeEmail(updatedData.email) );
    });

    it('should include new birthday', function () {
	user.should.have.property('birthday');
	assert.deepEqual( validator.toDate(user.birthday), validator.toDate(updatedData.birthday) );
    });

    it('should include new website', function () {
	user.should.have.property('website');
	user.website.should.equal( updatedData.website );	
    });

    it('should include new biography', function () {
	user.should.have.property('biography');
	user.biography.should.equal( updatedData.biography );	
    });

    it('should include new display name', function () {
	user.should.have.property('displayName');
	user.displayName.should.equal( updatedData.displayName );	
    });                    
});