summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-12-08 23:13:29 +0100
committerHarald Welte <laforge@gnumonks.org>2016-12-13 14:54:02 +0000
commit3cbc05210192324592cc8b79e12d3095be302f90 (patch)
tree372577c3257f0658547e7771e3ef1f4614dfb06a
parent73ed45599b94f666fedd043028daad9427c241bd (diff)
oap_client_test: show bug: disabled state does not reject message
There is a hole in OAP where a disabled OAP still accepts at least a Registration Reject message, after which it will do things it shouldn't. Show this by expecting the bugs, to be adjusted with the upcoming fix. Related: OS#1592 Change-Id: I4a5fde308b876946fea2571ea1a550f0cc7ee136
-rw-r--r--openbsc/tests/oap/oap_client_test.c41
-rw-r--r--openbsc/tests/oap/oap_client_test.err4
2 files changed, 41 insertions, 4 deletions
diff --git a/openbsc/tests/oap/oap_client_test.c b/openbsc/tests/oap/oap_client_test.c
index a54e386..45decf8 100644
--- a/openbsc/tests/oap/oap_client_test.c
+++ b/openbsc/tests/oap/oap_client_test.c
@@ -37,6 +37,12 @@ static void test_oap_api(void)
struct oap_client_state _state;
struct oap_client_state *state = &_state;
+ struct osmo_oap_message oap_rx;
+ struct msgb *msg_rx;
+
+ struct osmo_oap_message oap_tx;
+ struct msgb *msg_tx;
+
memset(config, 0, sizeof(*config));
memset(state, 0, sizeof(*state));
@@ -46,7 +52,38 @@ 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");
+ 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 */);
+ msgb_free(msg_rx);
+ OSMO_ASSERT(msg_tx /* BUG, expecting NULL */);
+ msgb_free(msg_tx);
+
+ fprintf(stderr, "- reject messages in disabled state\n");
+ memset(state, 0, sizeof(*state));
+ memset(&oap_rx, 0, sizeof(oap_rx));
+ state->state = OAP_DISABLED;
+ 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 */);
+ msgb_free(msg_rx);
+ OSMO_ASSERT(msg_tx /* BUG, expecting NULL */);
+ msgb_free(msg_tx);
+
fprintf(stderr, "- invalid client_id and shared secret\n");
+ memset(state, 0, sizeof(*state));
config->client_id = 0;
config->secret_k_present = 0;
config->secret_opc_present = 0;
@@ -92,10 +129,6 @@ static void test_oap_api(void)
OSMO_ASSERT( oap_client_init(config, state) == 0 );
OSMO_ASSERT(state->state == OAP_INITIALIZED);
- struct osmo_oap_message oap_rx;
- struct osmo_oap_message oap_tx;
- struct msgb *msg_rx;
- struct msgb *msg_tx;
fprintf(stderr, "- Missing challenge data\n");
memset(&oap_rx, 0, sizeof(oap_rx));
diff --git a/openbsc/tests/oap/oap_client_test.err b/openbsc/tests/oap/oap_client_test.err
index 248808e..9e52357 100644
--- a/openbsc/tests/oap/oap_client_test.err
+++ b/openbsc/tests/oap/oap_client_test.err
@@ -1,4 +1,8 @@
- make sure filling with zeros means uninitialized
+- reject messages in uninitialized state EXPECTING BUGS
+DLOAP OAP registration failed
+- reject messages in disabled state
+DLOAP OAP registration failed
- invalid client_id and shared secret
- reset state
- only client_id is invalid