Skip to content

Commit

Permalink
Add integration tests for the --header option
Browse files Browse the repository at this point in the history
  • Loading branch information
theoforger committed Dec 19, 2024
1 parent 08ef727 commit ab29198
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 0 deletions.
11 changes: 11 additions & 0 deletions integration/hurl/tests_ok/add_header.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
GET http://localhost:8000/add-header
HTTP 200

GET http://localhost:8000/add-header-with-aggregation
header-a: foo
HTTP 200

GET http://localhost:8000/add-header-with-duplicate
header-b: bar
{"message":"hi!"}
HTTP 200
4 changes: 4 additions & 0 deletions integration/hurl/tests_ok/add_header.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'

hurl --header 'header-b:baz' --header 'header-c:qux' tests_ok/add_header.hurl
25 changes: 25 additions & 0 deletions integration/hurl/tests_ok/add_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from app import app
from flask import request


@app.route("/add-header")
def add_header():
assert request.headers.get("header-b") == "baz"
assert request.headers.get("header-c") == "qux"
return ""


@app.route("/add-header-with-aggregation")
def add_header_with_aggregation():
assert request.headers.get("header-a") == "foo"
assert request.headers.get("header-b") == "baz"
assert request.headers.get("header-c") == "qux"
return ""


@app.route("/add-header-with-duplicate")
def add_header_with_duplicate():
assert request.headers.get("header-b") == "bar,baz"
assert request.headers.get("header-c") == "qux"
assert request.get_json()["message"] == "hi!"
return ""
4 changes: 4 additions & 0 deletions integration/hurl/tests_ok/add_header.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -Eeuo pipefail

hurl --header 'header-b:baz' --header 'header-c:qux' tests_ok/add_header.hurl
2 changes: 2 additions & 0 deletions integration/hurl/tests_ok/override_header.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GET http://localhost:8000/override-header
HTTP 200
4 changes: 4 additions & 0 deletions integration/hurl/tests_ok/override_header.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'

hurl --header 'User-Agent: different-user-agent' --header 'Accept: different-accept' --header 'Host: different-host' tests_ok/override_header.hurl
10 changes: 10 additions & 0 deletions integration/hurl/tests_ok/override_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from app import app
from flask import request


@app.route("/override-header")
def override_user_agent():
assert request.headers.get("User-Agent") == "different-user-agent"
assert request.headers.get("Accept") == "different-accept"
assert request.headers.get("Host") == "different-host"
return ""
4 changes: 4 additions & 0 deletions integration/hurl/tests_ok/override_header.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -Eeuo pipefail

hurl --header 'User-Agent: different-user-agent' --header 'Accept: different-accept' --header 'Host: different-host' tests_ok/override_header.hurl

0 comments on commit ab29198

Please sign in to comment.