aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/oap/oap_client_test.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-12-08 23:12:17 +0100
committerHarald Welte <laforge@gnumonks.org>2016-12-13 14:54:02 +0000
commit2fa74faf927ed1ca9fc311a206c1e18a7295be7a (patch)
tree1d36a7411f0e471c20f4b1db84b02e1323463034 /openbsc/tests/oap/oap_client_test.c
parent3cbc05210192324592cc8b79e12d3095be302f90 (diff)
oap_client: reject all messages in disabled/uninitialized state
Fixes the bug indicated in oap_client_test.c: adjust to actually expect the proper behavior. Also adjust for modified return value for message rejection. Instead of -1, just expect < 0. Adjust experr for new error messages. Related: OS#1592 Change-Id: I16165d228653e8a2689f9df94b77b470c06480c6
Diffstat (limited to 'openbsc/tests/oap/oap_client_test.c')
-rw-r--r--openbsc/tests/oap/oap_client_test.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/openbsc/tests/oap/oap_client_test.c b/openbsc/tests/oap/oap_client_test.c
index 45decf8da..ab651e63b 100644
--- a/openbsc/tests/oap/oap_client_test.c
+++ b/openbsc/tests/oap/oap_client_test.c
@@ -52,19 +52,15 @@ static void test_oap_api(void)
fprintf(stderr, "- make sure filling with zeros means uninitialized\n");
OSMO_ASSERT(state->state == OAP_UNINITIALIZED);
- fprintf(stderr, "- reject messages in uninitialized state EXPECTING BUGS\n");
+ fprintf(stderr, "- reject messages in uninitialized state\n");
memset(&oap_rx, 0, sizeof(oap_rx));
state->client_id = 1;
oap_rx.message_type = OAP_MSGT_REGISTER_ERROR;
msg_rx = oap_client_encoded(&oap_rx);
- /* ATTENTION: This shows a bug in OAP: the rc should be < 0, but OAP
- * happily accepts this message and breaks the uninitialized state. The
- * expected rc, state and msg_tx will be fixed along with the fix. */
- OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0 /* BUG, expecting < 0 */);
- OSMO_ASSERT(state->state == OAP_REQUESTED_CHALLENGE /* BUG, expecting OAP_UNINITIALIZED */);
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) < 0);
+ OSMO_ASSERT(state->state == OAP_UNINITIALIZED);
msgb_free(msg_rx);
- OSMO_ASSERT(msg_tx /* BUG, expecting NULL */);
- msgb_free(msg_tx);
+ OSMO_ASSERT(!msg_tx);
fprintf(stderr, "- reject messages in disabled state\n");
memset(state, 0, sizeof(*state));
@@ -73,14 +69,10 @@ static void test_oap_api(void)
state->client_id = 1;
oap_rx.message_type = OAP_MSGT_REGISTER_ERROR;
msg_rx = oap_client_encoded(&oap_rx);
- /* ATTENTION: This shows a bug in OAP: the rc should be < 0, but OAP
- * happily accepts this message and breaks the uninitialized state. The
- * expected rc, state and msg_tx will be fixed along with the fix. */
- OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0 /* BUG, expecting < 0 */);
- OSMO_ASSERT(state->state == OAP_REQUESTED_CHALLENGE /* BUG, expecting OAP_DISABLED */);
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) < 0);
+ OSMO_ASSERT(state->state == OAP_DISABLED);
msgb_free(msg_rx);
- OSMO_ASSERT(msg_tx /* BUG, expecting NULL */);
- msgb_free(msg_tx);
+ OSMO_ASSERT(!msg_tx);
fprintf(stderr, "- invalid client_id and shared secret\n");
memset(state, 0, sizeof(*state));
@@ -180,11 +172,11 @@ static void test_oap_api(void)
OSMO_ASSERT(state->state == OAP_INITIALIZED);
state->state = OAP_UNINITIALIZED;
- OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -1);
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) < 0);
OSMO_ASSERT(!msg_tx);
state->state = OAP_DISABLED;
- OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -1);
+ OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) < 0);
OSMO_ASSERT(!msg_tx);
state->state = OAP_INITIALIZED;