@testomatio/reporter 1.6.9 → 1.6.11-beta1.s3-fix
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/lib/client.js +34 -20
- package/lib/uploader.js +10 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -161,34 +161,48 @@ class Client {
|
|
|
161
161
|
suite_id,
|
|
162
162
|
test_id,
|
|
163
163
|
manuallyAttachedArtifacts,
|
|
164
|
-
meta,
|
|
165
164
|
} = testData;
|
|
166
|
-
let { message = '' } = testData;
|
|
165
|
+
let { message = '', meta = {} } = testData;
|
|
167
166
|
|
|
168
167
|
// stringify meta values and limit keys and values length to 255
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
168
|
+
meta = Object.entries(meta)
|
|
169
|
+
.filter(([, value]) => value !== null && value !== undefined)
|
|
170
|
+
.map(([key, value]) => {
|
|
171
|
+
try {
|
|
172
|
+
if (typeof value === 'object') {
|
|
173
|
+
value = JSON.stringify(value);
|
|
174
|
+
} else if (typeof value !== 'string') {
|
|
175
|
+
try {
|
|
176
|
+
value = value.toString();
|
|
177
|
+
} catch (err) {
|
|
178
|
+
console.warn(APP_PREFIX, `Can't convert meta value to string`, err);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
174
181
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
182
|
+
if (value?.length > 255) {
|
|
183
|
+
value = value.substring(0, 255);
|
|
184
|
+
debug(APP_PREFIX, `Meta info value "${value}" is too long, trimmed to 255 characters`);
|
|
185
|
+
}
|
|
180
186
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
+
if (key?.length > 255) {
|
|
188
|
+
const newKey = key.substring(0, 255);
|
|
189
|
+
debug(APP_PREFIX, `Meta info key "${key}" is too long, trimmed to 255 characters`);
|
|
190
|
+
return [newKey, value];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return [key, value];
|
|
194
|
+
} catch (err) {
|
|
195
|
+
debug(APP_PREFIX, `Error while processing meta info key ${key}`, err);
|
|
196
|
+
return [null, null];
|
|
187
197
|
}
|
|
188
|
-
}
|
|
189
|
-
|
|
198
|
+
})
|
|
199
|
+
.reduce((acc, [key, value]) => {
|
|
200
|
+
if (key) acc[key] = value;
|
|
201
|
+
return acc;
|
|
202
|
+
}, {});
|
|
190
203
|
|
|
191
204
|
let errorFormatted = '';
|
|
205
|
+
|
|
192
206
|
if (error) {
|
|
193
207
|
errorFormatted += this.formatError(error) || '';
|
|
194
208
|
message = error?.message;
|
package/lib/uploader.js
CHANGED
|
@@ -328,6 +328,11 @@ class S3Uploader {
|
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
+
// Normalize the URL
|
|
332
|
+
if (!s3Location.startsWith('http')) {
|
|
333
|
+
s3Location = `https://${s3Location}`;
|
|
334
|
+
}
|
|
335
|
+
|
|
331
336
|
return s3Location;
|
|
332
337
|
}
|
|
333
338
|
|
|
@@ -353,10 +358,13 @@ class S3Uploader {
|
|
|
353
358
|
credentials: {
|
|
354
359
|
accessKeyId: S3_ACCESS_KEY_ID,
|
|
355
360
|
secretAccessKey: S3_SECRET_ACCESS_KEY,
|
|
356
|
-
s3ForcePathStyle: S3_FORCE_PATH_STYLE,
|
|
357
361
|
},
|
|
358
362
|
};
|
|
359
363
|
|
|
364
|
+
if (S3_FORCE_PATH_STYLE) {
|
|
365
|
+
cfg.forcePathStyle = !['false', '0'].includes(String(S3_FORCE_PATH_STYLE || '').toLowerCase());
|
|
366
|
+
}
|
|
367
|
+
|
|
360
368
|
if (S3_SESSION_TOKEN) {
|
|
361
369
|
cfg.credentials.sessionToken = S3_SESSION_TOKEN;
|
|
362
370
|
}
|
|
@@ -367,6 +375,7 @@ class S3Uploader {
|
|
|
367
375
|
|
|
368
376
|
return cfg;
|
|
369
377
|
}
|
|
378
|
+
|
|
370
379
|
}
|
|
371
380
|
|
|
372
381
|
module.exports = S3Uploader;
|