Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* @param i Index of user from dab file
* @param conn Name of database connection, or default if no name provided
*/
Test.prototype.withUserToken = function (i, conn) {
const {user_tokens} = seed (conn);
const gatekeeper = blueprint.lookup ('service:gatekeeper');
const tokenGenerator = gatekeeper.getTokenGenerator ('gatekeeper:access_token');
const accessToken = user_tokens[i].serializeSync (tokenGenerator);
assert (!!accessToken, `The seed for ${conn} does not have a user_tokens.[${i}]`);
return this.set ('Authorization', `Bearer ${accessToken.access_token}`);
};
Test.prototype.fromUser = Test.prototype.withUserToken;
/**
* Creates a Blueprint testing request that has already be initialized to a client.
*
* @param i Index of client from dab file
* @param conn Name of database connection
*/
Test.prototype.withClientToken = function (i, conn) {
const {client_tokens} = seed (conn);
const gatekeeper = blueprint.lookup ('service:gatekeeper');
const tokenGenerator = gatekeeper.getTokenGenerator ('gatekeeper:access_token');
const accessToken = client_tokens[i].serializeSync (tokenGenerator);
assert (!!accessToken, `The seed for ${conn} does not have a client_tokens.[${i}]`);
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const assert = require ('assert');
const { seed } = require ('@onehilltech/blueprint-mongodb');
const { Test } = require ('supertest');
const blueprint = require ('@onehilltech/blueprint');
/**
* Creates a Blueprint testing request that has already be initialized to a user.
*
* @param i Index of user from dab file
* @param conn Name of database connection, or default if no name provided
*/
Test.prototype.withUserToken = function (i, conn) {
const {user_tokens} = seed (conn);
const gatekeeper = blueprint.lookup ('service:gatekeeper');
const tokenGenerator = gatekeeper.getTokenGenerator ('gatekeeper:access_token');
const accessToken = user_tokens[i].serializeSync (tokenGenerator);
assert (!!accessToken, `The seed for ${conn} does not have a user_tokens.[${i}]`);
return this.set ('Authorization', `Bearer ${accessToken.access_token}`);
};
Test.prototype.fromUser = Test.prototype.withUserToken;
/**
* Creates a Blueprint testing request that has already be initialized to a client.
*
const accessToken = user_tokens[i].serializeSync (tokenGenerator);
assert (!!accessToken, `The seed for ${conn} does not have a user_tokens.[${i}]`);
return this.set ('Authorization', `Bearer ${accessToken.access_token}`);
};
Test.prototype.fromUser = Test.prototype.withUserToken;
/**
* Creates a Blueprint testing request that has already be initialized to a client.
*
* @param i Index of client from dab file
* @param conn Name of database connection
*/
Test.prototype.withClientToken = function (i, conn) {
const {client_tokens} = seed (conn);
const gatekeeper = blueprint.lookup ('service:gatekeeper');
const tokenGenerator = gatekeeper.getTokenGenerator ('gatekeeper:access_token');
const accessToken = client_tokens[i].serializeSync (tokenGenerator);
assert (!!accessToken, `The seed for ${conn} does not have a client_tokens.[${i}]`);
return this.set ('Authorization', `Bearer ${accessToken.access_token}`);
};
Test.prototype.fromClient = Test.prototype.withClientToken;
const {
request
} = require ('@onehilltech/blueprint-testing');
* @param i Index of client from dab file
* @param conn Name of database connection
*/
Test.prototype.withClientToken = function (i, conn) {
const {client_tokens} = seed (conn);
const gatekeeper = blueprint.lookup ('service:gatekeeper');
const tokenGenerator = gatekeeper.getTokenGenerator ('gatekeeper:access_token');
const accessToken = client_tokens[i].serializeSync (tokenGenerator);
assert (!!accessToken, `The seed for ${conn} does not have a client_tokens.[${i}]`);
return this.set ('Authorization', `Bearer ${accessToken.access_token}`);
};
Test.prototype.fromClient = Test.prototype.withClientToken;
const {
request
} = require ('@onehilltech/blueprint-testing');
module.exports = request;