From 466cedd052427254d5f90b4bd02795129b2c60a4 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 29 Jan 2015 14:12:29 +0100 Subject: sgsn/test: Add tests for PurgeMs responses Currently there are not any test cases for PurgeMS GSUP messages in test_subscriber_gsup. This commit adds tests for incoming PurgeMSResult and -Error messages. Sponsored-by: On-Waves ehf --- openbsc/tests/sgsn/sgsn_test.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 733380a59..25e031014 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -445,6 +445,19 @@ static void test_subscriber_gsup(void) 0x06, 0x01, 0x00, }; + static const uint8_t purge_ms_err[] = { + 0x0d, + TEST_GSUP_IMSI1_IE, + 0x02, 0x01, 0x02, /* IMSI unknown in HLR */ + }; + + static const uint8_t purge_ms_res[] = { + 0x0e, + TEST_GSUP_IMSI1_IE, + 0x07, 0x00, + }; + + static const uint8_t insert_data_req[] = { 0x10, TEST_GSUP_IMSI1_IE, @@ -507,6 +520,7 @@ static void test_subscriber_gsup(void) rc = rx_gsup_message(update_location_res, sizeof(update_location_res)); OSMO_ASSERT(rc >= 0); OSMO_ASSERT(last_updated_subscr == s1); + OSMO_ASSERT(s1->flags & GPRS_SUBSCRIBER_ENABLE_PURGE); /* Check authorization */ OSMO_ASSERT(s1->authorized == 1); @@ -552,12 +566,28 @@ static void test_subscriber_gsup(void) OSMO_ASSERT(s1->flags & GPRS_SUBSCRIBER_CANCELLED); OSMO_ASSERT(s1->sgsn_data->mm == NULL); + /* Inject PurgeMsRes GSUP message */ + rc = rx_gsup_message(purge_ms_res, + sizeof(purge_ms_res)); + OSMO_ASSERT(rc >= 0); + OSMO_ASSERT(!(s1->flags & GPRS_SUBSCRIBER_ENABLE_PURGE)); + /* Free MM context and subscriber */ subscr_put(s1); s1found = gprs_subscr_get_by_imsi(imsi1); OSMO_ASSERT(s1found == NULL); gprs_llgmm_assign(llme, local_tlli, 0xffffffff, GPRS_ALGO_GEA0, NULL); + /* Inject PurgeMsRes GSUP message */ + rc = rx_gsup_message(purge_ms_res, + sizeof(purge_ms_res)); + OSMO_ASSERT(rc >= 0); + + /* Inject PurgeMsErr(IMSI unknown in HLR) GSUP message */ + rc = rx_gsup_message(purge_ms_err, + sizeof(purge_ms_err)); + OSMO_ASSERT(rc == -GMM_CAUSE_IMSI_UNKNOWN); + /* Inject InsertSubscrData GSUP message (unknown IMSI) */ last_updated_subscr = NULL; rc = rx_gsup_message(insert_data_req, sizeof(insert_data_req)); -- cgit v1.2.3