mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
@@ -1,40 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of clio: https://github.com/XRPLF/clio
|
||||
Copyright (c) 2023, the clio developers.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <util/Fixtures.h>
|
||||
|
||||
#include <rpc/common/impl/AdminVerificationStrategy.h>
|
||||
|
||||
#include <boost/json.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
class RPCAdminVerificationTest : public NoLoggerFixture
|
||||
{
|
||||
protected:
|
||||
rpc::detail::IPAdminVerificationStrategy strat_;
|
||||
};
|
||||
|
||||
TEST_F(RPCAdminVerificationTest, IsAdminOnlyForIP_127_0_0_1)
|
||||
{
|
||||
EXPECT_TRUE(strat_.isAdmin("127.0.0.1"));
|
||||
EXPECT_FALSE(strat_.isAdmin("127.0.0.2"));
|
||||
EXPECT_FALSE(strat_.isAdmin("127"));
|
||||
EXPECT_FALSE(strat_.isAdmin(""));
|
||||
EXPECT_FALSE(strat_.isAdmin("localhost"));
|
||||
}
|
||||
@@ -63,7 +63,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsFalseIfClioOnly)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_FALSE(res);
|
||||
@@ -83,7 +83,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsTrueIfProxied)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_TRUE(res);
|
||||
@@ -103,7 +103,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsTrueIfCurrentLedgerSpecified)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_TRUE(res);
|
||||
@@ -123,7 +123,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsTrueIfClosedLedgerSpecified)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_TRUE(res);
|
||||
@@ -143,7 +143,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsTrueIfAccountInfoWithQueueSpe
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_TRUE(res);
|
||||
@@ -163,7 +163,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsTrueIfLedgerWithQueueSpecifie
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_TRUE(res);
|
||||
@@ -183,7 +183,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsTrueIfLedgerWithFullSpecified
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_TRUE(res);
|
||||
@@ -203,7 +203,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsTrueIfLedgerWithAccountsSpeci
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_TRUE(res);
|
||||
@@ -223,7 +223,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsFalseIfAccountInfoQueueIsFals
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_FALSE(res);
|
||||
@@ -243,7 +243,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsFalseIfLedgerQueueIsFalse)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_FALSE(res);
|
||||
@@ -263,7 +263,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsFalseIfLedgerFullIsFalse)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_FALSE(res);
|
||||
@@ -283,7 +283,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsFalseIfLedgerAccountsIsFalse)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_FALSE(res);
|
||||
@@ -303,7 +303,7 @@ TEST_F(RPCForwardingProxyTest, ShouldNotForwardReturnsTrueIfAPIVersionIsV1)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_FALSE(res);
|
||||
@@ -323,7 +323,7 @@ TEST_F(RPCForwardingProxyTest, ShouldForwardReturnsFalseIfAPIVersionIsV2)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_FALSE(res);
|
||||
@@ -339,7 +339,7 @@ TEST_F(RPCForwardingProxyTest, ShouldNeverForwardSubscribe)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_FALSE(res);
|
||||
@@ -355,7 +355,7 @@ TEST_F(RPCForwardingProxyTest, ShouldNeverForwardUnsubscribe)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.shouldForward(ctx);
|
||||
ASSERT_FALSE(res);
|
||||
@@ -383,7 +383,7 @@ TEST_F(RPCForwardingProxyTest, ForwardCallsBalancerWithCorrectParams)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.forward(ctx);
|
||||
|
||||
@@ -413,7 +413,7 @@ TEST_F(RPCForwardingProxyTest, ForwardingFailYieldsErrorStatus)
|
||||
runSpawn([&](auto yield) {
|
||||
auto const range = mockBackendPtr->fetchLedgerRange();
|
||||
auto const ctx =
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP);
|
||||
web::Context(yield, method, apiVersion, params.as_object(), nullptr, tagFactory, *range, CLIENT_IP, true);
|
||||
|
||||
auto const res = proxy.forward(ctx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user