sgsn: Add VTY commands to manage subscriber cache

This adds the following commands to the ENABLE node:
  - show subscriber cache
  - update-subscriber imsi IMSI insert authorized (0|1)
  - update-subscriber imsi IMSI cancel
  - update-subscriber imsi IMSI commit

These commands are mainly testing tools and maintenance helpers. The
update commands work asynchronously and can be used to complete a
pending update request or to terminate an existing connection. The
'insert' command just update the subscriber records but does not
notify the GMM layer. Invoke the 'commit' command to continue with
pending procedures.

Note that the subscriber cache is not stored persistently and will
always be empty after an SGSN restart.

Sponsored-by: On-Waves ehf
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 64437a1..a3cb9e5 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -756,6 +756,22 @@
         res = self.vty.command("show running-config")
         self.assert_(res.find('auth-policy remote') > 0)
 
+    def testVtySubscriber(self):
+        self.vty.enable()
+        res = self.vty.command('show subscriber cache')
+        self.assert_(res.find('1234567890') < 0)
+        self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 insert authorized 1', ['']))
+        res = self.vty.command('show subscriber cache')
+        self.assert_(res.find('1234567890') >= 0)
+        self.assert_(res.find('Authorized: 1') >= 0)
+        self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 insert authorized 0', ['']))
+        res = self.vty.command('show subscriber cache')
+        self.assert_(res.find('Authorized: 0') >= 0)
+        self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 commit', ['']))
+        self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 cancel', ['']))
+        res = self.vty.command('show subscriber cache')
+        self.assert_(res.find('1234567890') < 0)
+
 def add_nat_test(suite, workdir):
     if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc_nat/osmo-bsc_nat")):
         print("Skipping the NAT test")