From e6052c4cc756f7d3a5023a0ba57fe8d80783967c Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 30 Jun 2016 10:25:49 +0200 Subject: Make random MSISDN assignment optional Previously if subscriber was automatically created it got assigned random MSISDN number. Make it optional (defaulting to previous behavior) by adding following: * new optional no-extension argument for subscriber-create-on-demand vty command * db unit tests * vty test Note: using the db made with new code might result in subscribers with empty extension. Such subscribers cannot be deleted using old code. Make sure not to mix db versions or manually fix it by editing sqlite with external program. Fixes: OS#1658 Change-Id: Ibbc2e88e4722b08854ebc631485f19ed56443cbb --- openbsc/tests/vty_test_runner.py | 51 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'openbsc/tests/vty_test_runner.py') diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index bae18669c..23939e84c 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -244,7 +244,7 @@ class TestVTYNITB(TestVTYGenericBSC): self.vty.command("configure terminal") self.vty.command("nitb") self.assertTrue(self.vty.verify("subscriber-create-on-demand", [''])) - self.assertTrue(self.vty.verify("subscriber-create-on-demand regexp", [''])) + self.assertTrue(self.vty.verify("subscriber-create-on-demand no-extension", [''])) self.vty.command("end") def testSi2Q(self): @@ -400,6 +400,9 @@ class TestVTYNITB(TestVTYGenericBSC): self.vty.enable() imsi = "204300854013739" + imsi2 = "222301824913762" + imsi3 = "333500854113763" + imsi4 = "444583744053764" # Initially we don't have this subscriber self.vty.verify('show subscriber imsi '+imsi, ['% No subscriber found for imsi '+imsi]) @@ -407,14 +410,60 @@ class TestVTYNITB(TestVTYGenericBSC): # Lets create one res = self.vty.command('subscriber create imsi '+imsi) self.assert_(res.find(" IMSI: "+imsi) > 0) + self.assert_(res.find("Extension") > 0) # Now we have it res = self.vty.command('show subscriber imsi '+imsi) self.assert_(res.find(" IMSI: "+imsi) > 0) + # With narrow random interval + self.vty.command("configure terminal") + self.vty.command("nitb") + self.assertTrue(self.vty.verify("subscriber-create-on-demand", [''])) + # wrong interval + res = self.vty.command("subscriber-create-on-demand random 221 122") + # error string will contain arguments + self.assert_(res.find("122") > 0) + self.assert_(res.find("221") > 0) + # correct interval - silent ok + self.assertTrue(self.vty.verify("subscriber-create-on-demand random 221 222", [''])) + self.vty.command("end") + + res = self.vty.command('subscriber create imsi ' + imsi2) + self.assert_(res.find(" IMSI: " + imsi2) > 0) + self.assert_(res.find("221") > 0 or res.find("222") > 0) + self.assert_(res.find(" Extension: ") > 0) + + # Without extension + self.vty.command("configure terminal") + self.vty.command("nitb") + self.assertTrue(self.vty.verify("subscriber-create-on-demand no-extension", [''])) + self.vty.command("end") + res = self.vty.command('subscriber create imsi ' + imsi3) + self.assert_(res.find(" IMSI: " + imsi3) > 0) + self.assertEquals(res.find("Extension"), -1) + + # With extension again + self.vty.command("configure terminal") + self.vty.command("nitb") + self.assertTrue(self.vty.verify("no subscriber-create-on-demand", [''])) + self.assertTrue(self.vty.verify("subscriber-create-on-demand", [''])) + self.assertTrue(self.vty.verify("subscriber-create-on-demand random 221 666", [''])) + self.vty.command("end") + + res = self.vty.command('subscriber create imsi ' + imsi4) + self.assert_(res.find(" IMSI: " + imsi4) > 0) + self.assert_(res.find(" Extension: ") > 0) + # Delete it res = self.vty.command('subscriber imsi ' + imsi + ' delete') self.assert_("" == res) + res = self.vty.command('subscriber imsi ' + imsi2 + ' delete') + self.assert_("" == res) + res = self.vty.command('subscriber imsi ' + imsi3 + ' delete') + self.assert_("" == res) + res = self.vty.command('subscriber imsi ' + imsi4 + ' delete') + self.assert_("" == res) # Now it should not be there anymore res = self.vty.command('show subscriber imsi '+imsi) -- cgit v1.2.3