Skip to content

Commit

Permalink
All changes for xrun version 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
schwaby.io committed Apr 23, 2024
1 parent a5d6ab0 commit 79f1715
Show file tree
Hide file tree
Showing 81 changed files with 6,899 additions and 95 deletions.
54 changes: 19 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/schwabyio/xrun/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/@schwabyio%252Fxrun)](https://www.npmjs.com/package/@schwabyio/xrun) [![code coverage](https://img.shields.io/badge/Code%20Coverage-80.32%25-green)](https://img.shields.io)

## Table of Contents
- [Overview](#overview)
- [Features](#features)
- [Demos](#demos)
1. [Demo Primary Commands](#demo-primary-commands)
2. [Demo Reporting](#demo-reporting)
- [Installation Steps](#installation-steps)
- [Usage](#usage)
- [Settings](#settings)

- [xRun - CLI Runner For Postman](#xrun---cli-runner-for-postman)
- [Overview](#overview)
- [Features](#features)
- [Installation Steps](#installation-steps)
- [Update Steps](#update-steps)
- [Usage](#usage)
- [Settings](#settings)


<br>
Expand All @@ -21,8 +21,8 @@
xRun is a command line interface (CLI) app that extends [Newman](https://github.com/postmanlabs/newman) to enable your organization to run Postman tests with speed and at scale.

## Features
* Direct support for [xtest!](https://github.com/schwabyio/xtest)
* Run Postman tests in parallel.
* Direct support for [xtest](https://github.com/schwabyio/xtest).
* Run Postman tests in parallel by setting the `limitConcurrency` configuration.
* Run tests locally or as part of Continuous Integration (CI) with your automated build server of choice.
* Generates beautiful html reports that allow you to quickly filter and zero in on test failures.
* Generate junit reports (provided by Postman's Newman).
Expand All @@ -31,29 +31,6 @@ xRun is a command line interface (CLI) app that extends [Newman](https://github.
* By default, all folders (and tests within) from the configured xRunProjectPath are run. You can exclude folders using an exclusion list.
* Single out one or more tests to run by specifying a CSV list of test cases from the command line.

<br>


## Demos

### Demo Primary Commands



TODO




### Demo Reporting



TODO




<br>

## Installation Steps
Expand Down Expand Up @@ -85,17 +62,24 @@ npm install -g @schwabyio/xrun
% xrun
No settings path is currently set. Please provide one below.
What is the absolute path to your xrun settings.json file? /Users/john/xrun/settings.json
The path you have provided is '/Users/john/xrun/settings.json
The path you have provided is '/Users/john/xrun/settings.json'
```
<br>


## Update Steps
To update to the latest version and dependencies.
1. Run the following command:
```console
npm update -g @schwabyio/xrun
```

## Usage
```console
% xrun
__________________________________________________________________________________________________________________________________
xRun Ver. 2.2.0
xRun Ver. 2.4.0
__________________________________________________________________________________________________________________________________


Expand Down
67 changes: 67 additions & 0 deletions lib/getTrustedCaCertFilePath.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
////////////////////////////////////////////////////////////////////////////////
// getTrustedCaCertFilePath.js - Get absolute file path of trusted CA cert //
// for Newman options.sslExtraCaCerts. //
// //
// Created by: schwaby.io //
////////////////////////////////////////////////////////////////////////////////
const { readdir } = require('node:fs/promises')
const path = require('node:path')


////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
const getTrustedCaCertFilePath = async function getTrustedCaCertFilePath(settings) {
const defaultTrustedCaCertDirectoryPath = 'trustedCaCert'
let directoryPath

//Check if settings.trustedCaCertDirectoryPath is an absolute path
if (path.isAbsolute(settings.trustedCaCertDirectoryPath)) {
directoryPath = settings.trustedCaCertDirectoryPath
} else {
//Need to join
directoryPath = path.join(settings.xRunProjectPath, settings.xRunProjectDirectoryName, settings.trustedCaCertDirectoryPath)
}

try {
const filePathArray = []

//Read directoryPath for a .pem file
const files = await readdir(directoryPath)

//Loop over all files
for (const fileName of files) {

//Only add files that match '.pem' file extension
if (path.extname(fileName) === '.pem') {
filePathArray.push(path.join(directoryPath, fileName))
}
}

if (filePathArray.length === 1) {
//There should only be one '.pem' file, return
return filePathArray[0]
} else if (filePathArray.length === 0) {
console.log(`WARNING: No '.pem' file was found within '${directoryPath}'`)
return null
} else {
console.log(`WARNING: Found more than one '.pem' file within '${directoryPath}'. Only using the first found '${filePathArray[0]}'`)
return filePathArray[0]
}

} catch (error) {
//Do not throw error

//Only display warnings when NOT using default trustedCaCertDirectoryPath
if (settings.trustedCaCertDirectoryPath !== defaultTrustedCaCertDirectoryPath) {
//Do not throw error, just display warningMessage
const warningMessage = `WARNING: unable to getTrustedCaCertFilePath(): ${error.code} '${directoryPath}' - ${error.message}`
console.log(warningMessage)
}

return null
}
}


module.exports = getTrustedCaCertFilePath
45 changes: 45 additions & 0 deletions lib/getTrustedCaCertFilePath.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const path = require('node:path')

const getTrustedCaCertFilePath = require('./getTrustedCaCertFilePath')

test('successfully returns a path to a trustedCaCertFile', async() => {
const settings = {}
settings['xRunProjectPath'] = path.join(__dirname, '/unit-tests/test-data/test-project6')
settings['xRunProjectDirectoryName'] = 'xrun'
settings['trustedCaCertDirectoryPath'] = 'trustedCaCert'
const trustedCaCertFilePath = await getTrustedCaCertFilePath(settings)

expect(trustedCaCertFilePath).toContain('unit-tests/test-data/test-project6/xrun/trustedCaCert/successfulCaCert.pem')
})


test('No error occurs when trustedCaCertDirectoryPath does NOT exist and trustedCaCertFilePath === null', async() => {
const settings = {}
settings['xRunProjectPath'] = path.join(__dirname, '/unit-tests/test-data/test-project3')
settings['xRunProjectDirectoryName'] = 'xrun'
settings['trustedCaCertDirectoryPath'] = 'trustedCaCert'
const trustedCaCertFilePath = await getTrustedCaCertFilePath(settings)

expect(trustedCaCertFilePath).toBeNull()
})

test('successfully returns a path to a trustedCaCertFile when using a custom trustedCaCertDirectoryPath', async() => {
const settings = {}
settings['xRunProjectPath'] = path.join(__dirname, '/unit-tests/test-data/test-project7')
settings['xRunProjectDirectoryName'] = 'xrun'
settings['trustedCaCertDirectoryPath'] = 'customTrustedCaCertDirectory'
const trustedCaCertFilePath = await getTrustedCaCertFilePath(settings)

expect(trustedCaCertFilePath).toContain('unit-tests/test-data/test-project7/xrun/customTrustedCaCertDirectory/successfulCaCert.pem')
})


test('successfully returns a path to a trustedCaCertFile when using an absolute path for trustedCaCertDirectoryPath', async() => {
const settings = {}
settings['xRunProjectPath'] = path.join(__dirname, '/unit-tests/test-data/test-project6')
settings['xRunProjectDirectoryName'] = 'xrun'
settings['trustedCaCertDirectoryPath'] = path.join(__dirname, '/unit-tests/test-data/trustedCaCertDirectory')
const trustedCaCertFilePath = await getTrustedCaCertFilePath(settings)

expect(trustedCaCertFilePath).toContain('/unit-tests/test-data/trustedCaCertDirectory/successfulCaCert.pem')
})
43 changes: 25 additions & 18 deletions lib/html-templates/template-xrun-collection.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -295,29 +295,36 @@
<div class="card-header">Response</div>
<div class="card-body">

<div class="grid text-start">
<div class="row mb-3">
<div class="col-2">Response Code</div>
<div class="col-auto border rounded">{{code}} {{status}}</div>
{{#if failureMessage}}
<div class="row mb-3 overflow-hidden maxHeight ">
<div class="col-2">Failure</div>
<div class="col overflow-auto border rounded maxHeight text-color-failed"><pre>{{failureMessage}}</pre></div>
</div>
{{else}}
<div class="grid text-start">
<div class="row mb-3">
<div class="col-2">Response Code</div>
<div class="col-auto border rounded">{{code}} {{status}}</div>
</div>

<div class="row mb-3 overflow-hidden maxHeight">
<div class="col-2">Response Headers</div>
<div class="col overflow-auto border rounded maxHeight"><pre>{{headersHtml}}</pre></div>
</div>
<div class="row mb-3 overflow-hidden maxHeight">
<div class="col-2">Response Headers</div>
<div class="col overflow-auto border rounded maxHeight"><pre>{{headersHtml}}</pre></div>
</div>

{{#if body}}
<div class="row mb-3 overflow-hidden maxHeight">
<div class="col-2">Response Body</div>
<div class="col overflow-auto border rounded maxHeight"><pre>{{bodyHtmlEscaped}}</pre></div>
</div>
{{/if}}
{{#if body}}
<div class="row mb-3 overflow-hidden maxHeight">
<div class="col-2">Response Body</div>
<div class="col overflow-auto border rounded maxHeight"><pre>{{bodyHtmlEscaped}}</pre></div>
</div>
{{/if}}

<div class="row mb-3">
<div class="col-2">Response Time</div>
<div class="col-auto border rounded">{{responseTime}}ms</div>
<div class="row mb-3">
<div class="col-2">Response Time</div>
<div class="col-auto border rounded">{{responseTime}}ms</div>
</div>
</div>
</div>
{{/if}}

</div>
</div>
Expand Down
8 changes: 0 additions & 8 deletions lib/html-templates/template-xrun-summary.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@
<div class="col-2 border rounded">{{timeoutScript}} ms</div>
</div>

<div class="row mb-3">

<div class="col-2"></div>

<div class="col-2">Script Timeout</div>
<div class="col-2 border rounded">{{timeoutScript}} ms</div>
</div>

</div>

</div>
Expand Down
6 changes: 6 additions & 0 deletions lib/json/settings-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,11 @@
"format": "boolean",
"default": true,
"arg": "ignoreRedirects"
},
"trustedCaCertDirectoryPath": {
"doc": "Directory path location to a single PEM formatted certificate file containing one or more trusted CAs. If an absolute directory path is provided that will be used, otherwise if just a directory name is provided, it will look for that directory from within the configured xRunProjectDirectoryName (e.g. <xRunProjectPath>/xrun/trustedCaCert ). Note: 1. The file name must not be included in the directory path. 2. Only one single pem file must exist in the directory (multiple CAs can be put in the single file). 3. The file must include a .pem file extension to be found.",
"format": "non-empty-string",
"default": "trustedCaCert",
"arg": "trustedCaCertDirectoryPath"
}
}
Loading

0 comments on commit 79f1715

Please sign in to comment.