-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathproxy_handler_test.cpp
45 lines (35 loc) · 1.2 KB
/
proxy_handler_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "gtest/gtest.h"
#include "request.hpp"
#include "response.hpp"
#include "proxy_handler.hpp"
#include "request_handler.hpp"
#include "config_parser.h"
#include <string>
#include <limits.h>
#include <unistd.h>
namespace http {
namespace server {
class ProxyHandlerTest : public ::testing::Test {
protected:
RequestHandler::Status Init() {
Response resp;
NginxConfig* config = new NginxConfig();
NginxConfigStatement* st = new NginxConfigStatement();
st->tokens_.push_back("root");
st->tokens_.push_back("ucla.edu");
return proxy_handler_.Init("/proxy", *config);
}
ProxyHandler proxy_handler_;
};
TEST_F(ProxyHandlerTest, InitTest) {
EXPECT_EQ(404, Init());
}
TEST_F(ProxyHandlerTest, BadRequestTest) {
Response resp;
std::string body = "GET /proxy HTTP/1.1\r\n\r\n";
std::unique_ptr<Request> req = Request::Parse(body);
Init();
EXPECT_EQ("HTTP/1.1 500 Internal Server Error\r\n", resp.ToString());
}
}
}