Add test or Undo of Accept of Follow
Some checks failed
PHP Code Checker / PHP Code Checker (pull_request) Failing after 48s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Successful in 1m5s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Successful in 1m7s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 1m7s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 1m7s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 3m4s
PHPUnit / PHPUnit – PHP 8.4 (pull_request) Successful in 1m19s
Some checks failed
PHP Code Checker / PHP Code Checker (pull_request) Failing after 48s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Successful in 1m5s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Successful in 1m7s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 1m7s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 1m7s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 3m4s
PHPUnit / PHPUnit – PHP 8.4 (pull_request) Successful in 1m19s
This commit is contained in:
parent
8ee1e2cad4
commit
454f489815
3 changed files with 34 additions and 8 deletions
|
@ -61,7 +61,7 @@
|
||||||
],
|
],
|
||||||
"test-debug": [
|
"test-debug": [
|
||||||
"@prepare-test",
|
"@prepare-test",
|
||||||
"@test-gatherpress"
|
"@test-event-sources"
|
||||||
],
|
],
|
||||||
"test-vs-event-list": "phpunit --filter=vs_event_list",
|
"test-vs-event-list": "phpunit --filter=vs_event_list",
|
||||||
"test-the-events-calendar": "phpunit --filter=the_events_calendar",
|
"test-the-events-calendar": "phpunit --filter=the_events_calendar",
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Undo {
|
||||||
$query = new \WP_Query( $args );
|
$query = new \WP_Query( $args );
|
||||||
|
|
||||||
// If no event source with that accept ID is found return.
|
// If no event source with that accept ID is found return.
|
||||||
if ( ! $query->have_posts ) {
|
if ( ! $query->have_posts() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,6 @@ class Test_Event_Sources extends \WP_UnitTestCase {
|
||||||
/**
|
/**
|
||||||
* Test receiving "Accept" of "Follow".
|
* Test receiving "Accept" of "Follow".
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function test_incoming_accept_of_follow() {
|
public function test_incoming_accept_of_follow() {
|
||||||
\add_filter( 'activitypub_defer_signature_verification', '__return_true' );
|
\add_filter( 'activitypub_defer_signature_verification', '__return_true' );
|
||||||
|
@ -258,7 +257,7 @@ class Test_Event_Sources extends \WP_UnitTestCase {
|
||||||
$blog = new Blog();
|
$blog = new Blog();
|
||||||
|
|
||||||
$json = array(
|
$json = array(
|
||||||
'id' => 'https://remote.example/random-id',
|
'id' => 'https://remote.example/random-accept-id',
|
||||||
'type' => 'Accept',
|
'type' => 'Accept',
|
||||||
'actor' => 'https://remote.example/@organizer',
|
'actor' => 'https://remote.example/@organizer',
|
||||||
'object' => array(
|
'object' => array(
|
||||||
|
@ -270,8 +269,8 @@ class Test_Event_Sources extends \WP_UnitTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$event_source = \Event_Bridge_For_ActivityPub\ActivityPub\Model\Event_Source::get_by_id( 'https://remote.example/@organizer' );
|
$event_source = \Event_Bridge_For_ActivityPub\ActivityPub\Model\Event_Source::get_by_id( 'https://remote.example/@organizer' );
|
||||||
$accepted = get_post_meta( $event_source->get__id(), '_event_bridge_or_activitypub_accept_of_follow', true );
|
$accepted = get_post_meta( $event_source->get__id(), '_event_bridge_for_activitypub_accept_of_follow', true );
|
||||||
$this->assertNotFalse( $accepted );
|
$this->assertEmpty( $accepted );
|
||||||
|
|
||||||
// Receive Accept.
|
// Receive Accept.
|
||||||
$request = new WP_REST_Request( 'POST', '/activitypub/1.0/users/0/inbox' );
|
$request = new WP_REST_Request( 'POST', '/activitypub/1.0/users/0/inbox' );
|
||||||
|
@ -280,10 +279,37 @@ class Test_Event_Sources extends \WP_UnitTestCase {
|
||||||
$response = \rest_do_request( $request );
|
$response = \rest_do_request( $request );
|
||||||
$this->assertEquals( 202, $response->get_status() );
|
$this->assertEquals( 202, $response->get_status() );
|
||||||
|
|
||||||
|
$accepted = get_post_meta( $event_source->get__id(), '_event_bridge_for_activitypub_accept_of_follow', true );
|
||||||
|
|
||||||
$accepted = get_post_meta( $event_source->get__id(), '_event_bridge_or_activitypub_accept_of_follow', true );
|
$this->assertEquals( 'https://remote.example/random-accept-id', $accepted );
|
||||||
|
|
||||||
$this->assertNotFalse( $accepted );
|
// Receive Undo of the Accept.
|
||||||
|
$json = array(
|
||||||
|
'id' => 'https://remote.example/random-undo-id',
|
||||||
|
'type' => 'Undo',
|
||||||
|
'actor' => 'https://remote.example/@organizer',
|
||||||
|
'object' => array(
|
||||||
|
'id' => 'https://remote.example/random-accept-id',
|
||||||
|
'type' => 'Accept',
|
||||||
|
'actor' => 'https://remote.example/@organizer',
|
||||||
|
'object' => array(
|
||||||
|
'id' => Event_Sources::compose_follow_id( $blog->get_id(), 'https://remote.example/@organizer' ),
|
||||||
|
'type' => 'Follow',
|
||||||
|
'to' => 'https://www.w3.org/ns/activitystreams#Public',
|
||||||
|
'object' => 'https://remote.example/@organizer',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$request = new WP_REST_Request( 'POST', '/activitypub/1.0/users/0/inbox' );
|
||||||
|
$request->set_header( 'Content-Type', 'application/activity+json' );
|
||||||
|
$request->set_body( \wp_json_encode( $json ) );
|
||||||
|
$response = \rest_do_request( $request );
|
||||||
|
$this->assertEquals( 202, $response->get_status() );
|
||||||
|
|
||||||
|
$accepted = get_post_meta( $event_source->get__id(), '_event_bridge_for_activitypub_accept_of_follow', true );
|
||||||
|
|
||||||
|
$this->assertEmpty( $accepted );
|
||||||
|
|
||||||
\remove_filter( 'activitypub_defer_signature_verification', '__return_true' );
|
\remove_filter( 'activitypub_defer_signature_verification', '__return_true' );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue