1
0
Fork 0
mirror of https://github.com/fjogeleit/http-request-action.git synced 2024-12-22 20:32:33 +00:00
http-request-action/.github/workflows/it-tests.yml

337 lines
12 KiB
YAML

on:
pull_request:
push:
branches: [main]
jobs:
test-method-get-on-existing-url:
name: "IT Test - Request Postman Echo GET"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with GET and a valid URL
id: execution
uses: ./
with:
url: 'https://postman-echo.com/get'
method: 'GET'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-method-post-on-existing-url:
name: "IT Test - Request Postman Echo POST"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with POST using valid data
id: execution
uses: ./
with:
url: "https://postman-echo.com/post"
method: 'POST'
data: '{ "key": "value" }'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-method-post-on-existing-url-with-unescaped-newline:
name: "IT Test - Request Postman Echo POST with Unescaped Newline"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with POST using unescaped new line within data
id: execution
uses: ./
with:
url: "https://postman-echo.com/post"
method: 'POST'
escapeData: 'true'
data: >-
{
"key":"multi line\ntest
text"
}
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-basic-auth:
name: "IT Test - Request Postman Echo BasicAuth"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with valid BasicAuth parameters
id: execution
uses: ./
with:
url: 'https://postman-echo.com/basic-auth'
method: 'GET'
username: 'postman'
password: 'password'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200 as this URL exists
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-ignore-failure-code-404:
name: "IT Test - Request Postman Echo with 404 Response and ignore failure code"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with unknown URL and ignoreStatusCode 404 for it
id: execution
uses: ./
with:
url: 'https://postman-echo.com/status/404'
method: 'GET'
ignoreStatusCodes: '404'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must 404
with:
expected: '404'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then the outcome value must be success as the error 404 is ignored
with:
expected: 'success'
actual: ${{ steps.execution.outcome }}
comparison: exact
test-input-ignore-failure-multiple-codes-401-404:
name: "IT Test - Request Postman Echo with 404 Response and ignore failure code"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with unknown URL and ignore status codes 401,404
id: execution
uses: ./
with:
url: 'https://postman-echo.com/status/404'
method: 'GET'
ignoreStatusCodes: '401,404'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 404
with:
expected: '404'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then the outcome value must be success as the error 404 is ignored
with:
expected: 'success'
actual: ${{ steps.execution.outcome }}
comparison: exact
test-input-files:
name: "IT Test - Request Postman Echo POST Multipart"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Test File
run: |
echo "test" > testfile.txt
- name: Given the gh-action is used with file and data
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
data: '{ "key": "value" }'
files: '{ "file": "${{ github.workspace }}/testfile.txt" }'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-responseFile:
name: "IT Test - Request Postman Echo POST and persist response"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Test File
run: |
echo "test" > testfile2.txt
- name: Given the gh-action is used with file and responseFile
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
file: "${{ github.workspace }}/testfile2.txt"
responseFile: "${{ github.workspace }}/response.json"
- name: Output responseFile
id: execution-response-file
run: |
echo "response_content=$(cat ${{ github.workspace }}/response.json)" >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.response_content value must include
with:
expected: '{"args":{},"data":"test\n","files":{},"form":{},"headers":{"host":"postman-echo.com",'
actual: ${{ steps.execution-response-file.outputs.response_content }}
comparison: contains
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.response_content value must include
with:
expected: '"accept":"application/json, text/plain, */*","content-type":"application/json","user-agent"'
actual: ${{ steps.execution-response-file.outputs.response_content }}
comparison: contains
test-input-files-without-data:
name: "IT Test - Request Postman Echo POST Multipart without data"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Test File
run: |
echo "test" > testfile3.txt
- name: Given the gh-action is used with file
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
files: '{ "file": "${{ github.workspace }}/testfile3.txt" }'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-file-with-single-file:
name: "IT Test - Request Postman Echo POST single file"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Test File
run: |
echo "test" > testfile4.txt
- name: Given the gh-action is used with file
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
file: "${{ github.workspace }}/testfile4.txt"
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-data-with-url-encoded-string:
name: "IT Test - Request Postman Echo POST URLEncoded string data"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with data form url encoded
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
contentType : 'application/x-www-form-urlencoded'
method: 'POST'
data: 'key=value'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-data-with-url-encoded-json-data:
name: "IT Test - Request Postman Echo POST URLEncoded json data"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with json data
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
contentType : 'application/x-www-form-urlencoded'
method: 'POST'
data: '{"key":"value"}'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-delete-http-method:
name: "IT Test - Request Postman Echo DELETE"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with method DELETE
id: execution
uses: ./
with:
url: 'https://postman-echo.com/delete'
contentType : 'application/json'
method: 'DELETE'
data: '{"key":"value"}'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
it-tests:
name: "All IT Tests have to pass"
runs-on: ubuntu-latest
if: always()
needs:
# Add your tests here so that they prevent the merge of broken changes
- test-method-get-on-existing-url
- test-method-post-on-existing-url
- test-method-post-on-existing-url-with-unescaped-newline
- test-basic-auth
- test-input-ignore-failure-code-404
- test-input-ignore-failure-multiple-codes-401-404
- test-input-files
- test-input-responseFile
- test-input-files-without-data
- test-input-file-with-single-file
- test-input-data-with-url-encoded-string
- test-input-data-with-url-encoded-json-data
- test-delete-http-method
steps:
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
jobs: ${{ toJSON(needs) }}