@sera4/essentia 1.1.41 → 1.1.43
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/helpers/test-server-wrapper.js +26 -20
- package/package.json +1 -1
- package/package.tar.gz +0 -0
|
@@ -15,7 +15,7 @@ export class TestServerWrapper {
|
|
|
15
15
|
this.chai = chai;
|
|
16
16
|
|
|
17
17
|
// Support for older/deprecated apis
|
|
18
|
-
const oldAuthHeaders = {
|
|
18
|
+
const oldAuthHeaders = {headers: {"Authorization" : `Token organization_token=${oldAuthToken}`}};
|
|
19
19
|
this.v1 = {
|
|
20
20
|
get: (url) => this.getWithPrefix("/v1", url, oldAuthHeaders),
|
|
21
21
|
post: (url) => this.postWithPrefix("/v1", url, oldAuthHeaders),
|
|
@@ -58,8 +58,8 @@ export class TestServerWrapper {
|
|
|
58
58
|
const request = this.chai.request(this.server).get(`${prefix}${sanitizedUrl}`);
|
|
59
59
|
this.applyHeaders(request, this.defaultHeaders);
|
|
60
60
|
|
|
61
|
-
if (options?.
|
|
62
|
-
this.applyHeaders(request,
|
|
61
|
+
if (options?.headers) {
|
|
62
|
+
this.applyHeaders(request, options.headers);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (options?.body) {
|
|
@@ -77,9 +77,10 @@ export class TestServerWrapper {
|
|
|
77
77
|
const request = this.chai.request(this.server).post(`${prefix}${sanitizedUrl}`);
|
|
78
78
|
this.applyHeaders(request, this.defaultHeaders);
|
|
79
79
|
|
|
80
|
-
if (options?.
|
|
81
|
-
this.applyHeaders(request,
|
|
80
|
+
if (options?.headers) {
|
|
81
|
+
this.applyHeaders(request, options.headers);
|
|
82
82
|
}
|
|
83
|
+
|
|
83
84
|
return request;
|
|
84
85
|
}
|
|
85
86
|
|
|
@@ -92,9 +93,10 @@ export class TestServerWrapper {
|
|
|
92
93
|
const request = this.chai.request(this.server).put(`${prefix}${sanitizedUrl}`);
|
|
93
94
|
this.applyHeaders(request, this.defaultHeaders);
|
|
94
95
|
|
|
95
|
-
if (options?.
|
|
96
|
-
this.applyHeaders(request,
|
|
96
|
+
if (options?.headers) {
|
|
97
|
+
this.applyHeaders(request, options.headers);
|
|
97
98
|
}
|
|
99
|
+
|
|
98
100
|
return request;
|
|
99
101
|
}
|
|
100
102
|
|
|
@@ -107,9 +109,10 @@ export class TestServerWrapper {
|
|
|
107
109
|
const request = this.chai.request(this.server).delete(`${prefix}${sanitizedUrl}`);
|
|
108
110
|
this.applyHeaders(request, this.defaultHeaders);
|
|
109
111
|
|
|
110
|
-
if (options?.
|
|
111
|
-
this.applyHeaders(request,
|
|
112
|
+
if (options?.headers) {
|
|
113
|
+
this.applyHeaders(request, options.headers);
|
|
112
114
|
}
|
|
115
|
+
|
|
113
116
|
return request;
|
|
114
117
|
}
|
|
115
118
|
|
|
@@ -122,8 +125,8 @@ export class TestServerWrapper {
|
|
|
122
125
|
const request = this.chai.request(this.server).post(`${prefix}${sanitizedUrl}`);
|
|
123
126
|
this.applyHeaders(request, this.defaultHeaders);
|
|
124
127
|
|
|
125
|
-
if (options?.
|
|
126
|
-
this.applyHeaders(request,
|
|
128
|
+
if (options?.headers) {
|
|
129
|
+
this.applyHeaders(request, options.headers);
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
request.attach("data", fs.readFileSync(file), {filename: "data"});
|
|
@@ -142,21 +145,24 @@ export class TestServerWrapper {
|
|
|
142
145
|
return this.routePrinter.getAll();
|
|
143
146
|
}
|
|
144
147
|
|
|
145
|
-
|
|
146
|
-
withMembership (m) {
|
|
147
|
-
const headers = { field: "tws-membership", value: JSON.stringify(m) }
|
|
148
|
+
withHeaders (headers) {
|
|
148
149
|
return {
|
|
149
|
-
get: (url, options) => this.get(url, {
|
|
150
|
-
post: (url, options) => this.post(url, {
|
|
151
|
-
put: (url, options) => this.put(url, {
|
|
152
|
-
delete: (url, options) => this.delete(url, {
|
|
153
|
-
upload: (url, fields, file, options) => this.upload(url, fields, file, {
|
|
150
|
+
get: (url, options) => this.get(url, {headers, ...options}),
|
|
151
|
+
post: (url, options) => this.post(url, {headers, ...options}),
|
|
152
|
+
put: (url, options) => this.put(url, {headers, ...options}),
|
|
153
|
+
delete: (url, options) => this.delete(url, {headers, ...options}),
|
|
154
|
+
upload: (url, fields, file, options) => this.upload(url, fields, file, {headers, ...options}),
|
|
154
155
|
stop: this.stop,
|
|
155
156
|
allRoutes: this.allRoutes,
|
|
156
157
|
v1: this.v1
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
160
|
|
|
161
|
+
withMembership (m) {
|
|
162
|
+
const h = { "tws-membership" : JSON.stringify(m) }
|
|
163
|
+
return this.withHeaders(h);
|
|
164
|
+
}
|
|
165
|
+
|
|
160
166
|
withS4 () {
|
|
161
167
|
return this.withMembership({s4_role: 1, id: uuidv4(), account_id: uuidv4(), tenant_id: uuidv4()});
|
|
162
168
|
}
|
|
@@ -164,4 +170,4 @@ export class TestServerWrapper {
|
|
|
164
170
|
withTap() {
|
|
165
171
|
return this.withMembership({s4_role: 2, id: uuidv4(), account_id: uuidv4(), tenant_id: uuidv4()});
|
|
166
172
|
}
|
|
167
|
-
}
|
|
173
|
+
}
|
package/package.json
CHANGED
package/package.tar.gz
CHANGED
|
Binary file
|