Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
permessage_deflate.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <websocketpp/error.hpp>
#include <websocketpp/extensions/extension.hpp>
#include <websocketpp/extensions/permessage_deflate/disabled.hpp>
#include <websocketpp/extensions/permessage_deflate/enabled.hpp>
#include <string>
#include <websocketpp/utilities.hpp>
#include <iostream>
Include dependency graph for permessage_deflate.cpp:

Go to the source code of this file.

Classes

struct  config
 
struct  ext_vars
 

Macros

#define BOOST_TEST_MODULE   permessage_deflate
 

Typedefs

typedef websocketpp::extensions::permessage_deflate::enabled< configenabled_type
 
typedef websocketpp::extensions::permessage_deflate::disabled< configdisabled_type
 

Functions

 BOOST_AUTO_TEST_CASE (disabled_is_disabled)
 
 BOOST_AUTO_TEST_CASE (disabled_is_off)
 
 BOOST_AUTO_TEST_CASE (enabled_is_enabled)
 
 BOOST_AUTO_TEST_CASE (enabled_starts_disabled)
 
 BOOST_AUTO_TEST_CASE (negotiation_empty_attr)
 
 BOOST_AUTO_TEST_CASE (negotiation_invalid_attr)
 
 BOOST_AUTO_TEST_CASE (negotiate_server_no_context_takeover_invalid)
 
 BOOST_AUTO_TEST_CASE (negotiate_server_no_context_takeover)
 
 BOOST_AUTO_TEST_CASE (negotiate_server_no_context_takeover_server_initiated)
 
 BOOST_AUTO_TEST_CASE (negotiate_client_no_context_takeover_invalid)
 
 BOOST_AUTO_TEST_CASE (negotiate_client_no_context_takeover)
 
 BOOST_AUTO_TEST_CASE (negotiate_client_no_context_takeover_server_initiated)
 
 BOOST_AUTO_TEST_CASE (negotiate_server_max_window_bits_invalid)
 
 BOOST_AUTO_TEST_CASE (negotiate_server_max_window_bits_valid)
 
 BOOST_AUTO_TEST_CASE (invalid_set_server_max_window_bits)
 
 BOOST_AUTO_TEST_CASE (negotiate_server_max_window_bits_decline)
 
 BOOST_AUTO_TEST_CASE (negotiate_server_max_window_bits_accept)
 
 BOOST_AUTO_TEST_CASE (negotiate_server_max_window_bits_largest)
 
 BOOST_AUTO_TEST_CASE (negotiate_server_max_window_bits_smallest)
 
 BOOST_AUTO_TEST_CASE (negotiate_client_max_window_bits_invalid)
 
 BOOST_AUTO_TEST_CASE (negotiate_client_max_window_bits_valid)
 
 BOOST_AUTO_TEST_CASE (invalid_set_client_max_window_bits)
 
 BOOST_AUTO_TEST_CASE (negotiate_client_max_window_bits_decline)
 
 BOOST_AUTO_TEST_CASE (negotiate_client_max_window_bits_accept)
 
 BOOST_AUTO_TEST_CASE (negotiate_client_max_window_bits_largest)
 
 BOOST_AUTO_TEST_CASE (negotiate_client_max_window_bits_smallest)
 
 BOOST_AUTO_TEST_CASE (negotiate_two_client_initiated1)
 
 BOOST_AUTO_TEST_CASE (negotiate_two_client_initiated2)
 
 BOOST_AUTO_TEST_CASE (negotiate_two_client_initiated3)
 
 BOOST_AUTO_TEST_CASE (negotiate_two_client_initiated4)
 
 BOOST_AUTO_TEST_CASE (negotiate_two_client_initiated5)
 
 BOOST_AUTO_TEST_CASE (negotiate_two_client_initiated6)
 
 BOOST_AUTO_TEST_CASE (negotiate_three_client_initiated1)
 
 BOOST_AUTO_TEST_CASE (negotiate_three_client_initiated2)
 
 BOOST_AUTO_TEST_CASE (negotiate_three_client_initiated3)
 
 BOOST_AUTO_TEST_CASE (negotiate_three_client_initiated4)
 
 BOOST_AUTO_TEST_CASE (negotiate_four_client_initiated)
 
 BOOST_AUTO_TEST_CASE (compress_data)
 
 BOOST_AUTO_TEST_CASE (compress_data_multiple)
 
 BOOST_AUTO_TEST_CASE (compress_data_large)
 
 BOOST_AUTO_TEST_CASE (compress_data_no_context_takeover)
 
 BOOST_AUTO_TEST_CASE (compress_empty)
 
 BOOST_AUTO_TEST_CASE (decompress_data)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   permessage_deflate

