Browse Source

updated Aauth/LoginTest & renamed loginFailedName to loginFailedUsername in all langs

v3-dev
REJack 6 years ago
parent
commit
8d1b91dfca
No known key found for this signature in database
GPG Key ID: 4A44B48700429F46
  1. 2
      CHANGES.md
  2. 2
      application/Language/de/Aauth.php
  3. 2
      application/Language/en/Aauth.php
  4. 2
      application/Language/es/Aauth.php
  5. 2
      application/Language/fa/Aauth.php
  6. 2
      application/Language/fr/Aauth.php
  7. 2
      application/Language/id/Aauth.php
  8. 2
      application/Language/ru/Aauth.php
  9. 2
      application/Language/sv/Aauth.php
  10. 2
      application/Language/zh-CN/Aauth.php
  11. 2
      application/Language/zh-TW/Aauth.php
  12. 2
      application/Libraries/Aauth.php
  13. 117
      tests/Aauth/Libraries/Aauth/LoginTest.php

2
CHANGES.md

@ -151,7 +151,7 @@
- aauth_error_no_access => notVerified - aauth_error_no_access => notVerified
- aauth_error_account_not_verified => notVerified - aauth_error_account_not_verified => notVerified
- aauth_error_login_failed_email => loginFailedEmail - aauth_error_login_failed_email => loginFailedEmail
- aauth_error_login_failed_name => loginFailedName - aauth_error_login_failed_name => loginFailedUsername
- aauth_error_login_failed_all => loginFailedAll - aauth_error_login_failed_all => loginFailedAll
- aauth_error_login_attempts_exceeded => loginAttemptsExceeded - aauth_error_login_attempts_exceeded => loginAttemptsExceeded
- aauth_error_email_invalid => invalidEmail - aauth_error_email_invalid => invalidEmail

2
application/Language/de/Aauth.php

@ -44,7 +44,7 @@ return [
'notVerified' => 'Dein Account wurde bisher nicht bestätigt. Bitte prüfe deine E-Mails und bestätige deine Registrierung.', 'notVerified' => 'Dein Account wurde bisher nicht bestätigt. Bitte prüfe deine E-Mails und bestätige deine Registrierung.',
'loginFailedEmail' => 'E-Mail-Adresse oder Passwort falsch.', 'loginFailedEmail' => 'E-Mail-Adresse oder Passwort falsch.',
'loginFailedName' => 'Benutzername oder Passwort falsch.', 'loginFailedUsername' => 'Benutzername oder Passwort falsch.',
'loginFailedAll' => 'E-Mail-Adresse, Benutzername oder Passwort falsch.', 'loginFailedAll' => 'E-Mail-Adresse, Benutzername oder Passwort falsch.',
'loginAttemptsExceeded' => 'Du hast die maximale Anzahl Login versuche erreicht, dein Account wurde gesperrt.', 'loginAttemptsExceeded' => 'Du hast die maximale Anzahl Login versuche erreicht, dein Account wurde gesperrt.',

2
application/Language/en/Aauth.php

@ -44,7 +44,7 @@ return [
'notVerified' => 'Your account has not been verified. Please check your email and verify your account.', 'notVerified' => 'Your account has not been verified. Please check your email and verify your account.',
'loginFailedEmail' => 'Email Address and Password do not match.', 'loginFailedEmail' => 'Email Address and Password do not match.',
'loginFailedName' => 'Username and Password do not match.', 'loginFailedUsername' => 'Username and Password do not match.',
'loginFailedAll' => 'Email, Username or Password do not match.', 'loginFailedAll' => 'Email, Username or Password do not match.',
'loginAttemptsExceeded' => 'You have exceeded your login attempts, your account has now been locked.', 'loginAttemptsExceeded' => 'You have exceeded your login attempts, your account has now been locked.',

2
application/Language/es/Aauth.php

@ -44,7 +44,7 @@ return [
'notVerified' => 'Tu cuenta aún no ha sido verificada, por favor revisa tu correo electrónico y verifica tu cuenta.', 'notVerified' => 'Tu cuenta aún no ha sido verificada, por favor revisa tu correo electrónico y verifica tu cuenta.',
'loginFailedEmail' => 'El Correo electrónico y contraseña no coinciden.', 'loginFailedEmail' => 'El Correo electrónico y contraseña no coinciden.',
'loginFailedName' => 'El Nombre de usuario y contraseña no coinciden.', 'loginFailedUsername' => 'El Nombre de usuario y contraseña no coinciden.',
'loginFailedAll' => 'El Correo electrónico, nombre de usuario y contraseña no coinciden.', 'loginFailedAll' => 'El Correo electrónico, nombre de usuario y contraseña no coinciden.',
'loginAttemptsExceeded' => 'Has excedido el número de intentos de inicio de sesión, tu cuenta ha sido bloqueada.', 'loginAttemptsExceeded' => 'Has excedido el número de intentos de inicio de sesión, tu cuenta ha sido bloqueada.',

2
application/Language/fa/Aauth.php

@ -44,7 +44,7 @@ return [
'notVerified' => 'حساب کاربری شما تایید نشده است. لطفا ایمیل خود را برای تایید حسا کاربری بررسی کنید.', 'notVerified' => 'حساب کاربری شما تایید نشده است. لطفا ایمیل خود را برای تایید حسا کاربری بررسی کنید.',
'loginFailedEmail' => 'ایمیل و کلمه عبور همخوانی ندارند.', 'loginFailedEmail' => 'ایمیل و کلمه عبور همخوانی ندارند.',
'loginFailedName' => 'نام کاربری و کلمه عبور همخوانی ندارند.', 'loginFailedUsername' => 'نام کاربری و کلمه عبور همخوانی ندارند.',
'loginFailedAll' => 'ایمیل یا نام کاربری با کلمه عبور همخوانی ندارد.', 'loginFailedAll' => 'ایمیل یا نام کاربری با کلمه عبور همخوانی ندارد.',
'loginAttemptsExceeded' => 'شما بیش از حد مجاز برای ورود به سایت تلاش کردید. حساب کاربری شما موقتا غیر فعال شد.', 'loginAttemptsExceeded' => 'شما بیش از حد مجاز برای ورود به سایت تلاش کردید. حساب کاربری شما موقتا غیر فعال شد.',

2
application/Language/fr/Aauth.php

@ -44,7 +44,7 @@ return [
'notVerified' => 'Votre compte n\'a pas été confirmé. Merci de vérifier vos email et de confirmer votre compte.', 'notVerified' => 'Votre compte n\'a pas été confirmé. Merci de vérifier vos email et de confirmer votre compte.',
'loginFailedEmail' => 'L\'adresse email et le mot de passe ne correspondent pas.', 'loginFailedEmail' => 'L\'adresse email et le mot de passe ne correspondent pas.',
'loginFailedName' => 'Le nom d\'utilisateur et le mot de passe ne correspondent pas.', 'loginFailedUsername' => 'Le nom d\'utilisateur et le mot de passe ne correspondent pas.',
'loginFailedAll' => 'L\'adresse email, le nom d\'utilisateur ou le mot de passe ne correspondent pas.', 'loginFailedAll' => 'L\'adresse email, le nom d\'utilisateur ou le mot de passe ne correspondent pas.',
'loginAttemptsExceeded' => 'Vous avez dépassé le nombre de tentatives de connexion autorisées, votre compte a été bloqué.', 'loginAttemptsExceeded' => 'Vous avez dépassé le nombre de tentatives de connexion autorisées, votre compte a été bloqué.',

2
application/Language/id/Aauth.php

@ -44,7 +44,7 @@ return [
'notVerified' => 'Akun anda belum diverifikasi. Silakan cek email anda dan verifikasi akun anda.', 'notVerified' => 'Akun anda belum diverifikasi. Silakan cek email anda dan verifikasi akun anda.',
'loginFailedEmail' => 'Email dan sandi yang anda masukkan tidak cocok.', 'loginFailedEmail' => 'Email dan sandi yang anda masukkan tidak cocok.',
'loginFailedName' => 'Username dan sandi yang Anda masukkan tidak cocok.', 'loginFailedUsername' => 'Username dan sandi yang Anda masukkan tidak cocok.',
'loginFailedAll' => 'Email, username dan sandi yang Anda masukkan tidak cocok.', 'loginFailedAll' => 'Email, username dan sandi yang Anda masukkan tidak cocok.',
'loginAttemptsExceeded' => 'Anda telah melebihi upaya login anda, akun anda telah diblokir.', 'loginAttemptsExceeded' => 'Anda telah melebihi upaya login anda, akun anda telah diblokir.',

2
application/Language/ru/Aauth.php

@ -44,7 +44,7 @@ return [
'notVerified' => 'Ваш акккаунт не подтвержден. Проверьте ваш ящик e-mail и подтвердите аккаунт.', 'notVerified' => 'Ваш акккаунт не подтвержден. Проверьте ваш ящик e-mail и подтвердите аккаунт.',
'loginFailedEmail' => 'Неверный email или пароль.', 'loginFailedEmail' => 'Неверный email или пароль.',
'loginFailedName' => 'Неверное имя пользователя или пароль.', 'loginFailedUsername' => 'Неверное имя пользователя или пароль.',
'loginFailedAll' => 'Неверный E-mail, имя пользователя или пароль.', 'loginFailedAll' => 'Неверный E-mail, имя пользователя или пароль.',
'loginAttemptsExceeded' => 'Количество попыток входа превышено, ваш аккаунт временно заблокирован.', 'loginAttemptsExceeded' => 'Количество попыток входа превышено, ваш аккаунт временно заблокирован.',

2
application/Language/sv/Aauth.php

@ -44,7 +44,7 @@ return [
'notVerified' => 'Ditt konto är inte bekräftat. Var vänlig kolla din e-post och bekräfta ditt konto.', 'notVerified' => 'Ditt konto är inte bekräftat. Var vänlig kolla din e-post och bekräfta ditt konto.',
'loginFailedEmail' => 'E-postadressen och lösenordet stämmer inte överens.', 'loginFailedEmail' => 'E-postadressen och lösenordet stämmer inte överens.',
'loginFailedName' => 'Användarnamnet och lösenordet stämmer inte överens.', 'loginFailedUsername' => 'Användarnamnet och lösenordet stämmer inte överens.',
'loginFailedAll' => 'E-postadress, användarnamn och lösenord stämmer inte överens.', 'loginFailedAll' => 'E-postadress, användarnamn och lösenord stämmer inte överens.',
'loginAttemptsExceeded' => 'Du har förbrukat dina försök att logga in, ditt konto har blivit låst.', 'loginAttemptsExceeded' => 'Du har förbrukat dina försök att logga in, ditt konto har blivit låst.',

2
application/Language/zh-CN/Aauth.php

@ -46,7 +46,7 @@ return [
'notVerified' => '您的帐户尚未验证,请检查信箱并验证帐户。', 'notVerified' => '您的帐户尚未验证,请检查信箱并验证帐户。',
'loginFailedEmail' => '电邮地址和密码不符', 'loginFailedEmail' => '电邮地址和密码不符',
'loginFailedName' => '用户名和密码不符', 'loginFailedUsername' => '用户名和密码不符',
'loginFailedAll' => '电邮地址、用户名和或密码不符', 'loginFailedAll' => '电邮地址、用户名和或密码不符',
'loginAttemptsExceeded' => '您已达到登入尝试限制数,您的帐户已被锁住。', 'loginAttemptsExceeded' => '您已达到登入尝试限制数,您的帐户已被锁住。',

2
application/Language/zh-TW/Aauth.php

@ -46,7 +46,7 @@ return [
'notVerified' => '您的帳號尚未驗證,請檢查信箱並驗證帳號。', 'notVerified' => '您的帳號尚未驗證,請檢查信箱並驗證帳號。',
'loginFailedEmail' => '電郵地址和密碼不符', 'loginFailedEmail' => '電郵地址和密碼不符',
'loginFailedName' => '用戶名和密碼不符', 'loginFailedUsername' => '用戶名和密碼不符',
'loginFailedAll' => '電郵地址、用戶名和或密碼不符', 'loginFailedAll' => '電郵地址、用戶名和或密碼不符',
'loginAttemptsExceeded' => '您已達到登入嘗試限制數,您的帳號已被鎖住。', 'loginAttemptsExceeded' => '您已達到登入嘗試限制數,您的帳號已被鎖住。',

2
application/Libraries/Aauth.php

@ -637,7 +637,7 @@ class Aauth
{ {
if (! $identifier || strlen($password) < $this->config->passwordMin || strlen($password) > $this->config->passwordMax) if (! $identifier || strlen($password) < $this->config->passwordMin || strlen($password) > $this->config->passwordMax)
{ {
$this->error(lang('Aauth.loginFailedName')); $this->error(lang('Aauth.loginFailedUsername'));
return false; return false;
} }

117
tests/Aauth/Libraries/Aauth/LoginTest.php

@ -1,5 +1,6 @@
<?php namespace Tests\Aauth\Libraries\Aauth; <?php namespace Tests\Aauth\Libraries\Aauth;
use Config\Aauth as AauthConfig;
use Config\Logger; use Config\Logger;
use Config\Services; use Config\Services;
use Tests\Support\Log\TestLogger; use Tests\Support\Log\TestLogger;
@ -7,6 +8,8 @@ use Tests\Support\Session\MockSession;
use CodeIgniter\Session\Handlers\FileHandler; use CodeIgniter\Session\Handlers\FileHandler;
use CodeIgniter\Test\CIDatabaseTestCase; use CodeIgniter\Test\CIDatabaseTestCase;
use App\Libraries\Aauth; use App\Libraries\Aauth;
use App\Models\Aauth\UserVariableModel;
use App\Models\Aauth\LoginTokenModel;
/** /**
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
@ -64,18 +67,126 @@ class LoginTest extends CIDatabaseTestCase
public function testLoginEmailTrue() public function testLoginEmailTrue()
{ {
$session = $this->getInstance(); $session = $this->getInstance();
$this->library = new Aauth(NULL, $session); $this->library = new Aauth(null, $session);
$this->assertTrue($this->library->login('admin@example.com', 'password123456')); $this->assertTrue($this->library->login('admin@example.com', 'password123456'));
print_r($_SESSION); }
public function testLoginFalseEmailFailedEmail()
{
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$this->assertFalse($this->library->login('adminaexample.com', 'password123456'));
$this->assertEquals(lang('Aauth.loginFailedEmail'), $this->library->getErrorsArray()[0]);
}
public function testLoginFalseEmailFailedPassword()
{
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$this->assertFalse($this->library->login('admin@aexample.com', 'password'));
$this->assertEquals(lang('Aauth.loginFailedEmail'), $this->library->getErrorsArray()[0]);
}
public function testLoginFalseEmailNotFound()
{
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$this->assertFalse($this->library->login('admina@example.com', 'password123456'));
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
}
public function testLoginUsernameTrue()
{
$session = $this->getInstance();
$config = new AauthConfig();
$config->loginUseUsername = true;
$this->library = new Aauth($config, $session);
$this->assertTrue($this->library->login('admin', 'password123456'));
}
public function testLoginFalseUsernameFailedPassword()
{
$session = $this->getInstance();
$config = new AauthConfig();
$config->loginUseUsername = true;
$this->library = new Aauth($config, $session);
$this->assertFalse($this->library->login('admin', 'password'));
$this->assertEquals(lang('Aauth.loginFailedUsername'), $this->library->getErrorsArray()[0]);
}
public function testLoginFalseUsernameNotFound()
{
$session = $this->getInstance();
$config = new AauthConfig();
$config->loginUseUsername = true;
$this->library = new Aauth($config, $session);
$this->assertFalse($this->library->login('admina', 'password'));
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
}
public function testLoginFalseNotVerified()
{
$userVariableModel = new UserVariableModel();
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$userVariableModel->save(1, 'verification_code', '12345678', true);
$this->assertFalse($this->library->login('admin@aexample.com', 'password123456'));
$this->assertEquals(lang('Aauth.notVerified'), $this->library->getErrorsArray()[0]);
}
public function testLoginFalseBanned()
{
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$this->library->banUser(1);
$this->assertFalse($this->library->login('admin@aexample.com', 'password123456'));
$this->assertEquals(lang('Aauth.invalidUserBanned'), $this->library->getErrorsArray()[0]);
}
public function testLoginFalse()
{
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$this->assertFalse($this->library->login('admin@aexample.com', 'password1234567'));
$this->assertEquals(lang('Aauth.loginFailedAll'), $this->library->getErrorsArray()[0]);
}
public function testLoginFalseLoginAttemptsExceeded()
{
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$this->library->login('admina@example.com', 'password123456');
$this->library->login('admina@example.com', 'password123456');
$this->library->login('admina@example.com', 'password123456');
$this->library->login('admina@example.com', 'password123456');
$this->library->login('admina@example.com', 'password123456');
$this->library->login('admina@example.com', 'password123456');
$this->library->login('admina@example.com', 'password123456');
$this->library->login('admina@example.com', 'password123456');
$this->library->login('admina@example.com', 'password123456');
$this->assertFalse($this->library->login('admina@example.com', 'password123456'));
$this->assertEquals(lang('Aauth.loginAttemptsExceeded'), $this->library->getErrorsArray()[0]);
} }
public function testIsLoggedIn() public function testIsLoggedIn()
{ {
$session = $this->getInstance(); $session = $this->getInstance();
$this->library = new Aauth(NULL, $session); $this->library = new Aauth(null, $session);
$session->set('user', [
'loggedIn' => true,
]);
$this->assertTrue($this->library->isLoggedIn());
}
public function testLogout()
{
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$session->set('user', [ $session->set('user', [
'loggedIn' => true, 'loggedIn' => true,
]); ]);
$this->assertTrue($this->library->isLoggedIn()); $this->assertTrue($this->library->isLoggedIn());
$this->library->logout();
$this->assertFalse($this->library->isLoggedIn());
} }
} }

Loading…
Cancel
Save