Skip to content

Commit 936f25b

Browse files
committed
feat: add option to skip tls check for servers using self-signed certs
resolves #18
1 parent 4bd1856 commit 936f25b

File tree

6 files changed

+23
-12
lines changed

6 files changed

+23
-12
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Options:
2323
- `-a, --auth-header <auth>` - Authorization header (required)
2424
- `-c, --config <path>` - Path to YAML configuration file (optional)
2525
- `-o, --har-file <path>` - Path to write HAR file output (optional)
26+
- `--skip-tls-verification` - Use when running a server with self-signed certificates (optional)
2627
- `-h, --help` - Show help message
2728

2829
## Features

bin/scimverify.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ let configPath = null;
1515
let baseUrl = null;
1616
let authHeader = null;
1717
let harFileName = null;
18+
let skipTlsVerification = false;
1819

1920
// Simple argument parser
2021
for (let i = 0; i < args.length; i++) {
@@ -27,6 +28,8 @@ for (let i = 0; i < args.length; i++) {
2728
authHeader = args[++i];
2829
} else if (arg === '--har-file' || arg === '-o') {
2930
harFileName = args[++i];
31+
} else if (arg === '--skip-tls-check') {
32+
skipTlsVerification = true;
3033
} else if (arg === '--help' || arg === '-h') {
3134
printHelp();
3235
process.exit(0);
@@ -44,6 +47,7 @@ Options:
4447
-b, --base-url <url> Base URL of the SCIM server
4548
-a, --auth-header <auth> Authorization header (e.g. "Bearer token")
4649
-o, --har-file <path> Path to write HAR file output
50+
--skip-tls-check Use when running a server with self-signed certificates
4751
-h, --help Show this help message
4852
4953
Example:
@@ -85,6 +89,7 @@ async function main() {
8589
const result = await runAllTests({
8690
baseURL: baseUrl,
8791
authHeader: authHeader,
92+
skipTlsVerification,
8893
...config,
8994
});
9095

scim.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ if (import.meta.url === `file://${process.argv[1]}`) {
113113
{
114114
baseURL: process.env.BASE_URL,
115115
authHeader: process.env.AUTH_HEADER,
116+
skipTlsVerification: !!process.env.SKIP_TLS_VERIFICATION,
116117
...parse(process.env.CONFIG),
117118
}
118119
).then((result) => {

server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ async function processQueue() {
5454
process.env.AUTH_HEADER = req.body.authHeader;
5555
process.env.CONFIG = JSON.stringify(req.body);
5656
process.env.HAR_VIA_DIAGNOSTIC = true;
57+
process.env.SKIP_TLS_VERIFICATION = false;
5758

5859
const responseStream = new Writable({
5960
write(chunk, encoding, callback) {

site/docker/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Before running the command below, make sure you have a local `config.yaml` file
1515
| `CONFIG_FILE` | No | Path to YAML configuration file |
1616
| `CONFIG` | No\* | YAML configuration |
1717
| `HAR_FILE_NAME` | No | Path to write HAR file output |
18+
| `SKIP_TLS_VERIFICATION` | No | Set non-empty value when running a server with self-signed certificates |
1819

1920
\* `CONFIG` is required when `CONFIG_FILE` is not set
2021

src/helpers.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import axios from 'axios';
2+
import https from 'https';
23
import fs from 'fs';
34

45
let harEntries = [];
@@ -16,7 +17,7 @@ function createHarEntry(t, request, response) {
1617
cookies: [],
1718
headers: Object.entries(request.headers)
1819
.filter(([_, value]) => value !== undefined && value !== null && value !== '')
19-
.map(([name, value]) => ({name, value})),
20+
.map(([name, value]) => ({ name, value })),
2021
queryString: [],
2122
postData: request.data ? {
2223
mimeType: request.headers['Content-Type'] || 'application/json',
@@ -32,7 +33,7 @@ function createHarEntry(t, request, response) {
3233
cookies: [],
3334
headers: Object.entries(response.headers)
3435
.filter(([_, value]) => value !== undefined && value !== null && value !== '')
35-
.map(([name, value]) => ({name, value})),
36+
.map(([name, value]) => ({ name, value })),
3637
content: {
3738
size: -1,
3839
mimeType: response.headers['content-type'] || 'application/json',
@@ -52,7 +53,7 @@ function createHarEntry(t, request, response) {
5253
}
5354

5455
export function writeHarFile(testName) {
55-
56+
5657
const har = {
5758
log: {
5859
version: '1.2',
@@ -64,7 +65,7 @@ export function writeHarFile(testName) {
6465
entries: harEntries
6566
}
6667
};
67-
68+
6869
const harPath = testName;
6970
fs.writeFileSync(harPath, JSON.stringify(har, null, 2));
7071
harEntries = []; // Clear entries after writing
@@ -90,7 +91,8 @@ export function getAxiosInstance(config, testContext = null) {
9091
validateStatus: function (status) {
9192
// Return true for any status code (don't throw errors)
9293
return true;
93-
}
94+
},
95+
...(config.skipTlsVerification && { httpsAgent: new https.Agent({ rejectUnauthorized: false }) })
9496
});
9597

9698
const t = testContext;
@@ -103,8 +105,8 @@ export function getAxiosInstance(config, testContext = null) {
103105
// Add response interceptor to log the raw HTTP response
104106
instance.interceptors.response.use(response => {
105107
const harEntry = createHarEntry(t, response.config, response);
106-
107-
if(process.env.HAR_VIA_DIAGNOSTIC) {
108+
109+
if (process.env.HAR_VIA_DIAGNOSTIC) {
108110
t?.diagnostic(harEntry);
109111
}
110112

@@ -114,8 +116,8 @@ export function getAxiosInstance(config, testContext = null) {
114116
}, error => {
115117
if (error.response) {
116118
const harEntry = createHarEntry(error.response.config, error.response);
117-
118-
if(process.env.HAR_VIA_DIAGNOSTIC) {
119+
120+
if (process.env.HAR_VIA_DIAGNOSTIC) {
119121
t?.diagnostic(harEntry);
120122
}
121123

@@ -126,7 +128,7 @@ export function getAxiosInstance(config, testContext = null) {
126128
return instance;
127129
}
128130

129-
export function canonicalize(resource, schema){
131+
export function canonicalize(resource, schema) {
130132
// Create a deep copy of the user object
131133
const canonicalizedResource = JSON.parse(JSON.stringify(resource));
132134
const schemas = canonicalizedResource.schemas || [];
@@ -140,14 +142,14 @@ export function canonicalize(resource, schema){
140142
if (!canonicalizedResource[coreSchema]) {
141143
canonicalizedResource[coreSchema] = {};
142144
}
143-
145+
144146
// Move attributes that are not schemas, meta, id, or extension schemas to the core schema
145147
Object.keys(canonicalizedResource).forEach(key => {
146148
// Skip schemas, meta, id, and extension schemas (which start with urn: but aren't the core schema)
147149
if (key === 'schemas' || key === 'meta' || key === 'id' || key == 'externalId' || schemas.includes(key)) {
148150
return;
149151
}
150-
152+
151153
// Move the attribute to the core schema and delete from root
152154
canonicalizedResource[coreSchema][key] = canonicalizedResource[key];
153155
delete canonicalizedResource[key];

0 commit comments

Comments
 (0)