mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-26 23:01:04 +08:00
test unauthenticated messages from vanilla sockets
fails on all auth mechanisms
This commit is contained in:
parent
c57d557460
commit
c35c0ca1bb
@ -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);
|
||||
|
@ -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
|
||||
|
||||
static void
|
||||
zap_handler (void *handler)
|
||||
@ -124,6 +133,32 @@ int main (void)
|
||||
close_zero_linger (client);
|
||||
close_zero_linger (server);
|
||||
|
||||
// Unauthenticated messages from a vanilla socket shouldn't be received
|
||||
server = zmq_socket (ctx, ZMQ_DEALER);
|
||||
assert (server);
|
||||
rc = zmq_setsockopt (server, ZMQ_ZAP_DOMAIN, "WRONG", 5);
|
||||
assert (rc == 0);
|
||||
rc = zmq_bind (server, "tcp://127.0.0.1:9002");
|
||||
assert (rc == 0);
|
||||
|
||||
struct sockaddr_in ip4addr;
|
||||
int s;
|
||||
|
||||
ip4addr.sin_family = AF_INET;
|
||||
ip4addr.sin_port = htons(9002);
|
||||
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);
|
||||
close_zero_linger (server);
|
||||
|
||||
// Shutdown
|
||||
rc = zmq_ctx_term (ctx);
|
||||
assert (rc == 0);
|
||||
|
@ -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
|
||||
|
||||
static void
|
||||
zap_handler (void *ctx)
|
||||
@ -137,6 +146,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);
|
||||
|
||||
// Shutdown
|
||||
rc = zmq_close (server);
|
||||
assert (rc == 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user