-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create main.cpp * Update tests.mk * Create cookie.test.mk * Update testbuild.yml * Update http.hpp * Update cookies.cpp * Update http.hpp * Update main.cpp * Update main.cpp * Added stupid headers test
- Loading branch information
Showing
10 changed files
with
111 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
# Test cookie core/http module | ||
TEST_COOKIE_TARGET = $(EXEPFX)cookie.test$(EXEEXT) | ||
test.cookie: $(TEST_COOKIE_TARGET) | ||
$(TEST_COOKIE_TARGET) | ||
|
||
$(TEST_COOKIE_TARGET): tests/cookie/main.o $(LIB_CORE_HTTP) $(LIB_CORE_POLYFILL) | ||
g++ $(CFLAGS) tests/cookie/main.cpp $(LIB_CORE_HTTP) $(LIB_CORE_POLYFILL) -o $(TEST_COOKIE_TARGET) | ||
|
||
tests/cookie/main.o: tests/cookie/main.cpp | ||
g++ -c $(CFLAGS) tests/cookie/main.cpp -o tests/cookie/main.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <iostream> | ||
#include <stdexcept> | ||
|
||
#include "../../lambda.hpp" | ||
|
||
using namespace Lambda; | ||
|
||
int main(int argc, char const *argv[]) { | ||
|
||
/* | ||
Check for serialization errors resulling in incorrect or garbage data | ||
*/ | ||
static const std::string compareValid = "userid=test_user_0\nx_lambda=control; Secure; expires=23 Oct 2077 08:28:00 GMT"; | ||
|
||
for (size_t i = 0; i < 100; i++) { | ||
|
||
auto newCookies = HTTP::Cookies(); | ||
newCookies.set("userid", "test_user_0"); | ||
newCookies.set("x_lambda", "control", { | ||
"Secure", | ||
{ "expires", "23 Oct 2077 08:28:00 GMT" } | ||
}); | ||
|
||
const auto generated = Strings::join(newCookies.serialize(), "\n"); | ||
|
||
if (generated != compareValid) { | ||
std::cout << "Cookie run # " << i << " produced invalid result:\n" << generated << "\n\n"; | ||
throw std::runtime_error("Invalid serialization result"); | ||
} | ||
} | ||
|
||
puts("Cookie serialization test ok"); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
# Test headers core/http module | ||
TEST_HEADERS_TARGET = $(EXEPFX)headers.test$(EXEEXT) | ||
test.headers: $(TEST_HEADERS_TARGET) | ||
$(TEST_HEADERS_TARGET) | ||
|
||
$(TEST_HEADERS_TARGET): tests/headers/main.o $(LIB_CORE_HTTP) $(LIB_CORE_POLYFILL) | ||
g++ $(CFLAGS) tests/headers/main.cpp $(LIB_CORE_HTTP) $(LIB_CORE_POLYFILL) -o $(TEST_HEADERS_TARGET) | ||
|
||
tests/headers/main.o: tests/headers/main.cpp | ||
g++ -c $(CFLAGS) tests/headers/main.cpp -o tests/headers/main.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <iostream> | ||
#include <stdexcept> | ||
|
||
#include "../../lambda.hpp" | ||
|
||
using namespace Lambda; | ||
|
||
static const std::string compareData = "connection: upgrade\r\ncontent-length: 100\r\ncontent-encoding: br\r\n"; | ||
|
||
int main(int argc, char const *argv[]) { | ||
|
||
HTTP::Headers headers = { | ||
{ "ContenT-encoDinG", "br" }, | ||
{ " content-length \t", "\t 100 " }, | ||
{ "connection", "upgrade" } | ||
}; | ||
|
||
std::string headersSerialized; | ||
|
||
for (const auto& item : headers.entries()) { | ||
headersSerialized += item.first + ": " + item.second + "\r\n"; | ||
} | ||
|
||
if (headersSerialized != compareData) { | ||
throw std::runtime_error("Serialized data mistmatch"); | ||
} | ||
|
||
puts("Headers serialization test ok"); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters