Skip to content

Commit

Permalink
Improved Cucumber tests and used WireMock
Browse files Browse the repository at this point in the history
  • Loading branch information
allouis committed Aug 13, 2024
1 parent 44742ee commit d470829
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 125 deletions.
26 changes: 18 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,35 @@ 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"
interval: 1s
retries: 120

cucumber-tests:
build: .
volumes:
- ./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:
activitypub-testing:
condition: service_healthy
- wiremock
- activitypub-testing


mysql-testing:
Expand All @@ -84,3 +85,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 d470829

Please sign in to comment.