1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- declare(strict_types=1);
- namespace lib\Net;
- use OC\Net\HostnameClassifier;
- use Test\TestCase;
- class HostnameClassifierTest extends TestCase {
- private HostnameClassifier $classifier;
- protected function setUp(): void {
- parent::setUp();
- $this->classifier = new HostnameClassifier();
- }
- public function localHostnamesData():array {
- return [
- ['localhost'],
- ['localHost'],
- ['random-host'],
- ['another-host.local'],
- ['service.localhost'],
- ['randomdomain.internal'],
- ];
- }
-
- public function testLocalHostname(string $host): void {
- $isLocal = $this->classifier->isLocalHostname($host);
- self::assertTrue($isLocal);
- }
- public function publicHostnamesData(): array {
- return [
- ['example.com'],
- ['example.net'],
- ['example.org'],
- ['host.domain'],
- ['cloud.domain.tld'],
- ];
- }
-
- public function testPublicHostname(string $host): void {
- $isLocal = $this->classifier->isLocalHostname($host);
- self::assertFalse($isLocal);
- }
- }
|