Skip to content

Instantly share code, notes, and snippets.

💭
Probably helping someone...

Danny Dainton DannyDainton

💭
Probably helping someone...
View GitHub Profile
@DannyDainton
DannyDainton / saveToPDF.js
Last active Jun 2, 2020
Save a JSON response containing a base64 value to a PDF file within Postman. Added this script to the `Tests` tab and view the response in the Visualiser. Reference post - https://medium.com/younited-tech-blog/serve-yourself-combining-postman-and-express-3fd1dd9f545c
View saveToPDF.js
let myPDFData = {
contract: Buffer.from(pm.response.json().contract, 'base64'),
reference: pm.response.json().reference
}
let template = `
<script src="https://unpkg.com/jspdf@latest/dist/jspdf.min.js"></script>
<button onclick="savePDF()">Save To PDF</button>
@DannyDainton
DannyDainton / naughtyStrings.json
Last active Mar 15, 2020
The Big List of Naughty Strings (https://github.com/minimaxir/big-list-of-naughty-strings) in a JSON data file that can be used with Postman's Collection Runner. You would only need to add the `{{naughtyValue}}` variable to the request and the Collection Runner will do the rest.
View naughtyStrings.json
[
{
"naughtyValue": ""
},
{
"naughtyValue": "undefined"
},
{
"naughtyValue": "undef"
},
View Bootstrap_Styled_Table.html
<html>
<head>
<title>My Awesome Template</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="table-responsive">
<table class="table table-striped table-bordered">
View Sample_Newman_Summary.json
{
"cursor": {
"position": 0,
"iteration": 0,
"length": 1,
"cycles": 1,
"empty": false,
"eof": false,
"bof": true,
"cr": false,
@DannyDainton
DannyDainton / NewmanCustomHTMLReport.hbs
Created Nov 16, 2018
The is a custom HTML Report template that can be used with the Postman Newman Collection Runner
View NewmanCustomHTMLReport.hbs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Postman - Reports</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
//custom script
@DannyDainton
DannyDainton / CheckAndSetAnAuthToken.js
Created Sep 10, 2018
Automatically set a JWT if the current one is invalid
View CheckAndSetAnAuthToken.js
// This can be placed in the Pre-requests on the collection level.
// It will check to see if certain valid variables are present in an environment file.
// If these are not present, it be go and get another valid token
// The 'AuthData' variable is a Base64 encoded client_id and client_secret
// This my need to be tweaked for your needs but the mechanism will work.
const moment = require('moment')
const getJWT = {
url: `${pm.environment.get('tokenBaseURL')}/Auth/connect/token`,
@DannyDainton
DannyDainton / DynamicallyUnsetVariables.js
Last active Oct 15, 2019
When placed in the Postman 'Tests' tab, this script will unset all the variables that start with a specifically given prefix so that it's slightly different from the .clear() built-in fuction.
View DynamicallyUnsetVariables.js
function cleanup() {
const clean = _.keys(pm.environment.toObject())
_.each(clean, (arrItem) => {
if (arrItem.startsWith("some_prefix")) {
pm.environment.unset(arrItem)
}
})
}
cleanup()
@DannyDainton
DannyDainton / PurgeRabbitQueues.js
Last active Jun 29, 2018
JQuery code to Purge Specific Queues on RabbitMQ
View PurgeRabbitQueues.js
var purgeQueue = (name, callback) => {
$.ajax({
url: 'api/queues/<VHOST>/' + name + '/contents/',
type: 'DELETE',
success: callback
})
}
$.ajax({
url: '/api/queues/',
View dummyUsers.json
{
"users":[
{
"id":1,
"first_name":"Robby",
"last_name":"McGrale",
"email":"rmcgrale0@skype.com",
"gender":"Female",
"ip_address":"98.160.131.109"
},
You can’t perform that action at this time.