Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/e2e/DNS/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ public function testInvalidServer(): void
new Client('not-ip-address', self::PORT);
$this->fail('Expected invalid IP address exception');
} catch (\Exception $e) {
$this->assertEquals('Server must be an IP address.', $e->getMessage());
$this->assertSame('Server must be an IP address.', $e->getMessage());
}

try {
new Client('ns1.digitalocean.com', self::PORT);
$this->fail('Expected invalid IP address exception');
} catch (\Exception $e) {
$this->assertEquals('Server must be an IP address.', $e->getMessage());
$this->assertSame('Server must be an IP address.', $e->getMessage());
}

try {
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/DNS/Resolver/CloudflareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function testResolveGoogleA(): void

/** @var Record $record */
$record = $response->answers[0];
$this->assertEquals(Record::TYPE_A, $record->type);
$this->assertEquals('google.com', $record->name);
$this->assertSame(Record::TYPE_A, $record->type);
$this->assertSame('google.com', $record->name);
$this->assertNotFalse(filter_var($record->rdata, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4));
}

Expand All @@ -47,8 +47,8 @@ public function testResolveGoogleAAAA(): void

/** @var Record $record */
$record = $response->answers[0];
$this->assertEquals(Record::TYPE_AAAA, $record->type);
$this->assertEquals('google.com', $record->name);
$this->assertSame(Record::TYPE_AAAA, $record->type);
$this->assertSame('google.com', $record->name);
$this->assertNotFalse(filter_var($record->rdata, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6));
}
}
8 changes: 4 additions & 4 deletions tests/unit/DNS/Resolver/GoogleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function testResolveGoogleA(): void

/** @var Record $record */
$record = $response->answers[0];
$this->assertEquals(Record::TYPE_A, $record->type);
$this->assertEquals('google.com', $record->name);
$this->assertSame(Record::TYPE_A, $record->type);
$this->assertSame('google.com', $record->name);
$this->assertNotFalse(filter_var($record->rdata, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4));
}

Expand All @@ -47,8 +47,8 @@ public function testResolveGoogleAAAA(): void

/** @var Record $record */
$record = $response->answers[0];
$this->assertEquals(Record::TYPE_AAAA, $record->type);
$this->assertEquals('google.com', $record->name);
$this->assertSame(Record::TYPE_AAAA, $record->type);
$this->assertSame('google.com', $record->name);
$this->assertNotFalse(filter_var($record->rdata, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6));
}
}
74 changes: 37 additions & 37 deletions tests/unit/DNS/Validator/DNSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,35 @@ public function testCNAME(): void
{
$validator = new DNS('appwrite.io', Record::TYPE_CNAME);

$this->assertEquals($validator->isValid(''), false);
$this->assertEquals($validator->isValid(null), false);
$this->assertEquals($validator->isValid(false), false);
$this->assertEquals($validator->isValid('cname-unit-test.appwrite.org'), true);
$this->assertEquals($validator->isValid('test1.appwrite.org'), false);
$this->assertSame($validator->isValid(''), false);
$this->assertSame($validator->isValid(null), false);
$this->assertSame($validator->isValid(false), false);
$this->assertSame($validator->isValid('cname-unit-test.appwrite.org'), true);
$this->assertSame($validator->isValid('test1.appwrite.org'), false);
}

public function testA(): void
{
// IPv4 for documentation purposes
$validator = new DNS('203.0.113.1', Record::TYPE_A);

$this->assertEquals($validator->isValid(''), false);
$this->assertEquals($validator->isValid(null), false);
$this->assertEquals($validator->isValid(false), false);
$this->assertEquals($validator->isValid('a-unit-test.appwrite.org'), true);
$this->assertEquals($validator->isValid('test1.appwrite.org'), false);
$this->assertSame($validator->isValid(''), false);
$this->assertSame($validator->isValid(null), false);
$this->assertSame($validator->isValid(false), false);
$this->assertSame($validator->isValid('a-unit-test.appwrite.org'), true);
$this->assertSame($validator->isValid('test1.appwrite.org'), false);
}

public function testAAAA(): void
{
// IPv6 for documentation purposes
$validator = new DNS('2001:db8::1', Record::TYPE_AAAA);

$this->assertEquals($validator->isValid(''), false);
$this->assertEquals($validator->isValid(null), false);
$this->assertEquals($validator->isValid(false), false);
$this->assertEquals($validator->isValid('aaaa-unit-test.appwrite.org'), true);
$this->assertEquals($validator->isValid('test1.appwrite.org'), false);
$this->assertSame($validator->isValid(''), false);
$this->assertSame($validator->isValid(null), false);
$this->assertSame($validator->isValid(false), false);
$this->assertSame($validator->isValid('aaaa-unit-test.appwrite.org'), true);
$this->assertSame($validator->isValid('test1.appwrite.org'), false);
}

