Skip to content

Commit

Permalink
fixup! Feat: link checking for phishing detection
Browse files Browse the repository at this point in the history
Signed-off-by: Hamza Mahjoubi <[email protected]>
  • Loading branch information
hamza221 committed Aug 13, 2024
1 parent 218d3da commit 37da2be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OCA\Mail\Service\PhishingDetection\ContactCheck;
use OCA\Mail\Service\PhishingDetection\CustomEmailCheck;
use OCA\Mail\Service\PhishingDetection\DateCheck;
use OCA\Mail\Service\PhishingDetection\LinkCheck;
use OCA\Mail\Service\PhishingDetection\PhishingDetectionService;
use OCA\Mail\Service\PhishingDetection\ReplyToCheck;
use OCP\AppFramework\Utility\ITimeFactory;
Expand All @@ -30,6 +31,7 @@ class PhishingDetectionServiceIntegrationTest extends TestCase {
private CustomEmailCheck $customEmailCheck;
private DateCheck $dateCheck;
private ReplyToCheck $replyToCheck;
private LinkCheck $linkCheck;
private PhishingDetectionService $service;

protected function setUp(): void {
Expand All @@ -40,7 +42,8 @@ protected function setUp(): void {
$this->customEmailCheck = new CustomEmailCheck($this->l10n);
$this->dateCheck = new DateCheck($this->l10n, \OC::$server->get(ITimeFactory::class));
$this->replyToCheck = new ReplyToCheck($this->l10n);
$this->service = new PhishingDetectionService($this->contactCheck, $this->customEmailCheck, $this->dateCheck, $this->replyToCheck);
$this->linkCheck = new LinkCheck($this->l10n);
$this->service = new PhishingDetectionService($this->contactCheck, $this->customEmailCheck, $this->dateCheck, $this->replyToCheck, $this->linkCheck);
}


Expand Down
10 changes: 8 additions & 2 deletions tests/Unit/Service/Phishing/PhishingDetectionServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OCA\Mail\Service\PhishingDetection\ContactCheck;
use OCA\Mail\Service\PhishingDetection\CustomEmailCheck;
use OCA\Mail\Service\PhishingDetection\DateCheck;
use OCA\Mail\Service\PhishingDetection\LinkCheck;
use OCA\Mail\Service\PhishingDetection\PhishingDetectionService;
use OCA\Mail\Service\PhishingDetection\ReplyToCheck;

Expand All @@ -24,6 +25,7 @@ class PhishingDetectionServiceTest extends TestCase {
private CustomEmailCheck|MockObject $customEmailCheck;
private DateCheck|MockObject $dateCheck;
private ReplyToCheck|MockObject $replyToCheck;
private LinkCheck|MockObject $linkCheck;
private PhishingDetectionService $service;

protected function setUp(): void {
Expand All @@ -32,7 +34,8 @@ protected function setUp(): void {
$this->customEmailCheck = $this->createMock(customEmailCheck::class);
$this->dateCheck = $this->createMock(DateCheck::class);
$this->replyToCheck = $this->createMock(ReplyToCheck::class);
$this->service = new PhishingDetectionService($this->contactCheck, $this->customEmailCheck, $this->dateCheck, $this->replyToCheck);
$this->linkCheck = $this->createMock(LinkCheck::class);
$this->service = new PhishingDetectionService($this->contactCheck, $this->customEmailCheck, $this->dateCheck, $this->replyToCheck, $this->linkCheck);
}


Expand All @@ -56,7 +59,10 @@ public function testCheckHeadersForPhishing(): void {
$this->customEmailCheck->expects($this->once())
->method('run')
->willReturn(new PhishingDetectionResult(PhishingDetectionResult::CUSTOM_EMAIL_CHECK, false));
$result = $this->service->checkHeadersForPhishing($parsedHeaders, false);
$this->linkCheck->expects($this->once())
->method('run')
->willReturn(new PhishingDetectionResult(PhishingDetectionResult::LINK_CHECK, false));
$result = $this->service->checkHeadersForPhishing($parsedHeaders, true, '');
$this->assertFalse($result["warning"]);
}

Expand Down

0 comments on commit 37da2be

Please sign in to comment.