Commit efaca82b authored by Simon Giesecke's avatar Simon Giesecke

Problem: testutil_security not using unity

Solution: migrate to unity and adapt users
parent 6e072460
......@@ -62,7 +62,6 @@ const char *zmq_errno_message ()
#define TEST_ASSERT_ZMQ_ERRNO(condition) \
TEST_ASSERT_MESSAGE ((condition), zmq_errno_message ())
void *ctx;
void *handler;
void *zap_thread;
void *server;
......@@ -71,14 +70,15 @@ char my_endpoint[MAX_SOCKET_STRING];
void setUp ()
{
setup_context_and_server_side (&ctx, &handler, &zap_thread, &server,
&server_mon, my_endpoint);
setup_test_context ();
setup_context_and_server_side (&handler, &zap_thread, &server, &server_mon,
my_endpoint);
}
void tearDown ()
{
shutdown_context_and_server_side (ctx, zap_thread, server, server_mon,
handler);
shutdown_context_and_server_side (zap_thread, server, server_mon, handler);
teardown_test_context ();
}
const int timeout = 250;
......@@ -91,13 +91,12 @@ const char large_routing_id[] = "0123456789012345678901234567890123456789"
"0123456789012345678901234567890123456789"
"012345678901234";
static void zap_handler_large_routing_id (void *ctx_)
static void zap_handler_large_routing_id (void * /*unused_*/)
{
zap_handler_generic (ctx_, zap_ok, large_routing_id);
zap_handler_generic (zap_ok, large_routing_id);
}
void expect_new_client_curve_bounce_fail (void *ctx_,
char *server_public_,
void expect_new_client_curve_bounce_fail (char *server_public_,
char *client_public_,
char *client_secret_,
char *my_endpoint_,
......@@ -109,20 +108,18 @@ void expect_new_client_curve_bounce_fail (void *ctx_,
curve_client_data_t curve_client_data = {server_public_, client_public_,
client_secret_};
expect_new_client_bounce_fail (
ctx_, my_endpoint_, server_, socket_config_curve_client,
&curve_client_data, client_mon_, expected_client_event_,
expected_client_value_);
my_endpoint_, server_, socket_config_curve_client, &curve_client_data,
client_mon_, expected_client_event_, expected_client_value_);
}
void test_null_key (void *ctx_,
void *server_,
void test_null_key (void *server_,
void *server_mon_,
char *my_endpoint_,
char *server_public_,
char *client_public_,
char *client_secret_)
{
expect_new_client_curve_bounce_fail (ctx_, server_public_, client_public_,
expect_new_client_curve_bounce_fail (server_public_, client_public_,
client_secret_, my_endpoint_, server_);
int handshake_failed_encryption_event_count =
......@@ -148,12 +145,10 @@ void test_curve_security_with_valid_credentials ()
curve_client_data_t curve_client_data = {
valid_server_public, valid_client_public, valid_client_secret};
void *client_mon;
void *client =
create_and_connect_client (ctx, my_endpoint, socket_config_curve_client,
&curve_client_data, &client_mon);
void *client = create_and_connect_client (
my_endpoint, socket_config_curve_client, &curve_client_data, &client_mon);
bounce (server, client);
int rc = zmq_close (client);
TEST_ASSERT_ZMQ_ERRNO (rc == 0);
test_context_socket_close (client);
int event = get_monitor_event_with_timeout (server_mon, NULL, NULL, -1);
assert (event == ZMQ_EVENT_HANDSHAKE_SUCCEEDED);
......@@ -165,8 +160,7 @@ void test_curve_security_with_valid_credentials ()
assert_no_more_monitor_events_with_timeout (client_mon, timeout);
rc = zmq_close (client_mon);
TEST_ASSERT_ZMQ_ERRNO (rc == 0);
test_context_socket_close (client_mon);
}
void test_curve_security_with_bogus_client_credentials ()
......@@ -177,7 +171,7 @@ void test_curve_security_with_bogus_client_credentials ()
zmq_curve_keypair (bogus_public, bogus_secret);
expect_new_client_curve_bounce_fail (
ctx, valid_server_public, bogus_public, bogus_secret, my_endpoint, server,
valid_server_public, bogus_public, bogus_secret, my_endpoint, server,
NULL, ZMQ_EVENT_HANDSHAKE_FAILED_AUTH, 400);
int server_event_count = 0;
......@@ -199,7 +193,7 @@ void expect_zmtp_mechanism_mismatch (void *client_,
int rc = zmq_connect (client_, my_endpoint_);
TEST_ASSERT_ZMQ_ERRNO (rc == 0);
expect_bounce_fail (server_, client_);
close_zero_linger (client_);
test_context_socket_close_zero_linger (client_);
expect_monitor_event_multiple (server_mon_,
ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL,
......@@ -210,16 +204,14 @@ void expect_zmtp_mechanism_mismatch (void *client_,
void test_curve_security_with_null_client_credentials ()
{
void *client = zmq_socket (ctx, ZMQ_DEALER);
TEST_ASSERT_NOT_NULL (client);
void *client = test_context_socket (ZMQ_DEALER);
expect_zmtp_mechanism_mismatch (client, my_endpoint, server, server_mon);
}
void test_curve_security_with_plain_client_credentials ()
{
void *client = zmq_socket (ctx, ZMQ_DEALER);
TEST_ASSERT_NOT_NULL (client);
void *client = test_context_socket (ZMQ_DEALER);
int rc = zmq_setsockopt (client, ZMQ_PLAIN_USERNAME, "admin", 5);
TEST_ASSERT_ZMQ_ERRNO (rc == 0);
rc = zmq_setsockopt (client, ZMQ_PLAIN_PASSWORD, "password", 8);
......@@ -579,7 +571,7 @@ void test_null_server_key ()
{
// Check CURVE security with a null server key
// This will be caught by the curve_server class, not passed to ZAP
test_null_key (ctx, server, server_mon, my_endpoint, null_key,
test_null_key (server, server_mon, my_endpoint, null_key,
valid_client_public, valid_client_secret);
}
......@@ -587,7 +579,7 @@ void test_null_client_public_key ()
{
// Check CURVE security with a null client public key
// This will be caught by the curve_server class, not passed to ZAP
test_null_key (ctx, server, server_mon, my_endpoint, valid_server_public,
test_null_key (server, server_mon, my_endpoint, valid_server_public,
null_key, valid_client_secret);
}
......@@ -595,7 +587,7 @@ void test_null_client_secret_key ()
{
// Check CURVE security with a null client public key
// This will be caught by the curve_server class, not passed to ZAP
test_null_key (ctx, server, server_mon, my_endpoint, valid_server_public,
test_null_key (server, server_mon, my_endpoint, valid_server_public,
valid_client_public, null_key);
}
......@@ -637,15 +629,16 @@ int main (void)
// test with a large routing id (resulting in large metadata)
fprintf (stderr,
"test_curve_security_with_valid_credentials (large routing id)\n");
setup_context_and_server_side (
&ctx, &handler, &zap_thread, &server, &server_mon, my_endpoint,
&zap_handler_large_routing_id, &socket_config_curve_server,
&valid_server_secret, large_routing_id);
setup_test_context ();
setup_context_and_server_side (&handler, &zap_thread, &server, &server_mon,
my_endpoint, &zap_handler_large_routing_id,
&socket_config_curve_server,
&valid_server_secret, large_routing_id);
test_curve_security_with_valid_credentials ();
shutdown_context_and_server_side (ctx, zap_thread, server, server_mon,
handler);
shutdown_context_and_server_side (zap_thread, server, server_mon, handler);
teardown_test_context ();
ctx = zmq_ctx_new ();
void *ctx = zmq_ctx_new ();
test_curve_security_invalid_keysize (ctx);
int rc = zmq_ctx_term (ctx);
TEST_ASSERT_ZMQ_ERRNO (rc == 0);
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment