Skip to content

Commit

Permalink
Improved Cucumber tests and used WireMock (#23)
Browse files Browse the repository at this point in the history
no-issue

I've added wiremock here as a starting point for allowing us to mock network requests
The cucumber steps have been updated to try and be a little more fluent and reusable.
  • Loading branch information
allouis authored Aug 13, 2024
1 parent 44742ee commit 62aef77
Show file tree
Hide file tree
Showing 6 changed files with 338 additions and 121 deletions.
24 changes: 20 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ services:
volumes:
- ./src:/opt/activitypub/src
environment:
- PORT=8080
- PORT=8083
- MYSQL_USER=ghost
- MYSQL_PASSWORD=password
- MYSQL_HOST=mysql-testing
- MYSQL_PORT=3306
- MYSQL_DATABASE=activitypub
- NODE_ENV=testing
- SKIP_SIGNATURE_VERIFICATION=true
command: node --import tsx src/app.ts
command: node --import tsx --watch src/app.ts
depends_on:
mysql-testing:
condition: service_healthy
healthcheck:
test: "wget --spider http://0.0.0.0:8080/ping"
test: "wget --spider http://0.0.0.0:8083/ping"
interval: 1s
retries: 120

Expand All @@ -66,11 +66,18 @@ services:
- ./features:/opt/activitypub/features
- ./cucumber.js:/opt/activitypub/cucumber.js
environment:
- MYSQL_USER=ghost
- MYSQL_PASSWORD=password
- MYSQL_HOST=mysql-testing
- MYSQL_PORT=3306
- MYSQL_DATABASE=activitypub
- NODE_ENV=testing
command: yarn run cucumber-js
depends_on:
wiremock:
condition: service_started
activitypub-testing:
condition: service_healthy
condition: service_healthy


mysql-testing:
Expand All @@ -84,3 +91,12 @@ services:
test: "mysql -ughost -ppassword activitypub -e 'select 1'"
interval: 1s
retries: 120

wiremock:
image: wiremock/wiremock:latest
ports:
- "8082:8080"
volumes:
- ./wiremock/mappings:/home/wiremock/mappings
- ./wiremock/__files:/home/wiremock/__files
entrypoint: ["/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose"]
9 changes: 9 additions & 0 deletions features/accept-follows.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: We automatically accept Follow requests

Scenario: We can be followed
Given an Actor "Alice"
Given a "Follow(Us)" Activity "F" by "Alice"
When "Alice" sends "F" to the Inbox
Then an "Accept(F)" Activity "A" is created by "Us"
And Activity "A" is sent to "Alice"
And "Alice" is in our Followers
8 changes: 4 additions & 4 deletions features/handle-create-article.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Feature: Create(Article)
We want to handle Create(Article) activities in the Inbox

Scenario: We recieve a Create(Article) activity from someone we follow
Given a valid "Create(Article)" activity
Given the actor is "known"
When it is sent to the Inbox
Given an Actor "Alice"
Given a "Create(Article)" Activity "A" by "Alice"
When "Alice" sends "A" to the Inbox
Then the request is accepted
Then the activity is in the Inbox
Then "A" is in our Inbox
Loading

0 comments on commit 62aef77

Please sign in to comment.