Skip to content

Commit f5189bf

Browse files
committed
tests: allow use getSigHeaders
1 parent efc0b64 commit f5189bf

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

lib/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export function prepareRequestOptions(request_options, options) {
193193
} else {
194194
request_options.headers = request_options.headers || {};
195195
Object.assign(request_options.headers, headers);
196+
console.log('--- debug used headers', request_options.headers);
196197
resolve(request_options);
197198
}
198199
});

modules/tests-ui/tester.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { run as iframely } from '../../lib/core.js';
1616
import * as whitelist from '../../lib/whitelist.js';
1717
import * as pluginLoader from '../../lib/loader/pluginLoader.js';
1818
import { difference } from '../../utils.js';
19+
import { fetchData } from '../../lib/fetch.js';
20+
1921
var plugins = pluginLoader._plugins;
2022

2123
var testOnePlugin = false;
@@ -60,6 +62,26 @@ function cerror() {
6062
}
6163
}
6264

65+
function getSigHeaders(url, cb) {
66+
const sigUrl = new URL(CONFIG.SIG_API);
67+
sigUrl.searchParams.append('url', url);
68+
fetchData({
69+
uri: sigUrl,
70+
json: true
71+
})
72+
.then(result => {
73+
console.log('-- got sig headers ', result)
74+
cb(null, result);
75+
})
76+
.catch(cb);;
77+
}
78+
79+
function getSigHeadersFunction() {
80+
if (CONFIG.SIG_API) {
81+
return getSigHeaders;
82+
}
83+
}
84+
6385
function updateObsoletePluginTests(providersIds, cb) {
6486
PluginTest.updateMany({
6587
_id: {
@@ -540,7 +562,8 @@ function processPluginTests(pluginTest, plugin, count, cb) {
540562
refresh: true,
541563
readability: true,
542564
disableHttp2: disableHttp2,
543-
getWhitelistRecord: whitelist.findWhitelistRecordFor
565+
getWhitelistRecord: whitelist.findWhitelistRecordFor,
566+
getSigHeaders: getSigHeadersFunction()
544567
}, callback);
545568
}, CONFIG.tests.pause_between_tests || 0);
546569
}

0 commit comments

Comments
 (0)