New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

artillery-plugin-expect

Package Overview
Dependencies
Maintainers
2
Versions
368
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

artillery-plugin-expect - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

8

index.js

@@ -93,7 +93,6 @@ /* This Source Code Form is subject to the terms of the Mozilla Public

let body = maybeParseBody(res);
_.each(expectations, ex => {
const checker = Object.keys(ex)[0];
debug(`checker: ${checker}`);
let result = EXPECTATIONS[checker].call(
let result = EXPECTATIONS[checker]?.call(
this,

@@ -156,4 +155,5 @@ ex,

(
res.headers['content-type'].indexOf('application/json') !== -1 ||
res.headers['content-type'].indexOf('application/problem+json') !== -1
res.headers['content-type'].indexOf('application/json') !== -1
|| res.headers['content-type'].indexOf('application/problem+json') !== -1
|| res.headers['content-type'].indexOf('application/ld+json') !== -1
)

@@ -160,0 +160,0 @@ ) {

@@ -8,3 +8,2 @@ /* This Source Code Form is subject to the terms of the Mozilla Public

const debug = require('debug')('plugin:expect');
const chalk = require('chalk');
const template = global.artillery ? global.artillery.util.template : require('artillery/util').template;

@@ -21,5 +20,44 @@ const _ = require('lodash');

matchesRegexp: expectMatchesRegexp,
notHasProperty: expectNotHasProperty
notHasProperty: expectNotHasProperty,
cdnHit: expectCdnHit,
};
function expectCdnHit(expectation, body, req, res, userContext) {
debug('check cdn');
debug('expectation');
let result = {
ok: false,
type: 'cdnHit',
got: 'cache status header not found'
};
if(expectation.cdnHit) {
result.expected = 'a cache header indicating a cache hit';
} else {
result.expected = 'a cache header indicating a cache miss';
}
const cacheHeaderNames = [
'cf-cache-status', // CloudFlare
'x-cache', // CloudFront, Fastly
'x-vercel-cache' // Vercel
];
const expectedHeaderValues = expectation.cdnHit ? ['hit', 'stale'] : ['miss'];
for(const h of cacheHeaderNames) {
if (res.headers[h]) {
for(const headerValue of expectedHeaderValues) {
if (res.headers[h].toLowerCase().startsWith(headerValue)) {
result.ok = true;
result.got = `${h} is ${res.headers[h]}`;
}
}
}
}
return result;
}
function expectEquals(expectation, body, req, res, userContext) {

@@ -113,7 +151,8 @@ debug('check equals');

if (
body !== null &&
body !== null &&
typeof body === 'object' &&
(
res.headers['content-type'].indexOf('application/json') !== -1 ||
res.headers['content-type'].indexOf('application/problem+json') !== -1
res.headers['content-type'].indexOf('application/json') !== -1
|| res.headers['content-type'].indexOf('application/problem+json') !== -1
|| res.headers['content-type'].indexOf('application/ld+json') !== -1
)

@@ -120,0 +159,0 @@ ) {

{
"name": "artillery-plugin-expect",
"version": "2.0.1",
"version": "2.1.0",
"description": "Expectations and assertions for HTTP",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc