Skip to content

EspoCRM – Open Source CRM Application

Add test

Yurii92db951dd2bb
diff --git a/application/Espo/Entities/User.php b/application/Espo/Entities/User.php
index 68dd2233d4..18956be601 100644
--- a/application/Espo/Entities/User.php
+++ b/application/Espo/Entities/User.php
@@ -61,6 +61,9 @@ class User extends Person
*/
public const string ATTR_AUTH_LOG_RECORD_ID = 'authLogRecordId';
+ /** @since 10.1.0 */
+ public const string FIELD_IS_ACTIVE= 'isActive';
+
/** @since 10.0.0 */
public const string FIELD_USER_NAME = 'userName';
/** @since 10.0.0 */
diff --git a/tests/integration/Espo/Core/Authentication/AuthenticationTest.php b/tests/integration/Espo/Core/Authentication/AuthenticationTest.php
index c1154f4452..5b3c724a8d 100644
--- a/tests/integration/Espo/Core/Authentication/AuthenticationTest.php
+++ b/tests/integration/Espo/Core/Authentication/AuthenticationTest.php
@@ -172,6 +172,38 @@ class AuthenticationTest extends BaseTestCase
$this->assertTrue($result->isFail());
}
+ /**
+ * @noinspection PhpUnhandledExceptionInspection
+ */
+ public function testLoginBasicFailInactiveUser(): void
+ {
+ $username = 'test';
+ $password = 'hello';
+
+ $this->createUser([
+ User::FIELD_USER_NAME => $username,
+ User::FIELD_PASSWORD => $password,
+ User::FIELD_IS_ACTIVE => false,
+ ]);
+
+ $applicationUser = $this->createMock(ApplicationUser::class);
+
+ $applicationUser
+ ->expects(self::never())
+ ->method('setUser');
+
+ $result = $this->createAuthentication($applicationUser)->login(
+ data: AuthenticationData::create()
+ ->withUsername($username)
+ ->withPassword($password),
+ request: $this->createSimpleGetRequest(),
+ response: $this->createMock(Response::class),
+ );
+
+ $this->assertFalse($result->isSuccess());
+ $this->assertTrue($result->isFail());
+ }
+
/**
* @noinspection PhpUnhandledExceptionInspection
*/