summaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-12-19 18:26:09 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-01-18 13:27:02 +0100
commit3d722450de1cf34931d95f7a748a9b6c48e933f0 (patch)
tree0469a537f0dae4fc22ce7a28e16eabf3457924e9 /openbsc/tests
parente21e184d84d6a932b58079084d254f498599e29e (diff)
sgsn/test: Add GMM test for a GSUP based attach procedure
This test calls test_gmm_attach() where the mocked subscriber functions insert GSUP messages instead of manipulating the subscriber structure directly. Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/sgsn/sgsn_test.c72
-rw-r--r--openbsc/tests/sgsn/sgsn_test.ok1
2 files changed, 73 insertions, 0 deletions
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index e36fa5a19..560b1114c 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -929,6 +929,77 @@ static void test_gmm_attach_subscr_real_auth(void)
subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;
}
+#define TEST_GSUP_IMSI_LONG_IE 0x01, 0x08, \
+ 0x21, 0x43, 0x65, 0x87, 0x09, 0x21, 0x43, 0xf5
+
+int my_subscr_request_auth_info_gsup_auth(struct sgsn_mm_ctx *mmctx)
+{
+ static const uint8_t send_auth_info_res[] = {
+ 0x0a,
+ TEST_GSUP_IMSI_LONG_IE,
+ 0x03, 0x22, /* Auth tuple */
+ 0x20, 0x10,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x21, 0x04,
+ 0x51, 0xe5, 0x51, 0xe5,
+ 0x22, 0x08,
+ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
+ };
+
+ OSMO_ASSERT(mmctx->subscr);
+
+ /* Fake an SendAuthInfoRes */
+ rx_gsup_message(send_auth_info_res, sizeof(send_auth_info_res));
+
+ return 0;
+};
+
+int my_subscr_request_update_gsup_auth(struct sgsn_mm_ctx *mmctx) {
+ static const uint8_t update_location_res[] = {
+ 0x06,
+ TEST_GSUP_IMSI_LONG_IE,
+ 0x04, 0x00, /* PDP info complete */
+ 0x05, 0x12,
+ 0x10, 0x01, 0x01,
+ 0x11, 0x02, 0xf1, 0x21, /* IPv4 */
+ 0x12, 0x09, 0x04, 't', 'e', 's', 't', 0x03, 'a', 'p', 'n',
+ };
+
+ OSMO_ASSERT(mmctx->subscr);
+
+ /* Fake an UpdateLocRes */
+ return rx_gsup_message(update_location_res, sizeof(update_location_res));
+};
+
+
+static void test_gmm_attach_subscr_gsup_auth(void)
+{
+ const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
+ struct gsm_subscriber *subscr;
+
+ sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;
+ subscr_request_update_location_cb = my_subscr_request_update_gsup_auth;
+ subscr_request_auth_info_cb = my_subscr_request_auth_info_gsup_auth;
+
+ subscr = gprs_subscr_get_or_create("123456789012345");
+ subscr->authorized = 1;
+ sgsn->cfg.require_authentication = 1;
+ sgsn->cfg.require_update_location = 1;
+ subscr_put(subscr);
+
+ printf("Auth policy 'remote', GSUP based auth: ");
+ test_gmm_attach();
+
+ subscr = gprs_subscr_get_by_imsi("123456789012345");
+ OSMO_ASSERT(subscr != NULL);
+ gprs_subscr_delete(subscr);
+
+ sgsn->cfg.auth_policy = saved_auth_policy;
+ subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
+ subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;
+}
+
/*
* Test the GMM Rejects
*/
@@ -1454,6 +1525,7 @@ int main(int argc, char **argv)
test_gmm_attach_subscr();
test_gmm_attach_subscr_fake_auth();
test_gmm_attach_subscr_real_auth();
+ test_gmm_attach_subscr_gsup_auth();
test_gmm_reject();
test_gmm_cancel();
test_gmm_ptmsi_allocation();
diff --git a/openbsc/tests/sgsn/sgsn_test.ok b/openbsc/tests/sgsn/sgsn_test.ok
index b118328df..a3c03428a 100644
--- a/openbsc/tests/sgsn/sgsn_test.ok
+++ b/openbsc/tests/sgsn/sgsn_test.ok
@@ -11,6 +11,7 @@ Auth policy 'closed': Testing GMM attach
Auth policy 'remote': Testing GMM attach
Auth policy 'remote', auth faked: Testing GMM attach
Auth policy 'remote', triplet based auth: Testing GMM attach
+Auth policy 'remote', GSUP based auth: Testing GMM attach
Testing GMM reject
- Attach Request (invalid MI length)
- Attach Request (invalid MI type)