Skip to content

Commit a992c55

Browse files
committed
More functional tests.
1 parent ec0f562 commit a992c55

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

test/functional/editor.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,85 @@ describe('Editor', function() {
455455
});
456456
}
457457
});
458+
459+
describe('ES', async function() {
460+
before(async function() {
461+
this.timeout(30000);
462+
463+
await this.page.select('#algorithm-select', 'ES256');
464+
465+
await this.page.click('textarea[name="public-key"]');
466+
await this.page.keyboard.down('ControlLeft');
467+
await this.page.keyboard.press('KeyA');
468+
await this.page.keyboard.up('ControlLeft');
469+
await this.page.keyboard.type(defaultTokens['es256'].publicKey, {
470+
delay: 5
471+
});
472+
473+
await this.page.click('textarea[name="private-key"]');
474+
await this.page.keyboard.down('ControlLeft');
475+
await this.page.keyboard.press('KeyA');
476+
await this.page.keyboard.up('ControlLeft');
477+
await this.page.keyboard.type(defaultTokens['es256'].privateKey, {
478+
delay: 5
479+
});
480+
});
481+
482+
const algs = Object.keys(defaultTokens)
483+
.filter(alg => alg.includes('es'));
484+
485+
for(const alg of algs) {
486+
it(alg.toUpperCase(), async function() {
487+
this.timeout(30000);
488+
489+
await this.page.evaluate(token => {
490+
window.test.tokenEditor.setValue(token);
491+
}, defaultTokens[alg].token);
492+
493+
await this.page.select('#algorithm-select', alg.toUpperCase());
494+
495+
const oldToken = await this.page.evaluate(() => {
496+
return window.test.tokenEditor.getValue();
497+
});
498+
499+
await this.page.click('.js-header');
500+
await this.page.keyboard.down('ControlLeft');
501+
await this.page.keyboard.press('KeyA');
502+
await this.page.keyboard.up('ControlLeft');
503+
await this.page.keyboard.type(JSON.stringify({
504+
alg: alg.toUpperCase(),
505+
typ: 'JWT'
506+
}, null, 2), {
507+
delay: 5
508+
});
509+
510+
await this.page.click('.js-payload');
511+
await this.page.keyboard.down('ControlLeft');
512+
await this.page.keyboard.press('KeyA');
513+
await this.page.keyboard.up('ControlLeft');
514+
await this.page.keyboard.type(JSON.stringify({
515+
sub: 'test'
516+
}, null, 2), {
517+
delay: 5
518+
});
519+
520+
const newToken = await this.page.evaluate(() => {
521+
return window.test.tokenEditor.getValue();
522+
});
523+
524+
expect(newToken).to.not.be.empty;
525+
expect(newToken).to.not.equal(oldToken);
526+
527+
const valid = await this.page.$eval('.validation-status',
528+
status => {
529+
return status.classList.contains('valid-token') &&
530+
status.textContent.indexOf('verified') !== -1;
531+
});
532+
533+
expect(valid).to.be.true;
534+
});
535+
}
536+
});
458537
});
459538

460539
describe('Should download public-keys when possible', function() {

0 commit comments

Comments
 (0)