From e48ce8a94eaaea2c2c2c4f63c400f681ce1a4999 Mon Sep 17 00:00:00 2001 From: Armin Date: Wed, 27 Feb 2019 02:34:44 +0100 Subject: [PATCH] Test fixes + add remove from outbox collection step --- test/features/activity-delete.feature | 55 +++++++++++++++++++ test/features/activity-delete.feature.disable | 28 ---------- test/features/activity-follow.feature | 1 - ...feature.disable => object-article.feature} | 2 +- test/features/support/steps.js | 9 +-- test/features/world.js | 2 +- 6 files changed, 62 insertions(+), 35 deletions(-) create mode 100644 test/features/activity-delete.feature delete mode 100644 test/features/activity-delete.feature.disable rename test/features/{activity-article.feature.disable => object-article.feature} (96%) diff --git a/test/features/activity-delete.feature b/test/features/activity-delete.feature new file mode 100644 index 000000000..0e0d13253 --- /dev/null +++ b/test/features/activity-delete.feature @@ -0,0 +1,55 @@ +Feature: Delete an object + I want to delete objects + + Background: + Given our own server runs at "http://localhost:4100" + And we have the following users in our database: + | Slug | + | bernd-das-brot| + And I send a POST request with the following activity to "/activitypub/users/bernd-das-brot/inbox": + """ + { + "@context": "https://www.w3.org/ns/activitystreams", + "id": "https://aronda.org/users/bernd-das-brot/status/lka7dfzkjn2398hsfd", + "type": "Create", + "actor": "https://aronda.org/users/bernd-das-brot", + "object": { + "id": "https://aronda.org/users/bernd-das-brot/status/kljsdfg9843jknsdf", + "type": "Article", + "published": "2019-02-07T19:37:55.002Z", + "attributedTo": "https://aronda.org/users/bernd-das-brot", + "content": "Hi Max, how are you?", + "to": "https://localhost:4100/activitypub/users/moritz" + } + } + """ + + Scenario: Deleting a post (Article Object) + When I send a POST request with the following activity to "/activitypub/users/bernd-das-brot/inbox": + """ + { + "@context": "https://www.w3.org/ns/activitystreams", + "id": "https://localhost:4100/users/karl-heinz/status/a4DJ2afdg323v32641vna42lkj685kasd2", + "type": "Delete", + "object": { + "id": "https://aronda.org/users/bernd-das-brot/status/kljsdfg9843jknsdf", + "type": "Article", + "published": "2019-02-07T19:37:55.002Z", + "attributedTo": "https://aronda.org/users/bernd-das-brot", + "content": "Hi Max, how are you?", + "to": "https://localhost:4100/activitypub/users/moritz" + } + } + """ + Then I expect the status code to be 200 + And the object is removed from the outbox collection of "bernd-das-brot" + """ + { + "id": "https://aronda.org/users/bernd-das-brot/status/kljsdfg9843jknsdf", + "type": "Article", + "published": "2019-02-07T19:37:55.002Z", + "attributedTo": "https://aronda.org/users/bernd-das-brot", + "content": "Hi Max, how are you?", + "to": "https://localhost:4100/activitypub/users/moritz" + } + """ diff --git a/test/features/activity-delete.feature.disable b/test/features/activity-delete.feature.disable deleted file mode 100644 index 9d671500f..000000000 --- a/test/features/activity-delete.feature.disable +++ /dev/null @@ -1,28 +0,0 @@ -Feature: Delete an object - I want to delete objects - - Background: - Given our own server runs at "http://localhost:4100" - And we have the following users in our database: - | Slug | - | bernd-das-brot| - - Scenario: Deleting a post (Article Object) - When I send a POST request with the following activity to "/activitypub/users/bernd-das-brot/inbox": - """ - { - "@context": "https://www.w3.org/ns/activitystreams", - "id": "https://localhost:4100/users/karl-heinz/status/a4DJ2afdg323v32641vna42lkj685kasd2", - "type": "Delete", - "object": { - "id": "https://aronda.org/users/marvin/status/kljsdfg9843jknsdf", - "type": "Article", - "published": "2019-02-07T19:37:55.002Z", - "attributedTo": "https://aronda.org/users/marvin", - "content": "Hi John, how are you?", - "to": "https://localhost:4100/activitypub/users/max" - } - } - """ - Then I expect the status code to be 200 - And the object is removed from the outbox collection of "karl-heinz" diff --git a/test/features/activity-follow.feature b/test/features/activity-follow.feature index 0797279d8..578e57cb1 100644 --- a/test/features/activity-follow.feature +++ b/test/features/activity-follow.feature @@ -36,7 +36,6 @@ Feature: Follow a user "type": "Undo", "actor": "http://localhost:4123/activitypub/users/peter-lustiger", "object": { - "@context": "https://www.w3.org/ns/activitystreams", "id": "https://localhost:4123/activitypub/users/bob-der-baumeister/status/83J23549sda1k72fsa4567na42312455kad83", "type": "Follow", "actor": "http://localhost:4123/activitypub/users/bob-der-baumeister", diff --git a/test/features/activity-article.feature.disable b/test/features/object-article.feature similarity index 96% rename from test/features/activity-article.feature.disable rename to test/features/object-article.feature index 858f85473..0a8af2606 100644 --- a/test/features/activity-article.feature.disable +++ b/test/features/object-article.feature @@ -21,7 +21,7 @@ Feature: Send and receive Articles "type": "Article", "published": "2019-02-07T19:37:55.002Z", "attributedTo": "https://aronda.org/users/marvin", - "content": "Hi John, how are you?", + "content": "Hi Max, how are you?", "to": "https://localhost:4100/activitypub/users/max" } } diff --git a/test/features/support/steps.js b/test/features/support/steps.js index 454db0e31..7f7bde455 100644 --- a/test/features/support/steps.js +++ b/test/features/support/steps.js @@ -108,16 +108,17 @@ Then('the post with id {string} to be created', async function (id) { const result = await client.request(` query { Post(id: "${id}") { - name + title } } `) - expect(result.data.Post).to.be.an('array').that.is.not.empty // eslint-disable-line }) -Then('the object is removed from the outbox collection of {string}', (name) => { - +Then('the object is removed from the outbox collection of {string}', async function (name, object) { + const response = await this.get(`/activitypub/users/${name}/outbox?page=true`) + const parsedResponse = JSON.parse(response.lastResponse) + expect(parsedResponse.orderedItems).to.not.include(object) }) Then('I send a GET request to {string} and expect a ordered collection', () => { diff --git a/test/features/world.js b/test/features/world.js index 26282f45a..9a27bd154 100644 --- a/test/features/world.js +++ b/test/features/world.js @@ -10,7 +10,7 @@ class CustomWorld { this.lastContentType = null this.lastInboxUrl = null this.lastActivity = null - // activity-article.feature.disable + // object-article.feature this.statusCode = null } get (pathname) {