Definition at line 28 of file permessage_deflate.cpp.

Typedef Documentation

◆ disabled_type

◆ enabled_type

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/43]

BOOST_AUTO_TEST_CASE ( compress_data )

Definition at line 503 of file permessage_deflate.cpp.

503 {
504 ext_vars v;
505
506 std::string compress_in = "Hello";
507 std::string compress_out;
508 std::string decompress_out;
509
510 v.exts.init(true);
511
512 v.ec = v.exts.compress(compress_in,compress_out);
513 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
514
515 v.ec = v.exts.decompress(reinterpret_cast<const uint8_t *>(compress_out.data()),compress_out.size(),decompress_out);
516 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
517 BOOST_CHECK_EQUAL( compress_in, decompress_out );
518}
lib::error_code init(bool is_server)
Initialize zlib state.
Definition enabled.hpp:260
lib::error_code compress(std::string const &in, std::string &out)
Compress bytes.
Definition enabled.hpp:506
lib::error_code decompress(uint8_t const *buf, size_t len, std::string &out)
Decompress bytes.
Definition enabled.hpp:544
unsigned char uint8_t
Definition stdint.h:124
enabled_type exts
websocketpp::lib::error_code ec
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/43]

BOOST_AUTO_TEST_CASE ( compress_data_large )

Definition at line 539 of file permessage_deflate.cpp.

539 {
540 ext_vars v;
541
542 std::string compress_in(600,'*');
543 std::string compress_out;
544 std::string decompress_out;
545
547
548 alist["server_max_window_bits"] = "8";
550
551 v.exts.negotiate(alist);
552 v.exts.init(true);
553
554 v.ec = v.exts.compress(compress_in,compress_out);
555 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
556
557 v.ec = v.exts.decompress(reinterpret_cast<const uint8_t *>(compress_out.data()),compress_out.size(),decompress_out);
558 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
559 BOOST_CHECK_EQUAL( compress_in, decompress_out );
560}
err_str_pair negotiate(http::attribute_list const &offer)
Negotiate extension.
Definition enabled.hpp:467
lib::error_code set_server_max_window_bits(uint8_t bits, mode::value mode)
Limit server LZ77 sliding window size.
Definition enabled.hpp:393
@ smallest
Use the smallest value common to both offers.
Definition enabled.hpp:200
std::map< std::string, std::string > attribute_list
The type of an HTTP attribute list.
Definition constants.hpp:45
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/43]

BOOST_AUTO_TEST_CASE ( compress_data_multiple )

Definition at line 520 of file permessage_deflate.cpp.

520 {
521 ext_vars v;
522
523 v.exts.init(true);
524
525 for (int i = 0; i < 2; i++) {
526 std::string compress_in = "Hello";
527 std::string compress_out;
528 std::string decompress_out;
529
530 v.ec = v.exts.compress(compress_in,compress_out);
531 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
532
533 v.ec = v.exts.decompress(reinterpret_cast<const uint8_t *>(compress_out.data()),compress_out.size(),decompress_out);
534 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
535 BOOST_CHECK_EQUAL( compress_in, decompress_out );
536 }
537}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/43]

BOOST_AUTO_TEST_CASE ( compress_data_no_context_takeover )

Definition at line 562 of file permessage_deflate.cpp.

562 {
563 ext_vars v;
564
565 std::string compress_in = "Hello";
566 std::string compress_out1;
567 std::string compress_out2;
568 std::string decompress_out;
569
571
572 alist["server_no_context_takeover"].clear();
574
575 v.exts.negotiate(alist);
576 v.exts.init(true);
577
578 v.ec = v.exts.compress(compress_in,compress_out1);
579 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
580
581 v.ec = v.exts.decompress(
582 reinterpret_cast<const uint8_t *>(compress_out1.data()),
583 compress_out1.size(),
584 decompress_out
585 );
586 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
587 BOOST_CHECK_EQUAL( compress_in, decompress_out );
588
589 decompress_out.clear();
590
591 v.ec = v.exts.compress(compress_in,compress_out2);
592 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
593
594 v.ec = v.exts.decompress(
595 reinterpret_cast<const uint8_t *>(compress_out2.data()),
596 compress_out2.size(),
597 decompress_out
598 );
599 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
600 BOOST_CHECK_EQUAL( compress_in, decompress_out );
601
602 BOOST_CHECK_EQUAL( compress_out1, compress_out2 );
603}
void enable_server_no_context_takeover()
Reset server's outgoing LZ77 sliding window for each new message.
Definition enabled.hpp:348
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/43]

