Merge pull request #3985 from svenluijten/clean-up-tests

Clean up styling in the tests
This commit is contained in:
daniel 2023-01-08 14:02:45 -07:00 committed by GitHub
commit 0d320c3d82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 994 additions and 1025 deletions

View file

@ -3,6 +3,7 @@
namespace Tests;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Hash;
trait CreatesApplication
@ -10,7 +11,7 @@ trait CreatesApplication
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
* @return Application
*/
public function createApplication()
{

View file

@ -3,19 +3,17 @@
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
class InstalledTest extends TestCase
{
/** @test */
public function nodeinfo_api()
public function nodeinfo_api(): void
{
$response = $this->get('/.well-known/nodeinfo');
$response->assertJson([
'links' => [
['rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0'],
], ]);
],
]);
}
}

View file

@ -3,9 +3,6 @@
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use App\User;
class LoginTest extends TestCase
{

View file

@ -2,10 +2,8 @@
namespace Tests\Unit;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Util\ActivityPub\Helpers;
use Tests\TestCase;
class APAnnounceStrategyTest extends TestCase
{
@ -47,12 +45,12 @@ class APAnnounceStrategyTest extends TestCase
{
$scope = Helpers::normalizeAudience($this->mastodon, false);
$actual = [
"to" => [],
"cc" => [
"https://pleroma.site/users/pixeldev",
"https://mastodon.social/users/dansup/followers",
'to' => [],
'cc' => [
'https://pleroma.site/users/pixeldev',
'https://mastodon.social/users/dansup/followers',
],
"scope" => "public",
'scope' => 'public',
];
$this->assertEquals($scope, $actual);
@ -62,12 +60,12 @@ class APAnnounceStrategyTest extends TestCase
{
$scope = Helpers::normalizeAudience($this->pleroma, false);
$actual = [
"to" => [
"https://pleroma.site/users/pixeldev/followers",
"https://mastodon.social/users/dansup",
'to' => [
'https://pleroma.site/users/pixeldev/followers',
'https://mastodon.social/users/dansup',
],
"cc" => [],
"scope" => "unlisted",
'cc' => [],
'scope' => 'unlisted',
];
$this->assertEquals($scope, $actual);

View file

@ -2,13 +2,13 @@
namespace Tests\Unit\ActivityPub;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Util\ActivityPub\Helpers;
use Tests\TestCase;
class AudienceScopeTest extends TestCase
{
protected array $invalid;
public function setUp(): void
{
parent::setUp();
@ -47,12 +47,12 @@ class AudienceScopeTest extends TestCase
{
$scope = Helpers::normalizeAudience($this->mastodon, false);
$actual = [
"to" => [],
"cc" => [
"https://pleroma.site/users/pixeldev",
"https://mastodon.social/users/dansup/followers",
'to' => [],
'cc' => [
'https://pleroma.site/users/pixeldev',
'https://mastodon.social/users/dansup/followers',
],
"scope" => "public",
'scope' => 'public',
];
$this->assertEquals($scope, $actual);
@ -62,12 +62,12 @@ class AudienceScopeTest extends TestCase
{
$scope = Helpers::normalizeAudience($this->pleroma, false);
$actual = [
"to" => [
"https://pleroma.site/users/pixeldev/followers",
"https://mastodon.social/users/dansup",
'to' => [
'https://pleroma.site/users/pixeldev/followers',
'https://mastodon.social/users/dansup',
],
"cc" => [],
"scope" => "unlisted",
'cc' => [],
'scope' => 'unlisted',
];
$this->assertEquals($scope, $actual);

View file

@ -4,11 +4,13 @@ namespace Tests\Unit\ActivityPub;
use App\Util\ActivityPub\Helpers;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class NoteAttachmentTest extends TestCase
{
protected array $pleroma;
protected array $mastodon;
protected array $invalidType;
protected array $invalidMime;
public function setUp(): void
{
@ -39,6 +41,5 @@ class NoteAttachmentTest extends TestCase
$valid = Helpers::verifyAttachments($this->invalidMime);
$this->assertFalse($valid);
}
}

View file

@ -4,11 +4,11 @@ namespace Tests\Unit\ActivityPub;
use App\Util\ActivityPub\Helpers;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class RemoteFollowTest extends TestCase
{
protected string $mastodon;
public function setUp(): void
{
parent::setUp();

View file

@ -2,8 +2,8 @@
namespace Tests\Unit\ActivityPub;
use PHPUnit\Framework\TestCase;
use App\Util\ActivityPub\Validator\StoryValidator;
use PHPUnit\Framework\TestCase;
class StoryValidationTest extends TestCase
{
@ -80,5 +80,4 @@ class StoryValidationTest extends TestCase
unset($activity['expiresAt']);
$this->assertFalse(StoryValidator::validate($activity));
}
}

View file

@ -2,19 +2,19 @@
namespace Tests\Unit\ActivityPub\Verb;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Util\ActivityPub\Validator\Accept;
use Tests\TestCase;
class AcceptVerbTest extends TestCase
{
protected $validAccept;
protected $invalidAccept;
protected array $validAccept;
protected array $invalidAccept;
protected array $mastodonAccept;
public function setUp(): void
{
parent::setUp();
$this->validAccept = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => 'https://example.org/og/b3e4a40b-0b26-4c5a-9079-094bd633fab7',
@ -27,6 +27,7 @@ class AcceptVerbTest extends TestCase
'object' => 'https://example.org/u/alice'
]
];
$this->invalidAccept = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => 'https://example.org/og/b3e4a40b-0b26-4c5a-9079-094bd633fab7',
@ -39,40 +40,39 @@ class AcceptVerbTest extends TestCase
'object' => 'https://example.org/u/alice'
]
];
$this->mastodonAccept = [
"@context" => [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
'@context' => [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
[
"toot" => "https://joinmastodon.org/ns#",
"sensitive" => "as:sensitive",
"ostatus" => "https://ostatus.org#",
"movedTo" => "as:movedTo",
"manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
"inReplyToAtomUri" => "ostatus:inReplyToAtomUri",
"conversation" => "ostatus:conversation",
"atomUri" => "ostatus:atomUri",
"Hashtag" => "as:Hashtag",
"Emoji" => "toot:Emoji",
'toot' => 'https://joinmastodon.org/ns#',
'sensitive' => 'as:sensitive',
'ostatus' => 'https://ostatus.org#',
'movedTo' => 'as:movedTo',
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri',
'conversation' => 'ostatus:conversation',
'atomUri' => 'ostatus:atomUri',
'Hashtag' => 'as:Hashtag',
'Emoji' => 'toot:Emoji',
],
],
"type" => "Accept",
"object" => [
"type" => "Follow",
"object" => "https://mastodon.example.org/users/admin",
"id" => "https://pixelfed.dev/users/dsup#follows/4",
"actor" => "https://pixelfed.dev/users/dsup",
'type' => 'Accept',
'object' => [
'type' => 'Follow',
'object' => 'https://mastodon.example.org/users/admin',
'id' => 'https://pixelfed.dev/users/dsup#follows/4',
'actor' => 'https://pixelfed.dev/users/dsup',
],
"nickname" => "dsup",
"id" => "https://mastodon.example.org/users/admin#accepts/follows/4",
"actor" => "https://mastodon.example.org/users/admin",
"signature" => [
"type" => "RsaSignature2017",
"signatureValue" => "rBzK4Kqhd4g7HDS8WE5oRbWQb2R+HF/6awbUuMWhgru/xCODT0SJWSri0qWqEO4fPcpoUyz2d25cw6o+iy9wiozQb3hQNnu69AR+H5Mytc06+g10KCHexbGhbAEAw/7IzmeXELHUbaqeduaDIbdt1zw4RkwLXdqgQcGXTJ6ND1wM3WMHXQCK1m0flasIXFoBxpliPAGiElV8s0+Ltuh562GvflG3kB3WO+j+NaR0ZfG5G9N88xMj9UQlCKit5gpAE5p6syUsCU2WGBHywTumv73i3OVTIFfq+P9AdMsRuzw1r7zoKEsthW4aOzLQDi01ZjvdBz8zH6JnjDU7SMN/Ig==",
"creator" => "https://mastodon.example.org/users/admin#main-key",
"created" => "2018-02-17T14:36:41Z",
'nickname' => 'dsup',
'id' => 'https://mastodon.example.org/users/admin#accepts/follows/4',
'actor' => 'https://mastodon.example.org/users/admin',
'signature' => [
'type' => 'RsaSignature2017',
'signatureValue' => 'rBzK4Kqhd4g7HDS8WE5oRbWQb2R+HF/6awbUuMWhgru/xCODT0SJWSri0qWqEO4fPcpoUyz2d25cw6o+iy9wiozQb3hQNnu69AR+H5Mytc06+g10KCHexbGhbAEAw/7IzmeXELHUbaqeduaDIbdt1zw4RkwLXdqgQcGXTJ6ND1wM3WMHXQCK1m0flasIXFoBxpliPAGiElV8s0+Ltuh562GvflG3kB3WO+j+NaR0ZfG5G9N88xMj9UQlCKit5gpAE5p6syUsCU2WGBHywTumv73i3OVTIFfq+P9AdMsRuzw1r7zoKEsthW4aOzLQDi01ZjvdBz8zH6JnjDU7SMN/Ig==',
'creator' => 'https://mastodon.example.org/users/admin#main-key',
'created' => '2018-02-17T14:36:41Z',
],
];
}

View file

@ -2,165 +2,172 @@
namespace Tests\Unit\ActivityPub\Verb;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Util\ActivityPub\Validator\Announce;
use Tests\TestCase;
class AnnounceTest extends TestCase
{
protected array $validAnnounce;
protected array $invalidAnnounce;
protected array $invalidDate;
protected array $contextMissing;
protected array $audienceMissing;
protected array $audienceMissing2;
protected array $invalidActor;
protected array $invalidActor2;
protected array $mastodonAnnounce;
public function setUp(): void
{
parent::setUp();
$this->validAnnounce = [
"@context" => "https://www.w3.org/ns/activitystreams",
"id" => "https://example.org/users/alice/statuses/100000000000001/activity",
"type" => "Announce",
"actor" => "https://example.org/users/alice",
"published" => "2018-12-31T23:59:59Z",
"to" => [
"https://www.w3.org/ns/activitystreams#Public"
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
'type' => 'Announce',
'actor' => 'https://example.org/users/alice',
'published' => '2018-12-31T23:59:59Z',
'to' => [
'https://www.w3.org/ns/activitystreams#Public'
],
"cc" => [
"https://example.org/users/bob",
"https://example.org/users/alice/followers"
'cc' => [
'https://example.org/users/bob',
'https://example.org/users/alice/followers'
],
"object" => "https://example.org/p/bob/100000000000000",
'object' => 'https://example.org/p/bob/100000000000000',
];
$this->invalidAnnounce = [
"@context" => "https://www.w3.org/ns/activitystreams",
"id" => "https://example.org/users/alice/statuses/100000000000001/activity",
"type" => "Announce2",
"actor" => "https://example.org/users/alice",
"published" => "2018-12-31T23:59:59Z",
"to" => [
"https://www.w3.org/ns/activitystreams#Public"
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
'type' => 'Announce2',
'actor' => 'https://example.org/users/alice',
'published' => '2018-12-31T23:59:59Z',
'to' => [
'https://www.w3.org/ns/activitystreams#Public'
],
"cc" => [
"https://example.org/users/bob",
"https://example.org/users/alice/followers"
'cc' => [
'https://example.org/users/bob',
'https://example.org/users/alice/followers'
],
"object" => "https://example.org/p/bob/100000000000000",
'object' => 'https://example.org/p/bob/100000000000000',
];
$this->invalidDate = [
"@context" => "https://www.w3.org/ns/activitystreams",
"id" => "https://example.org/users/alice/statuses/100000000000001/activity",
"type" => "Announce",
"actor" => "https://example.org/users/alice",
"published" => "2018-12-31T23:59:59ZEZE",
"to" => [
"https://www.w3.org/ns/activitystreams#Public"
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
'type' => 'Announce',
'actor' => 'https://example.org/users/alice',
'published' => '2018-12-31T23:59:59ZEZE',
'to' => [
'https://www.w3.org/ns/activitystreams#Public'
],
"cc" => [
"https://example.org/users/bob",
"https://example.org/users/alice/followers"
'cc' => [
'https://example.org/users/bob',
'https://example.org/users/alice/followers'
],
"object" => "https://example.org/p/bob/100000000000000",
'object' => 'https://example.org/p/bob/100000000000000',
];
$this->contextMissing = [
"id" => "https://example.org/users/alice/statuses/100000000000001/activity",
"type" => "Announce",
"actor" => "https://example.org/users/alice",
"published" => "2018-12-31T23:59:59Z",
"to" => [
"https://www.w3.org/ns/activitystreams#Public"
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
'type' => 'Announce',
'actor' => 'https://example.org/users/alice',
'published' => '2018-12-31T23:59:59Z',
'to' => [
'https://www.w3.org/ns/activitystreams#Public'
],
"cc" => [
"https://example.org/users/bob",
"https://example.org/users/alice/followers"
'cc' => [
'https://example.org/users/bob',
'https://example.org/users/alice/followers'
],
"object" => "https://example.org/p/bob/100000000000000",
'object' => 'https://example.org/p/bob/100000000000000',
];
$this->audienceMissing = [
"id" => "https://example.org/users/alice/statuses/100000000000001/activity",
"type" => "Announce",
"actor" => "https://example.org/users/alice",
"published" => "2018-12-31T23:59:59Z",
"object" => "https://example.org/p/bob/100000000000000",
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
'type' => 'Announce',
'actor' => 'https://example.org/users/alice',
'published' => '2018-12-31T23:59:59Z',
'object' => 'https://example.org/p/bob/100000000000000',
];
$this->audienceMissing2 = [
"@context" => "https://www.w3.org/ns/activitystreams",
"id" => "https://example.org/users/alice/statuses/100000000000001/activity",
"type" => "Announce",
"actor" => "https://example.org/users/alice",
"published" => "2018-12-31T23:59:59Z",
"to" => null,
"cc" => null,
"object" => "https://example.org/p/bob/100000000000000",
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
'type' => 'Announce',
'actor' => 'https://example.org/users/alice',
'published' => '2018-12-31T23:59:59Z',
'to' => null,
'cc' => null,
'object' => 'https://example.org/p/bob/100000000000000',
];
$this->invalidActor = [
"@context" => "https://www.w3.org/ns/activitystreams",
"id" => "https://example.org/users/alice/statuses/100000000000001/activity",
"type" => "Announce",
"actor" => "10000",
"published" => "2018-12-31T23:59:59Z",
"to" => [
"https://www.w3.org/ns/activitystreams#Public"
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
'type' => 'Announce',
'actor' => '10000',
'published' => '2018-12-31T23:59:59Z',
'to' => [
'https://www.w3.org/ns/activitystreams#Public'
],
"cc" => [
"https://example.org/users/bob",
"https://example.org/users/alice/followers"
'cc' => [
'https://example.org/users/bob',
'https://example.org/users/alice/followers'
],
"object" => "https://example.org/p/bob/100000000000000",
'object' => 'https://example.org/p/bob/100000000000000',
];
$this->invalidActor2 = [
"@context" => "https://www.w3.org/ns/activitystreams",
"id" => "https://example.org/users/alice/statuses/100000000000001/activity",
"type" => "Announce",
"published" => "2018-12-31T23:59:59Z",
"to" => [
"https://www.w3.org/ns/activitystreams#Public"
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => 'https://example.org/users/alice/statuses/100000000000001/activity',
'type' => 'Announce',
'published' => '2018-12-31T23:59:59Z',
'to' => [
'https://www.w3.org/ns/activitystreams#Public'
],
"cc" => [
"https://example.org/users/bob",
"https://example.org/users/alice/followers"
'cc' => [
'https://example.org/users/bob',
'https://example.org/users/alice/followers'
],
"object" => "https://example.org/p/bob/100000000000000",
'object' => 'https://example.org/p/bob/100000000000000',
];
$this->mastodonAnnounce = [
"type" => "Announce",
"to" => [
"https://www.w3.org/ns/activitystreams#Public",
'type' => 'Announce',
'to' => [
'https://www.w3.org/ns/activitystreams#Public',
],
"signature" => [
"type" => "RsaSignature2017",
"signatureValue" => "T95DRE0eAligvMuRMkQA01lsoz2PKi4XXF+cyZ0BqbrO12p751TEWTyyRn5a+HH0e4kc77EUhQVXwMq80WAYDzHKVUTf2XBJPBa68vl0j6RXw3+HK4ef5hR4KWFNBU34yePS7S1fEmc1mTG4Yx926wtmZwDpEMTp1CXOeVEjCYzmdyHpepPPH2ZZettiacmPRSqBLPGWZoot7kH/SioIdnrMGY0I7b+rqkIdnnEcdhu9N1BKPEO9Sr+KmxgAUiidmNZlbBXX6gCxp8BiIdH4ABsIcwoDcGNkM5EmWunGW31LVjsEQXhH5c1Wly0ugYYPCg/0eHLNBOhKkY/teSM8Lg==",
"creator" => "https://mastodon.example.org/users/admin#main-key",
"created" => "2018-02-17T19:39:15Z",
'signature' => [
'type' => 'RsaSignature2017',
'signatureValue' => 'T95DRE0eAligvMuRMkQA01lsoz2PKi4XXF+cyZ0BqbrO12p751TEWTyyRn5a+HH0e4kc77EUhQVXwMq80WAYDzHKVUTf2XBJPBa68vl0j6RXw3+HK4ef5hR4KWFNBU34yePS7S1fEmc1mTG4Yx926wtmZwDpEMTp1CXOeVEjCYzmdyHpepPPH2ZZettiacmPRSqBLPGWZoot7kH/SioIdnrMGY0I7b+rqkIdnnEcdhu9N1BKPEO9Sr+KmxgAUiidmNZlbBXX6gCxp8BiIdH4ABsIcwoDcGNkM5EmWunGW31LVjsEQXhH5c1Wly0ugYYPCg/0eHLNBOhKkY/teSM8Lg==',
'creator' => 'https://mastodon.example.org/users/admin#main-key',
'created' => '2018-02-17T19:39:15Z',
],
"published" => "2018-02-17T19:39:15Z",
"object" => "https://mastodon.example.org/@admin/99541947525187367",
"id" => "https://mastodon.example.org/users/admin/statuses/99542391527669785/activity",
"cc" => [
"https://mastodon.example.org/users/admin",
"https://mastodon.example.org/users/admin/followers",
'published' => '2018-02-17T19:39:15Z',
'object' => 'https://mastodon.example.org/@admin/99541947525187367',
'id' => 'https://mastodon.example.org/users/admin/statuses/99542391527669785/activity',
'cc' => [
'https://mastodon.example.org/users/admin',
'https://mastodon.example.org/users/admin/followers',
],
"atomUri" => "https://mastodon.example.org/users/admin/statuses/99542391527669785/activity",
"actor" => "https://mastodon.example.org/users/admin",
"@context" => [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
'atomUri' => 'https://mastodon.example.org/users/admin/statuses/99542391527669785/activity',
'actor' => 'https://mastodon.example.org/users/admin',
'@context' => [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
[
"toot" => "https://joinmastodon.org/ns#",
"sensitive" => "as:sensitive",
"ostatus" => "https://ostatus.org#",
"movedTo" => "as:movedTo",
"manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
"inReplyToAtomUri" => "ostatus:inReplyToAtomUri",
"conversation" => "ostatus:conversation",
"atomUri" => "ostatus:atomUri",
"Hashtag" => "as:Hashtag",
"Emoji" => "toot:Emoji",
'toot' => 'https://joinmastodon.org/ns#',
'sensitive' => 'as:sensitive',
'ostatus' => 'https://ostatus.org#',
'movedTo' => 'as:movedTo',
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri',
'conversation' => 'ostatus:conversation',
'atomUri' => 'ostatus:atomUri',
'Hashtag' => 'as:Hashtag',
'Emoji' => 'toot:Emoji',
],
],
];

View file

@ -2,44 +2,43 @@
namespace Tests\Unit\ActivityPub\Verb;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Util\ActivityPub\Validator\Follow;
use Tests\TestCase;
class FollowTest extends TestCase
{
protected array $basicFollow;
public function setUp(): void
{
parent::setUp();
$this->basicFollow = [
"type" => "Follow",
"signature" => [
"type" => "RsaSignature2017",
"signatureValue" => "Kn1/UkAQGJVaXBfWLAHcnwHg8YMAUqlEaBuYLazAG+pz5hqivsyrBmPV186Xzr+B4ZLExA9+SnOoNx/GOz4hBm0kAmukNSILAsUd84tcJ2yT9zc1RKtembK4WiwOw7li0+maeDN0HaB6t+6eTqsCWmtiZpprhXD8V1GGT8yG7X24fQ9oFGn+ng7lasbcCC0988Y1eGqNe7KryxcPuQz57YkDapvtONzk8gyLTkZMV4De93MyRHq6GVjQVIgtiYabQAxrX6Q8C+4P/jQoqdWJHEe+MY5JKyNaT/hMPt2Md1ok9fZQBGHlErk22/zy8bSN19GdG09HmIysBUHRYpBLig==",
"creator" => "http://mastodon.example.org/users/admin#main-key",
"created" => "2018-02-17T13:29:31Z",
'type' => 'Follow',
'signature' => [
'type' => 'RsaSignature2017',
'signatureValue' => 'Kn1/UkAQGJVaXBfWLAHcnwHg8YMAUqlEaBuYLazAG+pz5hqivsyrBmPV186Xzr+B4ZLExA9+SnOoNx/GOz4hBm0kAmukNSILAsUd84tcJ2yT9zc1RKtembK4WiwOw7li0+maeDN0HaB6t+6eTqsCWmtiZpprhXD8V1GGT8yG7X24fQ9oFGn+ng7lasbcCC0988Y1eGqNe7KryxcPuQz57YkDapvtONzk8gyLTkZMV4De93MyRHq6GVjQVIgtiYabQAxrX6Q8C+4P/jQoqdWJHEe+MY5JKyNaT/hMPt2Md1ok9fZQBGHlErk22/zy8bSN19GdG09HmIysBUHRYpBLig==',
'creator' => 'http://mastodon.example.org/users/admin#main-key',
'created' => '2018-02-17T13:29:31Z',
],
"object" => "http://pixelfed.dev/users/dsup",
"nickname" => "dsup",
"id" => "http://mastodon.example.org/users/admin#follows/2",
"actor" => "http://mastodon.example.org/users/admin",
"@context" => [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
'object' => 'http://pixelfed.dev/users/dsup',
'nickname' => 'dsup',
'id' => 'http://mastodon.example.org/users/admin#follows/2',
'actor' => 'http://mastodon.example.org/users/admin',
'@context' => [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
[
"toot" => "http://joinmastodon.org/ns#",
"sensitive" => "as:sensitive",
"ostatus" => "http://ostatus.org#",
"movedTo" => "as:movedTo",
"manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
"inReplyToAtomUri" => "ostatus:inReplyToAtomUri",
"conversation" => "ostatus:conversation",
"atomUri" => "ostatus:atomUri",
"Hashtag" => "as:Hashtag",
"Emoji" => "toot:Emoji",
'toot' => 'http://joinmastodon.org/ns#',
'sensitive' => 'as:sensitive',
'ostatus' => 'http://ostatus.org#',
'movedTo' => 'as:movedTo',
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri',
'conversation' => 'ostatus:conversation',
'atomUri' => 'ostatus:atomUri',
'Hashtag' => 'as:Hashtag',
'Emoji' => 'toot:Emoji',
],
],
];

View file

@ -2,44 +2,43 @@
namespace Tests\Unit\ActivityPub\Verb;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Util\ActivityPub\Validator\Like;
use Tests\TestCase;
class LikeTest extends TestCase
{
protected array $basicLike;
public function setUp(): void
{
parent::setUp();
$this->basicLike = [
"type" => "Like",
"signature" => [
"type" => "RsaSignature2017",
"signatureValue" => "fdxMfQSMwbC6wP6sh6neS/vM5879K67yQkHTbiT5Npr5wAac0y6+o3Ij+41tN3rL6wfuGTosSBTHOtta6R4GCOOhCaCSLMZKypnp1VltCzLDoyrZELnYQIC8gpUXVmIycZbREk22qWUe/w7DAFaKK4UscBlHDzeDVcA0K3Se5Sluqi9/Zh+ldAnEzj/rSEPDjrtvf5wGNf3fHxbKSRKFt90JvKK6hS+vxKUhlRFDf6/SMETw+EhwJSNW4d10yMUakqUWsFv4Acq5LW7l+HpYMvlYY1FZhNde1+uonnCyuQDyvzkff8zwtEJmAXC4RivO/VVLa17SmqheJZfI8oluVg==",
"creator" => "http://mastodon.example.org/users/admin#main-key",
"created" => "2018-02-17T18:57:49Z",
'type' => 'Like',
'signature' => [
'type' => 'RsaSignature2017',
'signatureValue' => 'fdxMfQSMwbC6wP6sh6neS/vM5879K67yQkHTbiT5Npr5wAac0y6+o3Ij+41tN3rL6wfuGTosSBTHOtta6R4GCOOhCaCSLMZKypnp1VltCzLDoyrZELnYQIC8gpUXVmIycZbREk22qWUe/w7DAFaKK4UscBlHDzeDVcA0K3Se5Sluqi9/Zh+ldAnEzj/rSEPDjrtvf5wGNf3fHxbKSRKFt90JvKK6hS+vxKUhlRFDf6/SMETw+EhwJSNW4d10yMUakqUWsFv4Acq5LW7l+HpYMvlYY1FZhNde1+uonnCyuQDyvzkff8zwtEJmAXC4RivO/VVLa17SmqheJZfI8oluVg==',
'creator' => 'http://mastodon.example.org/users/admin#main-key',
'created' => '2018-02-17T18:57:49Z',
],
"object" => "http://pixelfed.dev/p/1",
"nickname" => "dsup",
"id" => "http://mastodon.example.org/users/admin#likes/2",
"actor" => "http://mastodon.example.org/users/admin",
"@context" => [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
'object' => 'http://pixelfed.dev/p/1',
'nickname' => 'dsup',
'id' => 'http://mastodon.example.org/users/admin#likes/2',
'actor' => 'http://mastodon.example.org/users/admin',
'@context' => [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
[
"toot" => "http://joinmastodon.org/ns#",
"sensitive" => "as:sensitive",
"ostatus" => "http://ostatus.org#",
"movedTo" => "as:movedTo",
"manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
"inReplyToAtomUri" => "ostatus:inReplyToAtomUri",
"conversation" => "ostatus:conversation",
"atomUri" => "ostatus:atomUri",
"Hashtag" => "as:Hashtag",
"Emoji" => "toot:Emoji",
'toot' => 'http://joinmastodon.org/ns#',
'sensitive' => 'as:sensitive',
'ostatus' => 'http://ostatus.org#',
'movedTo' => 'as:movedTo',
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri',
'conversation' => 'ostatus:conversation',
'atomUri' => 'ostatus:atomUri',
'Hashtag' => 'as:Hashtag',
'Emoji' => 'toot:Emoji',
],
],
];

View file

@ -2,16 +2,13 @@
namespace Tests\Unit\ActivityPub\Verb;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Util\ActivityPub\Validator\UndoFollow;
use Tests\TestCase;
class UndoFollowTest extends TestCase
{
protected $validUndo;
protected $invalidUndo;
protected array $validUndo;
protected array $invalidUndo;
public function setUp(): void
{
@ -42,5 +39,4 @@ class UndoFollowTest extends TestCase
{
$this->assertFalse(UndoFollow::validate($this->invalidUndo));
}
}

View file

@ -2,8 +2,8 @@
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
use App\Util\Lexer\Bearcap;
use PHPUnit\Framework\TestCase;
class BearcapTest extends TestCase
{
@ -12,8 +12,8 @@ class BearcapTest extends TestCase
{
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=https://pixelfed.test/stories/admin/337892163734081536';
$expected = [
"token" => "LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2",
"url" => "https://pixelfed.test/stories/admin/337892163734081536",
'token' => 'LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2',
'url' => 'https://pixelfed.test/stories/admin/337892163734081536',
];
$actual = Bearcap::decode($str);
$this->assertEquals($expected, $actual);

View file

@ -2,6 +2,7 @@
namespace Tests\Unit;
use phpseclib\Crypt\RSA;
use Tests\TestCase;
class CryptoTest extends TestCase
@ -18,7 +19,7 @@ class CryptoTest extends TestCase
public function testRSASigning()
{
$rsa = new \phpseclib\Crypt\RSA();
$rsa = new RSA();
extract($rsa->createKey());
$rsa->loadKey($privatekey);
$plaintext = 'pixelfed rsa test';

View file

@ -3,16 +3,15 @@
namespace Tests\Unit;
use Carbon\Carbon;
use DateTime;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class DateTimeTest extends TestCase
{
/** @test */
public function mastodonTimestamp()
{
$ts = Carbon::createFromFormat(\DateTime::ISO8601, '2019-09-16T02:41:57Z');
$ts = Carbon::createFromFormat(DateTime::ISO8601, '2019-09-16T02:41:57Z');
$this->assertEquals(9, $ts->month);
$this->assertEquals(16, $ts->day);
$this->assertEquals(2019, $ts->year);
@ -23,7 +22,7 @@ class DateTimeTest extends TestCase
/** @test */
public function p3kTimestamp()
{
$ts = Carbon::createFromFormat(\DateTime::ISO8601, '2019-09-16T08:40:55+10:00');
$ts = Carbon::createFromFormat(DateTime::ISO8601, '2019-09-16T08:40:55+10:00');
$this->assertEquals(9, $ts->month);
$this->assertEquals(16, $ts->day);
$this->assertEquals(2019, $ts->year);

View file

@ -1,18 +0,0 @@
<?php
namespace Tests\Unit;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$this->assertTrue(true);
}
}

View file

@ -2,10 +2,8 @@
namespace Tests\Unit\Lexer;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Util\Lexer\RestrictedNames;
use Tests\TestCase;
class RestrictedNameTest extends TestCase
{

View file

@ -2,12 +2,10 @@
namespace Tests\Unit\Lexer;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Status;
use App\Util\Lexer\Autolink;
use App\Util\Lexer\Extractor;
use App\Status;
use Tests\TestCase;
class StatusLexerTest extends TestCase
{
@ -18,7 +16,7 @@ class StatusLexerTest extends TestCase
public function setUp(): void
{
parent::setUp();
$this->status = "@pixelfed hi, really like the website! #píxelfed";
$this->status = '@pixelfed hi, really like the website! #píxelfed';
$this->entities = Extractor::create()->extract($this->status);
$this->autolink = Autolink::create()->autolink($this->status);
}
@ -26,28 +24,28 @@ class StatusLexerTest extends TestCase
public function testLexerExtractor()
{
$expected = [
"hashtags" => [
"píxelfed",
'hashtags' => [
'píxelfed',
],
"urls" => [],
"mentions" => [
"pixelfed",
'urls' => [],
'mentions' => [
'pixelfed',
],
"replyto" => "pixelfed",
"hashtags_with_indices" => [
'replyto' => 'pixelfed',
'hashtags_with_indices' => [
[
"hashtag" => "píxelfed",
"indices" => [
'hashtag' => 'píxelfed',
'indices' => [
39,
48,
],
],
],
"urls_with_indices" => [],
"mentions_with_indices" => [
'urls_with_indices' => [],
'mentions_with_indices' => [
[
"screen_name" => "pixelfed",
"indices" => [
'screen_name' => 'pixelfed',
'indices' => [
0,
9,
],
@ -68,36 +66,36 @@ class StatusLexerTest extends TestCase
public function remoteMention()
{
$expected = [
"hashtags" => [
"dansup",
'hashtags' => [
'dansup',
],
"urls" => [],
"mentions" => [
"@dansup@mstdn.io",
"test",
'urls' => [],
'mentions' => [
'@dansup@mstdn.io',
'test',
],
"replyto" => null,
"hashtags_with_indices" => [
'replyto' => null,
'hashtags_with_indices' => [
[
"hashtag" => "dansup",
"indices" => [
'hashtag' => 'dansup',
'indices' => [
0,
7,
],
],
],
"urls_with_indices" => [],
"mentions_with_indices" => [
'urls_with_indices' => [],
'mentions_with_indices' => [
[
"screen_name" => "@dansup@mstdn.io",
"indices" => [
'screen_name' => '@dansup@mstdn.io',
'indices' => [
8,
24,
],
],
[
"screen_name" => "test",
"indices" => [
'screen_name' => 'test',
'indices' => [
25,
30,
],

View file

@ -2,10 +2,9 @@
namespace Tests\Unit\Lexer;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use App\Util\Lexer\Autolink;
use App\Util\Lexer\Extractor;
use Tests\TestCase;
class UsernameTest extends TestCase
{
@ -17,18 +16,18 @@ class UsernameTest extends TestCase
$autolink = Autolink::create()->autolink($username);
$expectedAutolink = '<a class="u-url mention" href="https://pixelfed.dev/dansup" rel="external nofollow noopener" target="_blank">@dansup</a>';
$expectedEntity = [
"hashtags" => [],
"urls" => [],
"mentions" => [
"dansup",
'hashtags' => [],
'urls' => [],
'mentions' => [
'dansup',
],
"replyto" => "dansup",
"hashtags_with_indices" => [],
"urls_with_indices" => [],
"mentions_with_indices" => [
'replyto' => 'dansup',
'hashtags_with_indices' => [],
'urls_with_indices' => [],
'mentions_with_indices' => [
[
"screen_name" => "dansup",
"indices" => [
'screen_name' => 'dansup',
'indices' => [
0,
7,
],
@ -47,18 +46,18 @@ class UsernameTest extends TestCase
$entities = Extractor::create()->extract($username);
$expectedAutolink = '<a class="u-url mention" href="https://pixelfed.dev/dansup.two" rel="external nofollow noopener" target="_blank">@dansup.two</a>';
$expectedEntity = [
"hashtags" => [],
"urls" => [],
"mentions" => [
"dansup.two",
'hashtags' => [],
'urls' => [],
'mentions' => [
'dansup.two',
],
"replyto" => "dansup.two",
"hashtags_with_indices" => [],
"urls_with_indices" => [],
"mentions_with_indices" => [
'replyto' => 'dansup.two',
'hashtags_with_indices' => [],
'urls_with_indices' => [],
'mentions_with_indices' => [
[
"screen_name" => "dansup.two",
"indices" => [
'screen_name' => 'dansup.two',
'indices' => [
0,
11,
],
@ -77,18 +76,18 @@ class UsernameTest extends TestCase
$entities = Extractor::create()->extract($username);
$expectedAutolink = '<a class="u-url mention" href="https://pixelfed.dev/dansup-too" rel="external nofollow noopener" target="_blank">@dansup-too</a>';
$expectedEntity = [
"hashtags" => [],
"urls" => [],
"mentions" => [
"dansup-too",
'hashtags' => [],
'urls' => [],
'mentions' => [
'dansup-too',
],
"replyto" => "dansup-too",
"hashtags_with_indices" => [],
"urls_with_indices" => [],
"mentions_with_indices" => [
'replyto' => 'dansup-too',
'hashtags_with_indices' => [],
'urls_with_indices' => [],
'mentions_with_indices' => [
[
"screen_name" => "dansup-too",
"indices" => [
'screen_name' => 'dansup-too',
'indices' => [
0,
11,
],
@ -107,18 +106,18 @@ class UsernameTest extends TestCase
$entities = Extractor::create()->extract($username);
$expectedAutolink = '<a class="u-url mention" href="https://pixelfed.dev/dansup_too" rel="external nofollow noopener" target="_blank">@dansup_too</a>';
$expectedEntity = [
"hashtags" => [],
"urls" => [],
"mentions" => [
"dansup_too",
'hashtags' => [],
'urls' => [],
'mentions' => [
'dansup_too',
],
"replyto" => "dansup_too",
"hashtags_with_indices" => [],
"urls_with_indices" => [],
"mentions_with_indices" => [
'replyto' => 'dansup_too',
'hashtags_with_indices' => [],
'urls_with_indices' => [],
'mentions_with_indices' => [
[
"screen_name" => "dansup_too",
"indices" => [
'screen_name' => 'dansup_too',
'indices' => [
0,
11,
],
@ -137,34 +136,34 @@ class UsernameTest extends TestCase
$entities = Extractor::create()->extract($text);
$expectedAutolink = 'hello <a class="u-url mention" href="https://pixelfed.dev/dansup" rel="external nofollow noopener" target="_blank">@dansup</a> and <a class="u-url mention" href="https://pixelfed.dev/pixelfed.team" rel="external nofollow noopener" target="_blank">@pixelfed.team</a> from <a class="u-url mention" href="https://pixelfed.dev/username_underscore" rel="external nofollow noopener" target="_blank">@username_underscore</a>';
$expectedEntity = [
"hashtags" => [],
"urls" => [],
"mentions" => [
"dansup",
"pixelfed.team",
"username_underscore",
'hashtags' => [],
'urls' => [],
'mentions' => [
'dansup',
'pixelfed.team',
'username_underscore',
],
"replyto" => null,
"hashtags_with_indices" => [],
"urls_with_indices" => [],
"mentions_with_indices" => [
'replyto' => null,
'hashtags_with_indices' => [],
'urls_with_indices' => [],
'mentions_with_indices' => [
[
"screen_name" => "dansup",
"indices" => [
'screen_name' => 'dansup',
'indices' => [
6,
13,
],
],
[
"screen_name" => "pixelfed.team",
"indices" => [
'screen_name' => 'pixelfed.team',
'indices' => [
18,
32,
],
],
[
"screen_name" => "username_underscore",
"indices" => [
'screen_name' => 'username_underscore',
'indices' => [
38,
58,
],

View file

@ -4,8 +4,6 @@ namespace Tests\Unit;
use Purify;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class PurifierTest extends TestCase
{

View file

@ -3,7 +3,6 @@
namespace Tests\Unit;
use Tests\TestCase;
use App\Services\SnowflakeService;
class SnowflakeTest extends TestCase
{

View file

@ -2,8 +2,8 @@
namespace Tests\Unit;
use Tests\TestCase;
use App\Util\Lexer\Nickname;
use Tests\TestCase;
class WebfingerTest extends TestCase
{
@ -11,36 +11,36 @@ class WebfingerTest extends TestCase
public function webfingerTest()
{
$expected = [
"domain" => "pixelfed.org",
"username" => "dansup",
'domain' => 'pixelfed.org',
'username' => 'dansup',
];
$actual = Nickname::normalizeProfileUrl('acct:dansup@pixelfed.org');
$this->assertEquals($expected, $actual);
$expected = [
"domain" => "pixelfed.org",
"username" => "dansup_",
'domain' => 'pixelfed.org',
'username' => 'dansup_',
];
$actual = Nickname::normalizeProfileUrl('acct:dansup@pixelfed.org');
$this->assertNotEquals($expected, $actual);
$expected = [
"domain" => "pixelfed.org",
"username" => "dansup",
'domain' => 'pixelfed.org',
'username' => 'dansup',
];
$actual = Nickname::normalizeProfileUrl('acct:@dansup@pixelfed.org');
$this->assertEquals($expected, $actual);
$expected = [
"domain" => "pixelfed.org",
"username" => "dansup",
'domain' => 'pixelfed.org',
'username' => 'dansup',
];
$actual = Nickname::normalizeProfileUrl('dansup@pixelfed.org');
$this->assertEquals($expected, $actual);
$expected = [
"domain" => "pixelfed.org",
"username" => "dansup",
'domain' => 'pixelfed.org',
'username' => 'dansup',
];
$actual = Nickname::normalizeProfileUrl('@dansup@pixelfed.org');
$this->assertEquals($expected, $actual);