Permalink
Browse files

chore: Commence file clean-up

  • Loading branch information...
michalholasek
michalholasek committed Jan 30, 2018
1 parent a8f1be7 commit d1bcbb1319e04d0791f14b540a1cba3d0ea980e8
Showing with 497 additions and 648 deletions.
  1. +2 −0 .eslintrc.js
  2. +0 −2 test/fixtures/blueprint-data.js
  3. +9 −8 test/fixtures/groupless-names.js
  4. +8 −0 test/fixtures/hooks-log.coffee
  5. +0 −15 test/fixtures/hooks-log.js
  6. +10 −0 test/fixtures/multifile/multifile_hooks.coffee
  7. +0 −15 test/fixtures/multifile/multifile_hooks.js
  8. +17 −0 test/fixtures/regression-152.coffee
  9. +0 −31 test/fixtures/regression-152.js
  10. +2 −3 test/fixtures/response/empty-body-hooks.js
  11. +3 −3 test/fixtures/sandboxed-hook.js
  12. +5 −3 test/fixtures/sandboxed-hooks-log.js
  13. +8 −9 test/fixtures/sanitation/any-content-guard-pattern-matching.js
  14. +6 −5 test/fixtures/sanitation/any-content-pattern-matching.js
  15. +2 −2 test/fixtures/sanitation/entire-request-body.js
  16. +2 −2 test/fixtures/sanitation/entire-response-body.js
  17. +6 −5 test/fixtures/sanitation/plain-text-response-body.js
  18. +3 −3 test/fixtures/sanitation/request-body-attribute.js
  19. +5 −5 test/fixtures/sanitation/request-headers.js
  20. +12 −12 test/fixtures/sanitation/response-body-attribute.js
  21. +11 −11 test/fixtures/sanitation/response-headers.js
  22. +2 −2 test/fixtures/sanitation/transaction-erroring-hooks.js
  23. +2 −2 test/fixtures/sanitation/transaction-marked-failed-after.js
  24. +3 −3 test/fixtures/sanitation/transaction-marked-failed-before.js
  25. +3 −3 test/fixtures/sanitation/transaction-marked-skipped.js
  26. +2 −2 test/fixtures/sanitation/transaction-passing.js
  27. +3 −5 test/fixtures/sanitation/transaction-secured-erroring-hooks.js
  28. +5 −4 test/fixtures/sanitation/uri-parameters.js
  29. +11 −0 test/fixtures/scripts/dummy-server-crash.coffee
  30. +0 −18 test/fixtures/scripts/dummy-server-crash.js
  31. +20 −0 test/fixtures/scripts/dummy-server-ignore-term.coffee
  32. +0 −23 test/fixtures/scripts/dummy-server-ignore-term.js
  33. +12 −0 test/fixtures/scripts/dummy-server-kill.coffee
  34. +0 −18 test/fixtures/scripts/dummy-server-kill.js
  35. +11 −0 test/fixtures/scripts/dummy-server.coffee
  36. +0 −17 test/fixtures/scripts/dummy-server.js
  37. +9 −0 test/fixtures/scripts/endless-ignore-term.coffee
  38. +0 −15 test/fixtures/scripts/endless-ignore-term.js
  39. +1 −0 test/fixtures/scripts/exit-0.coffee
  40. +0 −3 test/fixtures/scripts/exit-0.js
  41. +1 −0 test/fixtures/scripts/exit-3.coffee
  42. +0 −3 test/fixtures/scripts/exit-3.js
  43. +25 −0 test/fixtures/scripts/handle-windows-sigint.coffee
  44. +0 −36 test/fixtures/scripts/handle-windows-sigint.js
  45. +3 −0 test/fixtures/scripts/kill-self.coffee
  46. +0 −4 test/fixtures/scripts/kill-self.js
  47. +11 −0 test/fixtures/scripts/stderr.coffee
  48. +0 −16 test/fixtures/scripts/stderr.js
  49. +11 −0 test/fixtures/scripts/stdout-exit-3.coffee
  50. +0 −16 test/fixtures/scripts/stdout-exit-3.js
  51. +11 −0 test/fixtures/scripts/stdout.coffee
  52. +0 −16 test/fixtures/scripts/stdout.js
  53. +2 −2 test/fixtures/swagger-multiple-responses.js
  54. +1 −4 test/fixtures/swagger-transaction-names.js
  55. +4 −6 test/fixtures/test2_all.js
  56. +2 −2 test/fixtures/test2_events.js
  57. +4 −7 test/fixtures/test2_hooks.js
  58. +8 −0 test/fixtures/test_all.coffee
  59. +0 −16 test/fixtures/test_all.js
  60. +1 −8 test/fixtures/test_events.js
  61. +4 −0 test/fixtures/test_hooks.coffee
  62. +0 −11 test/fixtures/test_hooks.js
  63. +36 −49 test/integration/proxy-test.js
  64. +178 −203 test/unit/hooks-worker-client-test.js
