summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-03-30 11:22:26 +0200
committerHarald Welte <laforge@gnumonks.org>2016-03-31 11:56:21 +0200
commitd617c5d3ac65b5090f787da3e2911fb6742f515c (patch)
tree1effb76a0ed21ee1ff82ca5017ea49af211ba944
parent4554a62c4d16bd95ae4fb38ede0fd9f64a4d1429 (diff)
MM Auth test: add test to re-use existing auth
-rw-r--r--openbsc/tests/mm_auth/mm_auth_test.c31
-rw-r--r--openbsc/tests/mm_auth/mm_auth_test.ok6
2 files changed, 37 insertions, 0 deletions
diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c
index c0b8da424..e54189834 100644
--- a/openbsc/tests/mm_auth/mm_auth_test.c
+++ b/openbsc/tests/mm_auth/mm_auth_test.c
@@ -242,6 +242,36 @@ static void test_auth_then_ciph2()
));
}
+static void test_auth_reuse()
+{
+ int auth_action;
+ struct gsm_auth_tuple atuple = {0};
+ struct gsm_subscriber subscr = {0};
+ int key_seq;
+
+ printf("\n* test_auth_reuse()\n");
+
+ /* Ki entry, auth tuple negotiated, valid+matching incoming key_seq */
+ test_auth_info = default_auth_info;
+ test_last_auth_tuple = default_auth_tuple;
+ test_last_auth_tuple.key_seq = key_seq = 3;
+ test_last_auth_tuple.use_count = 1;
+ test_get_authinfo_rc = 0;
+ test_get_lastauthtuple_rc = 0;
+ auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
+ key_seq);
+ OSMO_ASSERT(auth_action == AUTH_DO_CIPH);
+ OSMO_ASSERT(auth_tuple_is(&atuple,
+ "gsm_auth_tuple {\n"
+ " .use_count = 2\n"
+ " .key_seq = 3\n"
+ " .rand = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n"
+ " .sres = 00 00 00 00 \n"
+ " .kc = 00 00 00 00 00 00 00 00 \n"
+ "}\n"
+ ));
+}
+
int main(void)
{
osmo_init_logging(&log_info);
@@ -251,5 +281,6 @@ int main(void)
test_auth_not_avail();
test_auth_then_ciph1();
test_auth_then_ciph2();
+ test_auth_reuse();
return 0;
}
diff --git a/openbsc/tests/mm_auth/mm_auth_test.ok b/openbsc/tests/mm_auth/mm_auth_test.ok
index 52feb3679..cc0e76960 100644
--- a/openbsc/tests/mm_auth/mm_auth_test.ok
+++ b/openbsc/tests/mm_auth/mm_auth_test.ok
@@ -22,3 +22,9 @@ wrapped: db_get_authinfo_for_subscr(): rc = 0
wrapped: db_get_lastauthtuple_for_subscr(): rc = 0
wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH
+
+* test_auth_reuse()
+wrapped: db_get_authinfo_for_subscr(): rc = 0
+wrapped: db_get_lastauthtuple_for_subscr(): rc = 0
+wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
+auth_get_tuple_for_subscr(key_seq=3) --> auth_action == AUTH_DO_CIPH