@auxcode/auxta 1.3.78-beta.111 → 1.3.78-beta.113
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.
|
@@ -29,3 +29,4 @@ export declare function getLastDayResults(): Promise<any>;
|
|
|
29
29
|
export declare function compareScreenshots(key: string, screenshot: string): Promise<any>;
|
|
30
30
|
export declare function postNotifications(body: UploadModel): Promise<void>;
|
|
31
31
|
export declare function postNotificationsOnFail(body: UploadModel): Promise<void>;
|
|
32
|
+
export declare function getVerifyReceivedEmail(from_name: string, from_email: string, subject: string, body: string, link: boolean): Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
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;
|
|
15
|
+
exports.getVerifyReceivedEmail = exports.postNotificationsOnFail = exports.postNotifications = exports.compareScreenshots = exports.getLastDayResults = exports.getReport = exports.updateReport = exports.uploadScenario = exports.uploadStep = exports.createEmptyReport = void 0;
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
const config_1 = require("../configs/config");
|
|
18
18
|
function headers(token) {
|
|
@@ -183,3 +183,16 @@ function postNotificationsOnFail(body) {
|
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
185
|
exports.postNotificationsOnFail = postNotificationsOnFail;
|
|
186
|
+
function getVerifyReceivedEmail(from_name, from_email, subject, body, link) {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
let token = yield auth();
|
|
189
|
+
return yield axios_1.default.post(`${config_1.config.auxtaURL}get-verify-received-email`, {
|
|
190
|
+
from_name: from_name,
|
|
191
|
+
from_email: from_email,
|
|
192
|
+
subject: subject,
|
|
193
|
+
body: body,
|
|
194
|
+
link: link
|
|
195
|
+
}, headers(token));
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
exports.getVerifyReceivedEmail = getVerifyReceivedEmail;
|
|
@@ -160,7 +160,8 @@ class AuxGoogleAuth {
|
|
|
160
160
|
static getNewTokenHeadless(oAuth2Client) {
|
|
161
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
162
|
const position = Math.floor(Math.random() * 6);
|
|
163
|
-
|
|
163
|
+
const token = TOKENS[position];
|
|
164
|
+
oAuth2Client.setCredentials(token);
|
|
164
165
|
this._oAuth2Client = oAuth2Client;
|
|
165
166
|
code_helper_1.default.log('Then', 'I login with the google account', status_of_step_1.default.PASSED);
|
|
166
167
|
});
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
export declare class EmailHelper {
|
|
2
2
|
verifyEmail(from_name: string, from_email: string, subject: string, body: string, link?: boolean): Promise<{
|
|
3
|
-
|
|
4
|
-
threadId: string;
|
|
5
|
-
link: string;
|
|
3
|
+
link: any;
|
|
6
4
|
} | undefined>;
|
|
7
5
|
sendEmail(to: string, subject: string, body: string): Promise<void>;
|
|
8
6
|
replyEmail(id: string, threadId: string, body: string): Promise<void>;
|
|
9
7
|
private static send;
|
|
10
8
|
private getHeader;
|
|
11
|
-
private getBody;
|
|
12
9
|
private getCurrentUserEmail;
|
|
13
|
-
private getUrl;
|
|
14
10
|
}
|
|
15
11
|
declare const _default: EmailHelper;
|
|
16
12
|
export default _default;
|
|
@@ -16,7 +16,7 @@ exports.EmailHelper = void 0;
|
|
|
16
16
|
const log_service_1 = __importDefault(require("../../auxta/services/log.service"));
|
|
17
17
|
const AuxGoogleAuth_1 = require("./AuxGoogleAuth");
|
|
18
18
|
const AuxTA_1 = require("../../AuxTA");
|
|
19
|
-
const
|
|
19
|
+
const report_service_1 = require("../../auxta/services/report.service");
|
|
20
20
|
const MailComposer = require('nodemailer/lib/mail-composer');
|
|
21
21
|
class EmailHelper {
|
|
22
22
|
verifyEmail(from_name, from_email, subject, body, link = false) {
|
|
@@ -28,70 +28,19 @@ class EmailHelper {
|
|
|
28
28
|
yield new Promise(r => setTimeout(r, 35000));
|
|
29
29
|
let timeoutCount = 12000;
|
|
30
30
|
while (timeoutCount <= 60000) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
for (const messageId of messagesIds) {
|
|
42
|
-
if (messageId.id) {
|
|
43
|
-
let gmailResponse;
|
|
44
|
-
try {
|
|
45
|
-
gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
|
|
46
|
-
userId: "me",
|
|
47
|
-
id: messageId.id.toString(),
|
|
48
|
-
format: 'FULL'
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
if (gmailResponse) {
|
|
55
|
-
log_service_1.default.push('Then', `I check payload && id && threadId`, AuxTA_1.StepStatus.PASSED);
|
|
56
|
-
if (gmailResponse.data.payload && gmailResponse.data.id && gmailResponse.data.threadId) {
|
|
57
|
-
const message_sender = this.getHeader('from', gmailResponse);
|
|
58
|
-
log_service_1.default.push('Then', `I got message_sender`, AuxTA_1.StepStatus.PASSED);
|
|
59
|
-
const message_subject = this.getHeader('subject', gmailResponse);
|
|
60
|
-
log_service_1.default.push('Then', `I got message_body`, AuxTA_1.StepStatus.PASSED);
|
|
61
|
-
const message_body = this.getBody(subject, gmailResponse);
|
|
62
|
-
log_service_1.default.push('Then', `I got message_body`, AuxTA_1.StepStatus.PASSED);
|
|
63
|
-
if (message_sender.toLocaleLowerCase().includes(from_email) && message_sender.toLocaleLowerCase().includes(from_name.toLocaleLowerCase()) &&
|
|
64
|
-
message_subject.toLocaleLowerCase().includes(subject.toLocaleLowerCase()) && message_body.toLocaleLowerCase().includes(body.toLocaleLowerCase())) {
|
|
65
|
-
log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.PASSED);
|
|
66
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.modify({
|
|
67
|
-
userId: "me",
|
|
68
|
-
id: gmailResponse.data.id,
|
|
69
|
-
requestBody: {
|
|
70
|
-
'addLabelIds': [],
|
|
71
|
-
'removeLabelIds': ['UNREAD']
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
log_service_1.default.push('Then', `I got modify email`, AuxTA_1.StepStatus.PASSED);
|
|
75
|
-
if (link) {
|
|
76
|
-
const html_link = yield this.getUrl(message_body);
|
|
77
|
-
log_service_1.default.push('Then', `I get html lik`, AuxTA_1.StepStatus.PASSED);
|
|
78
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.delete({
|
|
79
|
-
userId: "me",
|
|
80
|
-
id: gmailResponse.data.id,
|
|
81
|
-
});
|
|
82
|
-
log_service_1.default.push('Then', `I deleted email`, AuxTA_1.StepStatus.PASSED);
|
|
83
|
-
return {
|
|
84
|
-
id: gmailResponse.data.id,
|
|
85
|
-
threadId: gmailResponse.data.threadId,
|
|
86
|
-
link: html_link
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return { id: gmailResponse.data.id, threadId: gmailResponse.data.threadId, link: '' };
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
31
|
+
try {
|
|
32
|
+
const links = yield (0, report_service_1.getVerifyReceivedEmail)(from_name, from_email, subject, body, link);
|
|
33
|
+
log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.PASSED);
|
|
34
|
+
if (links) {
|
|
35
|
+
return {
|
|
36
|
+
link: links.data.link
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return;
|
|
93
41
|
}
|
|
94
42
|
}
|
|
43
|
+
catch (e) { }
|
|
95
44
|
log_service_1.default.push('Then', `Failed two get the email with the given criteria and waiting 12 seconds`, AuxTA_1.StepStatus.PASSED);
|
|
96
45
|
yield new Promise(r => setTimeout(r, timeoutCount));
|
|
97
46
|
timeoutCount += 12000;
|
|
@@ -160,27 +109,6 @@ class EmailHelper {
|
|
|
160
109
|
}
|
|
161
110
|
}
|
|
162
111
|
}
|
|
163
|
-
getBody(subject, gmailResponse) {
|
|
164
|
-
try {
|
|
165
|
-
let decodedBody = '';
|
|
166
|
-
for (let i = 0; i < gmailResponse.data.payload.parts.length; i++) {
|
|
167
|
-
const part = gmailResponse.data.payload.parts[i].body;
|
|
168
|
-
if (part.size > 0) {
|
|
169
|
-
decodedBody += base64.decode(part.data);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (decodedBody) {
|
|
173
|
-
return decodedBody;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
return '';
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
catch (e) {
|
|
180
|
-
console.log(e);
|
|
181
|
-
throw new Error(`Email with subject: ${subject} body ${gmailResponse.data.payload.parts[0].body.data} is empty`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
112
|
getCurrentUserEmail() {
|
|
185
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
186
114
|
yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
|
|
@@ -188,13 +116,6 @@ class EmailHelper {
|
|
|
188
116
|
return profile.data.emailAddress;
|
|
189
117
|
});
|
|
190
118
|
}
|
|
191
|
-
getUrl(body) {
|
|
192
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
const httpsStartIndex = body.indexOf('https');
|
|
194
|
-
const bodyHttpsStartIndexString = body.toString().substring(httpsStartIndex);
|
|
195
|
-
return bodyHttpsStartIndexString.substring(0, bodyHttpsStartIndexString.indexOf(' ')).replace('"', '');
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
119
|
}
|
|
199
120
|
exports.EmailHelper = EmailHelper;
|
|
200
121
|
exports.default = new EmailHelper();
|