BOOST_AUTO_TEST_CASE ( compress_empty )

Definition at line 605 of file permessage_deflate.cpp.

605 {
606 ext_vars v;
607
608 std::string compress_in;
609 std::string compress_out;
610 std::string decompress_out;
611
612 v.exts.init(true);
613
614 v.ec = v.exts.compress(compress_in,compress_out);
615 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
616
617 v.ec = v.exts.decompress(reinterpret_cast<const uint8_t *>(compress_out.data()),compress_out.size(),decompress_out);
618
619 compress_out.clear();
620 decompress_out.clear();
621
622 v.ec = v.exts.compress(compress_in,compress_out);
623 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
624
625 v.ec = v.exts.decompress(reinterpret_cast<const uint8_t *>(compress_out.data()),compress_out.size(),decompress_out);
626 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
627 BOOST_CHECK_EQUAL( compress_in, decompress_out );
628}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/43]

BOOST_AUTO_TEST_CASE ( decompress_data )
Todo
: more compression tests
  • compress at different compression levels

Definition at line 636 of file permessage_deflate.cpp.

636 {
637 ext_vars v;
638
639 uint8_t in[11] = {0xf2, 0x48, 0xcd, 0xc9, 0xc9, 0x07, 0x00, 0x00, 0x00, 0xff, 0xff};
640 std::string out;
641 std::string reference = "Hello";
642
643 v.exts.init(true);
644
645 v.ec = v.exts.decompress(in,11,out);
646
647 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
648 BOOST_CHECK_EQUAL( out, reference );
649}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/43]

BOOST_AUTO_TEST_CASE ( disabled_is_disabled )

Definition at line 59 of file permessage_deflate.cpp.

59 {
60 disabled_type exts;
61 BOOST_CHECK( !exts.is_implemented() );
62}
Stub class for use when disabling permessage_deflate extension.
Definition disabled.hpp:52
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [8/43]

BOOST_AUTO_TEST_CASE ( disabled_is_off )

Definition at line 64 of file permessage_deflate.cpp.

64 {
65 disabled_type exts;
66 BOOST_CHECK( !exts.is_enabled() );
67}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [9/43]

BOOST_AUTO_TEST_CASE ( enabled_is_enabled )

Definition at line 71 of file permessage_deflate.cpp.

71 {
72 ext_vars v;
73 BOOST_CHECK( v.exts.is_implemented() );
74 BOOST_CHECK( v.extc.is_implemented() );
75}
bool is_implemented() const
Test if this object implements the permessage-deflate specification.
Definition enabled.hpp:312
enabled_type extc
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [10/43]

BOOST_AUTO_TEST_CASE ( enabled_starts_disabled )

Definition at line 78 of file permessage_deflate.cpp.

78 {
79 ext_vars v;
80 BOOST_CHECK( !v.exts.is_enabled() );
81 BOOST_CHECK( !v.extc.is_enabled() );
82}
bool is_enabled() const
Test if the extension was negotiated for this connection.
Definition enabled.hpp:323
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [11/43]

BOOST_AUTO_TEST_CASE ( invalid_set_client_max_window_bits )

Definition at line 304 of file permessage_deflate.cpp.

304 {
305 ext_vars v;
306
309
312}
lib::error_code set_client_max_window_bits(uint8_t bits, mode::value mode)
Limit client LZ77 sliding window size.
Definition enabled.hpp:424
@ invalid_max_window_bits
Invalid value for max_window_bits.
Definition enabled.hpp:108
lib::error_code make_error_code(error::value e)
Create an error code in the permessage-deflate category.
Definition enabled.hpp:157
@ decline
Decline any value the remote endpoint offers. Insist on defaults.
Definition enabled.hpp:196
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [12/43]

