Skip to content
Snippets Groups Projects
Verified Commit d0930051 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Run tls server on different port

parent e26d4f6d
No related branches found
No related tags found
1 merge request!1Add basic CI
......@@ -13,14 +13,12 @@ build:
- export PATH="$PATH:/root/.local/bin"
- pip3 install --user reuse
- ./scripts/run_tls_testserver.sh &
- ./scripts/run_testserver.sh &
script:
- meson setup builddir -Db_coverage=true -Dtests=true -Dexamples=true
- meson compile -C builddir
- ./builddir/tests/requests_tls -d
- kill %1
- ./scripts/run_testserver.sh &
- sleep 2
- ./builddir/tests/requests_tls -d
- ./builddir/tests/requests -d
- ./builddir/examples/coeurl_example
- ninja -C builddir coverage-text
- grep TOTAL builddir/meson-logs/coverage.txt
......@@ -16,8 +16,8 @@ TEST_CASE("Basic request") {
Client g{};
g.set_verify_peer(false);
g.get("https://localhost:5000/", [&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/");
g.get("https://localhost:5443/", [&g](const Request &r) {
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.error_code() == CURLE_OK);
CHECK(r.response() == "OK");
......@@ -34,8 +34,8 @@ TEST_CASE("Basic request on bg thread") {
std::thread t([&g]() { g.run(); });
g.get("https://localhost:5000/", [&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/");
g.get("https://localhost:5443/", [&g](const Request &r) {
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.response() == "OK");
CHECK(r.response_headers()["content-type"] == "text/plain; charset=utf-8");
......@@ -50,9 +50,9 @@ TEST_CASE("Basic manual request") {
g.set_verify_peer(false);
auto r = std::make_shared<Request>(&g, Request::Method::GET,
"https://localhost:5000/");
"https://localhost:5443/");
r->on_complete([&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/");
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.response() == "OK");
CHECK(r.response_headers()["content-type"] == "text/plain; charset=utf-8");
......@@ -69,9 +69,9 @@ TEST_CASE("Basic redirect") {
g.set_verify_peer(false);
g.get(
"https://localhost:5000/redirect",
"https://localhost:5443/redirect",
[&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/redirect");
CHECK(r.url() == "https://localhost:5443/redirect");
CHECK(r.response_code() == 200);
CHECK(r.response() == "OK");
g.close();
......@@ -84,9 +84,9 @@ TEST_CASE("No redirect") {
g.set_verify_peer(false);
g.get(
"https://localhost:5000/redirect",
"https://localhost:5443/redirect",
[&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/redirect");
CHECK(r.url() == "https://localhost:5443/redirect");
CHECK(r.response_code() == 302);
g.close();
},
......@@ -100,9 +100,9 @@ TEST_CASE("Max redirects") {
g.set_verify_peer(false);
g.get(
"https://localhost:5000/double_redirect",
"https://localhost:5443/double_redirect",
[&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/double_redirect");
CHECK(r.url() == "https://localhost:5443/double_redirect");
CHECK(r.response_code() == 302);
g.close();
},
......@@ -116,10 +116,10 @@ TEST_CASE("Basic manual POST request") {
g.set_verify_peer(false);
auto r = std::make_shared<Request>(&g, Request::Method::POST,
"https://localhost:5000/post");
"https://localhost:5443/post");
r->request("ABCD");
r->on_complete([&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/post");
CHECK(r.url() == "https://localhost:5443/post");
CHECK(r.response_code() == 200);
CHECK(r.response() == "ABCD");
g.close();
......@@ -135,10 +135,10 @@ TEST_CASE("Basic manual PUT request") {
g.set_verify_peer(false);
auto r = std::make_shared<Request>(&g, Request::Method::PUT,
"https://localhost:5000/put");
"https://localhost:5443/put");
r->request("ABCD");
r->on_complete([&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/put");
CHECK(r.url() == "https://localhost:5443/put");
CHECK(r.response_code() == 200);
CHECK(r.response() == "ABCD");
g.close();
......@@ -154,9 +154,9 @@ TEST_CASE("Basic manual HEAD request") {
g.set_verify_peer(false);
auto r = std::make_shared<Request>(&g, Request::Method::HEAD,
"https://localhost:5000/");
"https://localhost:5443/");
r->on_complete([&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/");
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.response().empty());
g.close();
......@@ -172,9 +172,9 @@ TEST_CASE("Basic manual OPTIONS request") {
g.set_verify_peer(false);
auto r = std::make_shared<Request>(&g, Request::Method::OPTIONS,
"https://localhost:5000/");
"https://localhost:5443/");
r->on_complete([&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/");
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.response_headers()["allow"].find("HEAD") != std::string::npos);
CHECK(r.response_headers()["allow"].find("OPTIONS") != std::string::npos);
......@@ -193,9 +193,9 @@ TEST_CASE("Basic manual DELETE request") {
g.set_verify_peer(false);
auto r = std::make_shared<Request>(&g, Request::Method::DELETE,
"https://localhost:5000/delete");
"https://localhost:5443/delete");
r->on_complete([&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/delete");
CHECK(r.url() == "https://localhost:5443/delete");
CHECK(r.response_code() == 200);
g.close();
......@@ -210,9 +210,9 @@ TEST_CASE("Basic simple POST request") {
Client g{};
g.set_verify_peer(false);
g.post("https://localhost:5000/post", "ABCD", "text/plain",
g.post("https://localhost:5443/post", "ABCD", "text/plain",
[&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/post");
CHECK(r.url() == "https://localhost:5443/post");
CHECK(r.response_code() == 200);
CHECK(r.response() == "ABCD");
g.close();
......@@ -225,9 +225,9 @@ TEST_CASE("Basic simple PUT request") {
Client g{};
g.set_verify_peer(false);
g.put("https://localhost:5000/put", "ABCD", "text/plain",
g.put("https://localhost:5443/put", "ABCD", "text/plain",
[&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/put");
CHECK(r.url() == "https://localhost:5443/put");
CHECK(r.response_code() == 200);
CHECK(r.response() == "ABCD");
g.close();
......@@ -240,8 +240,8 @@ TEST_CASE("Basic simple HEAD request") {
Client g{};
g.set_verify_peer(false);
g.head("https://localhost:5000/", [&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/");
g.head("https://localhost:5443/", [&g](const Request &r) {
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.response().empty());
g.close();
......@@ -254,8 +254,8 @@ TEST_CASE("Basic simple OPTIONS request") {
Client g{};
g.set_verify_peer(false);
g.options("https://localhost:5000/", [&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/");
g.options("https://localhost:5443/", [&g](const Request &r) {
CHECK(r.url() == "https://localhost:5443/");
CHECK(r.response_code() == 200);
CHECK(r.response_headers()["allow"].find("HEAD") != std::string::npos);
CHECK(r.response_headers()["allow"].find("OPTIONS") != std::string::npos);
......@@ -271,8 +271,8 @@ TEST_CASE("Basic simple DELETE request") {
Client g{};
g.set_verify_peer(false);
g.delete_("https://localhost:5000/delete", [&g](const Request &r) {
CHECK(r.url() == "https://localhost:5000/delete");
g.delete_("https://localhost:5443/delete", [&g](const Request &r) {
CHECK(r.url() == "https://localhost:5443/delete");
CHECK(r.response_code() == 200);
g.close();
......
......@@ -34,7 +34,7 @@ def test_delete():
if __name__ == "__main__":
if len(sys.argv) >= 2:
app.run(debug=True, ssl_context=(sys.argv[1]+'/cert.pem', sys.argv[1]+'/key.pem'))
app.run(debug=True, ssl_context=(sys.argv[1]+'/cert.pem', sys.argv[1]+'/key.pem'), port=5443)
else:
app.run(debug=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment