Skip to content
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

Fix device/test_http_client tests #5309

Merged
merged 5 commits into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 14 additions & 6 deletions tests/device/test_http_client/test_http_client.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ TEST_CASE("HTTP GET & POST requests", "[HTTPClient]")
{
{
// small request
WiFiClient client;
HTTPClient http;
http.begin(getenv("SERVER_IP"), 8088, "/");
http.begin(client, getenv("SERVER_IP"), 8088, "/");
auto httpCode = http.GET();
REQUIRE(httpCode == HTTP_CODE_OK);
String payload = http.getString();
REQUIRE(payload == "hello!!!");
}
{
// request which returns 8000 bytes
WiFiClient client;
HTTPClient http;
http.begin(getenv("SERVER_IP"), 8088, "/data?size=8000");
http.begin(client, getenv("SERVER_IP"), 8088, "/data?size=8000");
auto httpCode = http.GET();
REQUIRE(httpCode == HTTP_CODE_OK);
String payload = http.getString();
Expand All @@ -48,17 +50,20 @@ TEST_CASE("HTTP GET & POST requests", "[HTTPClient]")
}
{
// can do two POST requests with one HTTPClient object (#1902)
WiFiClient client;
HTTPClient http;
http.begin(getenv("SERVER_IP"), 8088, "/");
http.begin(client, getenv("SERVER_IP"), 8088, "/");
http.addHeader("Content-Type", "text/plain");
auto httpCode = http.POST("foo");
Serial.println(httpCode);
REQUIRE(httpCode == HTTP_CODE_OK);
/* TBD: This test is broken because end() nulls the client*
liebman marked this conversation as resolved.
Show resolved Hide resolved
http.end();

httpCode = http.POST("bar");
REQUIRE(httpCode == HTTP_CODE_OK);
http.end();
*/
}
}

Expand All @@ -67,17 +72,21 @@ TEST_CASE("HTTPS GET request", "[HTTPClient]")
{
{
// small request
BearSSL::WiFiClientSecure client;
client.setInsecure();
HTTPClient http;
http.begin(getenv("SERVER_IP"), 8088, "/", fp);
http.begin(client, getenv("SERVER_IP"), 8088, "/", fp);
auto httpCode = http.GET();
REQUIRE(httpCode == HTTP_CODE_OK);
String payload = http.getString();
REQUIRE(payload == "hello!!!");
}
{
// request which returns 4000 bytes
BearSSL::WiFiClientSecure client;
client.setInsecure();
HTTPClient http;
http.begin(getenv("SERVER_IP"), 8088, "/data?size=4000", fp);
http.begin(client, getenv("SERVER_IP"), 8088, "/data?size=4000", fp);
auto httpCode = http.GET();
REQUIRE(httpCode == HTTP_CODE_OK);
String payload = http.getString();
Expand All @@ -89,7 +98,6 @@ TEST_CASE("HTTPS GET request", "[HTTPClient]")
}
}
}

}

void loop()
Expand Down
2 changes: 2 additions & 0 deletions tests/device/test_http_client/test_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import urllib2
import os
import ssl
import time

@setup('HTTP GET & POST requests')
def setup_http_get(e):
Expand Down Expand Up @@ -34,6 +35,7 @@ def flaskThread():
def teardown_http_get(e):
response = urllib2.urlopen('http://localhost:8088/shutdown')
html = response.read()
time.sleep(30)


@setup('HTTPS GET request')
Expand Down