|
@@ -6,6 +6,11 @@
|
|
|
|
|
|
using namespace kbf;
|
|
|
|
|
|
+extern const unsigned char cert_pem_start[] asm("_binary_cert_pem_start");
|
|
|
+extern const unsigned char cert_pem_end[] asm("_binary_cert_pem_end");
|
|
|
+extern const unsigned char key_pem_start[] asm("_binary_key_pem_start");
|
|
|
+extern const unsigned char key_pem_end[] asm("_binary_key_pem_end");
|
|
|
+
|
|
|
class CounterController : public WebService::Controller {
|
|
|
public:
|
|
|
CounterController() : Controller("/counter") {}
|
|
@@ -42,26 +47,27 @@ TEST_CASE("WebService", "[kbf_web_service]") {
|
|
|
auto webService = WebService();
|
|
|
webService.controller<CounterController>();
|
|
|
webService.controller<EchoController>();
|
|
|
- webService.start();
|
|
|
+ webService.startSSL(cert_pem_start, cert_pem_end, key_pem_start, key_pem_end);
|
|
|
|
|
|
+ http::Client::addCert(cert_pem_start, cert_pem_end);
|
|
|
auto client = http::Client();
|
|
|
|
|
|
- auto response = client.get("http://localhost/counter");
|
|
|
+ auto response = client.get("https://localhost/counter");
|
|
|
TEST_ASSERT_EQUAL(200, response->status);
|
|
|
TEST_ASSERT_EQUAL_STRING("0", response->body.c_str());
|
|
|
|
|
|
- response = client.get("http://localhost/counter");
|
|
|
+ response = client.get("https://localhost/counter");
|
|
|
TEST_ASSERT_EQUAL_STRING("1", response->body.c_str());
|
|
|
|
|
|
- response = client.post("http://localhost/counter", {{"str", "notallowed"}});
|
|
|
+ response = client.post("https://localhost/counter", {{"str", "notallowed"}});
|
|
|
TEST_ASSERT_EQUAL(405, response->status);
|
|
|
TEST_ASSERT_EQUAL_STRING("method not allowed", response->body.c_str());
|
|
|
|
|
|
- response = client.get("http://localhost/echo?str=foo");
|
|
|
+ response = client.get("https://localhost/echo?str=foo");
|
|
|
TEST_ASSERT_EQUAL(200, response->status);
|
|
|
TEST_ASSERT_EQUAL_STRING("foo", response->body.c_str());
|
|
|
|
|
|
- response = client.post("http://localhost/echo", {{"str", "bar"}});
|
|
|
+ response = client.post("https://localhost/echo", {{"str", "bar"}});
|
|
|
TEST_ASSERT_EQUAL(200, response->status);
|
|
|
TEST_ASSERT_EQUAL_STRING("bar", response->body.c_str());
|
|
|
|