
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
graphql-tester
Advanced tools
Module for writing fluent tests against a GraphQL API.
This example works against the live SWAPI Implementation available on http://graphql-swapi.parseapp.com. There is a real test, using Mocha and Chai for this under src/test/swapi/simple-swapi.tests.js
import {tester} from 'graphql-tester';
const test = tester({
url: 'http://graphql-swapi.parseapp.com'
});
// This tests a successful request for the name of person 1
test('{person(personID: 1) { name } }')
.then((response) => {
assert(response.success == true);
assert(response.status == 200);
assert(response.data.person.name == 'Luke Skywalker');
});
// This tests a request for the name of non-existant person 1234
test('{person(personID: 1234) { name } }')
.then((response) => {
assert(response.success == false);
assert(response.status == 200);
});
// This tests a malformed query
test('{person(personId: 1) { name } }')
.then((response) => {
assert(response.success == false);
assert(response.status == 400);
});
At it's core, this library allows you to make a request to a service and perform assertions on the response. The way that the request query is generated, and the response is asserted is entirely up to you. The above example uses a simple string for the query, and the core assert method. However, there is no need to use these mechanisms and you can use whatever makes the most sense for your tests.
The "tester" function is used to create a function that can be used to test a specific API. At creation time it is given all of the details needed to call the API, and then it can be used to make requests and get responses from the API. This function takes a single Object as a parameter, with the following keys:
This function will return a function that can be used to make requests to the API. This returned function takes a single parameter as being the GraphQL Query to execute, and will return a Promise for the response from the server. This Promise will be resolved with an Object containing:
If there was a catastrophic failure in making the request - connection refused, for example - then the Promise will instead be rejected.
Note that because a Promise is returned you get some benefits here. You can use this promise as a return in certain promise-aware testing tools - e.g. Mocha. You can also use the same promise to make assertions fit better into some BDD style tests.
FAQs
Test Framework for executing integration tests against GraphQL Services
The npm package graphql-tester receives a total of 1,038 weekly downloads. As such, graphql-tester popularity was classified as popular.
We found that graphql-tester 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
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.