This repository was archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
michalholasek
committed
Jan 31, 2018
1 parent
a8f1be7
commit d1bcbb1
Showing
64 changed files
with
497 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
}); |
17 changes: 8 additions & 9 deletions
17
test/fixtures/sanitation/any-content-guard-pattern-matching.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.