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
863a02b4
Commit
863a02b4
authored
Aug 17, 2017
by
sigiesec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: no ZAP tests for PLAIN mechanism
Solution: added ZAP tests for PLAIN
parent
00816875
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
3 deletions
+38
-3
test_security_zap.cpp
tests/test_security_zap.cpp
+4
-0
testutil_security.hpp
tests/testutil_security.hpp
+34
-3
No files found.
tests/test_security_zap.cpp
View file @
863a02b4
...
...
@@ -201,6 +201,10 @@ int main (void)
test_zap_errors
(
&
socket_config_null_server
,
NULL
,
&
socket_config_null_client
,
NULL
);
fprintf
(
stderr
,
"PLAIN mechanism
\n
"
);
test_zap_errors
(
&
socket_config_plain_server
,
NULL
,
&
socket_config_plain_client
,
NULL
);
if
(
zmq_has
(
"curve"
))
{
fprintf
(
stderr
,
"CURVE mechanism
\n
"
);
setup_testutil_security_curve
();
...
...
tests/testutil_security.hpp
View file @
863a02b4
...
...
@@ -49,6 +49,26 @@ void socket_config_null_server (void *server, void *server_secret)
assert
(
rc
==
0
);
}
// 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
)
{
int
rc
=
zmq_setsockopt
(
server
,
ZMQ_PLAIN_PASSWORD
,
test_plain_password
,
8
);
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
)
{
int
as_server
=
1
;
int
rc
=
zmq_setsockopt
(
server
,
ZMQ_PLAIN_SERVER
,
&
as_server
,
sizeof
(
int
));
assert
(
rc
==
0
);
}
// CURVE specific functions
// We'll generate random test keys at startup
...
...
@@ -175,12 +195,23 @@ void zap_handler_generic (void *ctx,
}
else
if
(
streq
(
mechanism
,
"PLAIN"
))
{
// TODO
authentication_succeeded
=
true
;
char
client_username
[
32
];
int
size
=
zmq_recv
(
handler
,
client_username
,
32
,
0
);
assert
(
size
>
0
);
client_username
[
size
]
=
0
;
char
client_password
[
32
];
size
=
zmq_recv
(
handler
,
client_password
,
32
,
0
);
assert
(
size
>
0
);
client_password
[
size
]
=
0
;
authentication_succeeded
=
streq
(
test_plain_username
,
client_username
)
&&
streq
(
test_plain_password
,
client_password
);
}
else
if
(
streq
(
mechanism
,
"NULL"
))
{
authentication_succeeded
=
true
;
authentication_succeeded
=
true
;
}
else
{
...
...
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