View
@@ -10,6 +10,8 @@ module.exports = {
'comma-dangle': ['error', 'never'],
'consistent-return': 'off',
'func-names': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'max-len': 'off',
'no-bitwise': 'off',
'no-continue': 'off',
@@ -1,5 +1,3 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
module.exports = {
'./test/fixtures/multiple-examples.apib': {
raw: 'FORMAT: 1A\n\n# Machines API\n\n# Group Machines\n\n# Machines collection [/machines/{id}]\n + Parameters\n - id (number, `1`)\n\n## Get Machines [GET]\n\n- Request (application/json)\n + Parameters\n - id (number, `2`)\n\n- Response 200 (application/json; charset=utf-8)\n\n [\n {\n "type": "bulldozer",\n "name": "willy"\n }\n ]\n\n- Request (application/json)\n + Parameters\n - id (number, `3`)\n\n- Response 200 (application/json; charset=utf-8)\n\n [\n {\n "type": "bulldozer",\n "name": "willy"\n }\n ]\n',
@@ -1,11 +1,12 @@
var hooks = require('hooks');
var before = hooks.before;
var after = hooks.after;
const hooks = require('hooks');
after(' > Machines collection > Get Machines', function(transaction){
transaction['fail'] = 'failed in sandboxed hook';
const before = hooks.before;
const after = hooks.after;
after(' > Machines collection > Get Machines', (transaction) => {
transaction.fail = 'failed in sandboxed hook';
});
before(' > Machines collection > Get Machines', function(transaction){
transaction['fail'] = 'failed in sandboxed hook';
});
before(' > Machines collection > Get Machines', (transaction) => {
transaction.fail = 'failed in sandboxed hook';
});
@@ -0,0 +1,8 @@
{before, after, log} = require 'hooks'
before "Machines > Machines collection > Get Machines", (transaction) ->
log {err: 'Error object!'}
log true
after "Machines > Machines collection > Get Machines", (transaction) ->
log "using hooks.log to debug"
View

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,10 @@
{after} = require 'hooks'
after "Name API > /name > GET", (transaction) ->
console.log "after name"
after "Greeting API > /greeting > GET", (transaction) ->
console.log "after greeting"
after "Message API > /message > GET", (transaction) ->
console.log "after message"

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,17 @@
hooks = require 'hooks'
# New hooks helper function
hooks.beforeEach = (hookFn) ->
hooks.beforeAll (done) ->
for transactionKey, transaction of hooks.transactions or {}
hooks.beforeHooks[transaction.name] ?= []
hooks.beforeHooks[transaction.name].unshift hookFn
done()
hooks.beforeEach (transaction) ->
# add query parameter to each transaction here
paramToAdd = "api-key=23456"
if transaction.fullPath.indexOf('?') > -1
transaction.fullPath += "&" + paramToAdd
else
transaction.fullPath += "?" + paramToAdd

This file was deleted.

Oops, something went wrong.
@@ -1,7 +1,6 @@
var hooks = require('hooks');
const hooks = require('hooks');
hooks.beforeEachValidation(function (transaction, done) {
hooks.beforeEachValidation((transaction, done) => {
if (transaction.real.body) {
transaction.fail = 'The response body must be empty';
}
@@ -1,3 +1,3 @@
after('Machines > Machines collection > Get Machines', function(transaction){
transaction['fail'] = 'failed in sandboxed hook';
});
after('Machines > Machines collection > Get Machines', (transaction) => {
transaction.fail = 'failed in sandboxed hook';
});
@@ -1,7 +1,9 @@
before("Machines > Machines collection > Get Machines", function (transaction) {
/* eslint-disable no-undef */
before('Machines > Machines collection > Get Machines', () => {
log('shall not print, but be present in logs');
});
after("Machines > Machines collection > Get Machines", function (transaction) {
log("using sandboxed hooks.log");
after('Machines > Machines collection > Get Machines', () => {
log('using sandboxed hooks.log');
});
@@ -1,31 +1,30 @@
var hooks = require('hooks');
var assert = require('chai').assert;
var tokenPattern = /([0-9]|[a-f]){24,}/g;
const assert = require('chai').assert;
const hooks = require('hooks');
hooks.beforeEach(function(transaction, done) {
const tokenPattern = /([0-9]|[a-f]){24,}/g;
hooks.beforeEach((transaction, done) => {
transaction.id = transaction.id.replace(tokenPattern, 'CENSORED');
transaction.origin.resourceName = transaction.origin.resourceName.replace(tokenPattern, 'CENSORED');
done();
});
hooks.afterEach(function(transaction, done) {
hooks.afterEach((transaction, done) => {
try {
JSON.stringify(transaction.test, function(key, value) {
JSON.stringify(transaction.test, (key, value) => {
if (typeof value === 'string') {
assert.notMatch(value, tokenPattern);
}
return value;
});
} catch (error) {
transaction.fail = 'Sensitive data would be sent to Dredd reporter';
transaction.test = {
start: transaction.test.start,
end: transaction.test.end,
duration: transaction.test.duration,
startedAt: transaction.test.startedAt,
message: transaction.fail,
message: transaction.fail
};
}
done();
@@ -1,14 +1,15 @@
var hooks = require('hooks');
var tokenPattern = /([0-9]|[a-f]){24,}/g;
const hooks = require('hooks');
hooks.beforeEach(function(transaction, done) {
const tokenPattern = /([0-9]|[a-f]){24,}/g;
hooks.beforeEach((transaction, done) => {
transaction.id = transaction.id.replace(tokenPattern, 'CENSORED');
transaction.origin.resourceName = transaction.origin.resourceName.replace(tokenPattern, 'CENSORED');
done();
});
hooks.afterEach(function(transaction, done) {
var test = JSON.stringify(transaction.test, function(key, value) {
hooks.afterEach((transaction, done) => {
const test = JSON.stringify(transaction.test, (key, value) => {
if (value.replace) {
return value.replace(tokenPattern, 'CENSORED');
}
@@ -1,6 +1,6 @@
var hooks = require('hooks');
const hooks = require('hooks');
hooks.after('Resource > Update Resource', function(transaction, done) {
hooks.after('Resource > Update Resource', (transaction, done) => {
transaction.test.request.body = '';
done();
});
@@ -1,6 +1,6 @@
var hooks = require('hooks');
const hooks = require('hooks');
hooks.after('Resource > Update Resource', function(transaction, done) {
hooks.after('Resource > Update Resource', (transaction, done) => {
transaction.test.actual.body = '';
transaction.test.expected.body = '';
transaction.test.expected.bodySchema = '';
@@ -1,16 +1,17 @@
var hooks = require('hooks');
var tokenPattern = /([0-9]|[a-f]){24,}/g;
const hooks = require('hooks');
hooks.after('Resource > Update Resource', function(transaction, done) {
var body;
const tokenPattern = /([0-9]|[a-f]){24,}/g;
hooks.after('Resource > Update Resource', (transaction, done) => {
let body;
body = transaction.test.actual.body;
transaction.test.actual.body = body.replace(tokenPattern, '--- CENSORED ---');
body = transaction.test.expected.body;
transaction.test.expected.body = body.replace(tokenPattern, '--- CENSORED ---');
// sanitation of diff in the patch format
// Sanitation of diff in the patch format
delete transaction.test.results.body.results.rawData;
done();
});
@@ -1,7 +1,7 @@
var hooks = require('hooks');
const hooks = require('hooks');
hooks.after('Resource > Update Resource', function(transaction, done) {
var body = JSON.parse(transaction.test.request.body);
hooks.after('Resource > Update Resource', (transaction, done) => {
const body = JSON.parse(transaction.test.request.body);
delete body.token;
transaction.test.request.body = JSON.stringify(body);
done();
@@ -1,9 +1,9 @@
var hooks = require('hooks');
var caseless = require('caseless');
const caseless = require('caseless');
const hooks = require('hooks');
hooks.after('Resource > Update Resource', function(transaction, done) {
var headers = transaction.test.request.headers;
var name = caseless(headers).has('Authorization');
hooks.after('Resource > Update Resource', (transaction, done) => {
const headers = transaction.test.request.headers;
const name = caseless(headers).has('Authorization');
delete headers[name];
transaction.test.request.headers = headers;
done();
@@ -1,8 +1,8 @@
var hooks = require('hooks');
const hooks = require('hooks');
hooks.after('Resource > Update Resource', function(transaction, done) {
// sanitation of the attribute in body
var body;
hooks.after('Resource > Update Resource', (transaction, done) => {
// Sanitation of the attribute in body
let body;
body = JSON.parse(transaction.test.actual.body);
delete body.token;
@@ -12,24 +12,24 @@ hooks.after('Resource > Update Resource', function(transaction, done) {
delete body.token;
transaction.test.expected.body = JSON.stringify(body);
// sanitation of the attribute in JSON Schema
var bodySchema = JSON.parse(transaction.test.expected.bodySchema);
// Sanitation of the attribute in JSON Schema
const bodySchema = JSON.parse(transaction.test.expected.bodySchema);
delete bodySchema.properties.token;
transaction.test.expected.bodySchema = JSON.stringify(bodySchema);
// sanitation of the attribute in validation output
var validationOutput = transaction.test.results.body;
// Sanitation of the attribute in validation output
const validationOutput = transaction.test.results.body;
var errors = [];
for (var i = 0; i < validationOutput.results.length; i++) {
const errors = [];
for (let i = 0; i < validationOutput.results.length; i++) {
if (validationOutput.results[i].pointer !== '/token') {
errors.push(validationOutput.results[i]);
}
}
validationOutput.results = errors;
var rawData = [];
for (var i = 0; i < validationOutput.rawData.length; i++) {
const rawData = [];
for (let i = 0; i < validationOutput.rawData.length; i++) {
if (validationOutput.rawData[i].property[0] !== 'token') {
rawData.push(validationOutput.rawData[i]);
}
@@ -1,9 +1,9 @@
var hooks = require('hooks');
var caseless = require('caseless');
const caseless = require('caseless');
const hooks = require('hooks');
hooks.after('Resource > Update Resource', function(transaction, done) {
var headers;
var name;
hooks.after('Resource > Update Resource', (transaction, done) => {
let headers;
let name;
headers = transaction.test.actual.headers;
name = caseless(headers).has('authorization');
@@ -15,19 +15,19 @@ hooks.after('Resource > Update Resource', function(transaction, done) {
delete headers[name];
transaction.test.expected.headers = headers;
// sanitation of the header in validation output
var validationOutput = transaction.test.results.headers;
// Sanitation of the header in validation output
const validationOutput = transaction.test.results.headers;
var errors = [];
for (var i = 0; i < validationOutput.results.length; i++) {
const errors = [];
for (let i = 0; i < validationOutput.results.length; i++) {
if (validationOutput.results[i].pointer.toLowerCase() !== '/authorization') {
errors.push(validationOutput.results[i]);
}
}
validationOutput.results = errors;
var rawData = [];
for (var i = 0; i < validationOutput.rawData.length; i++) {
const rawData = [];
for (let i = 0; i < validationOutput.rawData.length; i++) {
if (validationOutput.rawData[i].property[0].toLowerCase() !== 'authorization') {
rawData.push(validationOutput.rawData[i]);
}
@@ -1,6 +1,6 @@
var hooks = require('hooks');
const hooks = require('hooks');
hooks.after('Resource > Update Resource', function(transaction, done) {
hooks.after('Resource > Update Resource', (transaction, done) => {
JSON.parse('💥 boom 💥');
done();
});
Oops, something went wrong.

0 comments on commit d1bcbb1

Please sign in to comment.