How to use the rest-hapi.testHelper function in rest-hapi

To help you get started, we’ve selected a few rest-hapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JKHeadley / appy-backend / backend / server / api / auth.js View on Github external
};

              // EXPL: We use the actual endpoint to take advantage of policies. Specifically in this case we need to
              // take advantage of duplicate fields so that roleName and roleRank are populated.
              // (see: https://github.com/JKHeadley/rest-hapi#policies-vs-middleware)
              let request = {
                method: 'POST',
                url: '/user',
                params: {},
                query: {},
                payload: user,
                credentials: {scope: ['root', USER_ROLES.SUPER_ADMIN]},
                headers: {authorization: 'Bearer'}
              }

              let injectOptions = RestHapi.testHelper.mockInjection(request)

              return server.inject(injectOptions)
            })
            .then(function(result) {
github JKHeadley / appy-backend / backend / server / api / auth.js View on Github external
};

                            // EXPL: We use the actual endpoint to take advantage of policies. Specifically in this case we need to
                            // take advantage of duplicate fields so that roleName and roleRank are populated.
                            // (see: https://github.com/JKHeadley/rest-hapi#policies-vs-middleware)
                            let request = {
                              method: 'POST',
                              url: '/user',
                              params: {},
                              query: {},
                              payload: user,
                              credentials: {scope: ['root', USER_ROLES.SUPER_ADMIN]},
                              headers: {authorization: 'Bearer'}
                            }

                            let injectOptions = RestHapi.testHelper.mockInjection(request)

                            return server.inject(injectOptions)
                        })
                        .then(function(result) {
github JKHeadley / appy-backend / backend / gulp / seed.js View on Github external
role: roles[2]._id,
                  isActive: true
                }
              ]

              request = {
                method: 'POST',
                url: '/user',
                params: {},
                query: {},
                payload: users,
                credentials: {scope: ['root', USER_ROLES.SUPER_ADMIN]},
                headers: {authorization: 'Bearer'}
              }

              injectOptions = RestHapi.testHelper.mockInjection(request)

              return server.inject(injectOptions)
            })
            .then(function (result) {
github JKHeadley / appy-backend / scripts / seed.js View on Github external
role: roles[2]._id,
        isActive: true
      }
    ]

    request = {
      method: 'POST',
      url: '/user',
      params: {},
      query: {},
      payload: users,
      credentials: { scope: ['root', USER_ROLES.SUPER_ADMIN] },
      headers: { authorization: 'Bearer' }
    }

    injectOptions = RestHapi.testHelper.mockInjection(request)

    let result = await server.inject(injectOptions)
    users = result.result
    Log.log('seeding visitors')

    promises = []

    let addVisitor = function(visitor) {
      let rand = Math.random()

      let browser = 'Other'

      if (rand > 0 && rand <= 0.4) {
        browser = 'Chrome'
      } else if (rand > 0.4 && rand <= 0.7) {
        browser = 'Firefox'