BOOST_AUTO_TEST_CASE ( invalid_set_server_max_window_bits )

Definition at line 204 of file permessage_deflate.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [13/43]

BOOST_AUTO_TEST_CASE ( negotiate_client_max_window_bits_accept )

Definition at line 326 of file permessage_deflate.cpp.

326 {
327 ext_vars v;
328 v.attr["client_max_window_bits"] = "8";
329
331 v.esp = v.exts.negotiate(v.attr);
332 BOOST_CHECK( v.exts.is_enabled() );
333 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
334 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
335 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=8");
336}
@ accept
Accept any value the remote endpoint offers.
Definition enabled.hpp:194
websocketpp::err_str_pair esp
websocketpp::http::attribute_list attr
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [14/43]

BOOST_AUTO_TEST_CASE ( negotiate_client_max_window_bits_decline )

Definition at line 314 of file permessage_deflate.cpp.

314 {
315 ext_vars v;
316 v.attr["client_max_window_bits"] = "8";
317
319 v.esp = v.exts.negotiate(v.attr);
320 BOOST_CHECK( v.exts.is_enabled() );
321 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
322 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
323 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate");
324}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [15/43]

BOOST_AUTO_TEST_CASE ( negotiate_client_max_window_bits_invalid )

Definition at line 263 of file permessage_deflate.cpp.

263 {
264 ext_vars v;
265
266 std::vector<std::string> values;
267 values.push_back("foo");
268 values.push_back("7");
269 values.push_back("16");
270
271 std::vector<std::string>::const_iterator it;
272 for (it = values.begin(); it != values.end(); ++it) {
273 v.attr["client_max_window_bits"] = *it;
274
275 v.esp = v.exts.negotiate(v.attr);
276 BOOST_CHECK( !v.exts.is_enabled() );
277 BOOST_CHECK_EQUAL( v.esp.first, pmde::make_error_code(pmde::invalid_attribute_value) );
278 BOOST_CHECK_EQUAL( v.esp.second, "");
279 }
280}
GeneratorWrapper< T > values(std::initializer_list< T > values)
@ invalid_attribute_value
Invalid extension attribute value.
Definition enabled.hpp:99
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [16/43]

BOOST_AUTO_TEST_CASE ( negotiate_client_max_window_bits_largest )

Definition at line 338 of file permessage_deflate.cpp.

338 {
339 ext_vars v;
340 v.attr["client_max_window_bits"] = "8";
341
343 v.esp = v.exts.negotiate(v.attr);
344 BOOST_CHECK( v.exts.is_enabled() );
345 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
346 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
347 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=8");
348}
@ largest
Use the largest value common to both offers.
Definition enabled.hpp:198
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [17/43]

BOOST_AUTO_TEST_CASE ( negotiate_client_max_window_bits_smallest )

Definition at line 350 of file permessage_deflate.cpp.

350 {
351 ext_vars v;
352 v.attr["client_max_window_bits"] = "8";
353
355 v.esp = v.exts.negotiate(v.attr);
356 BOOST_CHECK( v.exts.is_enabled() );
357 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
358 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
359 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=8");
360}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [18/43]

BOOST_AUTO_TEST_CASE ( negotiate_client_max_window_bits_valid )

Definition at line 282 of file permessage_deflate.cpp.

282 {
283 ext_vars v;
284
285 v.attr["client_max_window_bits"].clear();
286 v.esp = v.exts.negotiate(v.attr);
287 BOOST_CHECK( v.exts.is_enabled() );
288 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
289 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate");
290
291 v.attr["client_max_window_bits"] = "8";
292 v.esp = v.exts.negotiate(v.attr);
293 BOOST_CHECK( v.exts.is_enabled() );
294 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
295 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=8");
296
297 v.attr["client_max_window_bits"] = "15";
298 v.esp = v.exts.negotiate(v.attr);
299 BOOST_CHECK( v.exts.is_enabled() );
300 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
301 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate");
302}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [19/43]

BOOST_AUTO_TEST_CASE ( negotiate_client_no_context_takeover )

Definition at line 145 of file permessage_deflate.cpp.

145 {
146 ext_vars v;
147 v.attr["client_no_context_takeover"].clear();
148
149 v.esp = v.exts.negotiate(v.attr);
150 BOOST_CHECK( v.exts.is_enabled() );
151 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
152 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_no_context_takeover");
153}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [20/43]

