Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var runner = new Runner(_.merge({}, spec.options)),
callbacks = {};
// add a spy for each callback
_.forEach(_.keys(Runner.Run.triggers), function (eventName) {
callbacks[eventName] = sinon.spy();
});
// the final done callback needs special attention
callbacks.done = sinon.spy(function () {
done(null, callbacks, spec);
});
// eslint-disable-next-line handle-callback-err
runner.run(new Collection(spec.collection), _.omit(spec, ['collection', 'options']), function (err, run) {
run.start(callbacks);
});
};
ig.forEachItem((el) => {}); // $ExpectType void
ig.forEachItemGroup((el) => {}); // $ExpectType void
ig.oneDeep("string"); // $ExpectType Certificate
pmCollection.ItemGroup.isItemGroup(ig); // $ExpectType boolean
// CollectionDefinition Tests
const colDef: pmCollection.CollectionDefinition = {};
colDef.info; // $ExpectType { id?: string | undefined; name?: string | undefined; version?: string | undefined; } | undefined
colDef.variable; // $ExpectType VariableDefinition | undefined
let collection: pmCollection.Collection;
collection = new pmCollection.Collection();
collection = new pmCollection.Collection({});
collection = new pmCollection.Collection({}, []);
collection.events; // $ExpectType EventList
collection.variables; // $ExpectType VariableList
collection.version; // $ExpectType Version | undefined
collection.syncVariablesFrom({}); // $ExpectType { created: string[]; updated: string[]; deleted: string[]; } | undefined
collection.syncVariablesFrom({}, true); // $ExpectType { created: string[]; updated: string[]; deleted: string[]; } | undefined
collection.syncVariablesTo({}); // ExpectType $ExpectType { [key: string]: VariableDefinition; }
collection.toJSON(); // $ExpectType CollectionDefinition
pmCollection.Collection.isCollection(collection); // $ExpectType boolean
// CookieDefinition Tests
ig.forEachItem((el) => {}); // $ExpectType void
ig.forEachItemGroup((el) => {}); // $ExpectType void
ig.oneDeep("string"); // $ExpectType Certificate
pmCollection.ItemGroup.isItemGroup(ig); // $ExpectType boolean
// CollectionDefinition Tests
const colDef: pmCollection.CollectionDefinition = {};
colDef.info; // $ExpectType { id?: string | undefined; name?: string | undefined; version?: string | undefined; } | undefined
colDef.variable; // $ExpectType VariableDefinition | undefined
let collection: pmCollection.Collection;
collection = new pmCollection.Collection();
collection = new pmCollection.Collection({});
collection = new pmCollection.Collection({}, []);
collection.events; // $ExpectType EventList
collection.variables; // $ExpectType VariableList
collection.version; // $ExpectType Version | undefined
collection.syncVariablesFrom({}); // $ExpectType { created: string[]; updated: string[]; deleted: string[]; } | undefined
collection.syncVariablesFrom({}, true); // $ExpectType { created: string[]; updated: string[]; deleted: string[]; } | undefined
collection.syncVariablesTo({}); // ExpectType $ExpectType { [key: string]: VariableDefinition; }
collection.toJSON(); // $ExpectType CollectionDefinition
pmCollection.Collection.isCollection(collection); // $ExpectType boolean
// CookieDefinition Tests
const cookieDef: pmCollection.CookieDefinition = {
// @TODO - Have to handle global level security scheme
// Extracing commonly used properties for ease of access throughout the importer
openapi = validation.openapi;
openapi.servers = _.isEmpty(openapi.servers) ? [{ url: '/' }] : openapi.servers;
openapi.securityDefs = _.get(openapi, 'components.securitySchemes', {});
openapi.baseUrl = _.get(openapi, 'servers.0.url', '{{baseURL}}');
openapi.baseUrlVariables = _.get(openapi, 'servers.0.variables');
// Fix {scheme} and {path} vars in the URL to :scheme and :path
openapi.baseUrl = util.fixPathVariablesInUrl(openapi.baseUrl);
// Creating a new instance of a Postman collection
// All generated folders and requests will go inside this
this.generatedStore.collection = new sdk.Collection({
info: {
name: _.get(openapi, 'info.title', COLLECTION_NAME),
version: _.get(openapi, 'info.version')
}
});
// saving in util for global access
util.components = openapi.components;
util.paths = openapi.paths;
// ---- Collection Variables ----
// adding the collection variables for all the necessary root level variables
// and adding them to the collection variables
util.convertToPmCollectionVariables(
openapi.baseUrlVariables,
'baseUrl',
var done = function (err, collection) {
if (err) {
return callback(err);
}
// ensure that the collection option is present before starting a run
if (!_.isObject(collection)) {
return callback(new Error(COLLECTION_LOAD_ERROR_MESSAGE));
}
// ensure that the collection reference is an SDK instance
// @todo - should this be handled by config loaders?
collection = new Collection(Collection.isCollection(collection) ?
// if the option contain an instance of collection, we simply clone it for future use
// create a collection in case it is not one. user can send v2 JSON as a source and that will be
// converted to a collection
collection.toJSON() : collection);
callback(null, collection);
};
// create and sanitize basic spec
openapi = this.openapi;
openapi.servers = _.isEmpty(openapi.servers) ? [{ url: '/' }] : openapi.servers;
openapi.securityDefs = _.get(openapi, 'components.securitySchemes', {});
openapi.baseUrl = _.get(openapi, 'servers.0.url', '{{baseURL}}');
// TODO: Multiple server variables need to be saved as environments
openapi.baseUrlVariables = _.get(openapi, 'servers.0.variables');
// Fix {scheme} and {path} vars in the URL to :scheme and :path
openapi.baseUrl = schemaUtils.fixPathVariablesInUrl(openapi.baseUrl);
// Creating a new instance of a Postman collection
// All generated folders and requests will go inside this
generatedStore.collection = new sdk.Collection({
info: {
name: _.get(openapi, 'info.title', COLLECTION_NAME),
version: _.get(openapi, 'info.version')
}
});
// ---- Collection Variables ----
// adding the collection variables for all the necessary root level variables
// and adding them to the collection variables
schemaUtils.convertToPmCollectionVariables(
openapi.baseUrlVariables,
'baseUrl',
openapi.baseUrl
).forEach((element) => {
generatedStore.collection.variables.add(element);
transformer.convert(content, options, function (error, convertedContent) {
if (error) {
callback(error);
return;
}
try {
var collection = new Collection(convertedContent);
var result = LuaGenerator.convert(collection)
callback(null, result);
} catch(error) {
callback(error);
}
});
initializeCollection: function() {
this.collection = new Collection();
},
convert: function(content, callback) {
try {
var collection = new Collection(content);
var result = LuaGenerator.convert(collection)
callback(null, result);
} catch(error) {
callback(error);
}
}
collection;
options = _.defaults(options, {
method: 'get',
url: undefined,
timeout: undefined,
ignoreRedirects: false
});
userRequest = {
method: options.method,
url: options.url,
header: options.header
};
collection = new sdk.Collection({
item: {
request: userRequest
}
});
runner.run(collection, {
timeout: {
global: options.timeout
},
certificates: options.sslClientCert && new sdk.CertificateList({}, [{
name: 'client-cert',
matches: [sdk.UrlMatchPattern.MATCH_ALL_URLS],
key: { src: options.sslClientKey },
cert: { src: options.sslClientCert },
passphrase: options.sslClientPassphrase