@auxcode/auxta 1.3.61 → 1.3.63
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/build/auxta/configs/config.d.ts +57 -0
- package/build/auxta/configs/config.js +69 -0
- package/build/auxta/enums/status-of.step.d.ts +7 -0
- package/build/auxta/enums/status-of.step.js +11 -0
- package/build/auxta/helpers/response.helper.d.ts +10 -0
- package/build/auxta/helpers/response.helper.js +15 -0
- package/build/auxta/helpers/start.helper.d.ts +1 -0
- package/build/auxta/helpers/start.helper.js +26 -0
- package/build/auxta/hooks/report.hook.d.ts +14 -0
- package/build/auxta/hooks/report.hook.js +67 -0
- package/build/auxta/models/upload.model.d.ts +35 -0
- package/build/auxta/models/upload.model.js +82 -0
- package/build/auxta/services/log.service.d.ts +31 -0
- package/build/auxta/services/log.service.js +61 -0
- package/build/auxta/services/report.service.d.ts +31 -0
- package/build/auxta/services/report.service.js +183 -0
- package/build/auxta/services/runtime.service.d.ts +16 -0
- package/build/auxta/services/runtime.service.js +41 -0
- package/build/auxta/utilities/runtime.helper.d.ts +15 -0
- package/build/auxta/utilities/runtime.helper.js +19 -0
- package/build/auxta/utilities/screenshot.helper.js +59 -0
- package/build/auxta/utilities/start-suite.helper.d.ts +17 -0
- package/build/auxta/utilities/start-suite.helper.js +31 -0
- package/build/macros/helpers/Aux2faAuth.d.ts +7 -0
- package/build/macros/helpers/Aux2faAuth.js +29 -0
- package/build/macros/helpers/AuxGoogleAuth.js +232 -0
- package/build/macros/helpers/code.helper.js +230 -0
- package/build/macros/helpers/emailHelper.js +5 -0
- package/build/macros/helpers/extend-default-page.d.ts +6 -0
- package/build/macros/helpers/extend-default-page.js +89 -0
- package/build/puppeteer/puppeteer.js +213 -0
- package/package.json +1 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.postNotificationsOnFail = exports.postNotifications = exports.compareScreenshots = exports.getLastDayResults = exports.getReport = exports.updateReport = exports.uploadScenario = exports.uploadStep = exports.createEmptyReport = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const config_1 = require("../configs/config");
|
|
18
|
+
function headers(token) {
|
|
19
|
+
return {
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
'cookie': `authToken=${token}`
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function auth() {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return axios_1.default.post(config_1.config.auxtaURL + 'login', config_1.config.auxtaCredentials, {
|
|
29
|
+
headers: {
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
.then(({ data }) => {
|
|
34
|
+
return data.token;
|
|
35
|
+
})
|
|
36
|
+
.catch(() => {
|
|
37
|
+
throw new Error("Invalid login credentials");
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function createEmptyReport(body) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const token = yield auth();
|
|
44
|
+
return (yield axios_1.default.post(config_1.config.auxtaURL + "create-empty-report", {
|
|
45
|
+
environment: body.environment,
|
|
46
|
+
digitalProductToken: body.digitalProduct,
|
|
47
|
+
bucket: body.bucket,
|
|
48
|
+
start: new Date(),
|
|
49
|
+
url: body.baseUrl
|
|
50
|
+
}, headers(token))).data.reportId;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.createEmptyReport = createEmptyReport;
|
|
54
|
+
function uploadStep(stepLog, scenarioName, screenshot, errMessage) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
let scenarios = [];
|
|
57
|
+
let token = yield auth();
|
|
58
|
+
let lastStep = stepLog[stepLog.length - 1];
|
|
59
|
+
const stepLogFormat = JSON.parse(JSON.stringify(stepLog));
|
|
60
|
+
stepLogFormat.pop();
|
|
61
|
+
let output = (yield axios_1.default.post(config_1.config.auxtaURL + "create-steps", {
|
|
62
|
+
json: {
|
|
63
|
+
name: scenarioName,
|
|
64
|
+
steps: [
|
|
65
|
+
...stepLogFormat,
|
|
66
|
+
(lastStep.result.status == 'failed')
|
|
67
|
+
? Object.assign(lastStep, {
|
|
68
|
+
result: Object.assign(Object.assign({}, lastStep.result), { error_message: JSON.stringify(errMessage) })
|
|
69
|
+
})
|
|
70
|
+
: lastStep,
|
|
71
|
+
{
|
|
72
|
+
keyword: "After",
|
|
73
|
+
result: {
|
|
74
|
+
status: "passed",
|
|
75
|
+
duration: 2678000000
|
|
76
|
+
},
|
|
77
|
+
embeddings: (screenshot) ? [{
|
|
78
|
+
data: screenshot.toString("base64"),
|
|
79
|
+
mime_type: "image/png"
|
|
80
|
+
}] : undefined,
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
}
|
|
84
|
+
}, headers(token))).data.scenarios;
|
|
85
|
+
scenarios.push({
|
|
86
|
+
stepRef: output.stepRef,
|
|
87
|
+
name: output.name,
|
|
88
|
+
status: output.status,
|
|
89
|
+
stepsCount: output.stepsCount
|
|
90
|
+
});
|
|
91
|
+
return scenarios;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
exports.uploadStep = uploadStep;
|
|
95
|
+
function uploadScenario(stepRes, scenarioName, uri, hasFailed) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
let token = yield auth();
|
|
98
|
+
return (yield axios_1.default.post(config_1.config.auxtaURL + "create-scenario", {
|
|
99
|
+
json: {
|
|
100
|
+
name: scenarioName,
|
|
101
|
+
uri: uri
|
|
102
|
+
},
|
|
103
|
+
scenarios: stepRes,
|
|
104
|
+
hasFailed: hasFailed
|
|
105
|
+
}, headers(token))).data;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
exports.uploadScenario = uploadScenario;
|
|
109
|
+
function updateReport(reportId, scenario, steps, isFinal) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
let token = yield auth();
|
|
112
|
+
yield axios_1.default.post(config_1.config.auxtaURL + "update-inprogress-report", {
|
|
113
|
+
reportId: reportId,
|
|
114
|
+
isFinal: isFinal,
|
|
115
|
+
data: Object.assign({ scenario: {
|
|
116
|
+
scenarioRef: scenario.scenarioId,
|
|
117
|
+
name: scenario.scenarioName,
|
|
118
|
+
uri: scenario.scenarioUri,
|
|
119
|
+
status: scenario.status,
|
|
120
|
+
scenariosCount: scenario.scenariosCount,
|
|
121
|
+
lastFiveStepsHash: scenario.lastFiveStepsHash
|
|
122
|
+
} }, steps)
|
|
123
|
+
}, headers(token));
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
exports.updateReport = updateReport;
|
|
127
|
+
function getReport(reportId) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
let token = yield auth();
|
|
130
|
+
return (yield axios_1.default.post(config_1.config.auxtaURL + "get-report", { reportId: reportId }, headers(token))).data;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
exports.getReport = getReport;
|
|
134
|
+
function getLastDayResults() {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
let token = yield auth();
|
|
137
|
+
return (yield axios_1.default.get(config_1.config.auxtaURL + `get-last-day-results?url=${config_1.config.baseURL}`, headers(token))).data.results;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
exports.getLastDayResults = getLastDayResults;
|
|
141
|
+
function compareScreenshots(key, screenshot) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
let token = yield auth();
|
|
144
|
+
const embedding = {
|
|
145
|
+
data: screenshot,
|
|
146
|
+
mime_type: "image/png"
|
|
147
|
+
};
|
|
148
|
+
return (yield axios_1.default.post(`${config_1.config.auxtaURL}save-compared-screenshot`, {
|
|
149
|
+
organization: config_1.config.organization,
|
|
150
|
+
key: key,
|
|
151
|
+
embedding: embedding,
|
|
152
|
+
}, headers(token))).data;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
exports.compareScreenshots = compareScreenshots;
|
|
156
|
+
function postNotifications(body) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
let token = yield auth();
|
|
159
|
+
yield axios_1.default.post(`${config_1.config.auxtaURL}post-notification-after-run-background`, {
|
|
160
|
+
environmentName: body.environment,
|
|
161
|
+
digitalProductToken: body.digitalProduct,
|
|
162
|
+
organizationName: body.organization,
|
|
163
|
+
bucketName: body.bucket,
|
|
164
|
+
reportId: body.reportId,
|
|
165
|
+
}, headers(token));
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
exports.postNotifications = postNotifications;
|
|
169
|
+
function postNotificationsOnFail(body) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
let token = yield auth();
|
|
172
|
+
yield axios_1.default.post(`${config_1.config.auxtaURL}post-notifications-after-case-fail-background`, {
|
|
173
|
+
environmentName: body.environment,
|
|
174
|
+
digitalProductToken: body.digitalProduct,
|
|
175
|
+
organizationName: body.organization,
|
|
176
|
+
bucketName: body.bucket,
|
|
177
|
+
reportId: body.reportId,
|
|
178
|
+
featureName: body.featureName,
|
|
179
|
+
scenarioName: body.scenarioName
|
|
180
|
+
}, headers(token));
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
exports.postNotificationsOnFail = postNotificationsOnFail;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface RunTime {
|
|
2
|
+
duration: String;
|
|
3
|
+
startTime: Date;
|
|
4
|
+
endTime: Date;
|
|
5
|
+
}
|
|
6
|
+
export declare class Runtime {
|
|
7
|
+
private start;
|
|
8
|
+
private end;
|
|
9
|
+
private runtime;
|
|
10
|
+
constructor(s: Date, e: Date);
|
|
11
|
+
private calculateDuration;
|
|
12
|
+
private splitAtDecimanlMinutes;
|
|
13
|
+
private splitAtDecimanlHours;
|
|
14
|
+
private formatRuntime;
|
|
15
|
+
returnRuntime(): RunTime;
|
|
16
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Runtime = void 0;
|
|
4
|
+
class Runtime {
|
|
5
|
+
constructor(s, e) {
|
|
6
|
+
this.start = s;
|
|
7
|
+
this.end = e;
|
|
8
|
+
}
|
|
9
|
+
calculateDuration() {
|
|
10
|
+
let currentTime = new Date;
|
|
11
|
+
let duration = currentTime.getTime() - this.start.getTime();
|
|
12
|
+
return duration;
|
|
13
|
+
}
|
|
14
|
+
splitAtDecimanlMinutes(time) {
|
|
15
|
+
let minutes = time.toFixed(2).toString().split('.');
|
|
16
|
+
return `${minutes[0]}m ${(Number(minutes[1]) / 100 * 60).toFixed(0)}s`;
|
|
17
|
+
}
|
|
18
|
+
splitAtDecimanlHours(time) {
|
|
19
|
+
let hours = time.toFixed(2).toString().split('.');
|
|
20
|
+
let minutes = (Number(hours[1]) / 100 * 60).toFixed(2).toString().split('.');
|
|
21
|
+
return `${hours[0]}h ${minutes[0]}m ${(Number(minutes[1]) / 100 * 60).toFixed(0)}s`;
|
|
22
|
+
}
|
|
23
|
+
formatRuntime(duration) {
|
|
24
|
+
if (duration / 1000 < 60)
|
|
25
|
+
return `${(duration / 1000).toFixed(0)}s`;
|
|
26
|
+
else {
|
|
27
|
+
if (duration / 60000 < 60)
|
|
28
|
+
return this.splitAtDecimanlMinutes(duration / 60000);
|
|
29
|
+
else
|
|
30
|
+
return this.splitAtDecimanlHours(duration / 3600000);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
returnRuntime() {
|
|
34
|
+
let duration = this.formatRuntime(this.calculateDuration());
|
|
35
|
+
let startTime = this.start;
|
|
36
|
+
let endTime = this.end;
|
|
37
|
+
this.runtime = { duration, startTime, endTime };
|
|
38
|
+
return this.runtime;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.Runtime = Runtime;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RunTime } from "../services/runtime.service";
|
|
2
|
+
export declare class CalculateRuntime {
|
|
3
|
+
private runtime;
|
|
4
|
+
startTimeSeconds: string;
|
|
5
|
+
startTimeMinutes: string;
|
|
6
|
+
startTimeHours: string;
|
|
7
|
+
startTimeDay: string;
|
|
8
|
+
startTimeMonth: string;
|
|
9
|
+
endTimeSeconds: string;
|
|
10
|
+
endTimeMinutes: string;
|
|
11
|
+
endTimeHours: string;
|
|
12
|
+
endTimeDay: string;
|
|
13
|
+
endTimeMonth: string;
|
|
14
|
+
constructor(r: RunTime);
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CalculateRuntime = void 0;
|
|
4
|
+
class CalculateRuntime {
|
|
5
|
+
constructor(r) {
|
|
6
|
+
this.runtime = r;
|
|
7
|
+
this.startTimeSeconds = (this.runtime.startTime.getSeconds() < 10) ? `0${this.runtime.startTime.getSeconds()}` : `${this.runtime.startTime.getSeconds()}`;
|
|
8
|
+
this.startTimeMinutes = (this.runtime.startTime.getMinutes() < 10) ? `0${this.runtime.startTime.getMinutes()}` : `${this.runtime.startTime.getMinutes()}`;
|
|
9
|
+
this.startTimeHours = (this.runtime.startTime.getHours() < 10) ? `0${this.runtime.startTime.getHours()}` : `${this.runtime.startTime.getHours()}`;
|
|
10
|
+
this.startTimeDay = (this.runtime.startTime.getDate() < 10) ? `0${this.runtime.startTime.getDate()}` : `${this.runtime.startTime.getDate()}`;
|
|
11
|
+
this.startTimeMonth = (this.runtime.startTime.getMonth() + 1 < 10) ? `0${this.runtime.startTime.getMonth() + 1}` : `${this.runtime.startTime.getMonth() + 1}`;
|
|
12
|
+
this.endTimeSeconds = (this.runtime.endTime.getSeconds() < 10) ? `0${this.runtime.endTime.getSeconds()}` : `${this.runtime.endTime.getSeconds()}`;
|
|
13
|
+
this.endTimeMinutes = (this.runtime.endTime.getMinutes() < 10) ? `0${this.runtime.endTime.getMinutes()}` : `${this.runtime.endTime.getMinutes()}`;
|
|
14
|
+
this.endTimeHours = (this.runtime.endTime.getHours() < 10) ? `0${this.runtime.endTime.getHours()}` : `${this.runtime.endTime.getHours()}`;
|
|
15
|
+
this.endTimeDay = (this.runtime.endTime.getDate() < 10) ? `0${this.runtime.endTime.getDate()}` : `${this.runtime.endTime.getDate()}`;
|
|
16
|
+
this.endTimeMonth = (this.runtime.endTime.getMonth() + 1 < 10) ? `0${this.runtime.endTime.getMonth() + 1}` : `${this.runtime.endTime.getMonth() + 1}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.CalculateRuntime = CalculateRuntime;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.captureScreenshotPage = exports.captureScreenshot = void 0;
|
|
16
|
+
const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
|
|
17
|
+
const log_service_1 = __importDefault(require("../services/log.service"));
|
|
18
|
+
const status_of_step_1 = __importDefault(require("../enums/status-of.step"));
|
|
19
|
+
function captureScreenshot() {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
try {
|
|
22
|
+
const pages = yield puppeteer_1.default.defaultPage.browser().pages();
|
|
23
|
+
if (!pages.length)
|
|
24
|
+
return undefined;
|
|
25
|
+
const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
|
|
26
|
+
const screenshotBuffer = yield lastPage.screenshot({
|
|
27
|
+
fullPage: true,
|
|
28
|
+
captureBeyondViewport: false,
|
|
29
|
+
encoding: 'binary'
|
|
30
|
+
});
|
|
31
|
+
if (Buffer.isBuffer(screenshotBuffer))
|
|
32
|
+
return screenshotBuffer;
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
log_service_1.default.push('When', e.toString(), status_of_step_1.default.FAILED);
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.captureScreenshot = captureScreenshot;
|
|
42
|
+
function captureScreenshotPage(page) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
try {
|
|
45
|
+
const screenshotBuffer = yield page.screenshot({
|
|
46
|
+
fullPage: true,
|
|
47
|
+
captureBeyondViewport: false,
|
|
48
|
+
encoding: 'binary'
|
|
49
|
+
});
|
|
50
|
+
if (Buffer.isBuffer(screenshotBuffer))
|
|
51
|
+
return screenshotBuffer;
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
log_service_1.default.push('When', e.toString(), status_of_step_1.default.FAILED);
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.captureScreenshotPage = captureScreenshotPage;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function startSuite(suites: string[], reportId?: string): Promise<{
|
|
2
|
+
nextSuites?: undefined;
|
|
3
|
+
reportId?: undefined;
|
|
4
|
+
currentSuite?: undefined;
|
|
5
|
+
retries?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
nextSuites: string[];
|
|
8
|
+
reportId: string | undefined;
|
|
9
|
+
currentSuite: string | undefined;
|
|
10
|
+
retries: string;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function retrySuite(suites: string[], reportId: string, currentSuite: string, retries: number): Promise<false | {
|
|
13
|
+
nextSuites: string[];
|
|
14
|
+
reportId: string;
|
|
15
|
+
currentSuite: string;
|
|
16
|
+
retries: number;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.retrySuite = exports.startSuite = void 0;
|
|
13
|
+
function startSuite(suites, reportId) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
if (suites.length === 0)
|
|
16
|
+
return {};
|
|
17
|
+
const next = suites.shift();
|
|
18
|
+
return { nextSuites: suites, reportId: reportId, currentSuite: next, retries: "0" };
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.startSuite = startSuite;
|
|
22
|
+
function retrySuite(suites, reportId, currentSuite, retries) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
console.log('I repeat again the current suite: ' + currentSuite);
|
|
25
|
+
if (retries >= 2) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return { nextSuites: suites, reportId: reportId, currentSuite: currentSuite, retries: retries };
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.retrySuite = retrySuite;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Aux2faAuth = void 0;
|
|
4
|
+
const twofactor = require("node-2fa");
|
|
5
|
+
class Aux2faAuth {
|
|
6
|
+
authenticator() {
|
|
7
|
+
const aux2fe_secret = this.getSecret();
|
|
8
|
+
return twofactor.generateToken(aux2fe_secret).token;
|
|
9
|
+
}
|
|
10
|
+
verifyToken(token) {
|
|
11
|
+
const aux2fe_secret = this.getSecret();
|
|
12
|
+
const result = twofactor.verifyToken(aux2fe_secret, token);
|
|
13
|
+
if (result != null) {
|
|
14
|
+
if (result.delta == 0) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
getSecret() {
|
|
21
|
+
const aux2fe_secret = process.env.aux2fe_secret;
|
|
22
|
+
if (!aux2fe_secret) {
|
|
23
|
+
throw new Error('No 2fe secret set');
|
|
24
|
+
}
|
|
25
|
+
return aux2fe_secret;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.Aux2faAuth = Aux2faAuth;
|
|
29
|
+
exports.default = new Aux2faAuth();
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.AuxGoogleAuth = void 0;
|
|
39
|
+
const config_1 = require("../../auxta/configs/config");
|
|
40
|
+
const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
|
|
41
|
+
const code_helper_1 = __importDefault(require("../helpers/code.helper"));
|
|
42
|
+
const status_of_step_1 = __importDefault(require("../../auxta/enums/status-of.step"));
|
|
43
|
+
const fs = require('fs');
|
|
44
|
+
const readline = require('readline');
|
|
45
|
+
const process = __importStar(require("process"));
|
|
46
|
+
const { google } = require("googleapis");
|
|
47
|
+
const SCOPES = [
|
|
48
|
+
'https://www.googleapis.com/auth/gmail.addons.current.action.compose',
|
|
49
|
+
'https://www.googleapis.com/auth/gmail.addons.current.message.action',
|
|
50
|
+
'https://www.googleapis.com/auth/gmail.labels',
|
|
51
|
+
'https://www.googleapis.com/auth/gmail.addons.current.message.metadata',
|
|
52
|
+
'https://www.googleapis.com/auth/gmail.addons.current.message.readonly',
|
|
53
|
+
'https://www.googleapis.com/auth/gmail.send',
|
|
54
|
+
'https://mail.google.com/',
|
|
55
|
+
'https://www.googleapis.com/auth/gmail.modify',
|
|
56
|
+
'https://www.googleapis.com/auth/gmail.compose',
|
|
57
|
+
'https://www.googleapis.com/auth/gmail.readonly',
|
|
58
|
+
'https://www.googleapis.com/auth/gmail.insert',
|
|
59
|
+
];
|
|
60
|
+
const TOKEN_PATH = 'token.json';
|
|
61
|
+
let TOKEN;
|
|
62
|
+
let EMAIL;
|
|
63
|
+
let PASSWORD;
|
|
64
|
+
class AuxGoogleAuth {
|
|
65
|
+
static get oAuth2Client() {
|
|
66
|
+
return this._oAuth2Client;
|
|
67
|
+
}
|
|
68
|
+
static get googleClient() {
|
|
69
|
+
return google;
|
|
70
|
+
}
|
|
71
|
+
static get gmailClient() {
|
|
72
|
+
return google.gmail({ version: 'v1', auth: this._oAuth2Client });
|
|
73
|
+
}
|
|
74
|
+
static setupBrowser() {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
yield this.authorize(this.credentialsJson);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
static setEmailPassword(email, password) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
EMAIL = email;
|
|
82
|
+
PASSWORD = password;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
static setupHeadless() {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
yield this.authorizeHeadless(this.credentialsJson);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
static authorize(credentials) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const { client_secret, client_id, redirect_uris } = credentials.installed;
|
|
93
|
+
const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
|
|
94
|
+
try {
|
|
95
|
+
let token = fs.readFileSync(TOKEN_PATH);
|
|
96
|
+
if (token.length > 0 && token !== undefined) {
|
|
97
|
+
oAuth2Client.setCredentials(JSON.parse(token));
|
|
98
|
+
this._oAuth2Client = oAuth2Client;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
yield this.getNewToken(oAuth2Client);
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
yield this.getNewToken(oAuth2Client);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
static authorizeHeadless(credentials) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const { client_secret, client_id, redirect_uris } = credentials.installed;
|
|
111
|
+
const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
|
|
112
|
+
try {
|
|
113
|
+
if (TOKEN) {
|
|
114
|
+
oAuth2Client.setCredentials(TOKEN);
|
|
115
|
+
this._oAuth2Client = oAuth2Client;
|
|
116
|
+
code_helper_1.default.log('Then', 'Getting the existing token', status_of_step_1.default.PASSED);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
yield this.getNewTokenHeadless(oAuth2Client);
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
yield this.getNewTokenHeadless(oAuth2Client);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
static getNewToken(oAuth2Client) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const authUrl = oAuth2Client.generateAuthUrl({
|
|
129
|
+
access_type: 'offline',
|
|
130
|
+
prompt: 'consent',
|
|
131
|
+
scope: SCOPES,
|
|
132
|
+
});
|
|
133
|
+
console.log('Authorize this app by visiting this url:', authUrl);
|
|
134
|
+
const rl = readline.createInterface({
|
|
135
|
+
input: process.stdin,
|
|
136
|
+
output: process.stdout,
|
|
137
|
+
});
|
|
138
|
+
rl.question('Enter the code from that page here: ', (code) => {
|
|
139
|
+
rl.close();
|
|
140
|
+
oAuth2Client.getToken(code, (err, token) => {
|
|
141
|
+
if (err)
|
|
142
|
+
return console.error('Error retrieving access token', err);
|
|
143
|
+
oAuth2Client.setCredentials(token);
|
|
144
|
+
fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {
|
|
145
|
+
if (err)
|
|
146
|
+
return console.error(err);
|
|
147
|
+
console.log('Token stored to', TOKEN_PATH);
|
|
148
|
+
});
|
|
149
|
+
this._oAuth2Client = oAuth2Client;
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
static getNewTokenHeadless(oAuth2Client) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
const authUrl = oAuth2Client.generateAuthUrl({
|
|
157
|
+
access_type: 'offline',
|
|
158
|
+
prompt: 'consent',
|
|
159
|
+
scope: SCOPES,
|
|
160
|
+
});
|
|
161
|
+
const code = yield this.LogIn(authUrl);
|
|
162
|
+
this._oAuth2Client = yield (new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
yield oAuth2Client.getToken(code, (err, token) => {
|
|
164
|
+
if (err)
|
|
165
|
+
return console.error('Error retrieving access token', err);
|
|
166
|
+
oAuth2Client.setCredentials(token);
|
|
167
|
+
TOKEN = token;
|
|
168
|
+
this._oAuth2Client = oAuth2Client;
|
|
169
|
+
code_helper_1.default.log('Then', 'I login with the google account', status_of_step_1.default.PASSED);
|
|
170
|
+
resolve(oAuth2Client);
|
|
171
|
+
});
|
|
172
|
+
})));
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
static LogIn(authUrl) {
|
|
176
|
+
var _a, _b;
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
const email = EMAIL ? EMAIL : process.env.google_account;
|
|
179
|
+
const password = PASSWORD ? PASSWORD : process.env.google_password;
|
|
180
|
+
if (email && password) {
|
|
181
|
+
const context = yield puppeteer_1.default.defaultPage.browser().createIncognitoBrowserContext();
|
|
182
|
+
const page = yield context.newPage();
|
|
183
|
+
yield page.goto(authUrl);
|
|
184
|
+
yield code_helper_1.default.waitForSelector('visible', '#identifierId', config_1.config.timeout, page);
|
|
185
|
+
yield ((_a = (yield page.$('#identifierId'))) === null || _a === void 0 ? void 0 : _a.type(email));
|
|
186
|
+
yield (yield page.$$('button'))[3].click();
|
|
187
|
+
yield code_helper_1.default.timeout(4000);
|
|
188
|
+
yield code_helper_1.default.waitForSelector('visible', 'input[type="password"]', config_1.config.timeout, page);
|
|
189
|
+
yield ((_b = (yield page.$('input[type="password"]'))) === null || _b === void 0 ? void 0 : _b.type(password));
|
|
190
|
+
yield (yield page.$$('button'))[1].click();
|
|
191
|
+
yield code_helper_1.default.timeout(4000);
|
|
192
|
+
yield code_helper_1.default.waitForSelector('visible', '#headingText', config_1.config.timeout, page);
|
|
193
|
+
yield (yield page.$$('button'))[2].click();
|
|
194
|
+
yield code_helper_1.default.timeout(4000);
|
|
195
|
+
const checkbox = yield page.$$('input[type="checkbox"]');
|
|
196
|
+
if (checkbox.length > 0) {
|
|
197
|
+
yield code_helper_1.default.waitForSelector('visible', 'input[type="checkbox"]', config_1.config.timeout, page);
|
|
198
|
+
yield checkbox[0].click();
|
|
199
|
+
yield (yield page.$$('button'))[2].click();
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
yield code_helper_1.default.waitForSelector('visible', `div[data-email="${email.toLocaleLowerCase()}"]`, config_1.config.timeout, page);
|
|
203
|
+
yield code_helper_1.default.timeout(4000);
|
|
204
|
+
yield (yield page.$$('button'))[2].click();
|
|
205
|
+
}
|
|
206
|
+
yield code_helper_1.default.timeout(4000);
|
|
207
|
+
yield code_helper_1.default.waitForSelector('visible', 'body', config_1.config.timeout, page);
|
|
208
|
+
const currentUrl = page.url();
|
|
209
|
+
const code = currentUrl.substring(currentUrl.indexOf("code=") + 5, currentUrl.lastIndexOf("&"));
|
|
210
|
+
code_helper_1.default.log('Then', 'I get the code form the url', status_of_step_1.default.PASSED);
|
|
211
|
+
yield page.close();
|
|
212
|
+
return decodeURIComponent(code);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
throw new Error('The email or password for the google account are empty');
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.AuxGoogleAuth = AuxGoogleAuth;
|
|
221
|
+
AuxGoogleAuth.credentialsJson = {
|
|
222
|
+
"installed": {
|
|
223
|
+
"client_id": "120362272213-usevfijf76jj5nsr502i2lai6nu71oq8.apps.googleusercontent.com",
|
|
224
|
+
"project_id": "auxta-library",
|
|
225
|
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
|
226
|
+
"token_uri": "https://oauth2.googleapis.com/token",
|
|
227
|
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
|
228
|
+
"client_secret": "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",
|
|
229
|
+
"redirect_uris": ["https://auxcode.com"]
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
exports.default = new AuxGoogleAuth();
|