6#include <boost/test/unit_test.hpp>
17BOOST_AUTO_TEST_SUITE(torcontrol_tests)
30 "PROTOCOLINFO PIVERSION",
31 "PROTOCOLINFO",
"PIVERSION");
33 "AUTH METHODS=COOKIE,SAFECOOKIE COOKIEFILE=\"/home/x/.tor/control_auth_cookie\"",
34 "AUTH",
"METHODS=COOKIE,SAFECOOKIE COOKIEFILE=\"/home/x/.tor/control_auth_cookie\"");
37 "AUTH",
"METHODS=NULL");
39 "AUTH METHODS=HASHEDPASSWORD",
40 "AUTH",
"METHODS=HASHEDPASSWORD");
42 "VERSION Tor=\"0.2.9.8 (git-a0df013ea241b026)\"",
43 "VERSION",
"Tor=\"0.2.9.8 (git-a0df013ea241b026)\"");
45 "AUTHCHALLENGE SERVERHASH=aaaa SERVERNONCE=bbbb",
46 "AUTHCHALLENGE",
"SERVERHASH=aaaa SERVERNONCE=bbbb");
63 auto r_it =
ret.begin();
64 auto e_it = expected.begin();
65 while (r_it !=
ret.end() && e_it != expected.end()) {
77 "METHODS=COOKIE,SAFECOOKIE COOKIEFILE=\"/home/x/.tor/control_auth_cookie\"", {
78 {
"METHODS",
"COOKIE,SAFECOOKIE"},
79 {
"COOKIEFILE",
"/home/x/.tor/control_auth_cookie"},
86 "METHODS=HASHEDPASSWORD", {
87 {
"METHODS",
"HASHEDPASSWORD"},
90 "Tor=\"0.2.9.8 (git-a0df013ea241b026)\"", {
91 {
"Tor",
"0.2.9.8 (git-a0df013ea241b026)"},
94 "SERVERHASH=aaaa SERVERNONCE=bbbb", {
95 {
"SERVERHASH",
"aaaa"},
96 {
"SERVERNONCE",
"bbbb"},
99 "ServiceID=exampleonion1234", {
100 {
"ServiceID",
"exampleonion1234"},
103 "PrivateKey=RSA1024:BLOB", {
104 {
"PrivateKey",
"RSA1024:BLOB"},
107 "ClientAuth=bob:BLOB", {
108 {
"ClientAuth",
"bob:BLOB"},
113 "Foo=Bar=Baz Spam=Eggs", {
128 "Foo=\"Bar\\ Baz\"", {
132 "Foo=\"Bar\\Baz\"", {
136 "Foo=\"Bar\\@Baz\"", {
140 "Foo=\"Bar\\\"Baz\" Spam=\"\\\"Eggs\\\"\"", {
142 {
"Spam",
"\"Eggs\""},
145 "Foo=\"Bar\\\\Baz\"", {
151 "Foo=\"Bar\\nBaz\\t\" Spam=\"\\rEggs\" Octals=\"\\1a\\11\\17\\18\\81\\377\\378\\400\\2222\" Final=Check", {
152 {
"Foo",
"Bar\nBaz\t"},
154 {
"Octals",
"\1a\11\17\1" "881\377\37" "8\40" "0\222" "2"},
158 "Valid=Mapping Escaped=\"Escape\\\\\"", {
159 {
"Valid",
"Mapping"},
160 {
"Escaped",
"Escape\\"},
163 "Valid=Mapping Bare=\"Escape\\\"", {});
165 "OneOctal=\"OneEnd\\1\" TwoOctal=\"TwoEnd\\11\"", {
166 {
"OneOctal",
"OneEnd\1"},
167 {
"TwoOctal",
"TwoEnd\11"},
174 auto r_it =
ret.begin();
184 "SOME=args,here MORE optional=arguments here", {
185 {
"SOME",
"args,here"},
BOOST_AUTO_TEST_SUITE_END()
#define BOOST_CHECK_EQUAL(v1, v2)
std::pair< std::string, std::string > SplitTorReplyLine(const std::string &s)
std::map< std::string, std::string > ParseTorReplyMapping(const std::string &s)
Parse reply arguments in the form 'METHODS=COOKIE,SAFECOOKIE COOKIEFILE=".../control_auth_cookie"'.
BOOST_AUTO_TEST_CASE(util_SplitTorReplyLine)
static void CheckSplitTorReplyLine(std::string input, std::string command, std::string args)
static void CheckParseTorReplyMapping(std::string input, std::map< std::string, std::string > expected)