BOOST_AUTO_TEST_CASE ( negotiate_client_no_context_takeover_invalid )

Definition at line 135 of file permessage_deflate.cpp.

135 {
136 ext_vars v;
137 v.attr["client_no_context_takeover"] = "foo";
138
139 v.esp = v.exts.negotiate(v.attr);
140 BOOST_CHECK( !v.exts.is_enabled() );
141 BOOST_CHECK_EQUAL( v.esp.first, pmde::make_error_code(pmde::invalid_attribute_value) );
142 BOOST_CHECK_EQUAL( v.esp.second, "");
143}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [21/43]

BOOST_AUTO_TEST_CASE ( negotiate_client_no_context_takeover_server_initiated )

Definition at line 155 of file permessage_deflate.cpp.

155 {
156 ext_vars v;
157
159 v.esp = v.exts.negotiate(v.attr);
160 BOOST_CHECK( v.exts.is_enabled() );
161 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
162 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_no_context_takeover");
163}
void enable_client_no_context_takeover()
Reset client's outgoing LZ77 sliding window for each new message.
Definition enabled.hpp:367
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [22/43]

BOOST_AUTO_TEST_CASE ( negotiate_four_client_initiated )

Definition at line 488 of file permessage_deflate.cpp.

488 {
489 ext_vars v;
490
491 v.attr["server_no_context_takeover"].clear();
492 v.attr["client_no_context_takeover"].clear();
493 v.attr["server_max_window_bits"] = "10";
494 v.attr["client_max_window_bits"] = "10";
495
496 v.esp = v.exts.negotiate(v.attr);
497 BOOST_CHECK( v.exts.is_enabled() );
498 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
499 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_no_context_takeover; client_no_context_takeover; server_max_window_bits=10; client_max_window_bits=10");
500}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [23/43]

BOOST_AUTO_TEST_CASE ( negotiate_server_max_window_bits_accept )

Definition at line 226 of file permessage_deflate.cpp.

226 {
227 ext_vars v;
228 v.attr["server_max_window_bits"] = "8";
229
231 v.esp = v.exts.negotiate(v.attr);
232 BOOST_CHECK( v.exts.is_enabled() );
233 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
234 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
235 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=8");
236}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [24/43]

BOOST_AUTO_TEST_CASE ( negotiate_server_max_window_bits_decline )

Definition at line 214 of file permessage_deflate.cpp.

214 {
215 ext_vars v;
216 v.attr["server_max_window_bits"] = "8";
217
219 v.esp = v.exts.negotiate(v.attr);
220 BOOST_CHECK( v.exts.is_enabled() );
221 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
222 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
223 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate");
224}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [25/43]

BOOST_AUTO_TEST_CASE ( negotiate_server_max_window_bits_invalid )

Definition at line 167 of file permessage_deflate.cpp.

167 {
168 ext_vars v;
169
170 std::vector<std::string> values;
171 values.push_back("");
172 values.push_back("foo");
173 values.push_back("7");
174 values.push_back("16");
175
176 std::vector<std::string>::const_iterator it;
177 for (it = values.begin(); it != values.end(); ++it) {
178 v.attr["server_max_window_bits"] = *it;
179
180 v.esp = v.exts.negotiate(v.attr);
181 BOOST_CHECK( !v.exts.is_enabled() );
182 BOOST_CHECK_EQUAL( v.esp.first, pmde::make_error_code(pmde::invalid_attribute_value) );
183 BOOST_CHECK_EQUAL( v.esp.second, "");
184 }
185}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [26/43]

BOOST_AUTO_TEST_CASE ( negotiate_server_max_window_bits_largest )

Definition at line 238 of file permessage_deflate.cpp.

238 {
239 ext_vars v;
240 v.attr["server_max_window_bits"] = "8";
241
243 v.esp = v.exts.negotiate(v.attr);
244 BOOST_CHECK( v.exts.is_enabled() );
245 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
246 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
247 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=8");
248}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [27/43]

BOOST_AUTO_TEST_CASE ( negotiate_server_max_window_bits_smallest )

Definition at line 250 of file permessage_deflate.cpp.

250 {
251 ext_vars v;
252 v.attr["server_max_window_bits"] = "8";
253
255 v.esp = v.exts.negotiate(v.attr);
256 BOOST_CHECK( v.exts.is_enabled() );
257 BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
258 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
259 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=8");
260}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [28/43]

