57        throw Exception(
"expected that buffer would begin with " + prefix);
 
   58    buf.
advance(prefix.length() + 1);
 
   64            throw Exception(
"expected that buffer would end with push-continuation 1");
 
   67    else if (pc_mode == 
PC_2)
 
   70            throw Exception(
"expected that buffer would end with push-continuation 2");
 
 
   81    else if (index == size - 1)
 
 
   89    static const std::string rchrs = 
"012abcABC,\"\\";
 
   94    for (
int i = 0; i < len; ++i)
 
   95        ret += rchrs[prng.
randrange32(
static_cast<uint32_t
>(rchrs.size()))];
 
 
  104    for (
int i = 0; i < len; ++i)
 
 
  111    static const int sizes[3] = {10, 100, 1000};
 
  116    for (
int i = 0; i < len; ++i)
 
 
  137    for (
size_t i = 0; i < frag.size(); ++i)
 
  143    for (
size_t i = 0; i < frag.size(); ++i)
 
  146        cc.
add(cli_opt, 
nullptr);
 
  148        ASSERT_EQ(cc.
complete(), i == frag.size() - 1);
 
  152    cc.erase(std::remove_if(cc.begin(), cc.end(), [](
const Option &o)
 
  153                            { return o.size() >= 1 && o.ref(0) == 
"push-continuation"; }),
 
 
  167    buf_append_string(buf, prefix + 
",route-gateway 10.213.0.1,ifconfig 10.213.0.48 255.255.0.0,ifconfig-ipv6 fdab::48/64 fdab::1,client-ip 192.168.4.1,ping 1,ping-restart 8,reneg-sec 60,cipher AES-128-GCM,compress stub-v2,peer-id 4,topology subnet,explicit-exit-notify");
 
  171    for (
int i = 0; i < 1000; ++i)
 
  189    ASSERT_EQ(frag.size(), 15);
 
  197  for (
const auto &e : opt)
 
 
  212    for (
int i = 0; i < n; ++i)
 
 
  219TEST(continuation, test_random_push_reply)
 
 
  224TEST(continuation, test_random_push_update)
 
 
  229TEST(continuation, test_fragment_push_reply)
 
 
  234TEST(continuation, test_fragment_push_update)
 
 
  239TEST(continuation, push_update_add)
 
  244    cc.
add(orig_opts, 
nullptr);
 
  250    cc.
add(update, 
nullptr, 
true);
 
  253    ASSERT_EQ(cc.size(), 5);
 
 
  256TEST(continuation, push_update_add_unsupported)
 
  261    cc.
add(orig_opts, 
nullptr);
 
  267    JY_EXPECT_THROW(cc.
add(update, 
nullptr, 
true), OptionListContinuation::push_update_unsupported_option, 
"my_unsupported_option");
 
  271    cc.
add(update, 
nullptr, 
true);
 
  274    ASSERT_EQ(cc.size(), 5);
 
 
  277TEST(continuation, push_update_remove)
 
  282    JY_EXPECT_THROW(cc.
add(update, 
nullptr, 
true), OptionListContinuation::push_update_unsupported_option, 
"my_unsupported_option");
 
  287    cc.
add(update, 
nullptr, 
true);
 
 
  292TEST(continuation, push_update_add_multiple)
 
  298    cc.
add(orig_opts, 
nullptr);
 
  305    cc.
add(update, 
nullptr, 
true);
 
  309    cc.
add(update, 
nullptr, 
true);
 
  313    ASSERT_TRUE(cc.
exists(
"f"));
 
  314    ASSERT_FALSE(cc.
exists(
"dns"));
 
  315    ASSERT_FALSE(cc.
exists(
"ifconfig"));
 
  316    ASSERT_TRUE(cc.
exists(
"bla"));
 
  319    ASSERT_EQ(idx->size(), 4);
 
  321    ASSERT_EQ(cc.size(), 10);
 
 
size_t size() const
Returns the size of the buffer in T objects.
void advance(const size_t delta)
Advances the buffer by the specified delta.
void set_size(const size_t size)
After an external method, operating on the array as a mutable unsigned char buffer,...
void reset_completion()
Resets completion flag. Intended to use by PUSH_UPDATE.
void finalize(const PushOptionsMerger::Ptr merger)
void add(const OptionList &other, OptionList::FilterBase *filt, bool push_update=false)
const IndexList * get_index_ptr(const std::string &name) const
static OptionList parse_from_csv_static(const std::string &str, Limits *lim)
void parse_from_csv(const std::string &str, Limits *lim)
static OptionList parse_from_csv_static_nomap(const std::string &str, Limits *lim)
std::string render_csv() const
std::string render(const unsigned int flags) const
bool exists(const std::string &name) const
static BufferPtr defragment(const std::vector< BufferPtr > &bv, const std::string &prefix)
static constexpr size_t FRAGMENT_SIZE
Abstract base class for random number generators.
std::uint32_t randrange32(const std::uint32_t end)
Return a uniformly distributed random number in the range [0, end)
#define OPENVPN_LOG(args)
constexpr BufferFlags GROW(1u<< 2)
if enabled, buffer will grow (otherwise buffer_full exception will be thrown)
bool starts_with(const STRING &str, const std::string &prefix)
bool ends_with(const STRING &str, const std::string &suffix)
void buf_append_string(Buffer &buf, const std::string &str)
std::string buf_to_string(const Buffer &buf)
static void test_roundtrip(const OptionList &opt_orig, const std::string &prefix)
static std::string get_csv_from_frag(Buffer buf, const size_t index, const size_t size, const std::string &prefix)
static std::string get_csv(Buffer buf, const PCMode pc_mode, const std::string &prefix)
static Option random_opt(RandomAPI &prng)
static void test_prefix_fragment(const std::string &prefix)
TEST(continuation, test_random_push_reply)
static void require_equal(const OptionList &opt1, const OptionList &opt2, const std::string &title)
static OptionList random_optionlist(RandomAPI &prng)
static std::string random_term(RandomAPI &prng)
static void test_prefix_random(const std::string &prefix)