Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
c35c0ca1
Commit
c35c0ca1
authored
Dec 03, 2014
by
Min RK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test unauthenticated messages from vanilla sockets
fails on all auth mechanisms
parent
c57d5574
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
0 deletions
+89
-0
test_security_curve.cpp
tests/test_security_curve.cpp
+27
-0
test_security_null.cpp
tests/test_security_null.cpp
+35
-0
test_security_plain.cpp
tests/test_security_plain.cpp
+27
-0
No files found.
tests/test_security_curve.cpp
View file @
c35c0ca1
...
@@ -18,6 +18,15 @@
...
@@ -18,6 +18,15 @@
*/
*/
#include "testutil.hpp"
#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
// We'll generate random test keys at startup
static
char
client_public
[
41
];
static
char
client_public
[
41
];
...
@@ -218,6 +227,24 @@ int main (void)
...
@@ -218,6 +227,24 @@ int main (void)
expect_bounce_fail
(
server
,
client
);
expect_bounce_fail
(
server
,
client
);
close_zero_linger
(
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\n
User-Agent: some_really_long_user_agent
\r\n
Host: localhost
\r\n
Header: 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
// Check return codes for invalid buffer sizes
client
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
client
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
assert
(
client
);
assert
(
client
);
...
...
tests/test_security_null.cpp
View file @
c35c0ca1
...
@@ -18,6 +18,15 @@
...
@@ -18,6 +18,15 @@
*/
*/
#include "testutil.hpp"
#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
static
void
zap_handler
(
void
*
handler
)
zap_handler
(
void
*
handler
)
...
@@ -124,6 +133,32 @@ int main (void)
...
@@ -124,6 +133,32 @@ int main (void)
close_zero_linger
(
client
);
close_zero_linger
(
client
);
close_zero_linger
(
server
);
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\n
User-Agent: some_really_long_user_agent
\r\n
Host: localhost
\r\n
Header: 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
// Shutdown
rc
=
zmq_ctx_term
(
ctx
);
rc
=
zmq_ctx_term
(
ctx
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
...
...
tests/test_security_plain.cpp
View file @
c35c0ca1
...
@@ -18,6 +18,15 @@
...
@@ -18,6 +18,15 @@
*/
*/
#include "testutil.hpp"
#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
static
void
zap_handler
(
void
*
ctx
)
zap_handler
(
void
*
ctx
)
...
@@ -137,6 +146,24 @@ int main (void)
...
@@ -137,6 +146,24 @@ int main (void)
expect_bounce_fail
(
server
,
client
);
expect_bounce_fail
(
server
,
client
);
close_zero_linger
(
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\n
User-Agent: some_really_long_user_agent
\r\n
Host: localhost
\r\n
Header: 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
// Shutdown
rc
=
zmq_close
(
server
);
rc
=
zmq_close
(
server
);
assert
(
rc
==
0
);
assert
(
rc
==
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment