From b735192754fe6a5eee95e7f4d7014e8ec0ba8cbb Mon Sep 17 00:00:00 2001 From: German Lena Date: Fri, 3 Feb 2017 12:04:48 -0300 Subject: [PATCH] added more tests --- example/test.html | 8 +- integration/redirect_authorize.test.js | 96 ++++++++++++++++++- integration/redirect_usernamepassword.test.js | 5 +- integration/selenium.js | 66 ++++++------- 4 files changed, 136 insertions(+), 39 deletions(-) diff --git a/example/test.html b/example/test.html index 7b4836f5..243be7e3 100644 --- a/example/test.html +++ b/example/test.html @@ -7,10 +7,10 @@ - - - - + + + + diff --git a/integration/redirect_authorize.test.js b/integration/redirect_authorize.test.js index 260036ea..765c6921 100644 --- a/integration/redirect_authorize.test.js +++ b/integration/redirect_authorize.test.js @@ -8,11 +8,105 @@ describe('redirect authorize', function () { var By = webdriver.By; var until = webdriver.until; - it('should result in a successful transaction ' + browser, function () { + it('[token] should result in a successful transaction ' + browser, function () { var driver = clientFactory(); driver.get('https://auth0.github.io/auth0.js/example/test.html'); driver.wait(until.elementLocated(By.id('loaded')), 10000); + driver.findElement(By.id('login-response-type')).sendKeys('token'); + driver.findElement(By.className('login-redirect-authorize')).click(); + driver.wait(until.elementLocated(By.id('hlploaded')), 30000); + driver.findElement(By.id('email')).sendKeys('johnfoo@gmail.com'); + driver.findElement(By.id('password')).sendKeys('1234'); + driver.findElement(By.id('upLogin')).click(); + driver.wait(until.elementLocated(By.id('parsed')), 10000); + + driver.findElement(By.id('err')).getText().then(function(value) { + expect(value).to.equal(''); + }); + + driver.findElement(By.id('result')).getText().then(function(value) { + expect(value).to.not.equal(''); + }); + + return driver.quit(); + }); + + it('[code] should result in a successful transaction ' + browser, function () { + var driver = clientFactory(); + + driver.get('https://auth0.github.io/auth0.js/example/test.html'); + driver.wait(until.elementLocated(By.id('loaded')), 10000); + driver.findElement(By.id('login-response-type')).sendKeys('code'); + driver.findElement(By.className('login-redirect-authorize')).click(); + driver.wait(until.elementLocated(By.id('hlploaded')), 30000); + driver.findElement(By.id('email')).sendKeys('johnfoo@gmail.com'); + driver.findElement(By.id('password')).sendKeys('1234'); + driver.findElement(By.id('upLogin')).click(); + driver.wait(until.elementLocated(By.id('parsed')), 10000); + + driver.getTitle().then(function(url) { + expect(value).to.contain('code='); + }); + + return driver.quit(); + }); + + it('[token openid] should result in a successful transaction ' + browser, function () { + var driver = clientFactory(); + + driver.get('https://auth0.github.io/auth0.js/example/test.html'); + driver.wait(until.elementLocated(By.id('loaded')), 10000); + driver.findElement(By.id('login-scope')).sendKeys('openid'); + driver.findElement(By.id('login-response-type')).sendKeys('token'); + driver.findElement(By.className('login-redirect-authorize')).click(); + driver.wait(until.elementLocated(By.id('hlploaded')), 30000); + driver.findElement(By.id('email')).sendKeys('johnfoo@gmail.com'); + driver.findElement(By.id('password')).sendKeys('1234'); + driver.findElement(By.id('upLogin')).click(); + driver.wait(until.elementLocated(By.id('parsed')), 10000); + + driver.findElement(By.id('err')).getText().then(function(value) { + expect(value).to.equal(''); + }); + + driver.findElement(By.id('result')).getText().then(function(value) { + expect(value).to.not.equal(''); + }); + + return driver.quit(); + }); + + it('[id_token] should result in a successful transaction ' + browser, function () { + var driver = clientFactory(); + + driver.get('https://auth0.github.io/auth0.js/example/test.html'); + driver.wait(until.elementLocated(By.id('loaded')), 10000); + driver.findElement(By.id('login-response-type')).sendKeys('id_token'); + driver.findElement(By.className('login-redirect-authorize')).click(); + driver.wait(until.elementLocated(By.id('hlploaded')), 30000); + driver.findElement(By.id('email')).sendKeys('johnfoo@gmail.com'); + driver.findElement(By.id('password')).sendKeys('1234'); + driver.findElement(By.id('upLogin')).click(); + driver.wait(until.elementLocated(By.id('parsed')), 10000); + + driver.findElement(By.id('err')).getText().then(function(value) { + expect(value).to.equal(''); + }); + + driver.findElement(By.id('result')).getText().then(function(value) { + expect(value).to.not.equal(''); + }); + + return driver.quit(); + }); + + it('[token id_token] should result in a successful transaction ' + browser, function () { + var driver = clientFactory(); + + driver.get('https://auth0.github.io/auth0.js/example/test.html'); + driver.wait(until.elementLocated(By.id('loaded')), 10000); + driver.findElement(By.id('login-response-type')).sendKeys('token id_token'); driver.findElement(By.className('login-redirect-authorize')).click(); driver.wait(until.elementLocated(By.id('hlploaded')), 30000); driver.findElement(By.id('email')).sendKeys('johnfoo@gmail.com'); diff --git a/integration/redirect_usernamepassword.test.js b/integration/redirect_usernamepassword.test.js index 321e5b33..cf0db32e 100644 --- a/integration/redirect_usernamepassword.test.js +++ b/integration/redirect_usernamepassword.test.js @@ -13,6 +13,10 @@ describe('redirect usernamepassword', function () { driver.get('https://auth0.github.io/auth0.js/example/test.html'); driver.wait(until.elementLocated(By.id('loaded')), 10000); + driver.findElement(By.id('login-response-type')).sendKeys('token'); + driver.findElement(By.id('login-scope')).sendKeys('openid'); + driver.findElement(By.id('login-username')).sendKeys('johnfoo@gmail.com'); + driver.findElement(By.id('login-password')).sendKeys('1234'); driver.findElement(By.className('login-redirect-usernamepassword')).click(); driver.wait(until.elementLocated(By.id('parsed')), 10000); @@ -20,7 +24,6 @@ describe('redirect usernamepassword', function () { expect(value).to.equal(''); }); - driver.findElement(By.id('result')).getText().then(function(value) { expect(value).to.not.equal(''); }); diff --git a/integration/selenium.js b/integration/selenium.js index 47c09124..f1670381 100644 --- a/integration/selenium.js +++ b/integration/selenium.js @@ -8,42 +8,42 @@ var capabilities = [ 'browserName': 'chrome', 'platform': 'Windows 10', 'version': '55.0' -}, -{ - 'browserName': 'chrome', - 'platform': 'Windows 10', - 'version': 'beta' -}, -{ - 'browserName': 'firefox', - 'platform': 'Windows 10', - 'version': '50.0' -}, -{ - 'browserName': 'firefox', - 'platform': 'Windows 10', - 'version': 'beta' -}, -{ - 'browserName': 'internet explorer', - 'platform': 'Windows 7', - 'version': '11.0' -}, -{ - 'browserName': 'internet explorer', - 'platform': 'Windows 7', - 'version': '10.0' -}, +}//, // { -// 'browserName': 'MicrosoftEdge', +// 'browserName': 'chrome', // 'platform': 'Windows 10', -// 'version': '13.10586' +// 'version': 'beta' // }, -{ - 'browserName': 'safari', - 'platform': 'macOS 10.12', - 'version': '10.0' -} +// { +// 'browserName': 'firefox', +// 'platform': 'Windows 10', +// 'version': '50.0' +// }, +// { +// 'browserName': 'firefox', +// 'platform': 'Windows 10', +// 'version': 'beta' +// }, +// { +// 'browserName': 'internet explorer', +// 'platform': 'Windows 7', +// 'version': '11.0' +// }, +// { +// 'browserName': 'internet explorer', +// 'platform': 'Windows 7', +// 'version': '10.0' +// }, +// // { +// // 'browserName': 'MicrosoftEdge', +// // 'platform': 'Windows 10', +// // 'version': '13.10586' +// // }, +// { +// 'browserName': 'safari', +// 'platform': 'macOS 10.12', +// 'version': '10.0' +// } ]; module.exports = {