-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added e2e tests for API endpoints #62
Open
mike182uk
wants to merge
3
commits into
main
Choose a base branch
from
add-e2e-tests-for-api-endpoints
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ services: | |
- NODE_ENV=testing | ||
- SKIP_SIGNATURE_VERIFICATION=true | ||
- ALLOW_PRIVATE_ADDRESS=true | ||
- NODE_TLS_REJECT_UNAUTHORIZED=0 | ||
command: node --import tsx --watch src/app.ts | ||
depends_on: | ||
mysql-testing: | ||
|
@@ -112,28 +113,29 @@ services: | |
activitypub-testing: | ||
condition: service_healthy | ||
|
||
|
||
mysql-testing: | ||
image: mysql:8.0.31 | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=root | ||
- MYSQL_USER=ghost | ||
- MYSQL_PASSWORD=password | ||
- MYSQL_DATABASE=activitypub | ||
ports: | ||
- "3308:3306" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useful for debugging test db |
||
healthcheck: | ||
test: "mysql -ughost -ppassword activitypub -e 'select 1'" | ||
interval: 1s | ||
retries: 120 | ||
|
||
fake-ghost-activitypub: | ||
image: wiremock/wiremock:3.9.2-1 | ||
entrypoint: ["/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose", "--port=80"] | ||
entrypoint: ["/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose", "--port=80", "--https-port=443"] | ||
volumes: | ||
- ./wiremock/fake-ghost/mappings:/home/wiremock/mappings | ||
|
||
fake-external-activitypub: | ||
image: wiremock/wiremock:3.9.2-1 | ||
entrypoint: ["/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose", "--port=80"] | ||
entrypoint: ["/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose", "--port=80", "--https-port=443"] | ||
|
||
fake-mastodon: | ||
image: wiremock/wiremock:3.9.2-1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@api | ||
Feature: Profile | ||
In order to view the details of a profile | ||
As an API user | ||
I want to be able to retrieve a profile | ||
|
||
Scenario: Succesfully retreiving a profile | ||
Given an Actor "Alice" | ||
When I request the profile for "Alice" | ||
Then the response has a 200 status code | ||
And the response body contains the profile for "Alice" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@api | ||
Feature: Search | ||
In order to find the details of an actor | ||
As an API user | ||
I want to be able to search for an actor | ||
|
||
Scenario: Succesfully searching for an actor | ||
Given an Actor "Alice" | ||
When I search for "Alice" | ||
Then the response has a 200 status code | ||
And the response body contains search results for "Alice" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,7 @@ await configure({ | |
filters: {}, | ||
loggers: [ | ||
{ category: 'activitypub', sinks: ['console'], level: 'info' }, | ||
{ category: 'fedify', sinks: ['console'], level: 'warning' } | ||
{ category: 'fedify', sinks: ['console'], level: process.env.NODE_ENV === 'testing' ? 'debug' : 'warning' } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. debug was useful to figure out why my test wasn't working 😅 |
||
], | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -266,8 +266,7 @@ describe('isFollowing', () => { | |
describe('isHandle', () => { | ||
it('should return a boolean indicating if the provided string is a handle', () => { | ||
expect(isHandle('@[email protected]')).toBe(true); | ||
expect(isHandle('@[email protected]/bar')).toBe(false); | ||
expect(isHandle('@foo@example')).toBe(false); | ||
expect(isHandle('@foo@example')).toBe(true); | ||
expect(isHandle('@example.com')).toBe(false); | ||
expect(isHandle('@foo')).toBe(false); | ||
expect(isHandle('@@foo')).toBe(false); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allouis I needed to add this otherwise the webfinger lookup on the
fake-external-activitypub
would not work.When Fedify does the lookup based on just being provided a handle (
@[email protected]
) it defaults to usinghttps
so i had to expose the--https-port
on the wiremock containers. This uses a self signed certificate, so had to enableNODE_TLS_REJECT_UNAUTHORIZED
so that node didn't complain about the certificate.Not sure if i've not set something up correct somewhere thats meaning i need to do this?