web_plsql 0.3.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +8 -8
- package/.eslintignore +3 -3
- package/.eslintrc.js +347 -273
- package/CHANGELOG.md +127 -106
- package/LICENSE +21 -21
- package/README.md +165 -164
- package/examples/apex.js +70 -70
- package/examples/credentials.js +22 -22
- package/examples/oracledb_example.js +30 -30
- package/examples/sample.js +101 -84
- package/examples/sql/doc_table.sql +13 -13
- package/examples/sql/install.sql +31 -31
- package/examples/sql/sample.pkb +223 -223
- package/examples/sql/sample.pks +24 -24
- package/examples/sql/uninstall.sql +5 -5
- package/examples/static/sample.css +25 -25
- package/jest.config.js +204 -0
- package/package.json +85 -109
- package/src/cgi.ts +95 -95
- package/src/config.ts +97 -97
- package/src/errorPage.ts +286 -286
- package/src/fileUpload.ts +126 -132
- package/src/index.ts +65 -66
- package/src/page.ts +275 -277
- package/src/procedure.ts +360 -359
- package/src/procedureError.ts +27 -27
- package/src/request.ts +139 -139
- package/src/requestError.ts +19 -19
- package/src/stream.ts +26 -26
- package/src/trace.ts +194 -193
- package/test/.eslintrc.json +5 -5
- package/test/{cgi.ts → __tests__/cgi.ts} +96 -95
- package/test/{config.ts → __tests__/config.ts} +41 -41
- package/test/__tests__/errorPage.ts +101 -0
- package/test/{oracledb_mock.ts → __tests__/oracledb_mock.ts} +98 -98
- package/test/{server.ts → __tests__/server.ts} +495 -498
- package/test/{stream.ts → __tests__/stream.ts} +21 -21
- package/test/mock/oracledb.ts +85 -85
- package/test/static/static.html +1 -1
- package/tsconfig.json +24 -23
- package/tsconfig.src.json +23 -22
- package/test/errorPage.ts +0 -101
- package/test/mocha.opts +0 -7
- package/tsconfig.test.json +0 -19
package/src/trace.ts
CHANGED
|
@@ -1,193 +1,194 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Trace utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import fs from 'fs';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import mkdirp from 'mkdirp';
|
|
8
|
-
import util from 'util';
|
|
9
|
-
import express from 'express';
|
|
10
|
-
|
|
11
|
-
const TRACE_ROOT_DIRECTORY = 'trace';
|
|
12
|
-
const SEPARATOR_LINE = '*'.repeat(132);
|
|
13
|
-
|
|
14
|
-
export class Trace {
|
|
15
|
-
_enabled: boolean;
|
|
16
|
-
_directory: string;
|
|
17
|
-
_filename: string;
|
|
18
|
-
_id: number;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Instantiate a new trace object.
|
|
22
|
-
*
|
|
23
|
-
* @param {'on' | 'off' | 'test'} trace - Tracing.
|
|
24
|
-
*/
|
|
25
|
-
constructor(trace: 'on' | 'off' | 'test') {
|
|
26
|
-
this._enabled = trace !== 'off';
|
|
27
|
-
this._directory = getTimestampDirectory();
|
|
28
|
-
this._filename = '';
|
|
29
|
-
this._id = 0;
|
|
30
|
-
|
|
31
|
-
// istanbul ignore if
|
|
32
|
-
if (!this._enabled) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// create the trace directory
|
|
37
|
-
try {
|
|
38
|
-
mkdirp.sync(this._directory);
|
|
39
|
-
if (trace === 'on') {
|
|
40
|
-
// istanbul ignore next
|
|
41
|
-
console.log(`Tracing to the directory "${this._directory}" is enabled.`);
|
|
42
|
-
}
|
|
43
|
-
} catch (e) {
|
|
44
|
-
// istanbul ignore next
|
|
45
|
-
console.error(`Unable to create new trace directory "${this._directory}"`, e);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Start a new trace session for a new request.
|
|
51
|
-
* This adds a trace line to the trace.log file and creating a new request trace file.
|
|
52
|
-
*
|
|
53
|
-
* @param {express.Request} req - The req object represents the HTTP request.
|
|
54
|
-
*/
|
|
55
|
-
start(req: express.Request) {
|
|
56
|
-
// istanbul ignore if
|
|
57
|
-
if (!this._enabled) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface TCustomRequest extends express.Request {
|
|
62
|
-
uniqueRequestID: number;
|
|
63
|
-
}
|
|
64
|
-
const customRequest = req as TCustomRequest;
|
|
65
|
-
|
|
66
|
-
// Create the next unique request id
|
|
67
|
-
customRequest.uniqueRequestID = ++this._id;
|
|
68
|
-
|
|
69
|
-
// append to the trace index
|
|
70
|
-
appendSync(path.join(this._directory, 'trace.log'), `${customRequest.uniqueRequestID.toString().padEnd(10)} - ${getTimestamp()} - ${customRequest.originalUrl}\n`);
|
|
71
|
-
|
|
72
|
-
// compute the trace filename
|
|
73
|
-
this._filename = path.join(this._directory, customRequest.uniqueRequestID.toString() + '.log');
|
|
74
|
-
|
|
75
|
-
// write the initial request information
|
|
76
|
-
this.append(SEPARATOR_LINE +
|
|
77
|
-
getSection('TIMESTAMP', getTimestamp()) +
|
|
78
|
-
getSection('REQUEST ID', customRequest.uniqueRequestID.toString()) +
|
|
79
|
-
getSection('REQUEST', Trace.inspectRequest(req)) +
|
|
80
|
-
SEPARATOR_LINE +
|
|
81
|
-
'\n');
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Write new message to the trace file.
|
|
86
|
-
*
|
|
87
|
-
* @param {string} text - Text to append.
|
|
88
|
-
*/
|
|
89
|
-
write(text: string): void {
|
|
90
|
-
// istanbul ignore else
|
|
91
|
-
if (this._enabled) {
|
|
92
|
-
this.append(`${getTimestamp()}:\n${trimRight(text)}\n${SEPARATOR_LINE}\n`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Append text to the trace file.
|
|
98
|
-
*
|
|
99
|
-
* @param {string} text - Text to append.
|
|
100
|
-
*/
|
|
101
|
-
append(text: string): void {
|
|
102
|
-
// istanbul ignore else
|
|
103
|
-
if (this._enabled) {
|
|
104
|
-
appendSync(this._filename, text);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Return a string representation of the value.
|
|
110
|
-
*
|
|
111
|
-
* @param {
|
|
112
|
-
* @returns {string} - The string representation.
|
|
113
|
-
*/
|
|
114
|
-
static inspect(value:
|
|
115
|
-
return util.inspect(value, {showHidden: false, depth: null, colors: false});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Return a string representation of the request.
|
|
120
|
-
*
|
|
121
|
-
* @param {
|
|
122
|
-
* @param {boolean} simple - Set to false to see all public properties of the request.
|
|
123
|
-
* @returns {string} - The string representation.
|
|
124
|
-
*/
|
|
125
|
-
static inspectRequest(req:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* @param {string}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Trace utilities
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import mkdirp from 'mkdirp';
|
|
8
|
+
import util from 'util';
|
|
9
|
+
import express from 'express';
|
|
10
|
+
|
|
11
|
+
const TRACE_ROOT_DIRECTORY = 'trace';
|
|
12
|
+
const SEPARATOR_LINE = '*'.repeat(132);
|
|
13
|
+
|
|
14
|
+
export class Trace {
|
|
15
|
+
_enabled: boolean;
|
|
16
|
+
_directory: string;
|
|
17
|
+
_filename: string;
|
|
18
|
+
_id: number;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Instantiate a new trace object.
|
|
22
|
+
*
|
|
23
|
+
* @param {'on' | 'off' | 'test'} trace - Tracing.
|
|
24
|
+
*/
|
|
25
|
+
constructor(trace: 'on' | 'off' | 'test') {
|
|
26
|
+
this._enabled = trace !== 'off';
|
|
27
|
+
this._directory = getTimestampDirectory();
|
|
28
|
+
this._filename = '';
|
|
29
|
+
this._id = 0;
|
|
30
|
+
|
|
31
|
+
// istanbul ignore if
|
|
32
|
+
if (!this._enabled) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// create the trace directory
|
|
37
|
+
try {
|
|
38
|
+
mkdirp.sync(this._directory);
|
|
39
|
+
if (trace === 'on') {
|
|
40
|
+
// istanbul ignore next
|
|
41
|
+
console.log(`Tracing to the directory "${this._directory}" is enabled.`);
|
|
42
|
+
}
|
|
43
|
+
} catch (e) {
|
|
44
|
+
// istanbul ignore next
|
|
45
|
+
console.error(`Unable to create new trace directory "${this._directory}"`, e);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Start a new trace session for a new request.
|
|
51
|
+
* This adds a trace line to the trace.log file and creating a new request trace file.
|
|
52
|
+
*
|
|
53
|
+
* @param {express.Request} req - The req object represents the HTTP request.
|
|
54
|
+
*/
|
|
55
|
+
start(req: express.Request): void {
|
|
56
|
+
// istanbul ignore if
|
|
57
|
+
if (!this._enabled) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface TCustomRequest extends express.Request {
|
|
62
|
+
uniqueRequestID: number;
|
|
63
|
+
}
|
|
64
|
+
const customRequest = req as TCustomRequest;
|
|
65
|
+
|
|
66
|
+
// Create the next unique request id
|
|
67
|
+
customRequest.uniqueRequestID = ++this._id;
|
|
68
|
+
|
|
69
|
+
// append to the trace index
|
|
70
|
+
appendSync(path.join(this._directory, 'trace.log'), `${customRequest.uniqueRequestID.toString().padEnd(10)} - ${getTimestamp()} - ${customRequest.originalUrl}\n`);
|
|
71
|
+
|
|
72
|
+
// compute the trace filename
|
|
73
|
+
this._filename = path.join(this._directory, customRequest.uniqueRequestID.toString() + '.log');
|
|
74
|
+
|
|
75
|
+
// write the initial request information
|
|
76
|
+
this.append(SEPARATOR_LINE +
|
|
77
|
+
getSection('TIMESTAMP', getTimestamp()) +
|
|
78
|
+
getSection('REQUEST ID', customRequest.uniqueRequestID.toString()) +
|
|
79
|
+
getSection('REQUEST', Trace.inspectRequest(req)) +
|
|
80
|
+
SEPARATOR_LINE +
|
|
81
|
+
'\n');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Write new message to the trace file.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} text - Text to append.
|
|
88
|
+
*/
|
|
89
|
+
write(text: string): void {
|
|
90
|
+
// istanbul ignore else
|
|
91
|
+
if (this._enabled) {
|
|
92
|
+
this.append(`${getTimestamp()}:\n${trimRight(text)}\n${SEPARATOR_LINE}\n`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Append text to the trace file.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} text - Text to append.
|
|
100
|
+
*/
|
|
101
|
+
append(text: string): void {
|
|
102
|
+
// istanbul ignore else
|
|
103
|
+
if (this._enabled) {
|
|
104
|
+
appendSync(this._filename, text);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Return a string representation of the value.
|
|
110
|
+
*
|
|
111
|
+
* @param {unknown} value - Any value.
|
|
112
|
+
* @returns {string} - The string representation.
|
|
113
|
+
*/
|
|
114
|
+
static inspect(value: unknown): string {
|
|
115
|
+
return util.inspect(value, {showHidden: false, depth: null, colors: false});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Return a string representation of the request.
|
|
120
|
+
*
|
|
121
|
+
* @param {express.Request} req - express.Request.
|
|
122
|
+
* @param {boolean} simple - Set to false to see all public properties of the request.
|
|
123
|
+
* @returns {string} - The string representation.
|
|
124
|
+
*/
|
|
125
|
+
static inspectRequest(req: express.Request, simple: boolean = true): string {
|
|
126
|
+
type RequestKeysType = keyof express.Request;
|
|
127
|
+
const simpleRequest: any = {};
|
|
128
|
+
|
|
129
|
+
// istanbul ignore else
|
|
130
|
+
if (simple) {
|
|
131
|
+
['originalUrl', 'params', 'query', 'url', 'method', 'body', 'files', 'secret', 'cookies'].forEach(key => {
|
|
132
|
+
if (req[key as RequestKeysType]) {
|
|
133
|
+
simpleRequest[key] = req[key as RequestKeysType];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
Object.keys(req).filter(key => typeof key === 'string' && key.length > 1 && key[0] !== '_').forEach(key => {
|
|
138
|
+
simpleRequest[key] = req[key as RequestKeysType];
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return util.inspect(simpleRequest, {showHidden: false, depth: null, colors: false});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Append text to the trace file.
|
|
148
|
+
*
|
|
149
|
+
* @param {string} filename - Trace file name.
|
|
150
|
+
* @param {string} text - Text to append.
|
|
151
|
+
*/
|
|
152
|
+
function appendSync(filename: string, text: string): void {
|
|
153
|
+
try {
|
|
154
|
+
fs.appendFileSync(filename, text);
|
|
155
|
+
} catch (e) {
|
|
156
|
+
// istanbul ignore next
|
|
157
|
+
console.error(`Unable to write to trace file "${filename}"`, e, text);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/*
|
|
162
|
+
* get a section of a trace message
|
|
163
|
+
*/
|
|
164
|
+
function getSection(section: string, text: string): string {
|
|
165
|
+
return `\n${section}\n${'='.repeat(section.length)}\n${text}\n`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/*
|
|
169
|
+
* get a timestamp
|
|
170
|
+
*/
|
|
171
|
+
function getTimestamp(): string {
|
|
172
|
+
return new Date().toISOString();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/*
|
|
176
|
+
* get a new directory name based on the current timestamp
|
|
177
|
+
*/
|
|
178
|
+
function getTimestampDirectory(): string {
|
|
179
|
+
return path.join(TRACE_ROOT_DIRECTORY, getTimestamp().replace(/(-|:)/g, ''));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/*
|
|
183
|
+
* trim any cr/lf at the end of the string
|
|
184
|
+
*/
|
|
185
|
+
function trimRight(text: string): string {
|
|
186
|
+
let s = text;
|
|
187
|
+
|
|
188
|
+
while (s[s.length] === '\n' || s[s.length] === '\r') {
|
|
189
|
+
// istanbul ignore next
|
|
190
|
+
s = s.slice(0, -1);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return s;
|
|
194
|
+
}
|
package/test/.eslintrc.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"mocha": true
|
|
4
|
-
}
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"mocha": true
|
|
4
|
+
}
|
|
5
|
+
}
|
|
@@ -1,95 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {getCGI} from '
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
case '
|
|
26
|
-
return
|
|
27
|
-
case '
|
|
28
|
-
return '
|
|
29
|
-
case '
|
|
30
|
-
return '
|
|
31
|
-
case 'accept
|
|
32
|
-
return 'ACCEPT
|
|
33
|
-
case 'accept-
|
|
34
|
-
return 'ACCEPT-
|
|
35
|
-
case '
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'
|
|
78
|
-
'
|
|
79
|
-
'
|
|
80
|
-
'
|
|
81
|
-
'
|
|
82
|
-
'
|
|
83
|
-
'
|
|
84
|
-
'
|
|
85
|
-
'
|
|
86
|
-
'
|
|
87
|
-
'
|
|
88
|
-
'
|
|
89
|
-
'
|
|
90
|
-
'
|
|
91
|
-
'
|
|
92
|
-
'
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
});
|
|
1
|
+
import {describe, it, expect} from '@jest/globals';
|
|
2
|
+
import {getCGI} from '../../src/cgi';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import os from 'os';
|
|
5
|
+
import type {oracleExpressMiddleware$options} from '../../src/config';
|
|
6
|
+
|
|
7
|
+
describe('cgi', () => {
|
|
8
|
+
it('with a proper configuration object and request', () => {
|
|
9
|
+
const PORT = 4711;
|
|
10
|
+
const ORIGINAL_URL = '/pls/base/package.procedure?p=1#1';
|
|
11
|
+
const DOCUMENT_TABLE_NAME = 'doc-table';
|
|
12
|
+
const REMOTE_ADDRESS = '127.0.0.1';
|
|
13
|
+
|
|
14
|
+
const req = {
|
|
15
|
+
protocol: 'http',
|
|
16
|
+
originalUrl: ORIGINAL_URL,
|
|
17
|
+
method: 'GET',
|
|
18
|
+
params: {
|
|
19
|
+
name: 'index.html'
|
|
20
|
+
},
|
|
21
|
+
httpVersion: '1.1',
|
|
22
|
+
ip: REMOTE_ADDRESS,
|
|
23
|
+
get(name: string) {
|
|
24
|
+
switch (name.toLowerCase()) {
|
|
25
|
+
case 'port':
|
|
26
|
+
return PORT.toString();
|
|
27
|
+
case 'host':
|
|
28
|
+
return 'HOST';
|
|
29
|
+
case 'user-agent':
|
|
30
|
+
return 'USER-AGENT';
|
|
31
|
+
case 'accept':
|
|
32
|
+
return 'ACCEPT';
|
|
33
|
+
case 'accept-encoding':
|
|
34
|
+
return 'ACCEPT-ENCODING';
|
|
35
|
+
case 'accept-language':
|
|
36
|
+
return 'ACCEPT-LANGUAGE';
|
|
37
|
+
case 'referer':
|
|
38
|
+
case 'referrer':
|
|
39
|
+
return 'HTTP-REFERER';
|
|
40
|
+
default:
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
cookies: {
|
|
45
|
+
cookie1: 'value1',
|
|
46
|
+
cookie2: 'value2'
|
|
47
|
+
},
|
|
48
|
+
connection: {
|
|
49
|
+
remoteAddress: REMOTE_ADDRESS
|
|
50
|
+
},
|
|
51
|
+
socket: {
|
|
52
|
+
localPort: PORT
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const options = {
|
|
57
|
+
doctable: DOCUMENT_TABLE_NAME
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const cgi = getCGI(req as unknown as express.Request, options as unknown as oracleExpressMiddleware$options);
|
|
61
|
+
|
|
62
|
+
expect(Object.keys(cgi)).toHaveLength(29);
|
|
63
|
+
|
|
64
|
+
expect(cgi).toStrictEqual({
|
|
65
|
+
'PLSQL_GATEWAY': 'WebDb',
|
|
66
|
+
'GATEWAY_IVERSION': '2',
|
|
67
|
+
'SERVER_SOFTWARE': 'web_plsql',
|
|
68
|
+
'GATEWAY_INTERFACE': 'CGI/1.1',
|
|
69
|
+
'SERVER_PORT': PORT.toString(),
|
|
70
|
+
'SERVER_NAME': os.hostname(),
|
|
71
|
+
'REQUEST_METHOD': 'GET',
|
|
72
|
+
'PATH_INFO': 'index.html',
|
|
73
|
+
'SCRIPT_NAME': '/pls/base',
|
|
74
|
+
'REMOTE_ADDR': REMOTE_ADDRESS,
|
|
75
|
+
'SERVER_PROTOCOL': 'HTTP/1.1',
|
|
76
|
+
'REQUEST_PROTOCOL': 'HTTP',
|
|
77
|
+
'REMOTE_USER': '',
|
|
78
|
+
'HTTP_USER_AGENT': 'USER-AGENT',
|
|
79
|
+
'HTTP_X_FORWARDED_FOR': '',
|
|
80
|
+
'HTTP_HOST': 'HOST',
|
|
81
|
+
'HTTP_ACCEPT': 'ACCEPT',
|
|
82
|
+
'HTTP_ACCEPT_ENCODING': 'ACCEPT-ENCODING',
|
|
83
|
+
'HTTP_ACCEPT_LANGUAGE': 'ACCEPT-LANGUAGE',
|
|
84
|
+
'HTTP_REFERER': 'HTTP-REFERER',
|
|
85
|
+
'WEB_AUTHENT_PREFIX': '',
|
|
86
|
+
'DAD_NAME': 'base',
|
|
87
|
+
'DOC_ACCESS_PATH': 'doc',
|
|
88
|
+
'DOCUMENT_TABLE': DOCUMENT_TABLE_NAME,
|
|
89
|
+
'PATH_ALIAS': '',
|
|
90
|
+
'REQUEST_CHARSET': 'UTF8',
|
|
91
|
+
'REQUEST_IANA_CHARSET': 'UTF-8',
|
|
92
|
+
'SCRIPT_PREFIX': '/pls',
|
|
93
|
+
'HTTP_COOKIE': 'cookie1=value1;cookie2=value2;'
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|