Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

allow insecure certs #38

Merged
merged 4 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,22 @@ _Example of a Validation Error_
[ Strest ] ✨ Done in 0.245s
```

## Allow Insecure certs

Boolean to allow:

- insecure certificates
- self-signed certificates
- expired certificates

```yaml
# Example
allowInsecure: true
someRequest:
url: ...
method: ...
```

## Configuration
You can create a file in your Computer's home directory called `.strestConfig.yml` which will be the custom config for **Strest**.

Expand Down
58 changes: 47 additions & 11 deletions SCHEMA.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# How to write Test? The Schema

- [`version`](#version) _Required_
- [`allowInsecure`](#allowInsecure)
- [`requests`](#requests) _Required_
- [`request`](#request)
- [`url`](#url) _Required_
Expand All @@ -16,16 +18,34 @@
- [`delay`](#delay)
- [`repeat`](#repeat)

## Specifications

### `version` **_Required_**

# Specifications
### `version`
**_Required_**<br>
Property specifying the version of the schema. Available versions:

- `1`

### `requests`
**_Required_**<br>
### `allowInsecure`

Boolean to allow:

- insecure certificates
- self-signed certificates
- expired certificates

```yaml
# Example
allowInsecure: true
someRequest:
url: ...
method: ...
```

### `requests` **_Required_**

Array which holds all the requests that are going to be tested

```yaml
# Example
requests:
Expand All @@ -36,20 +56,23 @@ requests:
request1000:
..
```
### `request`
**_At least one request is required_**<br>

### `request` **_At least one request is required_**

A single request. You can name the request however you want. Try not to overwrite names because
this will also overwrite the response data and you'll no longer be able to retrieve the data from the overwritten request.

```yaml
# Example
requests:
someRequestName: # <- a Request
..
```
### `url`
**_Required_**<br>

### `url` **_Required_**

The target URL to which the request will be sent to. _Needs to start with `http` or `https`_

```yaml
# Basic Example
someRequestName:
Expand All @@ -59,9 +82,11 @@ someRequestName:
someConnectedRequest:
url: http://localhost:3000/api/user/Value(getUser.id)/friends
```
### `method`
**_Required_**<br>

### `method` **_Required_**

The HTTP request method that will be used Strest to perform the request. All strings are accepted but consider to use one of the requests listed in the [Mozilla Developer Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods)

```yaml
# Example
somePostRequest:
Expand All @@ -74,7 +99,9 @@ someGetRequest:
```

### `delay`

If present, the execution of the request will be delayed by the specified number of milliseconds.

```yaml
# Example
someRequest:
Expand All @@ -84,6 +111,7 @@ someRequest:
```

### `data`

Specify data that you want to be sent with the request. This data can be formatted either `raw` or as `json`. You may only use one of those keys in a request.

However, `params` can always be added. They'll be added to the request's URL.
Expand Down Expand Up @@ -125,8 +153,11 @@ someRequest:
name: testUser
password: test123
```

### `headers`

Specify HTTP headers that you want to be sent with the request. Formatted as an Object.

```yaml
# Basic Example
someRequest:
Expand All @@ -145,7 +176,9 @@ someRequest:
...

```

### `repeat`

The following example request will be executed 5 times in a row

```yaml
Expand All @@ -157,11 +190,14 @@ someRequest:
```

### `validate`

Validate the incoming response either by a specific value or by a [`Type`](VALIDATION.md).
[More information](README.md#ResponseValidation) about how to validate responses.

### `log`

If set to `true`, the following information will be logged into the console for this request.

- Response Code
- Response Text
- HTTP Headers
Expand Down
3 changes: 2 additions & 1 deletion src/configSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const requestsSchema = Joi.object().keys({

export const Schema = Joi.object({
version: Joi.number().min(1).max(1),
requests: Joi.object({}).pattern(/([^\s]+)/, requestsSchema)
requests: Joi.object({}).pattern(/([^\s]+)/, requestsSchema),
allowInsecure: Joi.boolean().optional()
});


Expand Down
8 changes: 6 additions & 2 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ export const performTests = async (testObjects: object[], printAll: boolean) =>
let testObject: any
let abortBecauseTestFailed = false;

for(testObject of testObjects){

for(testObject of testObjects){

if(testObject['allowInsecure']){
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
}

if(!abortBecauseTestFailed){

const requests = testObject['requests'];
Expand Down
4 changes: 2 additions & 2 deletions tests/commands.jest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spawnSync, SpawnOptions } from 'child_process';
import * as path from 'path';
// import { spawnSync, SpawnOptions } from 'child_process';
// import * as path from 'path';

test('Strest Command Line', async () => {

Expand Down