Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
cucumber-steps-api
Advanced tools
Cucumber step library for API testing and support functions
Install npm module as dev dependency using
npm install --save-dev cucumber-steps-api
If target module is executable test suite then add cucumber-steps-api
as normal dependency using
npm install --save cucumber-steps-api
Add cucumber-steps-api
as dependency and require the module to register step definitions.
./node_modules/.bin/cucumber-js features/**/*.feature --require=cucumber-steps-api
Assuming the feature specification are located in features
directory
const gulp = require('gulp');
const cucumber = require('gulp-cucumber');
gulp.src('features/**/*.feature').pipe(
cucumber({
steps: ['cucumber-steps-api', `features/**/*.js`],
format: ['summary', `json:output/json/results-${Date.now()}.json`],
})
)
These features are not fully implemented yet.
These features are yet to be implemented
A new request client is initialized for each scenario. Any default options set on client are used for all subsequent requests. Any request level options are used for next requests only.
Cucumber Expression: I request {string} method at {expression} url
I request "GET" method at "https://httpbin.org/anything" url
I request "POST" method at "https://httpbin.org/anything" url
I request "OPTIONS" method at "https://httpbin.org/anything" url
/I request (GET|POST|PUT|PATCH|DEL|DELETE|HEAD|OPTIONS|LINK) method at "([^"]+)" url/
I request GET method at "https://httpbin.org/anything" url
I request POST method at "https://httpbin.org/anything" url
I request PUT method at "${ENV_NAME_FOR_URL}" url
/(?:\w|\s|[-_])+ is available at "([^"]+)" url/
API is available at "https://httpbin.org/anything" url
Service is available at "https://httpbin.org/anything" url
Any String Here is available at "${ENV_NAME_FOR_URL}" url
/I set "([^"]+)" header as "([^"]+)"/
I set "some-name" header as "some-value"
I set "other-name" header as "${some-variable}"
I set "Content-Type" header as "json"
I set "Accept" header as "application/json"
/I set headers(?: as):/
I set headers:
| some-name | some-value |
| some-other | other-value |
I set headers as:
| some-name | some-value |
| some-other | other-value |
/I set "([^"]+)" query param as "([^"]+)"/
I set "some-name" query param as "some-value"
I set "other-name" query param as "${some-variable}"
/I set query params as "([^"]+)"/
I set query params as "some-name=${some-variable-value}&other-name=other-uri-encoded-value"
/I set query params(?: as):/
I set query params:
| some-name | some-value |
| some-other | other-value |
I set query params as:
| some-name | some-value |
| some-other | other-value |
Set body using content, text, content template, data table or template files. Setting body for GET or HEAD method has no effect, the body will be ignored for GET and HEAD method.
/I set ?(JSON|XML|FormData|json|xml|form|form-data|multipart)? request body to '([^']+)'/
Set request body using provided text content and optionally set content-type for request.
I set request body to 'some text here'
I set JSON request body to '{"name":"value","other":"value"}'
I set XML request body to '<request><name>value</name><other>value</other></request>'
I set form request body to 'name=value&other=uriencodedvalue'
/I set ?(JSON|XML|FormData|json|xml|form|form-data|multipart)? request body with content:$/
Set request body using provided text content and optionally set content-type for request. Content can not use expression/variable resolvers. Any variable mentioned in content in form of $somevar
or ${somevar}
will be ignored.
I set request body with content:
"""
some multiline text here
some more text here
"""
I set JSON request body with content:
"""
{
"name":"value",
"other":"value"
}
"""
I set XML request body with content:
"""
<request>
<name>value</name>
<other>value</other>
</request>
"""
I set form request body with content:
"""
name=value&other=uriencodedvalue
"""
/I set ?(JSON|XML|FormData|json|xml|form|form-data|multipart)? request body (?:to|as):$/
Set request body using data table and optionally set content-type for request. The data table follows two column structure with first column having key and second column having value. Data table can not use expression/variable resolvers.
I set request body to:
| some-name | some-value |
| other | value |
I set JSON request body as:
| some-name | some-value |
| other | value |
/I set ?(JSON|XML|FormData|json|xml|form|form-data|multipart)? request body from "([^"]+)"(?: file)?$/
Set request body using content from a file and optionally set content-type for request.
I set request body from "sample.json" file
I set JSON request body from "sample.json"
I set XML request body from "sample.xml"
/I set ?(JSON|XML|FormData|json|xml|form|form-data|multipart)? request body from ?(JS|js)? template content:$/
Set request body using provided template and optionally set content-type for request. If template type is not specified then default value is js
.
I set request body from template content:
"""
{
id: options.guid(),
otherId: options.uuid.v4(),
name: options.faker.name.findName(),
address: options.chance.address()
}
"""
I set JSON request body from JS template content:
"""
{
id: options.guid(),
otherId: options.uuid.v4(),
name: options.faker.name.findName(),
address: options.chance.address()
}
"""
/I set ?(JSON|XML|FormData|json|xml|form|form-data|multipart)? request body from "([^"]+)" template$/
Set request body using a template file and optionally set content-type for request.
I set request body from "sample.js" template
I set JSON request body from "sample.tpl.js" template
/I set ?(JSON|XML|FormData|json|xml|form|form-data|multipart)? request body from "([^"]+)" template with options(?: as)?:$/
Set request body using a template file and context for template and optionally set content-type for request. The values defined in data table is available as options object in template.
I set request body from "sample.js" template with options as:
| param1 | value1 |
| param2 | value2 |
I set JSON request body from "sample.tpl.js" template with options:
| param1 | value1 |
| param2 | value2 |
HttpClient provides utility api to formulate request and send to remote server. It internally uses superagent instance.
Setting default request options for all subsequent requests -
const { HttpClient } = require('cucumber-steps-api');
const client = new HttpClient();
client.defaults
.authorization('AAAAAAAA', 'Digest')
.authorization('x.y.z', 'Bearer')
.type('json')
.type('application/json')
.accept('json')
.header('accept', 'json')
.header('name1', 'value1')
.headers({ name1: 'value1', name2: 'value2' })
.headers([
{ name: 'name1', value: 'value1' },
{ name: 'name2', value: 'value2' },
])
.query('name1', 'value1')
.queries(['name1=value1', 'name2=value2'])
.queries([
{ name: 'name1', value: 'value1' },
{ name: 'name2', value: 'value2' },
])
.queries([['name1', 'value1'], ['name2', 'value2']])
.key('path/to/key/file')
.cert('path/to/key/file')
.ca('path/to/key/file')
.timeout(30000) // 30 sec in milliseconds
.timeout({ deadline: 30000, response: 5000 });
Setting request options for next requests -
const { HttpClient } = require('cucumber-steps-api');
const client = new HttpClient();
client
.url('https://httpbin.org/anything')
.method('POST')
.authorization('AAAAAAAA', 'Digest')
.authorization('x.y.z', 'Bearer')
.type('json')
.type('application/json')
.accept('json')
.header('accept', 'json')
.header('name1', 'value1')
.headers({ name1: 'value1', name2: 'value2' })
.headers([
{ name: 'name1', value: 'value1' },
{ name: 'name2', value: 'value2' },
])
.query('name1', 'value1')
.queries(['name1=value1', 'name2=value2'])
.queries([
{ name: 'name1', value: 'value1' },
{ name: 'name2', value: 'value2' },
])
.queries([['name1', 'value1'], ['name2', 'value2']])
.key('path/to/key/file')
.cert('path/to/key/file')
.ca('path/to/key/file')
.timeout(30000) // 30 sec in milliseconds
.timeout({ deadline: 30000, response: 5000 })
.body({ somekey: 'somevalue' };
Send request with body client.send([body, headers, queries, type, accept])
const { HttpClient } = require('cucumber-steps-api');
const client = new HttpClient();
client
.url('https://httpbin.org/anything')
.method('POST')
.send(
{ somekey: 'somevalue' },
{ headername: 'headervalue', otherheader: 'value' },
[{ name: 'name1', value: 'value1' }, { name: 'name2', value: 'value2' }],
'json',
'json'
);
FAQs
Cucumber step library for API testing and support functions
We found that cucumber-steps-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.