@sera4/essentia 1.1.48 → 1.1.49
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 +24 -1
- package/package.json +1 -1
- package/package.tar.gz +0 -0
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import uuidv4 from 'uuid/v4.js';
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
|
|
4
|
+
const s4Domain = "sera4.com";
|
|
5
|
+
const mobileDomain = "tws-mob." + s4Domain;
|
|
6
|
+
const webDomain = "tws-web." + s4Domain;
|
|
7
|
+
|
|
4
8
|
/**
|
|
5
9
|
* A small wrapper around an express js server
|
|
6
10
|
* meant to be used in unit tests
|
|
7
11
|
*/
|
|
8
12
|
export class TestServerWrapper {
|
|
9
13
|
|
|
10
|
-
constructor(apiPrefix, expressServer, defaultHeaders, oldAuthToken, routePrinter, chai) {
|
|
14
|
+
constructor(apiPrefix, expressServer, defaultHeaders, oldAuthToken, routePrinter, chai, factory) {
|
|
11
15
|
this.server = expressServer;
|
|
12
16
|
this.defaultHeaders = defaultHeaders;
|
|
13
17
|
this.apiPrefix = apiPrefix;
|
|
14
18
|
this.routePrinter = routePrinter;
|
|
15
19
|
this.chai = chai;
|
|
20
|
+
this.mobileDomain = mobileDomain;
|
|
21
|
+
this.webDomain = webDomain;
|
|
22
|
+
this.factory = factory;
|
|
16
23
|
|
|
17
24
|
// Support for older/deprecated apis
|
|
18
25
|
const oldAuthHeaders = {headers: {"Authorization" : `Token organization_token=${oldAuthToken}`}};
|
|
@@ -158,6 +165,22 @@ export class TestServerWrapper {
|
|
|
158
165
|
}
|
|
159
166
|
}
|
|
160
167
|
|
|
168
|
+
// setup
|
|
169
|
+
async setMembership (membership, addlHeaders) {
|
|
170
|
+
let headers;
|
|
171
|
+
|
|
172
|
+
if (membership) {
|
|
173
|
+
headers = { "tws-account-id" : membership.account_id, "tws-membership-id": membership.id, "tws-tenant-id" : membership.tenant_id };
|
|
174
|
+
} else {
|
|
175
|
+
// auto create an s4 user
|
|
176
|
+
const m = await this.factory.create("membership", { s4Admin: true })
|
|
177
|
+
headers = { "tws-account-id" : m.account_id, "tws-membership-id": m.id, "tws-tenant-id" : m.tenant_id };
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
headers = { ...headers, "tws-request-host": this.webDomain, ...addlHeaders }
|
|
181
|
+
return this.withHeaders(headers);
|
|
182
|
+
};
|
|
183
|
+
|
|
161
184
|
withMembership (m) {
|
|
162
185
|
const h = { "tws-membership" : JSON.stringify(m) }
|
|
163
186
|
return this.withHeaders(h);
|
package/package.json
CHANGED
package/package.tar.gz
CHANGED
|
Binary file
|