-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE PPP-66918 WappSpector detection for Sitejet
- Loading branch information
Sofiia Kulish
committed
Dec 10, 2024
1 parent
fb30b55
commit 50166a3
Showing
6 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
|
||
namespace Plesk\Wappspector\MatchResult; | ||
|
||
class Sitejet extends MatchResult | ||
{ | ||
public const ID = 'sitejet'; | ||
public const NAME = 'Sitejet'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Plesk\Wappspector\Matchers; | ||
|
||
use League\Flysystem\Filesystem; | ||
use Plesk\Wappspector\MatchResult\EmptyMatchResult; | ||
use Plesk\Wappspector\MatchResult\MatchResultInterface; | ||
use Plesk\Wappspector\MatchResult\Sitejet as MatchResult; | ||
|
||
class Sitejet implements MatcherInterface | ||
{ | ||
public function match(Filesystem $fs, string $path): MatchResultInterface | ||
{ | ||
$indexHtmlPath = rtrim($path, '/') . '/index.html'; | ||
if (!$fs->fileExists($indexHtmlPath)) { | ||
return new EmptyMatchResult(); | ||
} | ||
|
||
$fileContent = $fs->read($indexHtmlPath); | ||
|
||
return $this->fileContentContainsString($fileContent, 'ed-element') | ||
&& $this->fileContentContainsString($fileContent, 'webcard.apiHost=') | ||
? new MatchResult($path) | ||
: new EmptyMatchResult(); | ||
} | ||
|
||
private function fileContentContainsString(string $fileContent, string $searchString): bool | ||
{ | ||
return strpos($fileContent, $searchString) !== false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
|
||
namespace Test\Matchers; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use Plesk\Wappspector\Matchers\MatcherInterface; | ||
use Plesk\Wappspector\Matchers\Sitejet; | ||
use Plesk\Wappspector\MatchResult\Sitejet as MatchResult; | ||
|
||
#[CoversClass(Sitejet::class)] | ||
class SitejetTest extends AbstractMatcherTestCase | ||
{ | ||
protected function getMatcherObj(): MatcherInterface | ||
{ | ||
return new Sitejet(); | ||
} | ||
|
||
protected function getMatchResultClassname(): string | ||
{ | ||
return MatchResult::class; | ||
} | ||
|
||
public static function detectablePathsProvider(): array | ||
{ | ||
return [ | ||
['sitejet', null], | ||
]; | ||
} | ||
} |