Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changeset/response-types-integration-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

test(integration): verify response content-type across core HTTP paths
Comment on lines +1 to +4
39 changes: 39 additions & 0 deletions test/integration/features/response-types/response-types.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Feature: HTTP response types
Scenario Outline: GET path returns expected response Content-Type
When a client requests path "<path>" with Accept header "<acceptHeader>"
Then the response status is <statusCode>
And the response Content-Type includes "<contentType>"
Comment on lines +2 to +5

Examples:
| path | acceptHeader | statusCode | contentType |
| / | application/nostr+json | 200 | application/nostr+json |
| / | text/html | 200 | text/html |
| /healthz | */* | 200 | text/plain |
| /terms | */* | 200 | text/html |
| /privacy | */* | 200 | text/html |
| /.well-known/nodeinfo | */* | 200 | application/json |
| /nodeinfo/2.1 | */* | 200 | application/json |
| /nodeinfo/2.0 | */* | 200 | application/json |

Scenario Outline: dynamic GET path returns expected response Content-Type
When a client requests dynamic path "<path>"
Then the response status is <statusCode>
And the response Content-Type includes "<contentType>"
Comment on lines +18 to +21

Examples:
| path | statusCode | contentType |
| /admissions/check/0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef | 200 | application/json |
| /invoices/non-existent-invoice/status | 404 | application/json |

Scenario Outline: POST path returns expected response Content-Type
When a client posts "<body>" to path "<path>" with Content-Type "<contentTypeHeader>"
Then the response status is <statusCode>
And the response Content-Type includes "<contentType>"
Comment on lines +28 to +31

Examples:
| path | contentTypeHeader | body | statusCode | contentType |
| /invoices | application/x-www-form-urlencoded | | 400 | text/plain |
| /callbacks/zebedee | application/json | {} | 403 | text/html |
| /callbacks/lnbits | application/json | {} | 403 | text/html |
| /callbacks/opennode | application/x-www-form-urlencoded | id=test&status=paid | 403 | text/html |
| /callbacks/nodeless | application/json | {} | 403 | text/html |
41 changes: 41 additions & 0 deletions test/integration/features/response-types/response-types.feature.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { When, World } from '@cucumber/cucumber'
import axios, { AxiosResponse } from 'axios'
Comment on lines +1 to +2

const BASE_URL = 'http://localhost:18808'

When(
'a client requests path {string} with Accept header {string}',
async function (this: World<Record<string, any>>, requestPath: string, acceptHeader: string) {
const response: AxiosResponse = await axios.get(`${BASE_URL}${requestPath}`, {
headers: { Accept: acceptHeader },
validateStatus: () => true,
})

this.parameters.httpResponse = response
},
)

When('a client requests dynamic path {string}', async function (this: World<Record<string, any>>, requestPath: string) {
const response: AxiosResponse = await axios.get(`${BASE_URL}${requestPath}`, {
validateStatus: () => true,
})

this.parameters.httpResponse = response
})

When(
'a client posts {string} to path {string} with Content-Type {string}',
async function (
this: World<Record<string, any>>,
body: string,
requestPath: string,
contentTypeHeader: string,
) {
const response: AxiosResponse = await axios.post(`${BASE_URL}${requestPath}`, body, {
headers: { 'content-type': contentTypeHeader },
validateStatus: () => true,
})

this.parameters.httpResponse = response
},
)
Comment on lines +37 to +41
Loading