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:----slRpquSqIx6VH06l27OCPehi5+9arwTVw1aiPY0l14rQhhtfa2iMgs747fZCMpwxI49smjE+/XTKhT4xUW07rTp0k/0qgdzgj9iFQyErFPkZdrcVyVAysjwFujWABjPMLo12oIgLhwqM9SAjNysZ3TbxLy4f5bAkiRJ5/TtjEyN3XlalmfutcoJbliZl2DgLQVGGhBhs9L2ms5DyKf0Btk5if25pQ8k3y4PEx/1u6K+pX6nam3jx+QlmdOYI4b+Xtt2aXkzUO3vcdOAKj3dIJqu02SmyeXYA/Xt7/SrZbvIgr+jEEu3BZSnMy3WE4xekbJvBlJ48bk+iBAC/Y6Nk0b45xRsrReQQ1a93mUh4H1q5Rey0D8DbllsGC8KBQ6SYMYXgFb5qICVNt/sBcXCUhPOG2/n8Lx/OlsQD8luhimcwJlle8uZwA6lXuOtspgKxZ+E+lvhsyEp9NoujP0T8r6naPpC/EZnBVl5jph77HzHS8sktWKGqm58s70dQe8YhKBXx8lPeu9pmBeqBPezSWCeFgawL2VkhHbIOcTJUM9J9Iquk9OmtRznoUYK0n46bY8/9WvjGbiAiQeUUEfnrPfkSiYJBo9WM3+oy9joird/WYeKC50x/hCFz94PArjN5J265tf74d0JdZr7lbrCsFc6sxuHNTD3mGOyOK6lLR6Y=----ATTACHMENT:----NjE5NzExNDU0NDU2MjA3NSA1MjcyMzA3NzM1MTA0NDQyIDUyNDU1MDkyNDU3MDg5Njk=