Skip to content

Commit 02d45c7

Browse files
committed
Merge pull request #135 from marco-c/vapis_keys_for_tests
Make it possible to define VAPID keys to use during tests via env variables
2 parents 7ee2b20 + 1db4c52 commit 02d45c7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/testSelenium.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ if (!process.env.GCM_API_KEY) {
1414
console.log('You need to set the GCM_API_KEY env variable to run the tests with Chromium.'.bold.red);
1515
}
1616

17+
if (!process.env.VAPID_PRIVATE_KEY || !process.env.VAPID_PUBLIC_KEY) {
18+
console.log('You haven\'t set the VAPID env variables, I\'ll generate them for you.'.bold.yellow);
19+
20+
var keys = webPush.generateVAPIDKeys();
21+
process.env.VAPID_PRIVATE_KEY = keys.privateKey.toString('base64');
22+
process.env.VAPID_PUBLIC_KEY = keys.publicKey.toString('base64');
23+
}
24+
1725
process.env.PATH = process.env.PATH + ':test_tools/';
1826

1927
suite('selenium', function() {
@@ -177,12 +185,11 @@ suite('selenium', function() {
177185
});
178186
});
179187

180-
var vapidKeys = webPush.generateVAPIDKeys();
181188
var vapidParam = {
182189
audience: 'https://www.mozilla.org/',
183190
subject: 'mailto:[email protected]',
184-
privateKey: vapidKeys.privateKey,
185-
publicKey: vapidKeys.publicKey,
191+
privateKey: new Buffer(process.env.VAPID_PRIVATE_KEY, 'base64'),
192+
publicKey: new Buffer(process.env.VAPID_PUBLIC_KEY, 'base64'),
186193
};
187194

188195
test('send/receive notification without payload with Firefox Release', function() {

0 commit comments

Comments
 (0)