mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-06 19:14:05 +02:00
test unauthenticated messages from vanilla sockets
fails on all auth mechanisms
This commit is contained in:
@@ -18,6 +18,15 @@
|
||||
*/
|
||||
|
||||
#include "testutil.hpp"
|
||||
#if defined (ZMQ_HAVE_WINDOWS)
|
||||
# include <winsock2.h>
|
||||
# include <stdexcept>
|
||||
#else
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
# include <arpa/inet.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
// We'll generate random test keys at startup
|
||||
static char client_public [41];
|
||||
@@ -218,6 +227,24 @@ int main (void)
|
||||
expect_bounce_fail (server, client);
|
||||
close_zero_linger (client);
|
||||
|
||||
// Unauthenticated messages from a vanilla socket shouldn't be received
|
||||
struct sockaddr_in ip4addr;
|
||||
int s;
|
||||
|
||||
ip4addr.sin_family = AF_INET;
|
||||
ip4addr.sin_port = htons (9998);
|
||||
inet_pton (AF_INET, "127.0.0.1", &ip4addr.sin_addr);
|
||||
|
||||
s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
rc = connect (s, (struct sockaddr*) &ip4addr, sizeof (ip4addr));
|
||||
assert (rc > -1);
|
||||
send (s, "GET / HTTP/1.0\r\nUser-Agent: some_really_long_user_agent\r\nHost: localhost\r\nHeader: shouldn't arrive\r\n\r\n", 102, 0);
|
||||
int timeout = 150;
|
||||
zmq_setsockopt (server, ZMQ_RCVTIMEO, &timeout, sizeof (timeout));
|
||||
char *buf = s_recv (server);
|
||||
assert (buf == NULL);
|
||||
close (s);
|
||||
|
||||
// Check return codes for invalid buffer sizes
|
||||
client = zmq_socket (ctx, ZMQ_DEALER);
|
||||
assert (client);
|
||||
|
Reference in New Issue
Block a user