TT#83370 selenium: add new admin login tests

controller_admin.t:
- test admin login with no credentials, wrong credentials, wrong password
and no password

Change-Id: I9b09568ba7c7382f5d74086ee1103c30bf833c07
changes/88/41088/3
Nico Schedel 5 years ago
parent b1b2b056fd
commit 1340394167

@ -11,9 +11,10 @@ has 'driver' => (
);
sub login_ok {
my ($self, $login, $pwd) = @_;
my ($self, $login, $pwd, $fail) = @_;
$login = 'administrator' unless $login;
$pwd = 'administrator' unless $pwd;
$fail = 0 unless $fail;
diag("Load login page (logout first)");
my $uri = $ENV{CATALYST_SERVER} || 'http://localhost:3000';
@ -27,9 +28,17 @@ sub login_ok {
$self->driver->fill_element('#password', 'css', $pwd);
$self->driver->find_element('#submit', 'css')->click();
diag("Check Admin interface");
is($self->driver->find_element('//*[@id="masthead"]//h2')->get_text(), "Dashboard", 'Dashboard is shown');
is($self->driver->get_title, 'Dashboard', 'We are in the Dashboard. Login Successful');
if ($fail){
diag("Check if login failed");
ok($self->driver->find_element('/html/body//div//h1[contains(text(), "Admin Sign In")]'), "Text 'Admin Sign In' found");
ok($self->driver->find_element('//form//div/span'), "Error Message was shown");
return 1
} else {
diag("Check Admin interface");
is($self->driver->find_element('//*[@id="masthead"]//h2')->get_text(), "Dashboard", 'Dashboard is shown');
is($self->driver->get_title, 'Dashboard', 'Login successful, something went wrong there');
return 0
}
}
sub create_domain {

@ -85,7 +85,35 @@ ok($d->find_element_by_xpath('//*[@id="administrator_table"]//tr[1]/td[contains(
ok($d->find_element_by_xpath('//*[@id="administrator_table"]//tr[1]/td[contains(text(), "' . $resellername . '")]'), 'Reseller is correct');
ok($d->find_element_by_xpath('//*[@id="administrator_table"]//tr[1]/td[7][contains(text(), "1")]'), 'Read-Only value is correct');
diag("New Administrator tries to login now");
diag("Try to log in new Administrator without any credentials");
$d->get("$uri/logout");
$d->get("$uri/login");
ok($d->find_element('/html/body//div//h1[contains(text(), "Admin Sign In")]'), "Text 'Admin Sign In' found");
is($d->get_title, '', 'No Tab Title was set');
$d->fill_element('#username', 'css', "");
$d->fill_element('#password', 'css', "");
$d->find_element('#submit', 'css')->click();
ok($d->find_element('/html/body//div//h1[contains(text(), "Admin Sign In")]'), "Text 'Admin Sign In' found");
ok($d->find_element('//form//div/span'), "Error Message was shown");
diag("Try to log in new Administrator with invalid credentials");
ok($c->login_ok("invalid", "creds", 1), "Login failed as intended");
diag("Try to log in new Administrator with invalid password");
ok($c->login_ok($adminname, "invalidpass", 1), "Login failed as intended");
diag("Try to log in new Administrator with no password");
$d->get("$uri/logout");
$d->get("$uri/login");
ok($d->find_element('/html/body//div//h1[contains(text(), "Admin Sign In")]'), "Text 'Admin Sign In' found");
is($d->get_title, '', 'No Tab Title was set');
$d->fill_element('#username', 'css', $adminname);
$d->fill_element('#password', 'css', "");
$d->find_element('#submit', 'css')->click();
ok($d->find_element('/html/body//div//h1[contains(text(), "Admin Sign In")]'), "Text 'Admin Sign In' found");
ok($d->find_element('//form//div/span'), "Error Message was shown");
diag("Try to log in new Administrator for real this time");
$c->login_ok($adminname, $adminpwd);
diag("Go to 'Administrators' page");

Loading…
Cancel
Save