20 #include <ripple/beast/unit_test.h>
21 #include <ripple/protocol/ErrorCodes.h>
22 #include <ripple/protocol/jss.h>
24 #include <test/jtx/WSClient.h>
37 using namespace test::jtx;
42 BEAST_EXPECT(env.
rpc(
"ping")[
"result"][
"role"] ==
"admin");
45 "ping")[
"result"][
"unlimited"].asBool());
50 BEAST_EXPECT(! env.rpc(
"ping")[
"result"].isMember(
"role"));
52 env.app().config())->invoke(
"ping")[
"result"];
54 !wsRes.isMember(
"unlimited") || !wsRes[
"unlimited"].asBool());
59 BEAST_EXPECT(env.rpc(
"ping")[
"result"][
"role"] ==
"proxied");
61 env.app().config())->invoke(
"ping")[
"result"];
63 !wsRes.isMember(
"unlimited") || !wsRes[
"unlimited"].asBool());
66 headers[
"X-Forwarded-For"] =
"12.34.56.78";
67 auto rpcRes = env.rpc(headers,
"ping")[
"result"];
68 BEAST_EXPECT(rpcRes[
"role"] ==
"proxied");
69 BEAST_EXPECT(rpcRes[
"ip"] ==
"12.34.56.78");
71 headers[
"X-Forwarded-For"] =
"87.65.43.21, 44.33.22.11";
72 rpcRes = env.rpc(headers,
"ping")[
"result"];
73 BEAST_EXPECT(rpcRes[
"ip"] ==
"87.65.43.21");
74 headers.
erase(
"X-Forwarded-For");
76 headers[
"Forwarded"] =
"for=88.77.66.55";
77 rpcRes = env.rpc(headers,
"ping")[
"result"];
78 BEAST_EXPECT(rpcRes[
"ip"] ==
"88.77.66.55");
80 headers[
"Forwarded"] =
"what=where;for=55.66.77.88;for=nobody;"
82 rpcRes = env.rpc(headers,
"ping")[
"result"];
83 BEAST_EXPECT(rpcRes[
"ip"] ==
"55.66.77.88");
85 headers[
"Forwarded"] =
"what=where;for=55.66.77.88, 99.00.11.22;"
87 rpcRes = env.rpc(headers,
"ping")[
"result"];
88 BEAST_EXPECT(rpcRes[
"ip"] ==
"55.66.77.88");
91 env.app().config(),
true, 2, headers)->invoke(
"ping")[
"result"];
93 !wsRes.isMember(
"unlimited") || !wsRes[
"unlimited"].asBool());
96 headers[
"X-User"] = name;
97 rpcRes = env.rpc(headers,
"ping")[
"result"];
98 BEAST_EXPECT(rpcRes[
"role"] ==
"identified");
99 BEAST_EXPECT(rpcRes[
"username"] == name);
100 BEAST_EXPECT(rpcRes[
"ip"] ==
"55.66.77.88");
102 env.app().config(),
true, 2, headers)->invoke(
"ping")[
"result"];
103 BEAST_EXPECT(wsRes[
"unlimited"].asBool());
std::unique_ptr< Config > secure_gateway(std::unique_ptr< Config >)
BEAST_DEFINE_TESTSUITE(AccountDelete, app, ripple)
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
std::unique_ptr< Config > no_admin(std::unique_ptr< Config >)
adjust config so no admin ports are enabled
virtual Config & config()=0
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::unique_ptr< WSClient > makeWSClient(Config const &cfg, bool v2, unsigned rpc_version, std::unordered_map< std::string, std::string > const &headers)
Returns a client operating through WebSockets/S.
A transaction testing environment.
Json::Value rpc(std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.