gnu-social/plugins/ActivityPub/tests/Objects/GSGroupTest.php

55 lines
2.5 KiB
PHP
Raw Permalink Normal View History

2022-03-11 14:55:58 +00: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/>.
// }}}
namespace Plugin\ActivityPub\tests\Objects;
use App\Core\DB\DB;
use Jchook\AssertThrows\AssertThrows;
use Plugin\ActivityPub\Entity\ActivitypubRsa;
2022-03-11 16:52:48 +00:00
use Plugin\ActivityPub\tests\ActivityPubTestCase;
2022-03-11 14:55:58 +00:00
use Plugin\ActivityPub\Util\Model\Actor;
2022-03-11 16:52:48 +00:00
class GSGroupTest extends ActivityPubTestCase
2022-03-11 14:55:58 +00:00
{
use AssertThrows;
public function testPersonFromJson()
{
static::bootKernel();
2022-03-11 16:52:48 +00:00
static::loadFixtures();
2022-03-11 14:55:58 +00:00
$fixtures_path = INSTALLDIR . '/plugins/ActivityPub/tests/fixtures/gnusocial/';
$person = Actor::fromJson(file_get_contents($fixtures_path . 'objects/group.jsonld'));
static::assertSame('https://testv3.gnusocial.rocks/actor/2/inbox.json', $person->getInboxUri());
static::assertSame('https://testv3.gnusocial.rocks/inbox.json', $person->getInboxSharedUri());
DB::flush();
$person_actor = $person->getActor();
static::assertSame('https://testv3.gnusocial.rocks/actor/2', $person_actor->getUri());
static::assertSame(\App\Entity\Actor::GROUP, $person_actor->getType());
static::assertSame('hackers', $person_actor->getNickname());
static::assertSame('Hackers!', $person_actor->getFullname());
$public_key = ActivityPubRsa::getByActor($person_actor)->getPublicKey();
static::assertSame("-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoZyKL+GyJbTV/ilVBlzz\n8OL/UwNi3KpfV5kQwXU0pPcBbw6y2JOfWnKUT1CfiHG3ntiOFnc+wQfHZk4hRSE8\n9Xe/G5Y215xW+gqx/kjt2GOENqzSzYXdEZ5Qsx6yumZD/yb6VZK9Og0HjX2mpRs9\nbactY76w4BQVntjZ17gSkMhYcyPFZTAIe7QDkeSPk5lkXfTwtaB3YcJSbQ3+s7La\npeEgukQDkrLUIP6cxayKrgUl4fhHdpx1Yk4Bzd/1XkZCjeBca94lP1p2M12amI+Z\nOLSTuLyEiCcku8aN+Ms9plwATmIDaGvKFVk0YVtBHdIJlYXV0yIscab3bqyhsLBK\njwIDAQAB\n-----END PUBLIC KEY-----\n", $public_key);
}
}