Commit 5af818eb authored by Christophe Maudoux's avatar Christophe Maudoux

WIP - Improve e2e tests (#1600)

parent 6657ac48
...@@ -412,6 +412,7 @@ prepare_test_server: ...@@ -412,6 +412,7 @@ prepare_test_server:
#@cp -f e2e-tests/index.* e2e-tests/conf/ #@cp -f e2e-tests/index.* e2e-tests/conf/
@cp -f $(SRCMANAGERDIR)/site/htdocs/manager* e2e-tests/conf/manager @cp -f $(SRCMANAGERDIR)/site/htdocs/manager* e2e-tests/conf/manager
@cp -f $(SRCPORTALDIR)/site/htdocs/index* e2e-tests/conf/portal @cp -f $(SRCPORTALDIR)/site/htdocs/index* e2e-tests/conf/portal
@cp e2e-tests/persistent/5efe8af397fc3577e05b483aca964f1b e2e-tests/conf/persistents
@cp e2e-tests/saml-sp.xml e2e-tests/conf/site/saml-sp.xml @cp e2e-tests/saml-sp.xml e2e-tests/conf/site/saml-sp.xml
@cp e2e-tests/rules.json e2e-tests/conf/site/test.json @cp e2e-tests/rules.json e2e-tests/conf/site/test.json
@for f in $$(find e2e-tests/conf -name '*.fcgi'); do \ @for f in $$(find e2e-tests/conf -name '*.fcgi'); do \
......
{"_session_kind":"Persistent","_loginHistory":{"successLogin":[{"ipAddr":"127.0.0.1","_utime":1548016089}]},"_2fDevices":"[{\"type\":\"U2F\",\"_keyHandle\":\"CTPeZD3aFrNOY4yVWH4o1MKSn2aLH2OwLOWTtrQSlt_6LtUyki5nzrwBEeuxj7PRSujFZQDaMTfrEb-gr22Qfg\",\"_userKey\":\"BI1MGzKj1C9mMV8PwrYMggQXlItLBNSB19rNnFgUpLMBjAkMW8w3Sqg8s_hUGbdfdWX99duquzIzRLUtRUEvJLo\",\"name\":\"MyU2FKey\",\"epoch\":1548016193},{\"epoch\":1548016213,\"name\":\"MyYubikey\",\"_yubikey\":\"cccccchehfff\",\"type\":\"UBK\"},{\"epoch\":1548018950,\"name\":\"MyU2FKeyBlue\",\"_userKey\":\"BDEa8pQfV9agdvsX63bcwceRTXR_QvDdm5hQ5ZKQUaH4HlOi8ab4fQfl9CIACALWYm0jQcpfaRAcACiSCdwGrnI\",\"_keyHandle\":\"ZD_G6EfDv4FzttWS9RCS80SaSlRTXgtJU9r-1gInsQ4Jj1555r7nnrYhIvRfE4CTyH7NyGrt9fMnMMgByAx97Q\",\"type\":\"U2F\"}]","_session_id":"5efe8af397fc3577e05b483aca964f1b","_session_uid":"dwho","_updateTime":"20190120221550","_utime":1548016089}
\ No newline at end of file
...@@ -6,9 +6,11 @@ describe('00 Lemonldap::NG', function() { ...@@ -6,9 +6,11 @@ describe('00 Lemonldap::NG', function() {
describe('Auth mechanism', function() { describe('Auth mechanism', function() {
it('Portal should display 11 lang flags', function() { it('Portal should display 11 lang flags', function() {
browser.driver.get('http://auth.example.com:' + process.env.TESTWEBSERVERPORT + '/'); browser.driver.get('http://auth.example.com:' + process.env.TESTWEBSERVERPORT + '/');
browser.sleep(500);
browser.driver.findElements(by.className('langicon')).then(function(elems) { browser.driver.findElements(by.className('langicon')).then(function(elems) {
expect(elems.length).toEqual(11); expect(elems.length).toEqual(11);
}); });
browser.sleep(500);
browser.driver.findElement(by.xpath("//img[@title='en']")).click(); browser.driver.findElement(by.xpath("//img[@title='en']")).click();
expect(browser.driver.findElement(by.css('[trmsg="9"]')).getText()).toEqual('Authentication required'); expect(browser.driver.findElement(by.css('[trmsg="9"]')).getText()).toEqual('Authentication required');
expect(browser.driver.findElement(by.css('[trspan="createAccount"]')).getText()).toEqual('Create an account'); expect(browser.driver.findElement(by.css('[trspan="createAccount"]')).getText()).toEqual('Create an account');
...@@ -78,11 +80,11 @@ describe('00 Lemonldap::NG', function() { ...@@ -78,11 +80,11 @@ describe('00 Lemonldap::NG', function() {
expect(browser.driver.findElement(by.css('[trspan="info"]')).getText()).toEqual("Information"); expect(browser.driver.findElement(by.css('[trspan="info"]')).getText()).toEqual("Information");
}); });
it('should display history', function() { it('should display history', function() {
// Two entries // Three entries
browser.driver.findElements(by.xpath('//table/tbody/tr')).then(function(elems) { browser.driver.findElements(by.xpath('//table/tbody/tr')).then(function(elems) {
expect(elems.length).toEqual(2); expect(elems.length).toEqual(3);
}); });
// Expect history with one login and one failed login // Expect history with two logins and one failed login
browser.driver.findElements(by.xpath('//form/div/div/h3')).then(function(elems) { browser.driver.findElements(by.xpath('//form/div/div/h3')).then(function(elems) {
expect(elems.length).toEqual(3); expect(elems.length).toEqual(3);
expect(elems[0].getText()).toEqual('Information'); expect(elems[0].getText()).toEqual('Information');
...@@ -96,10 +98,11 @@ describe('00 Lemonldap::NG', function() { ...@@ -96,10 +98,11 @@ describe('00 Lemonldap::NG', function() {
expect(elems[4].getText()).toEqual('Fehlermeldung'); expect(elems[4].getText()).toEqual('Fehlermeldung');
}); });
browser.driver.findElements(by.xpath('//table/tbody/tr/td')).then(function(elems) { browser.driver.findElements(by.xpath('//table/tbody/tr/td')).then(function(elems) {
expect(elems.length).toEqual(5); expect(elems.length).toEqual(7);
expect(elems[1].getText()).toEqual('127.0.0.1'); expect(elems[1].getText()).toEqual('127.0.0.1');
expect(elems[3].getText()).toEqual('127.0.0.1'); expect(elems[3].getText()).toEqual('127.0.0.1');
expect(elems[4].getText()).toEqual('Benutzername oder Passwort nicht korrekt'); expect(elems[5].getText()).toEqual('127.0.0.1');
expect(elems[6].getText()).toEqual('Benutzername oder Passwort nicht korrekt');
}); });
expect(browser.driver.findElement(by.css('[trspan="PE5"]')).getText()).toEqual('Benutzername oder Passwort nicht korrekt'); expect(browser.driver.findElement(by.css('[trspan="PE5"]')).getText()).toEqual('Benutzername oder Passwort nicht korrekt');
expect(browser.driver.findElement(by.id('timer')).getText()).toMatch(/^Du wirst in \d{2} Sekunden umgeleitet$/); expect(browser.driver.findElement(by.id('timer')).getText()).toMatch(/^Du wirst in \d{2} Sekunden umgeleitet$/);
......
...@@ -42,10 +42,11 @@ describe('0 Lemonldap::NG', function() { ...@@ -42,10 +42,11 @@ describe('0 Lemonldap::NG', function() {
expect(elems[4].getText()).toEqual("Message d'erreur"); expect(elems[4].getText()).toEqual("Message d'erreur");
}); });
browser.driver.findElements(by.xpath('//table/tbody/tr/td')).then(function(elems) { browser.driver.findElements(by.xpath('//table/tbody/tr/td')).then(function(elems) {
expect(elems.length).toEqual(5); expect(elems.length).toEqual(7);
expect(elems[1].getText()).toEqual('127.0.0.1'); expect(elems[1].getText()).toEqual('127.0.0.1');
expect(elems[3].getText()).toEqual('127.0.0.1'); expect(elems[3].getText()).toEqual('127.0.0.1');
expect(elems[4].getText()).toEqual('Mot de passe ou identifiant incorrect'); expect(elems[5].getText()).toEqual('127.0.0.1');
expect(elems[6].getText()).toEqual('Mot de passe ou identifiant incorrect');
}); });
browser.driver.findElement(by.xpath("//button[@type='button']")).click(); browser.driver.findElement(by.xpath("//button[@type='button']")).click();
browser.sleep(1000); browser.sleep(1000);
......
...@@ -27,7 +27,36 @@ describe('10 Lemonldap::NG', function() { ...@@ -27,7 +27,36 @@ describe('10 Lemonldap::NG', function() {
browser.sleep(1000); browser.sleep(1000);
}); });
}); });
it('Should submit TOTP form', function() { it('Should display 2FA Manager', function() {
expect(browser.driver.findElement(by.css('[trspan="choose2f"]')).getText()).toEqual('Choisissez votre second facteur');
browser.driver.findElements(by.xpath('//table/thead/tr/th')).then(function(elems) {
expect(elems.length).toEqual(4);
expect(elems[0].getText()).toEqual('Type');
expect(elems[1].getText()).toEqual('Nom');
expect(elems[2].getText()).toEqual('Date');
expect(elems[3].getText()).toEqual('Action');
});
browser.driver.findElements(by.xpath('//table/tbody/tr/td')).then(function(elems) {
expect(elems.length).toEqual(12);
expect(elems[0].getText()).toEqual('U2F');
expect(elems[1].getText()).toEqual('MyU2FKey');
expect(elems[2].getText()).toEqual('20/01/2019 à 21:29:53');
expect(elems[4].getText()).toEqual('UBK');
expect(elems[5].getText()).toEqual('MyYubikey');
expect(elems[6].getText()).toEqual('20/01/2019 à 21:30:13');
expect(elems[8].getText()).toEqual('U2F');
expect(elems[9].getText()).toEqual('MyU2FKeyBlue');
expect(elems[10].getText()).toEqual('20/01/2019 à 22:15:50');
});
expect(browser.driver.findElement(by.className('card-footer')).getText()).toEqual('TOTP2F');
browser.driver.findElements(by.className('btn-danger')).then(function(elems) {
expect(elems.length).toEqual(3);
elems[0].click();
});
expect(browser.driver.findElement(by.css('[trspan="choose2f"]')).getText()).toEqual("Vous n'êtes pas autorisé à faire cette requête");
browser.driver.findElement(by.xpath("//img[@title='totp2F']")).click();
});
it('Should display and submit TOTP form', function() {
browser.driver.findElements(by.css('[role="button"]')).then(function(links) { browser.driver.findElements(by.css('[role="button"]')).then(function(links) {
expect(links.length).toEqual(4); expect(links.length).toEqual(4);
expect(links[0].getText()).toEqual('Générer une nouvelle clef'); expect(links[0].getText()).toEqual('Générer une nouvelle clef');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment