From a47513aeeb728b6316ba6765afdd7e5adbf4f2e3 Mon Sep 17 00:00:00 2001 From: StevenWdV Date: Fri, 17 Dec 2021 15:21:53 +0100 Subject: Add PHP wrapper, use header for right platform for PHP & Swift, simplify Swift Windows fix --- wrappers/php/tests/DiscoveryTest.php | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 wrappers/php/tests/DiscoveryTest.php (limited to 'wrappers/php/tests') diff --git a/wrappers/php/tests/DiscoveryTest.php b/wrappers/php/tests/DiscoveryTest.php new file mode 100644 index 0000000..25ac187 --- /dev/null +++ b/wrappers/php/tests/DiscoveryTest.php @@ -0,0 +1,60 @@ +expectNotToPerformAssertions(); + Discovery::verify(file_get_contents(self::TEST_DATA_DIR . '/dummy/server_list.json.minisig'), + file_get_contents(self::TEST_DATA_DIR . '/dummy/server_list.json'), + 'server_list.json', 0); + } + + public function testInvalidSignature(): void + { + $this->expectException(InvalidSignatureException::class); + Discovery::verify(file_get_contents(self::TEST_DATA_DIR . '/dummy/random.txt'), + file_get_contents(self::TEST_DATA_DIR . '/dummy/server_list.json'), + 'server_list.json', 0); + } + + public function testWrongKey(): void + { + $this->expectException(InvalidSignatureUnknownKeyException::class); + Discovery::verify(file_get_contents(self::TEST_DATA_DIR . '/dummy/server_list.json.wrong_key.minisig'), + file_get_contents(self::TEST_DATA_DIR . '/dummy/server_list.json'), + 'server_list.json', 0); + } + + #[deprecated] + public function testOldSignature(): void + { + $this->expectException(SignatureTooOldException::class); + Discovery::verify(file_get_contents(self::TEST_DATA_DIR . '/dummy/server_list.json.minisig'), + file_get_contents(self::TEST_DATA_DIR . '/dummy/server_list.json'), + 'server_list.json', 1 << 31); + } + + public function testUnknownExpectedFileName(): void + { + $this->expectException(InvalidArgumentException::class); + Discovery::verify(file_get_contents(self::TEST_DATA_DIR . '/dummy/other_list.json.minisig'), + file_get_contents(self::TEST_DATA_DIR . '/dummy/other_list.json'), + 'other_list.json', 0); + } +} -- cgit v1.2.3