BOOST_AUTO_TEST_CASE ( negotiate_server_max_window_bits_valid )

Definition at line 187 of file permessage_deflate.cpp.

187 {
188 ext_vars v;
189 v.attr["server_max_window_bits"] = "8";
190
191 v.esp = v.exts.negotiate(v.attr);
192 BOOST_CHECK( v.exts.is_enabled() );
193 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
194 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=8");
195
196 v.attr["server_max_window_bits"] = "15";
197
198 v.esp = v.exts.negotiate(v.attr);
199 BOOST_CHECK( v.exts.is_enabled() );
200 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
201 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate");
202}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [29/43]

BOOST_AUTO_TEST_CASE ( negotiate_server_no_context_takeover )

Definition at line 114 of file permessage_deflate.cpp.

114 {
115 ext_vars v;
116 v.attr["server_no_context_takeover"].clear();
117
118 v.esp = v.exts.negotiate(v.attr);
119 BOOST_CHECK( v.exts.is_enabled() );
120 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
121 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_no_context_takeover");
122}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [30/43]

BOOST_AUTO_TEST_CASE ( negotiate_server_no_context_takeover_invalid )

Definition at line 104 of file permessage_deflate.cpp.

104 {
105 ext_vars v;
106 v.attr["server_no_context_takeover"] = "foo";
107
108 v.esp = v.exts.negotiate(v.attr);
109 BOOST_CHECK( !v.exts.is_enabled() );
110 BOOST_CHECK_EQUAL( v.esp.first, pmde::make_error_code(pmde::invalid_attribute_value) );
111 BOOST_CHECK_EQUAL( v.esp.second, "");
112}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [31/43]

BOOST_AUTO_TEST_CASE ( negotiate_server_no_context_takeover_server_initiated )

Definition at line 124 of file permessage_deflate.cpp.

124 {
125 ext_vars v;
126
128 v.esp = v.exts.negotiate(v.attr);
129 BOOST_CHECK( v.exts.is_enabled() );
130 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
131 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_no_context_takeover");
132}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [32/43]

BOOST_AUTO_TEST_CASE ( negotiate_three_client_initiated1 )

Definition at line 436 of file permessage_deflate.cpp.

436 {
437 ext_vars v;
438
439 v.attr["server_no_context_takeover"].clear();
440 v.attr["client_no_context_takeover"].clear();
441 v.attr["server_max_window_bits"] = "10";
442
443 v.esp = v.exts.negotiate(v.attr);
444 BOOST_CHECK( v.exts.is_enabled() );
445 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
446 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_no_context_takeover; client_no_context_takeover; server_max_window_bits=10");
447}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [33/43]

BOOST_AUTO_TEST_CASE ( negotiate_three_client_initiated2 )

Definition at line 449 of file permessage_deflate.cpp.

449 {
450 ext_vars v;
451
452 v.attr["server_no_context_takeover"].clear();
453 v.attr["client_no_context_takeover"].clear();
454 v.attr["client_max_window_bits"] = "10";
455
456 v.esp = v.exts.negotiate(v.attr);
457 BOOST_CHECK( v.exts.is_enabled() );
458 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
459 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_no_context_takeover; client_no_context_takeover; client_max_window_bits=10");
460}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [34/43]

BOOST_AUTO_TEST_CASE ( negotiate_three_client_initiated3 )

Definition at line 462 of file permessage_deflate.cpp.

462 {
463 ext_vars v;
464
465 v.attr["server_no_context_takeover"].clear();
466 v.attr["server_max_window_bits"] = "10";
467 v.attr["client_max_window_bits"] = "10";
468
469 v.esp = v.exts.negotiate(v.attr);
470 BOOST_CHECK( v.exts.is_enabled() );
471 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
472 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_no_context_takeover; server_max_window_bits=10; client_max_window_bits=10");
473}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [35/43]

BOOST_AUTO_TEST_CASE ( negotiate_three_client_initiated4 )

Definition at line 475 of file permessage_deflate.cpp.

