12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- declare(strict_types=1);
- namespace OCA\AdminAudit\Tests\Actions;
- use OCA\AdminAudit\Actions\Security;
- use OCA\AdminAudit\AuditLogger;
- use OCP\Authentication\TwoFactorAuth\IProvider;
- use OCP\IUser;
- use Test\TestCase;
- class SecurityTest extends TestCase {
-
- private $logger;
-
- private $security;
-
- private $user;
- protected function setUp(): void {
- parent::setUp();
- $this->logger = $this->createMock(AuditLogger::class);
- $this->security = new Security($this->logger);
- $this->user = $this->createMock(IUser::class);
- $this->user->method('getUID')->willReturn('myuid');
- $this->user->method('getDisplayName')->willReturn('mydisplayname');
- }
- public function testTwofactorFailed() {
- $this->logger->expects($this->once())
- ->method('info')
- ->with(
- $this->equalTo('Failed two factor attempt by user mydisplayname (myuid) with provider myprovider'),
- ['app' => 'admin_audit']
- );
- $provider = $this->createMock(IProvider::class);
- $provider->method('getDisplayName')
- ->willReturn('myprovider');
- $this->security->twofactorFailed($this->user, $provider);
- }
- public function testTwofactorSuccess() {
- $this->logger->expects($this->once())
- ->method('info')
- ->with(
- $this->equalTo('Successful two factor attempt by user mydisplayname (myuid) with provider myprovider'),
- ['app' => 'admin_audit']
- );
- $provider = $this->createMock(IProvider::class);
- $provider->method('getDisplayName')
- ->willReturn('myprovider');
- $this->security->twofactorSuccess($this->user, $provider);
- }
- }
|