/**
Expand All @@ -78,39 +78,39 @@ public function testCAA(): void
$letsencrypt = new DNS('letsencrypt.org', Record::TYPE_CAA, $digitalOceanIp);

// No CAA record succeeds on main domain & subdomains for any issuer
$this->assertEquals($certainly->isValid('caa.appwrite.org'), true);
$this->assertEquals($certainly->isValid('sub.caa.appwrite.org'), true);
$this->assertEquals($certainly->isValid('sub.sub.caa.appwrite.org'), true);
$this->assertEquals($letsencrypt->isValid('caa.appwrite.org'), true);
$this->assertEquals($letsencrypt->isValid('sub.caa.appwrite.org'), true);
$this->assertEquals($letsencrypt->isValid('sub.sub.caa.appwrite.org'), true);
$this->assertSame($certainly->isValid('caa.appwrite.org'), true);
$this->assertSame($certainly->isValid('sub.caa.appwrite.org'), true);
$this->assertSame($certainly->isValid('sub.sub.caa.appwrite.org'), true);
$this->assertSame($letsencrypt->isValid('caa.appwrite.org'), true);
$this->assertSame($letsencrypt->isValid('sub.caa.appwrite.org'), true);
$this->assertSame($letsencrypt->isValid('sub.sub.caa.appwrite.org'), true);

// Custom flags and tag is allowed, but only for Certainly
$this->assertEquals($certainly->isValid('certainly-full.caa.appwrite.org'), true);
$this->assertEquals($letsencrypt->isValid('certainly-full.caa.appwrite.org'), false);
$this->assertSame($certainly->isValid('certainly-full.caa.appwrite.org'), true);
$this->assertSame($letsencrypt->isValid('certainly-full.caa.appwrite.org'), false);

// Custom flags&tag are not allowed if validator includes specific flags&tag
$certainlyFull = new DNS('0 issue "certainly.com"', Record::TYPE_CAA, $digitalOceanIp);
$this->assertEquals($certainlyFull->isValid('certainly-full.caa.appwrite.org'), false);
$this->assertSame($certainlyFull->isValid('certainly-full.caa.appwrite.org'), false);

// Custom flags&tag still allows if they match exactly
$certainlyFull = new DNS('128 issuewild "certainly.com;account=123456;validationmethods=dns-01"', Record::TYPE_CAA, $digitalOceanIp);
$this->assertEquals($certainlyFull->isValid('certainly-full.caa.appwrite.org'), true);
$this->assertSame($certainlyFull->isValid('certainly-full.caa.appwrite.org'), true);

// Certainly CAA allows Certainly, but not LetsEncrypt; Same for subdomains
$this->assertEquals($certainly->isValid('certainly.caa.appwrite.org'), true);
$this->assertEquals($letsencrypt->isValid('certainly.caa.appwrite.org'), false);
$this->assertEquals($certainly->isValid('sub.certainly.caa.appwrite.org'), true);
$this->assertEquals($letsencrypt->isValid('sub.certainly.caa.appwrite.org'), false);
$this->assertEquals($certainly->isValid('sub.sub.certainly.caa.appwrite.org'), true);
$this->assertEquals($letsencrypt->isValid('sub.sub.certainly.caa.appwrite.org'), false);
$this->assertSame($certainly->isValid('certainly.caa.appwrite.org'), true);
$this->assertSame($letsencrypt->isValid('certainly.caa.appwrite.org'), false);
$this->assertSame($certainly->isValid('sub.certainly.caa.appwrite.org'), true);
$this->assertSame($letsencrypt->isValid('sub.certainly.caa.appwrite.org'), false);
$this->assertSame($certainly->isValid('sub.sub.certainly.caa.appwrite.org'), true);
$this->assertSame($letsencrypt->isValid('sub.sub.certainly.caa.appwrite.org'), false);

// LetsEncrypt CAA on subdomain with parent allowing Certainly. Only LetsEncrypt is allowed; Same for subdomains
$this->assertEquals($certainly->isValid('letsencrypt.certainly.caa.appwrite.org'), false);
$this->assertEquals($letsencrypt->isValid('letsencrypt.certainly.caa.appwrite.org'), true);
$this->assertEquals($certainly->isValid('sub.letsencrypt.certainly.caa.appwrite.org'), false);
$this->assertEquals($letsencrypt->isValid('sub.letsencrypt.certainly.caa.appwrite.org'), true);
$this->assertEquals($certainly->isValid('sub.sub.letsencrypt.certainly.caa.appwrite.org'), false);
$this->assertEquals($letsencrypt->isValid('sub.sub.letsencrypt.certainly.caa.appwrite.org'), true);
$this->assertSame($certainly->isValid('letsencrypt.certainly.caa.appwrite.org'), false);
$this->assertSame($letsencrypt->isValid('letsencrypt.certainly.caa.appwrite.org'), true);
$this->assertSame($certainly->isValid('sub.letsencrypt.certainly.caa.appwrite.org'), false);
$this->assertSame($letsencrypt->isValid('sub.letsencrypt.certainly.caa.appwrite.org'), true);
$this->assertSame($certainly->isValid('sub.sub.letsencrypt.certainly.caa.appwrite.org'), false);
$this->assertSame($letsencrypt->isValid('sub.sub.letsencrypt.certainly.caa.appwrite.org'), true);
}
}