setSubject("acct:" . $this->getEmail()); $data->addAlias('https://www.example.com/~' . $this->getUsername() . "/"); $link = new DelirehberiWebFinger\JsonRDLink(); $link->setRel('http://openid.net/specs/connect/1.0/issuer') ->setHref('https://openid.example.com'); $data->addLink($link); $link = new DelirehberiWebFinger\JsonRDLink(); $link->setRel('http://webfinger.example/rel/profile-page') ->setHref('https://www.example.com/~' . $this->getUsername() . "/"); $data->addLink($link); $link = new DelirehberiWebFinger\JsonRDLink(); $link->setRel('http://webfinger.example/rel/businesscard') ->setHref('https://www.example.com/~' . $this->getUsername() . "/" . $this->getVcardUrl()); $data->addLink($link); $data->addProperty('http://example.com/ns/role', 'employee'); return $data; } public function getVcardUrl() { return "bob.vcf"; } public function getUsername() { return "bob"; } public function getEmail() { return 'bob@example.com'; } }); } public function exampleUserAdapter() { $user = $this->exampleUser(); $userAdapter = new DelirehberiWebFinger\Adapter\ArrayAdapter(); $userAdapter->add($user); $userAdapter->setScheme(DelirehberiWebFinger\Constants::Account); $userAdapter->setFilter(function ($user, string $query) { if ($user->getEmail() == $query) { return true; } return false; }); return $userAdapter; } public function testArrayAdapterForAcct() { $userAdapter = $this->exampleUserAdapter(); $webfinger = new DelirehberiWebFinger\WebFinger(); $webfinger->addResource($userAdapter); try { $data = $webfinger->response("?resource=acct:bob@example.com"); } catch (Exception $a) { echo $a->getMessage(); } $result = $data->toJSON(); $this->assertEquals(self::BOB_RESPONSE, $result); } public function testArrayAdapterForHttps() { $content = (new class implements DelirehberiWebFinger\ResourceDescriptorInterface { public function transform(): DelirehberiWebFinger\JsonRD { $data = new DelirehberiWebFinger\JsonRD(); $data ->setSubject($this->getFullUrl()); $data->addAlias('https://www.example.com/blog/' . $this->getId()); $data->addProperty('http://blgx.example.net/ns/version', "1.3"); $link = new DelirehberiWebFinger\JsonRDLink(); $link->setRel('copyright') ->setHref('http://www.example.com/copyright'); $data->addLink($link); $link = new DelirehberiWebFinger\JsonRDLink(); $link->setRel('author') ->setHref($this->getAuthorUrl()) ->addTitle('en_US', $this->getAuthorTitle()) ->addTitle('tr_TR', $this->getAuthorTitle('tr_TR')) ->addProperty('http://example.com/role', 'editor'); $data->addLink($link); return $data; } public function getId() { return 10; } public function getAuthorTitle($locale = 'en_US') { $titles = [ 'en_US' => "Steve`s world", 'tr_TR' => 'Steve`in dünyası', ]; return $titles[$locale]; } public function getSlug() { return "hello-world"; } public function getFullUrl() { return "http://blog.example.com/" . $this->getSlug(); } public function getAuthorUrl() { return "http://blog.example.com/author/steve"; } }); $contentAdapter = new DelirehberiWebFinger\Adapter\ArrayAdapter(); $contentAdapter ->add($content) ->setScheme(DelirehberiWebFinger\Constants::Content); $contentAdapter->addModifier(function ($query) { $url = parse_url($query); if (!isset($url['path'])) { return null; } $path = trim($url['path'], '/'); return $path; }); $contentAdapter->setFilter(function ($content, $query) { if ($content->getSlug() == $query) { return true; } return false; }); $webfinger = new DelirehberiWebFinger\WebFinger(); $webfinger->addResource($contentAdapter); try { $data = $webfinger->response("?resource=http://blog.example.com/hello-world"); } catch (Exception $e) { var_dump($e->getMessage()); } $this->assertEquals(self::CONTENT_RESPONSE, $data->toJSON()); } public function testArrayAdapterAcctForRel() { $userAdapter = $this->exampleUserAdapter(); $webfinger = new DelirehberiWebFinger\WebFinger(); $webfinger->addResource($userAdapter); try { $data = $webfinger->response("?resource=acct:bob@example.com&rel=http://openid.net/specs/connect/1.0/issuer"); } catch (Exception $e) { var_dump($e->getMessage()); } $this->assertEquals(self::REL_BOB_RESPONSE, $data->toJSON()); } } __halt_compiler();----SIGNATURE:----p2VkBNamCnmrvWFsgTO2Y+pN/2tEpj8M0IAurk1CV77uD9/GDWGMdtQ+Ba2A9d9RaOpMTmZt6lxKuVAUNakauRWOxKuFOhi1WDYkbc3PlL2Pxr1YmKV9OFXjvOWK1W/eBkx96DeIApzy7cBpFgZia+6X+Wq5R6rYAsDetr5dMn9uio2N8Y9CVN+jhPVIp9I3z0BjXGfnjDulxvxnQQDoDplWYCOCP4DJc1tOmYy4keKytkI2jKo5OrwN/KVPm7ZfWohem2P5QW0QORGIT8ppV8gSt/LygOMwzeiEPv1k6NZ95O29lJRwjWh47/VDuPtOo5f1KtejNyRDroYK0FHHFrrfE0kZZuK3ff29uzmq83LhrJb6QdY0+6Vy42cBbV/xfdfBlTQFgAkGN+hayZH0tx+J7d/16ZjC8yLuQCXHlMxfV8igS3MRKc+2CJe2j6mCXDOBfGihgwGEoZ9KBs2+lLyXG11IVdNzoz6GsMwi6e6azS7uE9pN1GO/1r/uEL125zfhERQmSWKM/+FpRqrj9wgOLoBz/NtJbtT9zddFo5r3e9PMhFsPv3eacn3p0AyEEPLoxGXufZp+LxmUS72tz/IXcMDQfzQ7VFbFtvS8manJnF8ZLRghw1cOkJaghxSW2fJSwEINJZHGs6kNejpUkglkiXQle4ics0pPnD1XMkA=----ATTACHMENT:----NzkzMzAxODUzMDA3ODUwNSA0MTU0NDM0MzU1OTgwMzAxIDE3ODYwMzMyOTA1Mjg5NTA=