475 {
476 ext_vars v;
477
478 v.attr["client_no_context_takeover"].clear();
479 v.attr["server_max_window_bits"] = "10";
480 v.attr["client_max_window_bits"] = "10";
481
482 v.esp = v.exts.negotiate(v.attr);
483 BOOST_CHECK( v.exts.is_enabled() );
484 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
485 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_no_context_takeover; server_max_window_bits=10; client_max_window_bits=10");
486}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [36/43]

BOOST_AUTO_TEST_CASE ( negotiate_two_client_initiated1 )

Definition at line 364 of file permessage_deflate.cpp.

364 {
365 ext_vars v;
366
367 v.attr["server_no_context_takeover"].clear();
368 v.attr["client_no_context_takeover"].clear();
369
370 v.esp = v.exts.negotiate(v.attr);
371 BOOST_CHECK( v.exts.is_enabled() );
372 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
373 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_no_context_takeover; client_no_context_takeover");
374}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [37/43]

BOOST_AUTO_TEST_CASE ( negotiate_two_client_initiated2 )

Definition at line 376 of file permessage_deflate.cpp.

376 {
377 ext_vars v;
378
379 v.attr["server_no_context_takeover"].clear();
380 v.attr["server_max_window_bits"] = "10";
381
382 v.esp = v.exts.negotiate(v.attr);
383 BOOST_CHECK( v.exts.is_enabled() );
384 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
385 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_no_context_takeover; server_max_window_bits=10");
386}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [38/43]

BOOST_AUTO_TEST_CASE ( negotiate_two_client_initiated3 )

Definition at line 388 of file permessage_deflate.cpp.

388 {
389 ext_vars v;
390
391 v.attr["server_no_context_takeover"].clear();
392 v.attr["client_max_window_bits"] = "10";
393
394 v.esp = v.exts.negotiate(v.attr);
395 BOOST_CHECK( v.exts.is_enabled() );
396 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
397 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_no_context_takeover; client_max_window_bits=10");
398}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [39/43]

BOOST_AUTO_TEST_CASE ( negotiate_two_client_initiated4 )

Definition at line 400 of file permessage_deflate.cpp.

400 {
401 ext_vars v;
402
403 v.attr["client_no_context_takeover"].clear();
404 v.attr["server_max_window_bits"] = "10";
405
406 v.esp = v.exts.negotiate(v.attr);
407 BOOST_CHECK( v.exts.is_enabled() );
408 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
409 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_no_context_takeover; server_max_window_bits=10");
410}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [40/43]

BOOST_AUTO_TEST_CASE ( negotiate_two_client_initiated5 )

Definition at line 412 of file permessage_deflate.cpp.

412 {
413 ext_vars v;
414
415 v.attr["client_no_context_takeover"].clear();
416 v.attr["client_max_window_bits"] = "10";
417
418 v.esp = v.exts.negotiate(v.attr);
419 BOOST_CHECK( v.exts.is_enabled() );
420 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
421 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_no_context_takeover; client_max_window_bits=10");
422}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [41/43]

BOOST_AUTO_TEST_CASE ( negotiate_two_client_initiated6 )

Definition at line 424 of file permessage_deflate.cpp.

424 {
425 ext_vars v;
426
427 v.attr["server_max_window_bits"] = "10";
428 v.attr["client_max_window_bits"] = "10";
429
430 v.esp = v.exts.negotiate(v.attr);
431 BOOST_CHECK( v.exts.is_enabled() );
432 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
433 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=10; client_max_window_bits=10");
434}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [42/43]

BOOST_AUTO_TEST_CASE ( negotiation_empty_attr )

Definition at line 84 of file permessage_deflate.cpp.

84 {
85 ext_vars v;
86
87 v.esp = v.exts.negotiate(v.attr);
88 BOOST_CHECK( v.exts.is_enabled() );
89 BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
90 BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate");
91}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [43/43]

BOOST_AUTO_TEST_CASE ( negotiation_invalid_attr )

Definition at line 93 of file permessage_deflate.cpp.

93 {
94 ext_vars v;
95 v.attr["foo"] = "bar";
96
97 v.esp = v.exts.negotiate(v.attr);
98 BOOST_CHECK( !v.exts.is_enabled() );
99 BOOST_CHECK_EQUAL( v.esp.first, pmde::make_error_code(pmde::invalid_attributes) );
100 BOOST_CHECK_EQUAL( v.esp.second, "");
101}
@ invalid_attributes
Invalid extension attributes.
Definition enabled.hpp:96
Here is the call graph for this function: