-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.help.ts
278 lines (260 loc) · 8.24 KB
/
utils.help.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
//noinspection TsLint
/*import {C8oSettings} from "./c8osdk-js-core/src/c8o/c8oSettings";
import {C8oLogLevel} from "./c8osdk-js-core/src/c8o/c8oLogLevel";*/
import { C8oSettings, C8oLogLevel } from "./c8osdk-js-core/src/index";
import { C8o } from "./lib/c8o.service";
import { HttpHeaders } from '@angular/common/http';
import { C8oCore } from "./c8osdk-js-core/src/index";
import { Utils } from 'handlebars';
/**
* @class
* @ignore
*/
export class Info {
// if you wants to use a proxy you mast change remote host and port please change configuration in Root/config/karama.conf.js
// Set this property to use local studio for tests
static local = false;
static remote: "T";
// Remote infos
static get http() {
return "https://";
}
static get host() {
//return "192.168.100.70"
//return "c8o-dev.convertigo.net";
//return "localhost";
return "test-convertigo.convertigo.net"
//return "test-convertigo.convertigo.net";
}
static get port() {
//return "28080";
//return "8080"
return "443"
}
static get project_path() {
//return "/cems/projects/ClientSDKtesting";
return "/convertigo/projects/ClientSDKtesting";
}
// Local infos
static get httpLocal() {
return "http://";
}
static get hostLocal() {
return "localhost";
}
static get portLocal() {
return "18080"
}
static get project_pathLocal() {
return "/convertigo/projects/ClientSDKtesting";
}
public static get endpoint() {
if (!Info.local) {
return Info.http + Info.host /*+ ":" + Info.port */ + Info.project_path;
}
else {
return Info.httpLocal + Info.hostLocal + ":" + Info.portLocal + Info.project_pathLocal;
}
}
public static get logLevelLocal(): C8oLogLevel {
if (require("../../package.json").test == "testing version") {
return C8oLogLevel.ERROR
}
else {
return C8oLogLevel.TRACE;
}
}
public static get log(): boolean {
if (require("../../package.json").test == "testing version") {
return false;
}
else {
return true;
}
}
}
//noinspection TsLint
/**
* @class
* @ignore
*/
export class Stuff {
static get C8o(): C8oSettings {
let c8oSettings: C8oSettings = new C8oSettings();
c8oSettings
.setEndPoint(Info.endpoint)
.setLogRemote(Info.log)
.setLogC8o(Info.log)
.setLogLevelLocal(Info.logLevelLocal)
.addHeader("x-convertigo-mb", "7.5.0-beta")
.setNormalizeParameters(true)
.setKeepSessionAlive(false);
return c8oSettings;
}
static get C8o_FS() {
let c8oSettings: C8oSettings = new C8oSettings();
c8oSettings
.setEndPoint(Info.endpoint)
.setDefaultDatabaseName("clientsdktesting")
.setLogRemote(Info.log)
.setLogC8o(Info.log)
.setLogLevelLocal(Info.logLevelLocal)
.addHeader("x-convertigo-mb", "7.5.0-beta")
.setKeepSessionAlive(true);
return c8oSettings;
}
static get C8o_FS_PULL() {
let c8oSettings: C8oSettings = new C8oSettings();
c8oSettings
.setEndPoint(Info.endpoint)
.setDefaultDatabaseName("qa_fs_pull")
.setLogRemote(Info.log)
.setLogC8o(Info.log)
.setLogLevelLocal(Info.logLevelLocal)
.addHeader("x-convertigo-mb", "7.5.0-beta")
.setNormalizeParameters(true)
.setKeepSessionAlive(false);
return c8oSettings;
}
static get C8o_FS_PUSH() {
let c8oSettings: C8oSettings = new C8oSettings();
c8oSettings
.setDefaultDatabaseName("qa_fs_push")
.setLogRemote(Info.log)
.setLogC8o(Info.log)
.setLogLevelLocal(Info.logLevelLocal)
.setLogLevelLocal(C8oLogLevel.TRACE)
.addHeader("x-convertigo-mb", "7.5.0-beta")
.setKeepSessionAlive(false)
.setEndPoint(Info.endpoint);
return c8oSettings;
}
static get C8o_LC() {
let c8oSettings: C8oSettings = new C8oSettings();
c8oSettings
.setEndPoint(Info.endpoint)
.setLogRemote(Info.log)
.setLogC8o(Info.log)
.setLogLevelLocal(Info.logLevelLocal)
.addHeader("x-convertigo-mb", "7.5.0-beta")
.setKeepSessionAlive(false);
return c8oSettings;
}
static get C8o_FS_FILES() {
const c8oSettings: C8oSettings = new C8oSettings();
c8oSettings
.setDefaultDatabaseName("qa_fs_files")
.setEndPoint(Info.endpoint)
.setLogRemote(Info.log)
.setLogC8o(Info.log)
.setLogLevelLocal(Info.logLevelLocal)
.addHeader("x-convertigo-mb", "7.5.0-beta")
.setKeepSessionAlive(false);
return c8oSettings;
}
static get C8o_Sessions(): C8oSettings {
let c8oSettings: C8oSettings = new C8oSettings();
c8oSettings
.setEndPoint(Info.endpoint)
.setLogRemote(Info.log)
.setLogC8o(Info.log)
.setLogLevelLocal(Info.logLevelLocal)
.addHeader("x-convertigo-mb", "7.5.0-beta")
.setNormalizeParameters(true)
.setKeepSessionAlive(false);
return c8oSettings;
}
static get C8o_SessionsKeepAlive(): C8oSettings {
let c8oSettings: C8oSettings = new C8oSettings();
c8oSettings
.setEndPoint(Info.endpoint)
.setLogRemote(Info.log)
.setLogC8o(Info.log)
.setLogLevelLocal(Info.logLevelLocal)
.addHeader("x-convertigo-mb", "7.5.0-beta")
.setNormalizeParameters(true)
.setKeepSessionAlive(true);
return c8oSettings;
}
}
//noinspection TsLint
/**
* @class
* @ignore
*/
export class Functions {
/**
* compare equality bettwen two arrays
* @param a array 1
* @param b array 2
*/
static isEqual(a, b) {
// if length is not equal
if (a.length != b.length)
return "False";
else {
// comapring each element of array
for (var i = 0; i < a.length; i++)
if (a[i] != b[i])
return "False";
return "True";
}
}
static CheckLogRemoteHelper(c8o: C8o, lv: any, msg: string) {
c8o.callJson(".GetLogs").then(
(response: any) => {
let sLine = response["document"]["line"];
//qexpect(sLine != null).toBeTruthy();
for (let lvl of lv) {
let line = JSON.parse(sLine);
expect(line[2]).toBe(lvl);
let newMsg = line[4];
newMsg = newMsg.substring(newMsg.indexOf("logID="));
expect(msg).toBe(newMsg);
}
return null;
}
);
}
static async pingasync() {
}
static async wait(time) {
console.log("Waiting for " + time + " ms");
return await new Promise(resolve => setTimeout(resolve, time));
}
static async removesess(c8o, resolve) {
console.log("Removing session");
let params: any = { "__sequence": "RemoveSession", "__uuid": c8o.deviceUUID };
params = c8o.httpInterface.transformRequest(params);
let headersObject = { "Content-Type": "application/x-www-form-urlencoded", "x-convertigo-sdk": c8o.sdkVersion };
Object.assign(headersObject, c8o.headers);
let headers = new HttpHeaders(headersObject);
await Functions.wait(5000);
let a = await c8o.httpPublic.post(Info.endpoint + "/.json", params, {
headers: headers,
withCredentials: true
});
a.subscribe(async (re) => {
await Functions.wait(10000);
resolve();
})
}
}
/**
* @class
* @ignore
*/
export class PlainObjectA {
public name: string;
public bObjects: Array<any>;
public bObject: PlainObjectB;
}
/**
* @class
* @ignore
*/
export class PlainObjectB {
public name: string;
public num: number;
public enabled: boolean;
}