@nrfcloud/bdd-feature-runner-aws
Advanced tools
Comparing version 2.4.2 to 2.4.3
@@ -12,3 +12,3 @@ export declare type Headers = { | ||
}; | ||
request(method: string, path: string, queryString?: object, extraHeaders?: Headers, body?: any): Promise<string>; | ||
request(method: string, path: string, queryString?: object, extraHeaders?: Headers, body?: any, passBinary?: boolean): Promise<string>; | ||
} |
@@ -23,13 +23,14 @@ "use strict"; | ||
} | ||
async request(method, path, queryString, extraHeaders, body) { | ||
async request(method, path, queryString, extraHeaders, body, passBinary = false) { | ||
const headers = Object.assign({}, this.headers, extraHeaders); | ||
const url = `${this.endpoint.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}${toQueryString(queryString || {})}`; | ||
const bodyToSend = body | ||
? !passBinary && typeof body !== 'string' | ||
? JSON.stringify(body) | ||
: body | ||
: undefined; | ||
const res = await fetch(url, { | ||
method, | ||
headers, | ||
body: body | ||
? typeof body !== 'string' | ||
? JSON.stringify(body) | ||
: body | ||
: undefined, | ||
body: bodyToSend, | ||
}); | ||
@@ -36,0 +37,0 @@ const contentType = res.headers.get('content-type') || '', mediaType = contentType.split(';')[0]; |
@@ -8,2 +8,3 @@ "use strict"; | ||
const uuid_1 = require("uuid"); | ||
const fs_1 = require("fs"); | ||
const client = new rest_client_1.RestClient(); | ||
@@ -29,7 +30,8 @@ exports.restStepRunners = () => { | ||
return [ | ||
// Note! Setting a header sets it for all future requests too, until you change it, or clear it (see below) | ||
s(/^the ([^ ]+) header is "([^"]+)"$/, async ([name, value]) => { | ||
client.headers[name] = value; | ||
}), | ||
s(/^the ([^ ]+) header is "([^"]+)"$/, async ([name, value]) => { | ||
client.headers[name] = value; | ||
s(/^I clear the ([^ ]+) request header$/, async ([name]) => { | ||
delete client.headers[name]; | ||
}), | ||
@@ -123,2 +125,13 @@ s(/^the endpoint is "([^"]+)"$/, async ([endpoint]) => { | ||
}), | ||
s(/^I (POST|PUT|PATCH) (?:to )?([^ ]+) with the file "([^"]+)"$/, async ([method, path, localFile]) => { | ||
const re = new RegExp('<guid>', 'i'); | ||
if (path.match(re)) { | ||
path = path.replace('<guid>', uuid_1.v4()); | ||
} | ||
const buffer = fs_1.readFileSync(localFile); | ||
return [ | ||
await client.request(method, path, undefined, undefined, buffer, true), | ||
buffer.length, | ||
]; | ||
}), | ||
s(/^a page with ([0-9]+)(?: of ([0-9]+))? items? is returned$/, async ([num, total]) => { | ||
@@ -125,0 +138,0 @@ chai_1.expect(client.response.body).to.have.property('items'); |
{ | ||
"name": "@nrfcloud/bdd-feature-runner-aws", | ||
"version": "2.4.2", | ||
"description": "BDD Test Runner for cloud native applications made with AWS", | ||
"version": "2.4.3", | ||
"description": "BDD Test Runner for cloud native applications made with AWS.", | ||
"main": "dist/index.js", | ||
@@ -48,2 +48,3 @@ "typings": "dist/index.d.ts", | ||
"toposort": "^2.0.2", | ||
"uuid": "^3.3.3", | ||
"ws": "^6.2.1" | ||
@@ -50,0 +51,0 @@ }, |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
332598
9601
1
20
2
+ Addeduuid@^3.3.3
+ Addeduuid@3.4.0(transitive)