Reintroduce email support for login (fixes #165; reverts #e208d30513f7cfafb6405324fee5b88902dcf2fb) - 2

Change-Id: Ia145f1e47295e2e5df0248604262024f87583bab
diff --git a/t/plugin/auth-oauth.t b/t/plugin/auth-oauth.t
index 45281df..7dc2549 100644
--- a/t/plugin/auth-oauth.t
+++ b/t/plugin/auth-oauth.t
@@ -116,7 +116,7 @@
 
 $t->get_ok('/')
   ->status_is(200)
-  ->element_exists('form[action=/user/login] input[name=handle]')
+  ->element_exists('form[action=/user/login] input[name=handle_or_email]')
   ->element_exists('aside.active')
   ->element_exists_not('aside.off')
   ;
@@ -128,12 +128,12 @@
 
 # Test for bug with long password
 $t->post_ok('/user/login' => form => {
-  handle => 'test',
+  handle_or_email => 'test',
   pwd => 'kjskjhndkjndqknaskjnakjdnkjdankajdnkjdsankjdsakjdfkjahzroiuqzriudjoijdmlamdlkmdsalkmdl' })
   ->status_is(302)
   ->header_is('Location' => '/');
 
-$t->post_ok('/user/login' => form => { handle => 'test', pwd => 'fail' })
+$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'fail' })
   ->status_is(302)
   ->header_is('Location' => '/');
 
@@ -141,11 +141,11 @@
   ->status_is(200)
   ->element_exists('div.notify-error')
   ->text_is('div.notify-error', 'Bad CSRF token')
-  ->element_exists('input[name=handle][value=test]')
+  ->element_exists('input[name=handle_or_email][value=test]')
   ->element_exists_not('div.button.top a')
   ;
 
-$t->post_ok('/user/login' => form => { handle => 'test', pwd => 'pass' })
+$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'pass' })
   ->status_is(302)
   ->header_is('Location' => '/');
 
@@ -158,7 +158,7 @@
   ;
 
 $t->post_ok('/user/login' => form => {
-  handle => 'test',
+  handle_or_email => 'test',
   pwd => 'ldaperr',
   csrf_token => $csrf
 })
@@ -170,14 +170,14 @@
   ->status_is(200)
   ->element_exists('div.notify-error')
   ->text_is('div.notify-error', '2022: LDAP Authentication failed due to unknown user or password!')
-  ->element_exists('input[name=handle][value=test]')
+  ->element_exists('input[name=handle_or_email][value=test]')
   ->element_exists_not('div.button.top a')
   ->element_exists_not('div.notify-success')
   ->tx->res->dom->at('input[name=csrf_token]')->attr('value')
   ;
 
 $t->post_ok('/user/login' => form => {
-  handle => 'test',
+  handle_or_email => 'test',
   pwd => 'unknown',
   csrf_token => $csrf
 })
@@ -189,13 +189,13 @@
   ->status_is(200)
   ->element_exists('div.notify-error')
   ->text_is('div.notify-error', '2022: LDAP Authentication failed due to unknown user or password!')
-  ->element_exists('input[name=handle][value=test]')
+  ->element_exists('input[name=handle_or_email][value=test]')
   ->element_exists_not('div.button.top a')
   ->tx->res->dom->at('input[name=csrf_token]')->attr('value')
   ;
 
 $t->post_ok('/user/login' => form => {
-  handle => 'test',
+  handle_or_email => 'test',
   pwd => 'pass',
   csrf_token => $csrf
 })
@@ -256,8 +256,8 @@
   ->element_exists_not('div.notify-error')
   ->element_exists('div.notify-success')
   ->text_is('div.notify-success', 'Logout successful')
-  ->element_exists("input[name=handle]")
-  ->element_exists("input[name=handle][value=test]")
+  ->element_exists("input[name=handle_or_email]")
+  ->element_exists("input[name=handle_or_email][value=test]")
   ;
 
 $t->get_ok('/?q=Baum')
@@ -286,7 +286,7 @@
 is($fwd, '/?q=Baum&ql=poliqarp', 'Redirect is valid');
 
 $t->post_ok('/user/login' => form => {
-  handle => 'test',
+  handle_or_email => 'test',
   pwd => 'pass',
   csrf_token => $csrf,
   fwd => 'http://bad.example.com/test'
@@ -302,7 +302,7 @@
   ;
 
 $t->post_ok('/user/login' => form => {
-  handle => 'test',
+  handle_or_email => 'test',
   pwd => 'pass',
   csrf_token => $csrf,
   fwd => $fwd
@@ -436,7 +436,7 @@
 # This should fail
 my $wide_char_login = "\x{61}\x{E5}\x{61}"; # "\x{443}\x{434}";
 $t->post_ok('/user/login' => form => {
-  handle => $wide_char_login,
+  handle_or_email => $wide_char_login,
   pwd => 'pass',
   csrf_token => $csrf,
   fwd => $fwd
@@ -448,7 +448,7 @@
   ->status_is(200)
   ->element_exists('div.notify-error')
   ->text_is('div.notify-error', 'Invalid character in request')
-  ->element_exists('input[name=handle]:not([value])')
+  ->element_exists('input[name=handle_or_email]:not([value])')
   ->element_exists_not('div.button.top a')
   ;
 
@@ -456,7 +456,7 @@
 # UTF8 request
 my $username = b('täst')->encode;
 $t->post_ok('/user/login' => form => {
-  handle => $username,
+  handle_or_email => $username,
   pwd => 'pass',
   csrf_token => $csrf
 })
@@ -783,7 +783,7 @@
   ->element_exists_not('div.notify-error')
   ->element_exists('div.notify-success')
   ->text_is('div.notify-success', 'Logout successful')
-  ->element_exists("input[name=handle]")
+  ->element_exists("input[name=handle_or_email]")
   ->tx->res->dom->at('input[name=csrf_token]')->attr('value')
   ;
 
@@ -817,7 +817,7 @@
   state => 'abcde',
   scope => 'search match',
   redirect_uri => 'http://test.com/',
-  handle => 'test',
+  handle_or_email => 'test',
   pwd => 'pass',
   fwd => $fwd
 }))