mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Merge pull request #3985 from svenluijten/clean-up-tests
Clean up styling in the tests
This commit is contained in:
commit
0d320c3d82
23 changed files with 994 additions and 1025 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace Tests;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
trait CreatesApplication
|
||||
|
@ -10,11 +11,11 @@ trait CreatesApplication
|
|||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
* @return \Illuminate\Foundation\Application
|
||||
* @return Application
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
$app = require __DIR__ . '/../bootstrap/app.php';
|
||||
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
$response = $this->get('/.well-known/nodeinfo');
|
||||
$response->assertJson([
|
||||
'links' => [
|
||||
['rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0'],
|
||||
], ]);
|
||||
}
|
||||
/** @test */
|
||||
public function nodeinfo_api(): void
|
||||
{
|
||||
$response = $this->get('/.well-known/nodeinfo');
|
||||
$response->assertJson([
|
||||
'links' => [
|
||||
['rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,17 +3,14 @@
|
|||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use App\User;
|
||||
|
||||
class LoginTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function view_login_page()
|
||||
{
|
||||
$response = $this->get('login');
|
||||
/** @test */
|
||||
public function view_login_page()
|
||||
{
|
||||
$response = $this->get('login');
|
||||
|
||||
$response->assertSee('Forgot Password');
|
||||
}
|
||||
}
|
||||
$response->assertSee('Forgot Password');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,85 +2,83 @@
|
|||
|
||||
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
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->invalid = [
|
||||
'id' => 'test',
|
||||
'type' => 'Announce',
|
||||
'actor' => null,
|
||||
'published' => '',
|
||||
'to' => ['test'],
|
||||
'cc' => 'test',
|
||||
'object' => 'test'
|
||||
];
|
||||
$this->invalid = [
|
||||
'id' => 'test',
|
||||
'type' => 'Announce',
|
||||
'actor' => null,
|
||||
'published' => '',
|
||||
'to' => ['test'],
|
||||
'cc' => 'test',
|
||||
'object' => 'test'
|
||||
];
|
||||
|
||||
$this->mastodon = json_decode('{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://mastodon.social/users/dansup/statuses/100784657480587830/activity","type":"Announce","actor":"https://mastodon.social/users/dansup","published":"2018-09-25T05:03:49Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://pleroma.site/users/pixeldev","https://mastodon.social/users/dansup/followers"],"object":"https://pleroma.site/objects/68b5c876-f52b-4819-8d81-de6839d73fbc","atomUri":"https://mastodon.social/users/dansup/statuses/100784657480587830/activity"}', true);
|
||||
$this->mastodon = json_decode('{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://mastodon.social/users/dansup/statuses/100784657480587830/activity","type":"Announce","actor":"https://mastodon.social/users/dansup","published":"2018-09-25T05:03:49Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://pleroma.site/users/pixeldev","https://mastodon.social/users/dansup/followers"],"object":"https://pleroma.site/objects/68b5c876-f52b-4819-8d81-de6839d73fbc","atomUri":"https://mastodon.social/users/dansup/statuses/100784657480587830/activity"}', true);
|
||||
|
||||
$this->pleroma = json_decode('{"@context":"https://www.w3.org/ns/activitystreams","actor":"https://pleroma.site/users/pixeldev","cc":["https://www.w3.org/ns/activitystreams#Public"],"context":"tag:mastodon.social,2018-10-14:objectId=59146153:objectType=Conversation","context_id":12325955,"id":"https://pleroma.site/activities/db2273eb-d504-4e3a-8f74-c343d069755a","object":"https://mastodon.social/users/dansup/statuses/100891324792793720","published":"2018-10-14T01:22:18.554227Z","to":["https://pleroma.site/users/pixeldev/followers","https://mastodon.social/users/dansup"],"type":"Announce"}', true);
|
||||
}
|
||||
$this->pleroma = json_decode('{"@context":"https://www.w3.org/ns/activitystreams","actor":"https://pleroma.site/users/pixeldev","cc":["https://www.w3.org/ns/activitystreams#Public"],"context":"tag:mastodon.social,2018-10-14:objectId=59146153:objectType=Conversation","context_id":12325955,"id":"https://pleroma.site/activities/db2273eb-d504-4e3a-8f74-c343d069755a","object":"https://mastodon.social/users/dansup/statuses/100891324792793720","published":"2018-10-14T01:22:18.554227Z","to":["https://pleroma.site/users/pixeldev/followers","https://mastodon.social/users/dansup"],"type":"Announce"}', true);
|
||||
}
|
||||
|
||||
public function testBasicValidation()
|
||||
{
|
||||
$this->assertFalse(Helpers::validateObject($this->invalid));
|
||||
}
|
||||
public function testBasicValidation()
|
||||
{
|
||||
$this->assertFalse(Helpers::validateObject($this->invalid));
|
||||
}
|
||||
|
||||
public function testMastodonValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->mastodon));
|
||||
}
|
||||
public function testMastodonValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->mastodon));
|
||||
}
|
||||
|
||||
public function testPleromaValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->pleroma));
|
||||
}
|
||||
public function testPleromaValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->pleroma));
|
||||
}
|
||||
|
||||
public function testMastodonAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->mastodon, false);
|
||||
$actual = [
|
||||
"to" => [],
|
||||
"cc" => [
|
||||
"https://pleroma.site/users/pixeldev",
|
||||
"https://mastodon.social/users/dansup/followers",
|
||||
],
|
||||
"scope" => "public",
|
||||
];
|
||||
public function testMastodonAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->mastodon, false);
|
||||
$actual = [
|
||||
'to' => [],
|
||||
'cc' => [
|
||||
'https://pleroma.site/users/pixeldev',
|
||||
'https://mastodon.social/users/dansup/followers',
|
||||
],
|
||||
'scope' => 'public',
|
||||
];
|
||||
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
|
||||
public function testPleromaAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->pleroma, false);
|
||||
$actual = [
|
||||
"to" => [
|
||||
"https://pleroma.site/users/pixeldev/followers",
|
||||
"https://mastodon.social/users/dansup",
|
||||
],
|
||||
"cc" => [],
|
||||
"scope" => "unlisted",
|
||||
];
|
||||
public function testPleromaAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->pleroma, false);
|
||||
$actual = [
|
||||
'to' => [
|
||||
'https://pleroma.site/users/pixeldev/followers',
|
||||
'https://mastodon.social/users/dansup',
|
||||
],
|
||||
'cc' => [],
|
||||
'scope' => 'unlisted',
|
||||
];
|
||||
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
|
||||
public function testInvalidAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->invalid, false);
|
||||
$actual = [
|
||||
'to' => [],
|
||||
'cc' => [],
|
||||
'scope' => 'private'
|
||||
];
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
public function testInvalidAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->invalid, false);
|
||||
$actual = [
|
||||
'to' => [],
|
||||
'cc' => [],
|
||||
'scope' => 'private'
|
||||
];
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,85 +2,85 @@
|
|||
|
||||
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
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
protected array $invalid;
|
||||
|
||||
$this->invalid = [
|
||||
'id' => 'test',
|
||||
'type' => 'Announce',
|
||||
'actor' => null,
|
||||
'published' => '',
|
||||
'to' => ['test'],
|
||||
'cc' => 'test',
|
||||
'object' => 'test'
|
||||
];
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->mastodon = json_decode('{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://mastodon.social/users/dansup/statuses/100784657480587830/activity","type":"Announce","actor":"https://mastodon.social/users/dansup","published":"2018-09-25T05:03:49Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://pleroma.site/users/pixeldev","https://mastodon.social/users/dansup/followers"],"object":"https://pleroma.site/objects/68b5c876-f52b-4819-8d81-de6839d73fbc","atomUri":"https://mastodon.social/users/dansup/statuses/100784657480587830/activity"}', true);
|
||||
$this->invalid = [
|
||||
'id' => 'test',
|
||||
'type' => 'Announce',
|
||||
'actor' => null,
|
||||
'published' => '',
|
||||
'to' => ['test'],
|
||||
'cc' => 'test',
|
||||
'object' => 'test'
|
||||
];
|
||||
|
||||
$this->pleroma = json_decode('{"@context":"https://www.w3.org/ns/activitystreams","actor":"https://pleroma.site/users/pixeldev","cc":["https://www.w3.org/ns/activitystreams#Public"],"context":"tag:mastodon.social,2018-10-14:objectId=59146153:objectType=Conversation","context_id":12325955,"id":"https://pleroma.site/activities/db2273eb-d504-4e3a-8f74-c343d069755a","object":"https://mastodon.social/users/dansup/statuses/100891324792793720","published":"2018-10-14T01:22:18.554227Z","to":["https://pleroma.site/users/pixeldev/followers","https://mastodon.social/users/dansup"],"type":"Announce"}', true);
|
||||
}
|
||||
$this->mastodon = json_decode('{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":{"@id":"as:movedTo","@type":"@id"},"Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":{"@id":"toot:featured","@type":"@id"},"schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://mastodon.social/users/dansup/statuses/100784657480587830/activity","type":"Announce","actor":"https://mastodon.social/users/dansup","published":"2018-09-25T05:03:49Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://pleroma.site/users/pixeldev","https://mastodon.social/users/dansup/followers"],"object":"https://pleroma.site/objects/68b5c876-f52b-4819-8d81-de6839d73fbc","atomUri":"https://mastodon.social/users/dansup/statuses/100784657480587830/activity"}', true);
|
||||
|
||||
public function testBasicValidation()
|
||||
{
|
||||
$this->assertFalse(Helpers::validateObject($this->invalid));
|
||||
}
|
||||
$this->pleroma = json_decode('{"@context":"https://www.w3.org/ns/activitystreams","actor":"https://pleroma.site/users/pixeldev","cc":["https://www.w3.org/ns/activitystreams#Public"],"context":"tag:mastodon.social,2018-10-14:objectId=59146153:objectType=Conversation","context_id":12325955,"id":"https://pleroma.site/activities/db2273eb-d504-4e3a-8f74-c343d069755a","object":"https://mastodon.social/users/dansup/statuses/100891324792793720","published":"2018-10-14T01:22:18.554227Z","to":["https://pleroma.site/users/pixeldev/followers","https://mastodon.social/users/dansup"],"type":"Announce"}', true);
|
||||
}
|
||||
|
||||
public function testMastodonValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->mastodon));
|
||||
}
|
||||
public function testBasicValidation()
|
||||
{
|
||||
$this->assertFalse(Helpers::validateObject($this->invalid));
|
||||
}
|
||||
|
||||
public function testPleromaValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->pleroma));
|
||||
}
|
||||
public function testMastodonValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->mastodon));
|
||||
}
|
||||
|
||||
public function testMastodonAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->mastodon, false);
|
||||
$actual = [
|
||||
"to" => [],
|
||||
"cc" => [
|
||||
"https://pleroma.site/users/pixeldev",
|
||||
"https://mastodon.social/users/dansup/followers",
|
||||
],
|
||||
"scope" => "public",
|
||||
];
|
||||
public function testPleromaValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->pleroma));
|
||||
}
|
||||
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
public function testMastodonAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->mastodon, false);
|
||||
$actual = [
|
||||
'to' => [],
|
||||
'cc' => [
|
||||
'https://pleroma.site/users/pixeldev',
|
||||
'https://mastodon.social/users/dansup/followers',
|
||||
],
|
||||
'scope' => 'public',
|
||||
];
|
||||
|
||||
public function testPleromaAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->pleroma, false);
|
||||
$actual = [
|
||||
"to" => [
|
||||
"https://pleroma.site/users/pixeldev/followers",
|
||||
"https://mastodon.social/users/dansup",
|
||||
],
|
||||
"cc" => [],
|
||||
"scope" => "unlisted",
|
||||
];
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
public function testPleromaAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->pleroma, false);
|
||||
$actual = [
|
||||
'to' => [
|
||||
'https://pleroma.site/users/pixeldev/followers',
|
||||
'https://mastodon.social/users/dansup',
|
||||
],
|
||||
'cc' => [],
|
||||
'scope' => 'unlisted',
|
||||
];
|
||||
|
||||
public function testInvalidAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->invalid, false);
|
||||
$actual = [
|
||||
'to' => [],
|
||||
'cc' => [],
|
||||
'scope' => 'private'
|
||||
];
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
|
||||
public function testInvalidAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->invalid, false);
|
||||
$actual = [
|
||||
'to' => [],
|
||||
'cc' => [],
|
||||
'scope' => 'private'
|
||||
];
|
||||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,41 +4,42 @@ 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
|
||||
{
|
||||
parent::setUp();
|
||||
$this->pleroma = json_decode('{"@context":"https://www.w3.org/ns/activitystreams","actor":"https://pleroma.site/users/pixeldev","cc":["https://pleroma.site/users/pixeldev/followers"],"context":"https://pleroma.site/contexts/cbe919c6-238e-4e5d-9065-fcb3c312b56a","context_id":8651628,"id":"https://pleroma.site/activities/65b2c43f-f33e-438e-b141-4e2047b43012","object":{"actor":"https://pleroma.site/users/pixeldev","announcement_count":2,"announcements":["https://playvicious.social/users/jalcine","https://mastodon.social/users/dansup"],"attachment":[{"mediaType":"image/png","name":"Screen Shot 2018-09-08 at 10.59.38 PM.png","type":"Document","url":"https://s3.wasabisys.com/pleroma-site/1c49e1f9-1187-404d-a063-1b37ecec44e9/Screen Shot 2018-09-08 at 10.59.38 PM.png"},{"mediaType":"image/jpeg","name":"archer-danger-zone.jpg","type":"Document","url":"https://s3.wasabisys.com/pleroma-site/cd70cdb6-0148-4dcb-bac6-11fd4aa59834/archer-danger-zone.jpg"}],"attributedTo":"https://pleroma.site/users/pixeldev","cc":["https://pleroma.site/users/pixeldev/followers"],"content":"New middleware for specific actions, acts like sudo requiring periodic password verification. <a href=\'https://pleroma.site/tag/dangerzone\' rel=\'tag\'>#dangerZone</a>","context":"https://pleroma.site/contexts/cbe919c6-238e-4e5d-9065-fcb3c312b56a","context_id":8651628,"conversation":"https://pleroma.site/contexts/cbe919c6-238e-4e5d-9065-fcb3c312b56a","emoji":{},"id":"https://pleroma.site/objects/b7576ec9-ae2b-4076-a426-0d8a65b23876","published":"2018-09-09T05:05:53.763752Z","sensitive":false,"summary":"","tag":[{"href":"https://pleroma.site/tags/dangerzone","name":"#dangerzone","type":"Hashtag"}],"to":["https://www.w3.org/ns/activitystreams#Public"],"type":"Note"},"published":"2018-09-09T05:05:53.749866Z","to":["https://www.w3.org/ns/activitystreams#Public"],"type":"Create"}', true, 9);
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->pleroma = json_decode('{"@context":"https://www.w3.org/ns/activitystreams","actor":"https://pleroma.site/users/pixeldev","cc":["https://pleroma.site/users/pixeldev/followers"],"context":"https://pleroma.site/contexts/cbe919c6-238e-4e5d-9065-fcb3c312b56a","context_id":8651628,"id":"https://pleroma.site/activities/65b2c43f-f33e-438e-b141-4e2047b43012","object":{"actor":"https://pleroma.site/users/pixeldev","announcement_count":2,"announcements":["https://playvicious.social/users/jalcine","https://mastodon.social/users/dansup"],"attachment":[{"mediaType":"image/png","name":"Screen Shot 2018-09-08 at 10.59.38 PM.png","type":"Document","url":"https://s3.wasabisys.com/pleroma-site/1c49e1f9-1187-404d-a063-1b37ecec44e9/Screen Shot 2018-09-08 at 10.59.38 PM.png"},{"mediaType":"image/jpeg","name":"archer-danger-zone.jpg","type":"Document","url":"https://s3.wasabisys.com/pleroma-site/cd70cdb6-0148-4dcb-bac6-11fd4aa59834/archer-danger-zone.jpg"}],"attributedTo":"https://pleroma.site/users/pixeldev","cc":["https://pleroma.site/users/pixeldev/followers"],"content":"New middleware for specific actions, acts like sudo requiring periodic password verification. <a href=\'https://pleroma.site/tag/dangerzone\' rel=\'tag\'>#dangerZone</a>","context":"https://pleroma.site/contexts/cbe919c6-238e-4e5d-9065-fcb3c312b56a","context_id":8651628,"conversation":"https://pleroma.site/contexts/cbe919c6-238e-4e5d-9065-fcb3c312b56a","emoji":{},"id":"https://pleroma.site/objects/b7576ec9-ae2b-4076-a426-0d8a65b23876","published":"2018-09-09T05:05:53.763752Z","sensitive":false,"summary":"","tag":[{"href":"https://pleroma.site/tags/dangerzone","name":"#dangerzone","type":"Hashtag"}],"to":["https://www.w3.org/ns/activitystreams#Public"],"type":"Note"},"published":"2018-09-09T05:05:53.749866Z","to":["https://www.w3.org/ns/activitystreams#Public"],"type":"Create"}', true, 9);
|
||||
|
||||
$this->mastodon = json_decode('{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791/activity","type":"Create","actor":"https://mastodon.social/users/dansup","published":"2018-10-13T18:43:33Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"object":{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791","type":"Note","summary":null,"inReplyTo":null,"published":"2018-10-13T18:43:33Z","url":"https://mastodon.social/@dansup/100889802384218791","attributedTo":"https://mastodon.social/users/dansup","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"sensitive":false,"atomUri":"https://mastodon.social/users/dansup/statuses/100889802384218791","inReplyToAtomUri":null,"conversation":"tag:mastodon.social,2018-10-13:objectId=59103420:objectType=Conversation","content":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>","contentMap":{"en":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>"},"attachment":[{"type":"Document","mediaType":"image/jpeg","url":"https://files.mastodon.social/media_attachments/files/007/110/573/original/96a196885a77c9a4.jpg","name":null}],"tag":[{"type":"Hashtag","href":"https://mastodon.social/tags/coffee","name":"#coffee"}]}}', true, 9);
|
||||
$this->mastodon = json_decode('{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791/activity","type":"Create","actor":"https://mastodon.social/users/dansup","published":"2018-10-13T18:43:33Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"object":{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791","type":"Note","summary":null,"inReplyTo":null,"published":"2018-10-13T18:43:33Z","url":"https://mastodon.social/@dansup/100889802384218791","attributedTo":"https://mastodon.social/users/dansup","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"sensitive":false,"atomUri":"https://mastodon.social/users/dansup/statuses/100889802384218791","inReplyToAtomUri":null,"conversation":"tag:mastodon.social,2018-10-13:objectId=59103420:objectType=Conversation","content":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>","contentMap":{"en":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>"},"attachment":[{"type":"Document","mediaType":"image/jpeg","url":"https://files.mastodon.social/media_attachments/files/007/110/573/original/96a196885a77c9a4.jpg","name":null}],"tag":[{"type":"Hashtag","href":"https://mastodon.social/tags/coffee","name":"#coffee"}]}}', true, 9);
|
||||
|
||||
$this->invalidType = json_decode('{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791/activity","type":"Create","actor":"https://mastodon.social/users/dansup","published":"2018-10-13T18:43:33Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"object":{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791","type":"Note","summary":null,"inReplyTo":null,"published":"2018-10-13T18:43:33Z","url":"https://mastodon.social/@dansup/100889802384218791","attributedTo":"https://mastodon.social/users/dansup","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"sensitive":false,"atomUri":"https://mastodon.social/users/dansup/statuses/100889802384218791","inReplyToAtomUri":null,"conversation":"tag:mastodon.social,2018-10-13:objectId=59103420:objectType=Conversation","content":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>","contentMap":{"en":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>"},"attachment":[{"type":"NotDocument","mediaType":"image/jpeg","url":"https://files.mastodon.social/media_attachments/files/007/110/573/original/96a196885a77c9a4.jpg","name":null}],"tag":[{"type":"Hashtag","href":"https://mastodon.social/tags/coffee","name":"#coffee"}]}}', true, 9);
|
||||
$this->invalidType = json_decode('{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791/activity","type":"Create","actor":"https://mastodon.social/users/dansup","published":"2018-10-13T18:43:33Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"object":{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791","type":"Note","summary":null,"inReplyTo":null,"published":"2018-10-13T18:43:33Z","url":"https://mastodon.social/@dansup/100889802384218791","attributedTo":"https://mastodon.social/users/dansup","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"sensitive":false,"atomUri":"https://mastodon.social/users/dansup/statuses/100889802384218791","inReplyToAtomUri":null,"conversation":"tag:mastodon.social,2018-10-13:objectId=59103420:objectType=Conversation","content":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>","contentMap":{"en":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>"},"attachment":[{"type":"NotDocument","mediaType":"image/jpeg","url":"https://files.mastodon.social/media_attachments/files/007/110/573/original/96a196885a77c9a4.jpg","name":null}],"tag":[{"type":"Hashtag","href":"https://mastodon.social/tags/coffee","name":"#coffee"}]}}', true, 9);
|
||||
|
||||
$this->invalidMime = json_decode('{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791/activity","type":"Create","actor":"https://mastodon.social/users/dansup","published":"2018-10-13T18:43:33Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"object":{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791","type":"Note","summary":null,"inReplyTo":null,"published":"2018-10-13T18:43:33Z","url":"https://mastodon.social/@dansup/100889802384218791","attributedTo":"https://mastodon.social/users/dansup","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"sensitive":false,"atomUri":"https://mastodon.social/users/dansup/statuses/100889802384218791","inReplyToAtomUri":null,"conversation":"tag:mastodon.social,2018-10-13:objectId=59103420:objectType=Conversation","content":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>","contentMap":{"en":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>"},"attachment":[{"type":"Document","mediaType":"image/webp","url":"https://files.mastodon.social/media_attachments/files/007/110/573/original/96a196885a77c9a4.jpg","name":null}],"tag":[{"type":"Hashtag","href":"https://mastodon.social/tags/coffee","name":"#coffee"}]}}', true, 9);
|
||||
}
|
||||
$this->invalidMime = json_decode('{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791/activity","type":"Create","actor":"https://mastodon.social/users/dansup","published":"2018-10-13T18:43:33Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"object":{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791","type":"Note","summary":null,"inReplyTo":null,"published":"2018-10-13T18:43:33Z","url":"https://mastodon.social/@dansup/100889802384218791","attributedTo":"https://mastodon.social/users/dansup","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"sensitive":false,"atomUri":"https://mastodon.social/users/dansup/statuses/100889802384218791","inReplyToAtomUri":null,"conversation":"tag:mastodon.social,2018-10-13:objectId=59103420:objectType=Conversation","content":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>","contentMap":{"en":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>"},"attachment":[{"type":"Document","mediaType":"image/webp","url":"https://files.mastodon.social/media_attachments/files/007/110/573/original/96a196885a77c9a4.jpg","name":null}],"tag":[{"type":"Hashtag","href":"https://mastodon.social/tags/coffee","name":"#coffee"}]}}', true, 9);
|
||||
}
|
||||
|
||||
public function testMastodon()
|
||||
{
|
||||
$valid = Helpers::verifyAttachments($this->mastodon);
|
||||
$this->assertTrue($valid);
|
||||
}
|
||||
public function testMastodon()
|
||||
{
|
||||
$valid = Helpers::verifyAttachments($this->mastodon);
|
||||
$this->assertTrue($valid);
|
||||
}
|
||||
|
||||
public function testInvalidAttachmentType()
|
||||
{
|
||||
$valid = Helpers::verifyAttachments($this->invalidType);
|
||||
$this->assertFalse($valid);
|
||||
}
|
||||
|
||||
public function testInvalidMimeType()
|
||||
{
|
||||
$valid = Helpers::verifyAttachments($this->invalidMime);
|
||||
$this->assertFalse($valid);
|
||||
}
|
||||
public function testInvalidAttachmentType()
|
||||
{
|
||||
$valid = Helpers::verifyAttachments($this->invalidType);
|
||||
$this->assertFalse($valid);
|
||||
}
|
||||
|
||||
public function testInvalidMimeType()
|
||||
{
|
||||
$valid = Helpers::verifyAttachments($this->invalidMime);
|
||||
$this->assertFalse($valid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,24 +4,24 @@ 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
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
protected string $mastodon;
|
||||
|
||||
$this->mastodon = '{"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://localtesting.pleroma.lol/users/lain","nickname":"lain","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"}]}';
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
}
|
||||
$this->mastodon = '{"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://localtesting.pleroma.lol/users/lain","nickname":"lain","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"}]}';
|
||||
|
||||
/** @test */
|
||||
public function validateMastodonFollowObject()
|
||||
{
|
||||
$mastodon = json_decode($this->mastodon, true);
|
||||
$mastodon = Helpers::validateObject($mastodon);
|
||||
$this->assertTrue($mastodon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function validateMastodonFollowObject()
|
||||
{
|
||||
$mastodon = json_decode($this->mastodon, true);
|
||||
$mastodon = Helpers::validateObject($mastodon);
|
||||
$this->assertTrue($mastodon);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,83 +2,82 @@
|
|||
|
||||
namespace Tests\Unit\ActivityPub;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Util\ActivityPub\Validator\StoryValidator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class StoryValidationTest extends TestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->activity = json_decode('{"@context":"https://www.w3.org/ns/activitystreams","id":"https://pixelfed.test/stories/dansup/338581222496276480","type":"Story","to":["https://pixelfed.test/users/dansup/followers"],"cc":[],"attributedTo":"https://pixelfed.test/users/dansup","published":"2021-09-01T07:20:53+00:00","expiresAt":"2021-09-02T07:21:04+00:00","duration":3,"can_reply":true,"can_react":true,"attachment":{"type":"Image","url":"https://pixelfed.test/storage/_esm.t3/xV9/R2LF1xwhAA/011oqKVPDySG3WCPW7yIs2wobvccoITMnG/yT_FZX04f2DCzTA3K8HD2OS7FptXTHPiE1c_ZkHASBQ8UlPKH4.jpg","mediaType":"image/jpeg"}}', true);
|
||||
}
|
||||
$this->activity = json_decode('{"@context":"https://www.w3.org/ns/activitystreams","id":"https://pixelfed.test/stories/dansup/338581222496276480","type":"Story","to":["https://pixelfed.test/users/dansup/followers"],"cc":[],"attributedTo":"https://pixelfed.test/users/dansup","published":"2021-09-01T07:20:53+00:00","expiresAt":"2021-09-02T07:21:04+00:00","duration":3,"can_reply":true,"can_react":true,"attachment":{"type":"Image","url":"https://pixelfed.test/storage/_esm.t3/xV9/R2LF1xwhAA/011oqKVPDySG3WCPW7yIs2wobvccoITMnG/yT_FZX04f2DCzTA3K8HD2OS7FptXTHPiE1c_ZkHASBQ8UlPKH4.jpg","mediaType":"image/jpeg"}}', true);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function schemaTest()
|
||||
{
|
||||
$this->assertTrue(StoryValidator::validate($this->activity));
|
||||
}
|
||||
/** @test */
|
||||
public function schemaTest()
|
||||
{
|
||||
$this->assertTrue(StoryValidator::validate($this->activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function invalidContext()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
unset($activity['@context']);
|
||||
$activity['@@context'] = 'https://www.w3.org/ns/activitystreams';
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
/** @test */
|
||||
public function invalidContext()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
unset($activity['@context']);
|
||||
$activity['@@context'] = 'https://www.w3.org/ns/activitystreams';
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function missingContext()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
unset($activity['@context']);
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
/** @test */
|
||||
public function missingContext()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
unset($activity['@context']);
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function missingId()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
unset($activity['id']);
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
/** @test */
|
||||
public function missingId()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
unset($activity['id']);
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function missingType()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
unset($activity['type']);
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
/** @test */
|
||||
public function missingType()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
unset($activity['type']);
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function invalidType()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
$activity['type'] = 'Store';
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
/** @test */
|
||||
public function invalidType()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
$activity['type'] = 'Store';
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function missingTo()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
unset($activity['to']);
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
/** @test */
|
||||
public function missingTo()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
unset($activity['to']);
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function missingTimestamps()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
unset($activity['published']);
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
|
||||
$activity = $this->activity;
|
||||
unset($activity['expiresAt']);
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
/** @test */
|
||||
public function missingTimestamps()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
unset($activity['published']);
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
|
||||
$activity = $this->activity;
|
||||
unset($activity['expiresAt']);
|
||||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,96 +2,96 @@
|
|||
|
||||
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',
|
||||
'type' => 'Accept',
|
||||
'actor' => 'https://example.org/u/alice',
|
||||
'object' => [
|
||||
'id' => 'https://example.net/u/bob#follows/bb27f601-ddb9-4567-8f16-023d90605ca9',
|
||||
'type' => 'Follow',
|
||||
'actor' => 'https://example.net/u/bob',
|
||||
'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',
|
||||
'type' => 'Accept2',
|
||||
'actor' => 'https://example.org/u/alice',
|
||||
'object' => [
|
||||
'id' => 'https://example.net/u/bob#follows/bb27f601-ddb9-4567-8f16-023d90605ca9',
|
||||
'type' => 'Follow',
|
||||
'actor' => 'https://example.net/u/bob',
|
||||
'object' => 'https://example.org/u/alice'
|
||||
]
|
||||
];
|
||||
$this->mastodonAccept = [
|
||||
"@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",
|
||||
],
|
||||
],
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
"type" => "Accept",
|
||||
$this->validAccept = [
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => 'https://example.org/og/b3e4a40b-0b26-4c5a-9079-094bd633fab7',
|
||||
'type' => 'Accept',
|
||||
'actor' => 'https://example.org/u/alice',
|
||||
'object' => [
|
||||
'id' => 'https://example.net/u/bob#follows/bb27f601-ddb9-4567-8f16-023d90605ca9',
|
||||
'type' => 'Follow',
|
||||
'actor' => 'https://example.net/u/bob',
|
||||
'object' => 'https://example.org/u/alice'
|
||||
]
|
||||
];
|
||||
|
||||
"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",
|
||||
],
|
||||
];
|
||||
}
|
||||
$this->invalidAccept = [
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => 'https://example.org/og/b3e4a40b-0b26-4c5a-9079-094bd633fab7',
|
||||
'type' => 'Accept2',
|
||||
'actor' => 'https://example.org/u/alice',
|
||||
'object' => [
|
||||
'id' => 'https://example.net/u/bob#follows/bb27f601-ddb9-4567-8f16-023d90605ca9',
|
||||
'type' => 'Follow',
|
||||
'actor' => 'https://example.net/u/bob',
|
||||
'object' => 'https://example.org/u/alice'
|
||||
]
|
||||
];
|
||||
|
||||
/** @test */
|
||||
public function basic_accept()
|
||||
{
|
||||
$this->assertTrue(Accept::validate($this->validAccept));
|
||||
}
|
||||
$this->mastodonAccept = [
|
||||
'@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',
|
||||
],
|
||||
],
|
||||
'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',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function invalid_accept()
|
||||
{
|
||||
$this->assertFalse(Accept::validate($this->invalidAccept));
|
||||
}
|
||||
/** @test */
|
||||
public function basic_accept()
|
||||
{
|
||||
$this->assertTrue(Accept::validate($this->validAccept));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function mastodon_accept()
|
||||
{
|
||||
$this->assertTrue(Accept::validate($this->mastodonAccept));
|
||||
}
|
||||
/** @test */
|
||||
public function invalid_accept()
|
||||
{
|
||||
$this->assertFalse(Accept::validate($this->invalidAccept));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function mastodon_accept()
|
||||
{
|
||||
$this->assertTrue(Accept::validate($this->mastodonAccept));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,211 +2,218 @@
|
|||
|
||||
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();
|
||||
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"
|
||||
],
|
||||
"cc" => [
|
||||
"https://example.org/users/bob",
|
||||
"https://example.org/users/alice/followers"
|
||||
],
|
||||
"object" => "https://example.org/p/bob/100000000000000",
|
||||
];
|
||||
$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'
|
||||
],
|
||||
'cc' => [
|
||||
'https://example.org/users/bob',
|
||||
'https://example.org/users/alice/followers'
|
||||
],
|
||||
'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"
|
||||
],
|
||||
"cc" => [
|
||||
"https://example.org/users/bob",
|
||||
"https://example.org/users/alice/followers"
|
||||
],
|
||||
"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'
|
||||
],
|
||||
'cc' => [
|
||||
'https://example.org/users/bob',
|
||||
'https://example.org/users/alice/followers'
|
||||
],
|
||||
'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"
|
||||
],
|
||||
"cc" => [
|
||||
"https://example.org/users/bob",
|
||||
"https://example.org/users/alice/followers"
|
||||
],
|
||||
"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'
|
||||
],
|
||||
'cc' => [
|
||||
'https://example.org/users/bob',
|
||||
'https://example.org/users/alice/followers'
|
||||
],
|
||||
'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"
|
||||
],
|
||||
"cc" => [
|
||||
"https://example.org/users/bob",
|
||||
"https://example.org/users/alice/followers"
|
||||
],
|
||||
"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'
|
||||
],
|
||||
'cc' => [
|
||||
'https://example.org/users/bob',
|
||||
'https://example.org/users/alice/followers'
|
||||
],
|
||||
'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",
|
||||
];
|
||||
$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',
|
||||
];
|
||||
|
||||
$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",
|
||||
];
|
||||
$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',
|
||||
];
|
||||
|
||||
$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"
|
||||
],
|
||||
"cc" => [
|
||||
"https://example.org/users/bob",
|
||||
"https://example.org/users/alice/followers"
|
||||
],
|
||||
"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'
|
||||
],
|
||||
'cc' => [
|
||||
'https://example.org/users/bob',
|
||||
'https://example.org/users/alice/followers'
|
||||
],
|
||||
'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"
|
||||
],
|
||||
"cc" => [
|
||||
"https://example.org/users/bob",
|
||||
"https://example.org/users/alice/followers"
|
||||
],
|
||||
"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'
|
||||
],
|
||||
'cc' => [
|
||||
'https://example.org/users/bob',
|
||||
'https://example.org/users/alice/followers'
|
||||
],
|
||||
'object' => 'https://example.org/p/bob/100000000000000',
|
||||
];
|
||||
|
||||
$this->mastodonAnnounce = [
|
||||
"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",
|
||||
],
|
||||
"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",
|
||||
[
|
||||
"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",
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
$this->mastodonAnnounce = [
|
||||
'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',
|
||||
],
|
||||
'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',
|
||||
[
|
||||
'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',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function basic_accept()
|
||||
{
|
||||
$this->assertTrue(Announce::validate($this->validAnnounce));
|
||||
}
|
||||
/** @test */
|
||||
public function basic_accept()
|
||||
{
|
||||
$this->assertTrue(Announce::validate($this->validAnnounce));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function invalid_accept()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->invalidAnnounce));
|
||||
}
|
||||
/** @test */
|
||||
public function invalid_accept()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->invalidAnnounce));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function invalid_date()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->invalidDate));
|
||||
}
|
||||
/** @test */
|
||||
public function invalid_date()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->invalidDate));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function context_missing()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->contextMissing));
|
||||
}
|
||||
/** @test */
|
||||
public function context_missing()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->contextMissing));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function audience_missing()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->audienceMissing));
|
||||
$this->assertFalse(Announce::validate($this->audienceMissing2));
|
||||
}
|
||||
/** @test */
|
||||
public function audience_missing()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->audienceMissing));
|
||||
$this->assertFalse(Announce::validate($this->audienceMissing2));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function invalid_actor()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->invalidActor));
|
||||
$this->assertFalse(Announce::validate($this->invalidActor2));
|
||||
}
|
||||
/** @test */
|
||||
public function invalid_actor()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->invalidActor));
|
||||
$this->assertFalse(Announce::validate($this->invalidActor2));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function mastodon_announce()
|
||||
{
|
||||
$this->assertTrue(Announce::validate($this->mastodonAnnounce));
|
||||
}
|
||||
/** @test */
|
||||
public function mastodon_announce()
|
||||
{
|
||||
$this->assertTrue(Announce::validate($this->mastodonAnnounce));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,52 +2,51 @@
|
|||
|
||||
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();
|
||||
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",
|
||||
],
|
||||
"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",
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
$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',
|
||||
],
|
||||
'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',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function basic_follow()
|
||||
{
|
||||
$this->assertTrue(Follow::validate($this->basicFollow));
|
||||
}
|
||||
}
|
||||
/** @test */
|
||||
public function basic_follow()
|
||||
{
|
||||
$this->assertTrue(Follow::validate($this->basicFollow));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,52 +2,51 @@
|
|||
|
||||
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();
|
||||
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",
|
||||
],
|
||||
"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",
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
$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',
|
||||
],
|
||||
'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',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function basic_like()
|
||||
{
|
||||
$this->assertTrue(Like::validate($this->basicLike));
|
||||
}
|
||||
}
|
||||
/** @test */
|
||||
public function basic_like()
|
||||
{
|
||||
$this->assertTrue(Like::validate($this->basicLike));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,45 +2,41 @@
|
|||
|
||||
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 array $validUndo;
|
||||
protected array $invalidUndo;
|
||||
|
||||
protected $validUndo;
|
||||
protected $invalidUndo;
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->validUndo = json_decode('{"@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"}],"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":"Undo","object":{"type":"Follow","object":"http://localtesting.pleroma.lol/users/lain","nickname":"lain","id":"http://mastodon.example.org/users/admin#follows/2","actor":"http://mastodon.example.org/users/admin"},"actor":"http://mastodon.example.org/users/admin","id":"http://mastodon.example.org/users/admin#follow/2/undo"}', true, 8);
|
||||
|
||||
$this->validUndo = json_decode('{"@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"}],"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":"Undo","object":{"type":"Follow","object":"http://localtesting.pleroma.lol/users/lain","nickname":"lain","id":"http://mastodon.example.org/users/admin#follows/2","actor":"http://mastodon.example.org/users/admin"},"actor":"http://mastodon.example.org/users/admin","id":"http://mastodon.example.org/users/admin#follow/2/undo"}', true, 8);
|
||||
$this->invalidUndo = [
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => 'https://example.org/og/b3e4a40b-0b26-4c5a-9079-094bd633fab7',
|
||||
'type' => 'Undo',
|
||||
'actor' => 'https://example.org/u/alice',
|
||||
'object' => [
|
||||
'id' => 'https://example.net/u/bob#follows/bb27f601-ddb9-4567-8f16-023d90605ca9',
|
||||
'type' => 'Follow',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$this->invalidUndo = [
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => 'https://example.org/og/b3e4a40b-0b26-4c5a-9079-094bd633fab7',
|
||||
'type' => 'Undo',
|
||||
'actor' => 'https://example.org/u/alice',
|
||||
'object' => [
|
||||
'id' => 'https://example.net/u/bob#follows/bb27f601-ddb9-4567-8f16-023d90605ca9',
|
||||
'type' => 'Follow',
|
||||
]
|
||||
];
|
||||
}
|
||||
/** @test */
|
||||
public function valid_undo_follow()
|
||||
{
|
||||
$this->assertTrue(UndoFollow::validate($this->validUndo));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function valid_undo_follow()
|
||||
{
|
||||
$this->assertTrue(UndoFollow::validate($this->validUndo));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function invalid_undo_follow()
|
||||
{
|
||||
$this->assertFalse(UndoFollow::validate($this->invalidUndo));
|
||||
}
|
||||
|
||||
}
|
||||
/** @test */
|
||||
public function invalid_undo_follow()
|
||||
{
|
||||
$this->assertFalse(UndoFollow::validate($this->invalidUndo));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,76 +2,76 @@
|
|||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Util\Lexer\Bearcap;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BearcapTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function validTest()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
$expected = [
|
||||
"token" => "LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2",
|
||||
"url" => "https://pixelfed.test/stories/admin/337892163734081536",
|
||||
];
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
/** @test */
|
||||
public function validTest()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
$expected = [
|
||||
'token' => 'LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2',
|
||||
'url' => 'https://pixelfed.test/stories/admin/337892163734081536',
|
||||
];
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function invalidTokenParameterName()
|
||||
{
|
||||
$str = 'bear:?token=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
/** @test */
|
||||
public function invalidTokenParameterName()
|
||||
{
|
||||
$str = 'bear:?token=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function invalidUrlParameterName()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&url=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
/** @test */
|
||||
public function invalidUrlParameterName()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&url=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function invalidScheme()
|
||||
{
|
||||
$str = 'bearcap:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&url=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
/** @test */
|
||||
public function invalidScheme()
|
||||
{
|
||||
$str = 'bearcap:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&url=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function missingToken()
|
||||
{
|
||||
$str = 'bear:?u=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
/** @test */
|
||||
public function missingToken()
|
||||
{
|
||||
$str = 'bear:?u=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function missingUrl()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
/** @test */
|
||||
public function missingUrl()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function invalidHttpUrl()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=http://pixelfed.test/stories/admin/337892163734081536';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
/** @test */
|
||||
public function invalidHttpUrl()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=http://pixelfed.test/stories/admin/337892163734081536';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function invalidUrlSchema()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=phar://pixelfed.test/stories/admin/337892163734081536';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
/** @test */
|
||||
public function invalidUrlSchema()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=phar://pixelfed.test/stories/admin/337892163734081536';
|
||||
$actual = Bearcap::decode($str);
|
||||
$this->assertFalse($actual);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -3,31 +3,30 @@
|
|||
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');
|
||||
$this->assertEquals(9, $ts->month);
|
||||
$this->assertEquals(16, $ts->day);
|
||||
$this->assertEquals(2019, $ts->year);
|
||||
$this->assertEquals(2, $ts->hour);
|
||||
$this->assertEquals(41, $ts->minute);
|
||||
}
|
||||
/** @test */
|
||||
public function mastodonTimestamp()
|
||||
{
|
||||
$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);
|
||||
$this->assertEquals(2, $ts->hour);
|
||||
$this->assertEquals(41, $ts->minute);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function p3kTimestamp()
|
||||
{
|
||||
$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);
|
||||
$this->assertEquals(8, $ts->hour);
|
||||
$this->assertEquals(40, $ts->minute);
|
||||
}
|
||||
/** @test */
|
||||
public function p3kTimestamp()
|
||||
{
|
||||
$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);
|
||||
$this->assertEquals(8, $ts->hour);
|
||||
$this->assertEquals(40, $ts->minute);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -2,20 +2,18 @@
|
|||
|
||||
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
|
||||
{
|
||||
/** @test */
|
||||
public function restrictedUsername()
|
||||
{
|
||||
$names = RestrictedNames::get();
|
||||
$this->assertContains('p', $names);
|
||||
$this->assertContains('admin', $names);
|
||||
$this->assertNotContains('dansup', $names);
|
||||
$this->assertNotContains('earth', $names);
|
||||
}
|
||||
/** @test */
|
||||
public function restrictedUsername()
|
||||
{
|
||||
$names = RestrictedNames::get();
|
||||
$this->assertContains('p', $names);
|
||||
$this->assertContains('admin', $names);
|
||||
$this->assertNotContains('dansup', $names);
|
||||
$this->assertNotContains('earth', $names);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,57 +2,55 @@
|
|||
|
||||
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
|
||||
{
|
||||
public $status;
|
||||
public $entities;
|
||||
public $autolink;
|
||||
public $autolink;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->status = "@pixelfed hi, really like the website! #píxelfed";
|
||||
$this->entities = Extractor::create()->extract($this->status);
|
||||
$this->autolink = Autolink::create()->autolink($this->status);
|
||||
$this->status = '@pixelfed hi, really like the website! #píxelfed';
|
||||
$this->entities = Extractor::create()->extract($this->status);
|
||||
$this->autolink = Autolink::create()->autolink($this->status);
|
||||
}
|
||||
|
||||
public function testLexerExtractor()
|
||||
{
|
||||
$expected = [
|
||||
"hashtags" => [
|
||||
"píxelfed",
|
||||
],
|
||||
"urls" => [],
|
||||
"mentions" => [
|
||||
"pixelfed",
|
||||
],
|
||||
"replyto" => "pixelfed",
|
||||
"hashtags_with_indices" => [
|
||||
[
|
||||
"hashtag" => "píxelfed",
|
||||
"indices" => [
|
||||
39,
|
||||
48,
|
||||
],
|
||||
],
|
||||
],
|
||||
"urls_with_indices" => [],
|
||||
"mentions_with_indices" => [
|
||||
[
|
||||
"screen_name" => "pixelfed",
|
||||
"indices" => [
|
||||
0,
|
||||
9,
|
||||
'hashtags' => [
|
||||
'píxelfed',
|
||||
],
|
||||
'urls' => [],
|
||||
'mentions' => [
|
||||
'pixelfed',
|
||||
],
|
||||
'replyto' => 'pixelfed',
|
||||
'hashtags_with_indices' => [
|
||||
[
|
||||
'hashtag' => 'píxelfed',
|
||||
'indices' => [
|
||||
39,
|
||||
48,
|
||||
],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
'urls_with_indices' => [],
|
||||
'mentions_with_indices' => [
|
||||
[
|
||||
'screen_name' => 'pixelfed',
|
||||
'indices' => [
|
||||
0,
|
||||
9,
|
||||
],
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$this->assertEquals($this->entities, $expected);
|
||||
|
@ -64,40 +62,40 @@ class StatusLexerTest extends TestCase
|
|||
$this->assertEquals($this->autolink, $expected);
|
||||
}
|
||||
|
||||
/** @test **/
|
||||
/** @test * */
|
||||
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,
|
||||
],
|
||||
|
@ -108,7 +106,7 @@ class StatusLexerTest extends TestCase
|
|||
$this->assertEquals($actual, $expected);
|
||||
}
|
||||
|
||||
/** @test **/
|
||||
/** @test * */
|
||||
public function mentionLimit()
|
||||
{
|
||||
$text = '@test1 @test @test2 @test3 @test4 @test5 test post';
|
||||
|
@ -118,7 +116,7 @@ class StatusLexerTest extends TestCase
|
|||
$this->assertEquals($count, Status::MAX_MENTIONS);
|
||||
}
|
||||
|
||||
/** @test **/
|
||||
/** @test * */
|
||||
public function hashtagLimit()
|
||||
{
|
||||
$text = '#hashtag0 #hashtag1 #hashtag2 #hashtag3 #hashtag4 #hashtag5 #hashtag6 #hashtag7 #hashtag8 #hashtag9 #hashtag10 #hashtag11 #hashtag12 #hashtag13 #hashtag14 #hashtag15 #hashtag16 #hashtag17 #hashtag18 #hashtag19 #hashtag20 #hashtag21 #hashtag22 #hashtag23 #hashtag24 #hashtag25 #hashtag26 #hashtag27 #hashtag28 #hashtag29 #hashtag30 #hashtag31';
|
||||
|
@ -129,7 +127,7 @@ class StatusLexerTest extends TestCase
|
|||
}
|
||||
|
||||
|
||||
/** @test **/
|
||||
/** @test * */
|
||||
public function linkLimit()
|
||||
{
|
||||
$text = 'https://example.org https://example.net https://example.com';
|
||||
|
|
|
@ -2,178 +2,177 @@
|
|||
|
||||
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
|
||||
{
|
||||
/** @test **/
|
||||
public function genericUsername()
|
||||
{
|
||||
$username = '@dansup';
|
||||
$entities = Extractor::create()->extract($username);
|
||||
$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",
|
||||
],
|
||||
"replyto" => "dansup",
|
||||
"hashtags_with_indices" => [],
|
||||
"urls_with_indices" => [],
|
||||
"mentions_with_indices" => [
|
||||
[
|
||||
"screen_name" => "dansup",
|
||||
"indices" => [
|
||||
0,
|
||||
7,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->assertEquals($expectedAutolink, $autolink);
|
||||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
/** @test * */
|
||||
public function genericUsername()
|
||||
{
|
||||
$username = '@dansup';
|
||||
$entities = Extractor::create()->extract($username);
|
||||
$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',
|
||||
],
|
||||
'replyto' => 'dansup',
|
||||
'hashtags_with_indices' => [],
|
||||
'urls_with_indices' => [],
|
||||
'mentions_with_indices' => [
|
||||
[
|
||||
'screen_name' => 'dansup',
|
||||
'indices' => [
|
||||
0,
|
||||
7,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->assertEquals($expectedAutolink, $autolink);
|
||||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
|
||||
/** @test **/
|
||||
public function usernameWithPeriod()
|
||||
{
|
||||
$username = '@dansup.two';
|
||||
$autolink = Autolink::create()->autolink($username);
|
||||
$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",
|
||||
],
|
||||
"replyto" => "dansup.two",
|
||||
"hashtags_with_indices" => [],
|
||||
"urls_with_indices" => [],
|
||||
"mentions_with_indices" => [
|
||||
[
|
||||
"screen_name" => "dansup.two",
|
||||
"indices" => [
|
||||
0,
|
||||
11,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->assertEquals($expectedAutolink, $autolink);
|
||||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
/** @test * */
|
||||
public function usernameWithPeriod()
|
||||
{
|
||||
$username = '@dansup.two';
|
||||
$autolink = Autolink::create()->autolink($username);
|
||||
$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',
|
||||
],
|
||||
'replyto' => 'dansup.two',
|
||||
'hashtags_with_indices' => [],
|
||||
'urls_with_indices' => [],
|
||||
'mentions_with_indices' => [
|
||||
[
|
||||
'screen_name' => 'dansup.two',
|
||||
'indices' => [
|
||||
0,
|
||||
11,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->assertEquals($expectedAutolink, $autolink);
|
||||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
|
||||
/** @test **/
|
||||
public function usernameWithDash()
|
||||
{
|
||||
$username = '@dansup-too';
|
||||
$autolink = Autolink::create()->autolink($username);
|
||||
$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",
|
||||
],
|
||||
"replyto" => "dansup-too",
|
||||
"hashtags_with_indices" => [],
|
||||
"urls_with_indices" => [],
|
||||
"mentions_with_indices" => [
|
||||
[
|
||||
"screen_name" => "dansup-too",
|
||||
"indices" => [
|
||||
0,
|
||||
11,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->assertEquals($expectedAutolink, $autolink);
|
||||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
/** @test * */
|
||||
public function usernameWithDash()
|
||||
{
|
||||
$username = '@dansup-too';
|
||||
$autolink = Autolink::create()->autolink($username);
|
||||
$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',
|
||||
],
|
||||
'replyto' => 'dansup-too',
|
||||
'hashtags_with_indices' => [],
|
||||
'urls_with_indices' => [],
|
||||
'mentions_with_indices' => [
|
||||
[
|
||||
'screen_name' => 'dansup-too',
|
||||
'indices' => [
|
||||
0,
|
||||
11,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->assertEquals($expectedAutolink, $autolink);
|
||||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
|
||||
/** @test **/
|
||||
public function usernameWithUnderscore()
|
||||
{
|
||||
$username = '@dansup_too';
|
||||
$autolink = Autolink::create()->autolink($username);
|
||||
$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",
|
||||
],
|
||||
"replyto" => "dansup_too",
|
||||
"hashtags_with_indices" => [],
|
||||
"urls_with_indices" => [],
|
||||
"mentions_with_indices" => [
|
||||
[
|
||||
"screen_name" => "dansup_too",
|
||||
"indices" => [
|
||||
0,
|
||||
11,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->assertEquals($expectedAutolink, $autolink);
|
||||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
/** @test * */
|
||||
public function usernameWithUnderscore()
|
||||
{
|
||||
$username = '@dansup_too';
|
||||
$autolink = Autolink::create()->autolink($username);
|
||||
$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',
|
||||
],
|
||||
'replyto' => 'dansup_too',
|
||||
'hashtags_with_indices' => [],
|
||||
'urls_with_indices' => [],
|
||||
'mentions_with_indices' => [
|
||||
[
|
||||
'screen_name' => 'dansup_too',
|
||||
'indices' => [
|
||||
0,
|
||||
11,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->assertEquals($expectedAutolink, $autolink);
|
||||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
|
||||
/** @test **/
|
||||
public function multipleMentions()
|
||||
{
|
||||
$text = 'hello @dansup and @pixelfed.team from @username_underscore';
|
||||
$autolink = Autolink::create()->autolink($text);
|
||||
$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",
|
||||
],
|
||||
"replyto" => null,
|
||||
"hashtags_with_indices" => [],
|
||||
"urls_with_indices" => [],
|
||||
"mentions_with_indices" => [
|
||||
[
|
||||
"screen_name" => "dansup",
|
||||
"indices" => [
|
||||
6,
|
||||
13,
|
||||
],
|
||||
],
|
||||
[
|
||||
"screen_name" => "pixelfed.team",
|
||||
"indices" => [
|
||||
18,
|
||||
32,
|
||||
],
|
||||
],
|
||||
[
|
||||
"screen_name" => "username_underscore",
|
||||
"indices" => [
|
||||
38,
|
||||
58,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
/** @test * */
|
||||
public function multipleMentions()
|
||||
{
|
||||
$text = 'hello @dansup and @pixelfed.team from @username_underscore';
|
||||
$autolink = Autolink::create()->autolink($text);
|
||||
$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',
|
||||
],
|
||||
'replyto' => null,
|
||||
'hashtags_with_indices' => [],
|
||||
'urls_with_indices' => [],
|
||||
'mentions_with_indices' => [
|
||||
[
|
||||
'screen_name' => 'dansup',
|
||||
'indices' => [
|
||||
6,
|
||||
13,
|
||||
],
|
||||
],
|
||||
[
|
||||
'screen_name' => 'pixelfed.team',
|
||||
'indices' => [
|
||||
18,
|
||||
32,
|
||||
],
|
||||
],
|
||||
[
|
||||
'screen_name' => 'username_underscore',
|
||||
'indices' => [
|
||||
38,
|
||||
58,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEquals($expectedAutolink, $autolink);
|
||||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
$this->assertEquals($expectedAutolink, $autolink);
|
||||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,20 +4,18 @@ namespace Tests\Unit;
|
|||
|
||||
use Purify;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
class PurifierTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
/** @test */
|
||||
public function puckTest()
|
||||
{
|
||||
$actual = Purify::clean("<span class=\"fa-spin fa\">catgirl spinning around in the interblag</span>");
|
||||
$expected = '<span>catgirl spinning around in the interblag</span>';
|
||||
$actual = Purify::clean("<span class=\"fa-spin fa\">catgirl spinning around in the interblag</span>");
|
||||
$expected = '<span>catgirl spinning around in the interblag</span>';
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$actual = Purify::clean("<p class=\"fa-spin fa\">catgirl spinning around in the interblag</p>");
|
||||
$expected = '<p>catgirl spinning around in the interblag</p>';
|
||||
$actual = Purify::clean("<p class=\"fa-spin fa\">catgirl spinning around in the interblag</p>");
|
||||
$expected = '<p>catgirl spinning around in the interblag</p>';
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$actual = Purify::clean('<a class="navbar-brand d-flex align-items-center" href="https://pixelfed.social" title="Logo"><img src="/img/pixelfed-icon-color.svg" height="30px" class="px-2"><span class="font-weight-bold mb-0 d-none d-sm-block" style="font-size:20px;">pixelfed</span></a>');
|
||||
|
|
|
@ -3,15 +3,14 @@
|
|||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Services\SnowflakeService;
|
||||
|
||||
class SnowflakeTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function snowflakeTest()
|
||||
{
|
||||
$expected = 266077397319815168;
|
||||
$actual = 266077397319815168;
|
||||
$this->assertEquals($expected, $actual);
|
||||
$expected = 266077397319815168;
|
||||
$actual = 266077397319815168;
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,47 +2,47 @@
|
|||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Util\Lexer\Nickname;
|
||||
use Tests\TestCase;
|
||||
|
||||
class WebfingerTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function webfingerTest()
|
||||
{
|
||||
$expected = [
|
||||
"domain" => "pixelfed.org",
|
||||
"username" => "dansup",
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('acct:dansup@pixelfed.org');
|
||||
$this->assertEquals($expected, $actual);
|
||||
/** @test */
|
||||
public function webfingerTest()
|
||||
{
|
||||
$expected = [
|
||||
'domain' => 'pixelfed.org',
|
||||
'username' => 'dansup',
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('acct:dansup@pixelfed.org');
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$expected = [
|
||||
"domain" => "pixelfed.org",
|
||||
"username" => "dansup_",
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('acct:dansup@pixelfed.org');
|
||||
$this->assertNotEquals($expected, $actual);
|
||||
$expected = [
|
||||
'domain' => 'pixelfed.org',
|
||||
'username' => 'dansup_',
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('acct:dansup@pixelfed.org');
|
||||
$this->assertNotEquals($expected, $actual);
|
||||
|
||||
$expected = [
|
||||
"domain" => "pixelfed.org",
|
||||
"username" => "dansup",
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('acct:@dansup@pixelfed.org');
|
||||
$this->assertEquals($expected, $actual);
|
||||
$expected = [
|
||||
'domain' => 'pixelfed.org',
|
||||
'username' => 'dansup',
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('acct:@dansup@pixelfed.org');
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$expected = [
|
||||
"domain" => "pixelfed.org",
|
||||
"username" => "dansup",
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('dansup@pixelfed.org');
|
||||
$this->assertEquals($expected, $actual);
|
||||
$expected = [
|
||||
'domain' => 'pixelfed.org',
|
||||
'username' => 'dansup',
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('dansup@pixelfed.org');
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$expected = [
|
||||
"domain" => "pixelfed.org",
|
||||
"username" => "dansup",
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('@dansup@pixelfed.org');
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
$expected = [
|
||||
'domain' => 'pixelfed.org',
|
||||
'username' => 'dansup',
|
||||
];
|
||||
$actual = Nickname::normalizeProfileUrl('@dansup@pixelfed.org');
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue