2022-03-14 00:54:48 +09:00
< ? php
declare ( strict_types = 1 );
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
2022-03-15 03:33:47 +09:00
namespace Plugin\ActivityPub\Test\Objects ;
2022-03-14 00:54:48 +09:00
use App\Entity\Actor ;
2022-03-14 03:11:11 +09:00
use App\Util\GNUsocialTestCase ;
2022-03-14 00:54:48 +09:00
use Plugin\ActivityPub\Entity\ActivitypubActor ;
use Plugin\ActivityPub\Entity\ActivitypubRsa ;
use Plugin\ActivityPub\Util\Explorer ;
2022-03-15 03:33:47 +09:00
class GSActorPersonTest extends GNUsocialTestCase
2022-03-14 00:54:48 +09:00
{
public function testPersonFromJson ()
{
2022-03-15 03:33:47 +09:00
self :: bootKernel ();
$person = Explorer :: getOneFromUri ( 'https://instance.gnusocial.test/actor/42' , try_online : false );
2022-03-14 00:54:48 +09:00
$ap_person = ActivitypubActor :: getByPK ([ 'actor_id' => $person -> getId ()]);
2022-03-15 03:33:47 +09:00
static :: assertSame ( 'https://instance.gnusocial.test/actor/42/inbox.json' , $ap_person -> getInboxUri ());
static :: assertSame ( 'https://instance.gnusocial.test/inbox.json' , $ap_person -> getInboxSharedUri ());
2022-03-14 00:54:48 +09:00
$person = $ap_person -> getActor ();
2022-03-15 03:33:47 +09:00
static :: assertSame ( 'https://instance.gnusocial.test/actor/42' , $person -> getUri ());
2022-03-14 00:54:48 +09:00
static :: assertSame ( Actor :: PERSON , $person -> getType ());
static :: assertSame ( 'diogo' , $person -> getNickname ());
static :: assertSame ( 'Diogo Peralta Cordeiro' , $person -> getFullname ());
$public_key = ActivityPubRsa :: getByActor ( $person ) -> getPublicKey ();
static :: assertSame ( " -----BEGIN PUBLIC KEY----- \n MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArBB+3ldwA2qC1hQTtIho \n 9KYhvvMlPdydn8dA6OlyIQ3Jy57ADt2e144jDSY5RQ3esmzWm2QqsI8rAsZsAraO \n l2+855y7Fw35WH4GBc7PJ6MLAEvMk1YWeS/rttXaDzh2i4n/AXkMuxDjS1IBqw2w \n n0qTz2sdGcBJ+mop6AB9Qt2lseBc5IW040jSnfLEDDIaYgoc5m2yRsjGKItOh3BG \n jGHDb6JB9FySToSMGIt0/tE5k06wfvAxtkxX5dfGeKtciBpC2MGT169iyMIOM8DN \n FhSl8mowtV1NJQ7nN692USrmNvSJjqe9ugPCDPPvwQ5A6A61Qrgpz5pav/o5Sz69 \n zQIDAQAB \n -----END PUBLIC KEY----- \n " , $public_key );
}
}