testutil_security.hpp 23.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
/*
    Copyright (c) 2007-2017 Contributors as noted in the AUTHORS file

    This file is part of libzmq, the ZeroMQ core engine in C++.

    libzmq is free software; you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License (LGPL) as published
    by the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    As a special exception, the Contributors give you permission to link
    this library with independent modules to produce an executable,
    regardless of the license terms of these independent modules, and to
    copy and distribute the resulting executable under terms of your choice,
    provided that you also meet, for each linked independent module, the
    terms and conditions of the license of that module. An independent
    module is a module which is not derived from or based on this library.
    If you modify this library, you must extend this exception to your
    version of the library.

    libzmq is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
    License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __TESTUTIL_SECURITY_HPP_INCLUDED__
#define __TESTUTIL_SECURITY_HPP_INCLUDED__

#include "testutil.hpp"

//  security test utils

typedef void(socket_config_fn) (void *, void *);

39 40 41 42 43
const char *test_zap_domain = "ZAPTEST";

//  NULL specific functions
void socket_config_null_client (void *server, void *server_secret)
{
44 45
    LIBZMQ_UNUSED (server);
    LIBZMQ_UNUSED (server_secret);
46 47 48 49
}

void socket_config_null_server (void *server, void *server_secret)
{
50 51
    LIBZMQ_UNUSED (server_secret);

52 53
    int rc = zmq_setsockopt (server, ZMQ_ZAP_DOMAIN, test_zap_domain,
                             strlen (test_zap_domain));
54 55 56
    assert (rc == 0);
}

57 58 59 60 61 62
//  PLAIN specific functions
const char *test_plain_username = "testuser";
const char *test_plain_password = "testpass";

void socket_config_plain_client (void *server, void *server_secret)
{
63 64
    LIBZMQ_UNUSED (server_secret);

65 66
    int rc =
      zmq_setsockopt (server, ZMQ_PLAIN_PASSWORD, test_plain_password, 8);
67 68 69 70 71 72 73 74
    assert (rc == 0);

    rc = zmq_setsockopt (server, ZMQ_PLAIN_USERNAME, test_plain_username, 8);
    assert (rc == 0);
}

void socket_config_plain_server (void *server, void *server_secret)
{
75 76
    LIBZMQ_UNUSED (server_secret);

77
    int as_server = 1;
78 79
    int rc =
      zmq_setsockopt (server, ZMQ_PLAIN_SERVER, &as_server, sizeof (int));
80
    assert (rc == 0);
81 82 83

    rc = zmq_setsockopt (server, ZMQ_ZAP_DOMAIN, test_zap_domain,
                         strlen (test_zap_domain));
84
    assert (rc == 0);
85 86
}

87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
//  CURVE specific functions

//  We'll generate random test keys at startup
char valid_client_public[41];
char valid_client_secret[41];
char valid_server_public[41];
char valid_server_secret[41];

void setup_testutil_security_curve ()
{
    //  Generate new keypairs for these tests
    int rc = zmq_curve_keypair (valid_client_public, valid_client_secret);
    assert (rc == 0);
    rc = zmq_curve_keypair (valid_server_public, valid_server_secret);
    assert (rc == 0);
}

void socket_config_curve_server (void *server, void *server_secret)
{
    int as_server = 1;
107 108
    int rc =
      zmq_setsockopt (server, ZMQ_CURVE_SERVER, &as_server, sizeof (int));
109 110 111 112
    assert (rc == 0);

    rc = zmq_setsockopt (server, ZMQ_CURVE_SECRETKEY, server_secret, 41);
    assert (rc == 0);
113 114 115

    rc = zmq_setsockopt (server, ZMQ_ZAP_DOMAIN, test_zap_domain,
                         strlen (test_zap_domain));
116
    assert (rc == 0);
117 118 119 120 121 122 123

#ifdef ZMQ_ZAP_ENFORCE_DOMAIN
    int required = 1;
    rc = zmq_setsockopt (server, ZMQ_ZAP_ENFORCE_DOMAIN, &required,
            sizeof (int));
    assert (rc == 0);
#endif
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
}

struct curve_client_data_t
{
    const char *server_public;
    const char *client_public;
    const char *client_secret;
};

void socket_config_curve_client (void *client, void *data)
{
    curve_client_data_t *curve_client_data =
      static_cast<curve_client_data_t *> (data);

    int rc = zmq_setsockopt (client, ZMQ_CURVE_SERVERKEY,
                             curve_client_data->server_public, 41);
    assert (rc == 0);
    rc = zmq_setsockopt (client, ZMQ_CURVE_PUBLICKEY,
                         curve_client_data->client_public, 41);
    assert (rc == 0);
    rc = zmq_setsockopt (client, ZMQ_CURVE_SECRETKEY,
                         curve_client_data->client_secret, 41);
    assert (rc == 0);
}

//  --------------------------------------------------------------------------
//  This methods receives and validates ZAP requests (allowing or denying
//  each client connection).

enum zap_protocol_t
{
155 156 157 158 159 160 161 162
    zap_ok,
    // ZAP-compliant non-standard cases
    zap_status_temporary_failure,
    zap_status_internal_error,
    // ZAP protocol errors
    zap_wrong_version,
    zap_wrong_request_id,
    zap_status_invalid,
163
    zap_too_many_parts,
164 165 166
    zap_disconnect,
    zap_do_not_recv,
    zap_do_not_send
167 168 169 170 171 172
};

void *zap_requests_handled;

void zap_handler_generic (void *ctx,
                          zap_protocol_t zap_protocol,
173
                          const char *expected_routing_id = "IDENT")
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
{
    void *control = zmq_socket (ctx, ZMQ_REQ);
    assert (control);
    int rc = zmq_connect (control, "inproc://handler-control");
    assert (rc == 0);

    void *handler = zmq_socket (ctx, ZMQ_REP);
    assert (handler);
    rc = zmq_bind (handler, "inproc://zeromq.zap.01");
    assert (rc == 0);

    //  Signal main thread that we are ready
    rc = s_send (control, "GO");
    assert (rc == 2);

    zmq_pollitem_t items[] = {
190 191
      {control, 0, ZMQ_POLLIN, 0},
      {handler, 0, ZMQ_POLLIN, 0},
192 193
    };

194 195 196
    // if ordered not to receive the request, ignore the second poll item
    const int numitems = (zap_protocol == zap_do_not_recv) ? 1 : 2;

197
    //  Process ZAP requests forever
198
    while (zmq_poll (items, numitems, -1) >= 0) {
199 200 201 202 203 204 205 206 207 208 209 210 211
        if (items[0].revents & ZMQ_POLLIN) {
            char *buf = s_recv (control);
            assert (buf);
            assert (streq (buf, "STOP"));
            free (buf);
            break; //  Terminating - main thread signal
        }
        if (!(items[1].revents & ZMQ_POLLIN))
            continue;

        char *version = s_recv (handler);
        if (!version)
            break; //  Terminating - peer's socket closed
212
        if (zap_protocol == zap_disconnect) {
213
            free (version);
214
            break;
215
        }
216 217 218 219

        char *sequence = s_recv (handler);
        char *domain = s_recv (handler);
        char *address = s_recv (handler);
220
        char *routing_id = s_recv (handler);
221
        char *mechanism = s_recv (handler);
222 223 224 225 226 227 228 229
        bool authentication_succeeded = false;
        if (streq (mechanism, "CURVE")) {
            uint8_t client_key[32];
            int size = zmq_recv (handler, client_key, 32, 0);
            assert (size == 32);

            char client_key_text[41];
            zmq_z85_encode (client_key_text, client_key, 32);
230

231 232
            authentication_succeeded =
              streq (client_key_text, valid_client_public);
233
        } else if (streq (mechanism, "PLAIN")) {
234
            char client_username[32];
235 236
            int size = zmq_recv (handler, client_username, 32, 0);
            assert (size > 0);
237
            client_username[size] = 0;
238

239
            char client_password[32];
240 241
            size = zmq_recv (handler, client_password, 32, 0);
            assert (size > 0);
242
            client_password[size] = 0;
243 244 245 246

            authentication_succeeded =
              streq (test_plain_username, client_username)
              && streq (test_plain_password, client_password);
247
        } else if (streq (mechanism, "NULL")) {
248
            authentication_succeeded = true;
249
        } else {
250 251 252
            fprintf (stderr, "Unsupported mechanism: %s\n", mechanism);
            assert (false);
        }
253 254

        assert (streq (version, "1.0"));
255
        assert (streq (routing_id, expected_routing_id));
256 257 258 259 260 261 262 263

        s_sendmore (handler, zap_protocol == zap_wrong_version
                               ? "invalid_version"
                               : version);
        s_sendmore (handler, zap_protocol == zap_wrong_request_id
                               ? "invalid_request_id"
                               : sequence);

264
        if (authentication_succeeded) {
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
            const char *status_code;
            switch (zap_protocol) {
                case zap_status_internal_error:
                    status_code = "500";
                    break;
                case zap_status_temporary_failure:
                    status_code = "300";
                    break;
                case zap_status_invalid:
                    status_code = "invalid_status";
                    break;
                default:
                    status_code = "200";
            }
            s_sendmore (handler, status_code);
            s_sendmore (handler, "OK");
            s_sendmore (handler, "anonymous");
            if (zap_protocol == zap_too_many_parts) {
                s_sendmore (handler, "");
            }
285 286
            if (zap_protocol != zap_do_not_send)
                s_send (handler, "");
287 288 289 290
        } else {
            s_sendmore (handler, "400");
            s_sendmore (handler, "Invalid client public key");
            s_sendmore (handler, "");
291
            if (zap_protocol != zap_do_not_send)
292
                s_send (handler, "");
293 294 295 296 297
        }
        free (version);
        free (sequence);
        free (domain);
        free (address);
298
        free (routing_id);
299 300 301 302 303 304 305 306
        free (mechanism);

        zmq_atomic_counter_inc (zap_requests_handled);
    }
    rc = zmq_unbind (handler, "inproc://zeromq.zap.01");
    assert (rc == 0);
    close_zero_linger (handler);

307 308 309
    if (zap_protocol != zap_disconnect) {
        rc = s_send (control, "STOPPED");
        assert (rc == 7);
310
    }
311 312 313 314 315 316 317 318 319 320 321 322 323 324
    close_zero_linger (control);
}

void zap_handler (void *ctx)
{
    zap_handler_generic (ctx, zap_ok);
}

//  Monitor event utilities

//  Read one event off the monitor socket; return value and address
//  by reference, if not null, and event number by value. Returns -1
//  in case of error.

325 326 327 328
static int get_monitor_event_internal (void *monitor,
                                       int *value,
                                       char **address,
                                       int recv_flag)
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
{
    //  First frame in message contains event number and value
    zmq_msg_t msg;
    zmq_msg_init (&msg);
    if (zmq_msg_recv (&msg, monitor, recv_flag) == -1) {
        assert (errno == EAGAIN);
        return -1; //  timed out or no message available
    }
    assert (zmq_msg_more (&msg));

    uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
    uint16_t event = *(uint16_t *) (data);
    if (value)
        *value = *(uint32_t *) (data + 2);

    //  Second frame in message contains event address
    zmq_msg_init (&msg);
    int res = zmq_msg_recv (&msg, monitor, recv_flag) == -1;
    assert (res != -1);
    assert (!zmq_msg_more (&msg));

    if (address) {
        uint8_t *data = (uint8_t *) zmq_msg_data (&msg);
        size_t size = zmq_msg_size (&msg);
        *address = (char *) malloc (size + 1);
        memcpy (*address, data, size);
355
        *address[size] = 0;
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
    }
    return event;
}

int get_monitor_event_with_timeout (void *monitor,
                                    int *value,
                                    char **address,
                                    int timeout)
{
    int res;
    if (timeout == -1) {
        // process infinite timeout in small steps to allow the user
        // to see some information on the console

        int timeout_step = 250;
        int wait_time = 0;
        zmq_setsockopt (monitor, ZMQ_RCVTIMEO, &timeout_step,
                        sizeof (timeout_step));
        while ((res = get_monitor_event_internal (monitor, value, address, 0))
               == -1) {
            wait_time += timeout_step;
            fprintf (stderr, "Still waiting for monitor event after %i ms\n",
                     wait_time);
        }
    } else {
        zmq_setsockopt (monitor, ZMQ_RCVTIMEO, &timeout, sizeof (timeout));
        res = get_monitor_event_internal (monitor, value, address, 0);
    }
    int timeout_infinite = -1;
    zmq_setsockopt (monitor, ZMQ_RCVTIMEO, &timeout_infinite,
                    sizeof (timeout_infinite));
    return res;
}

390 391 392 393 394 395 396 397
int get_monitor_event (void *monitor, int *value, char **address)
{
    return get_monitor_event_with_timeout (monitor, value, address, -1);
}

void expect_monitor_event (void *monitor, int expected_event)
{
    int event = get_monitor_event (monitor, NULL, NULL);
398
    if (event != expected_event) {
399 400 401 402 403 404
        fprintf (stderr, "Expected monitor event %x but received %x\n",
                 expected_event, event);
        assert (event == expected_event);
    }
}

405
#ifdef ZMQ_BUILD_DRAFT_API
406 407 408 409 410 411

void print_unexpected_event (int event,
                             int err,
                             int expected_event,
                             int expected_err)
{
412 413 414 415
    fprintf (stderr,
             "Unexpected event: 0x%x, value = %i/0x%x (expected: 0x%x, value "
             "= %i/0x%x)\n",
             event, err, err, expected_event, expected_err, expected_err);
416 417
}

418
//  expects that one or more occurrences of the expected event are received
419 420 421 422
//  via the specified socket monitor
//  returns the number of occurrences of the expected event
//  interrupts, if a ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL with EPIPE, ECONNRESET
//  or ECONNABORTED occurs; in this case, 0 is returned
423
//  this should be investigated further, see
424 425 426
//  https://github.com/zeromq/libzmq/issues/2644
int expect_monitor_event_multiple (void *server_mon,
                                   int expected_event,
427 428
                                   int expected_err = -1,
                                   bool optional = false)
429 430 431
{
    int count_of_expected_events = 0;
    int client_closed_connection = 0;
432 433
    int timeout = 250;
    int wait_time = 0;
434 435 436 437 438

    int event;
    int err;
    while (
      (event = get_monitor_event_with_timeout (server_mon, &err, NULL, timeout))
439 440
        != -1
      || !count_of_expected_events) {
441
        if (event == -1) {
442 443
            if (optional)
                break;
444 445 446
            wait_time += timeout;
            fprintf (stderr,
                     "Still waiting for first event after %ims (expected event "
447
                     "%x (value %i/0x%x))\n",
448 449 450
                     wait_time, expected_event, expected_err, expected_err);
            continue;
        }
451 452 453 454
        // ignore errors with EPIPE/ECONNRESET/ECONNABORTED, which can happen
        // ECONNRESET can happen on very slow machines, when the engine writes
        // to the peer and then tries to read the socket before the peer reads
        // ECONNABORTED happens when a client aborts a connection via RST/timeout
455
        if (event == ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL
456 457
            && ((err == EPIPE && expected_err != EPIPE) || err == ECONNRESET
                || err == ECONNABORTED)) {
458 459 460 461
            fprintf (stderr,
                     "Ignored event (skipping any further events): %x (err = "
                     "%i == %s)\n",
                     event, err, zmq_strerror (err));
462 463 464 465 466
            client_closed_connection = 1;
            break;
        }
        if (event != expected_event
            || (-1 != expected_err && err != expected_err)) {
467
            print_unexpected_event (event, err, expected_event, expected_err);
468 469 470 471
            assert (false);
        }
        ++count_of_expected_events;
    }
472 473
    assert (optional || count_of_expected_events > 0
            || client_closed_connection);
474 475 476

    return count_of_expected_events;
}
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491

// assert_* are macros rather than functions, to allow assertion failures be
// attributed to the causing source code line
#define assert_no_more_monitor_events_with_timeout(monitor, timeout)           \
    {                                                                          \
        int event_count = 0;                                                   \
        int event, err;                                                        \
        while ((event = get_monitor_event_with_timeout ((monitor), &err, NULL, \
                                                        (timeout)))            \
               != -1) {                                                        \
            if (event == ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL                  \
                && (err == EPIPE || err == ECONNRESET                          \
                    || err == ECONNABORTED)) {                                 \
                fprintf (stderr,                                               \
                         "Ignored event (skipping any further events): %x "    \
492 493
                         "(err = %i == %s)\n",                                 \
                         event, err, zmq_strerror (err));                      \
494 495 496 497 498 499 500 501
                continue;                                                      \
            }                                                                  \
            ++event_count;                                                     \
            print_unexpected_event (event, err, 0, 0);                         \
        }                                                                      \
        assert (event_count == 0);                                             \
    }

502 503
#endif

504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
void setup_handshake_socket_monitor (void *ctx,
                                     void *server,
                                     void **server_mon,
                                     const char *monitor_endpoint)
{
#ifdef ZMQ_BUILD_DRAFT_API
    //  Monitor handshake events on the server
    int rc = zmq_socket_monitor (server, monitor_endpoint,
                                 ZMQ_EVENT_HANDSHAKE_SUCCEEDED
                                   | ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL
                                   | ZMQ_EVENT_HANDSHAKE_FAILED_AUTH
                                   | ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL);
    assert (rc == 0);

    //  Create socket for collecting monitor events
    *server_mon = zmq_socket (ctx, ZMQ_PAIR);
    assert (*server_mon);
521 522 523
    int linger = 0;
    rc = zmq_setsockopt (*server_mon, ZMQ_LINGER, &linger, sizeof(linger));
    assert (rc == 0);
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540

    //  Connect it to the inproc endpoints so they'll get events
    rc = zmq_connect (*server_mon, monitor_endpoint);
    assert (rc == 0);
#endif
}

void setup_context_and_server_side (
  void **ctx,
  void **zap_control,
  void **zap_thread,
  void **server,
  void **server_mon,
  char *my_endpoint,
  zmq_thread_fn zap_handler_ = &zap_handler,
  socket_config_fn socket_config_ = &socket_config_curve_server,
  void *socket_config_data_ = valid_server_secret,
541
  const char *routing_id = "IDENT")
542 543 544 545 546 547 548 549 550 551 552 553
{
    *ctx = zmq_ctx_new ();
    assert (*ctx);

    //  Spawn ZAP handler
    zap_requests_handled = zmq_atomic_counter_new ();
    assert (zap_requests_handled != NULL);

    *zap_control = zmq_socket (*ctx, ZMQ_REP);
    assert (*zap_control);
    int rc = zmq_bind (*zap_control, "inproc://handler-control");
    assert (rc == 0);
554 555 556
    int linger = 0;
    rc = zmq_setsockopt (*zap_control, ZMQ_LINGER, &linger, sizeof(linger));
    assert (rc == 0);
557 558 559 560 561 562 563 564 565 566 567 568 569 570

    if (zap_handler_) {
        *zap_thread = zmq_threadstart (zap_handler_, *ctx);

        char *buf = s_recv (*zap_control);
        assert (buf);
        assert (streq (buf, "GO"));
        free (buf);
    } else
        *zap_thread = NULL;

    //  Server socket will accept connections
    *server = zmq_socket (*ctx, ZMQ_DEALER);
    assert (*server);
571 572
    rc = zmq_setsockopt (*server, ZMQ_LINGER, &linger, sizeof(linger));
    assert (rc == 0);
573 574 575

    socket_config_ (*server, socket_config_data_);

576 577
    rc =
      zmq_setsockopt (*server, ZMQ_ROUTING_ID, routing_id, strlen (routing_id));
578 579 580 581 582 583 584 585 586
    assert (rc == 0);

    rc = zmq_bind (*server, "tcp://127.0.0.1:*");
    assert (rc == 0);

    size_t len = MAX_SOCKET_STRING;
    rc = zmq_getsockopt (*server, ZMQ_LAST_ENDPOINT, my_endpoint, &len);
    assert (rc == 0);

587
    const char server_monitor_endpoint[] = "inproc://monitor-server";
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
    setup_handshake_socket_monitor (*ctx, *server, server_mon,
                                    server_monitor_endpoint);
}

void shutdown_context_and_server_side (void *ctx,
                                       void *zap_thread,
                                       void *server,
                                       void *server_mon,
                                       void *zap_control,
                                       bool zap_handler_stopped = false)
{
    if (zap_thread && !zap_handler_stopped) {
        int rc = s_send (zap_control, "STOP");
        assert (rc == 4);
        char *buf = s_recv (zap_control);
        assert (buf);
        assert (streq (buf, "STOPPED"));
        free (buf);
        rc = zmq_unbind (zap_control, "inproc://handler-control");
        assert (rc == 0);
    }
609 610
    int rc = zmq_close (zap_control);
    assert (rc == 0);
611 612

#ifdef ZMQ_BUILD_DRAFT_API
613 614
    rc = zmq_close (server_mon);
    assert (rc == 0);
615
#endif
616 617
    rc = zmq_close (server);
    assert (rc == 0);
618 619 620 621 622

    //  Wait until ZAP handler terminates
    if (zap_thread)
        zmq_threadclose (zap_thread);

623
    rc = zmq_ctx_term (ctx);
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
    assert (rc == 0);

    zmq_atomic_counter_destroy (&zap_requests_handled);
}

void *create_and_connect_client (void *ctx,
                                 char *my_endpoint,
                                 socket_config_fn socket_config_,
                                 void *socket_config_data_,
                                 void **client_mon = NULL)
{
    void *client = zmq_socket (ctx, ZMQ_DEALER);
    assert (client);

    socket_config_ (client, socket_config_data_);

    int rc = zmq_connect (client, my_endpoint);
    assert (rc == 0);

    if (client_mon) {
        setup_handshake_socket_monitor (ctx, client, client_mon,
                                        "inproc://client-monitor");
    }

    return client;
}

void expect_new_client_bounce_fail (void *ctx,
                                    char *my_endpoint,
                                    void *server,
                                    socket_config_fn socket_config_,
                                    void *socket_config_data_,
                                    void **client_mon = NULL,
                                    int expected_client_event = 0,
                                    int expected_client_value = 0)
{
    void *my_client_mon;
    assert (client_mon == NULL || expected_client_event == 0);
    if (expected_client_event != 0)
        client_mon = &my_client_mon;
    void *client = create_and_connect_client (ctx, my_endpoint, socket_config_,
                                              socket_config_data_, client_mon);
    expect_bounce_fail (server, client);

#ifdef ZMQ_BUILD_DRAFT_API
    if (expected_client_event != 0) {
        int events_received = 0;
        events_received = expect_monitor_event_multiple (
          my_client_mon, expected_client_event, expected_client_value, false);

        assert (events_received == 1);

        int rc = zmq_close (my_client_mon);
        assert (rc == 0);
    }
#endif

    close_zero_linger (client);
}

684
#endif