diff --git a/src/Appwrite/GraphQL/Types/Mapper.php b/src/Appwrite/GraphQL/Types/Mapper.php index 1675acc308..42bdc4b149 100644 --- a/src/Appwrite/GraphQL/Types/Mapper.php +++ b/src/Appwrite/GraphQL/Types/Mapper.php @@ -232,14 +232,14 @@ class Mapper case 'Appwrite\Network\Validator\Email': case 'Appwrite\Event\Validator\Event': case 'Utopia\Validator\HexColor': - case 'Appwrite\Network\Validator\Host': - case 'Appwrite\Network\Validator\IP': + case 'Utopia\Validator\Host': + case 'Utopia\Validator\IP': case 'Utopia\Database\Validator\Key': - case 'Appwrite\Network\Validator\Origin': + case 'Utopia\Validator\Origin': case 'Appwrite\Auth\Validator\Password': case 'Utopia\Validator\Text': case 'Utopia\Database\Validator\UID': - case 'Appwrite\Network\Validator\URL': + case 'Utopia\Validator\URL': case 'Utopia\Validator\WhiteList': default: $type = Type::string(); diff --git a/tests/unit/Network/Validators/DomainTest.php b/tests/unit/Network/Validators/DomainTest.php deleted file mode 100644 index c158e39416..0000000000 --- a/tests/unit/Network/Validators/DomainTest.php +++ /dev/null @@ -1,43 +0,0 @@ -domain = new Domain(); - } - - public function tearDown(): void - { - $this->domain = null; - } - - public function testIsValid(): void - { - // Assertions - $this->assertEquals(true, $this->domain->isValid('example.com')); - $this->assertEquals(true, $this->domain->isValid('subdomain.example.com')); - $this->assertEquals(true, $this->domain->isValid('subdomain.example-app.com')); - $this->assertEquals(true, $this->domain->isValid('subdomain.example_app.com')); - $this->assertEquals(true, $this->domain->isValid('subdomain-new.example.com')); - $this->assertEquals(true, $this->domain->isValid('subdomain_new.example.com')); - $this->assertEquals(true, $this->domain->isValid('localhost')); - $this->assertEquals(true, $this->domain->isValid('appwrite.io')); - $this->assertEquals(true, $this->domain->isValid('appwrite.org')); - $this->assertEquals(true, $this->domain->isValid('appwrite.org')); - $this->assertEquals(false, $this->domain->isValid(false)); - $this->assertEquals(false, $this->domain->isValid('.')); - $this->assertEquals(false, $this->domain->isValid('..')); - $this->assertEquals(false, $this->domain->isValid('')); - $this->assertEquals(false, $this->domain->isValid(['string', 'string'])); - $this->assertEquals(false, $this->domain->isValid(1)); - $this->assertEquals(false, $this->domain->isValid(1.2)); - } -} diff --git a/tests/unit/Network/Validators/HostTest.php b/tests/unit/Network/Validators/HostTest.php deleted file mode 100755 index a2c89ba1e2..0000000000 --- a/tests/unit/Network/Validators/HostTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @version 1.0 RC4 - * @license The MIT License (MIT) - */ - -namespace Tests\Unit\Network\Validators; - -use Utopia\Validator\Host; -use PHPUnit\Framework\TestCase; - -class HostTest extends TestCase -{ - protected ?Host $host = null; - - public function setUp(): void - { - $this->host = new Host(['appwrite.io', 'subdomain.appwrite.test', 'localhost']); - } - - public function tearDown(): void - { - $this->host = null; - } - - public function testIsValid(): void - { - // Assertions - $this->assertEquals($this->host->isValid('https://appwrite.io/link'), true); - $this->assertEquals($this->host->isValid('https://localhost'), true); - $this->assertEquals($this->host->isValid('localhost'), false); - $this->assertEquals($this->host->isValid('http://subdomain.appwrite.test/path'), true); - $this->assertEquals($this->host->isValid('http://test.subdomain.appwrite.test/path'), false); - $this->assertEquals($this->host->getType(), 'string'); - } -} diff --git a/tests/unit/Network/Validators/IPTest.php b/tests/unit/Network/Validators/IPTest.php deleted file mode 100755 index 370f3d60ca..0000000000 --- a/tests/unit/Network/Validators/IPTest.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @version 1.0 RC4 - * @license The MIT License (MIT) - */ - -namespace Tests\Unit\Network\Validators; - -use Utopia\Validator\IP; -use PHPUnit\Framework\TestCase; - -class IPTest extends TestCase -{ - protected ?IP $validator; - - public function setUp(): void - { - $this->validator = new IP(); - } - - public function tearDown(): void - { - $this->validator = null; - } - - public function testIsValidIP(): void - { - $this->assertEquals($this->validator->isValid('2001:0db8:85a3:08d3:1319:8a2e:0370:7334'), true); - $this->assertEquals($this->validator->isValid('109.67.204.101'), true); - $this->assertEquals($this->validator->isValid(23.5), false); - $this->assertEquals($this->validator->isValid('23.5'), false); - $this->assertEquals($this->validator->isValid(null), false); - $this->assertEquals($this->validator->isValid(true), false); - $this->assertEquals($this->validator->isValid(false), false); - $this->assertEquals($this->validator->getType(), 'string'); - } - - public function testIsValidIPALL(): void - { - $this->validator = new IP(IP::ALL); - - // Assertions - $this->assertEquals($this->validator->isValid('2001:0db8:85a3:08d3:1319:8a2e:0370:7334'), true); - $this->assertEquals($this->validator->isValid('109.67.204.101'), true); - $this->assertEquals($this->validator->isValid(23.5), false); - $this->assertEquals($this->validator->isValid('23.5'), false); - $this->assertEquals($this->validator->isValid(null), false); - $this->assertEquals($this->validator->isValid(true), false); - $this->assertEquals($this->validator->isValid(false), false); - } - - public function testIsValidIPV4(): void - { - $this->validator = new IP(IP::V4); - - // Assertions - $this->assertEquals($this->validator->isValid('2001:0db8:85a3:08d3:1319:8a2e:0370:7334'), false); - $this->assertEquals($this->validator->isValid('109.67.204.101'), true); - $this->assertEquals($this->validator->isValid(23.5), false); - $this->assertEquals($this->validator->isValid('23.5'), false); - $this->assertEquals($this->validator->isValid(null), false); - $this->assertEquals($this->validator->isValid(true), false); - $this->assertEquals($this->validator->isValid(false), false); - } - - public function testIsValidIPV6(): void - { - $this->validator = new IP(IP::V6); - - // Assertions - $this->assertEquals($this->validator->isValid('2001:0db8:85a3:08d3:1319:8a2e:0370:7334'), true); - $this->assertEquals($this->validator->isValid('109.67.204.101'), false); - $this->assertEquals($this->validator->isValid(23.5), false); - $this->assertEquals($this->validator->isValid('23.5'), false); - $this->assertEquals($this->validator->isValid(null), false); - $this->assertEquals($this->validator->isValid(true), false); - $this->assertEquals($this->validator->isValid(false), false); - } -} diff --git a/tests/unit/Network/Validators/URLTest.php b/tests/unit/Network/Validators/URLTest.php deleted file mode 100755 index b73df8f5a8..0000000000 --- a/tests/unit/Network/Validators/URLTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @version 1.0 RC4 - * @license The MIT License (MIT) - */ - -namespace Tests\Unit\Network\Validators; - -use Utopia\Validator\URL; -use PHPUnit\Framework\TestCase; - -class URLTest extends TestCase -{ - protected ?URL $url; - - public function setUp(): void - { - $this->url = new URL(); - } - - public function tearDown(): void - { - $this->url = null; - } - - public function testIsValid(): void - { - $this->assertEquals('Value must be a valid URL', $this->url->getDescription()); - $this->assertEquals(true, $this->url->isValid('http://example.com')); - $this->assertEquals(true, $this->url->isValid('https://example.com')); - $this->assertEquals(true, $this->url->isValid('htts://example.com')); // does not validate protocol - $this->assertEquals(false, $this->url->isValid('example.com')); // though, requires some kind of protocol - $this->assertEquals(false, $this->url->isValid('http:/example.com')); - $this->assertEquals(true, $this->url->isValid('http://exa-mple.com')); - $this->assertEquals(false, $this->url->isValid('htt@s://example.com')); - $this->assertEquals(true, $this->url->isValid('http://www.example.com/foo%2\u00c2\u00a9zbar')); - $this->assertEquals(true, $this->url->isValid('http://www.example.com/?q=%3Casdf%3E')); - $this->assertEquals(true, $this->url->isValid('https://example.com/foo%2\u00c2\u00ä9zbär')); - } - - public function testIsValidAllowedSchemes(): void - { - $this->url = new URL(['http', 'https']); - $this->assertEquals('Value must be a valid URL with following schemes (http, https)', $this->url->getDescription()); - $this->assertEquals(true, $this->url->isValid('http://example.com')); - $this->assertEquals(true, $this->url->isValid('https://example.com')); - $this->assertEquals(false, $this->url->isValid('gopher://www.example.com')); - } -}