diff --git a/src/api.py b/src/api.py index 0d802d61..8e4ddda4 100644 --- a/src/api.py +++ b/src/api.py @@ -883,6 +883,16 @@ class BMRPCDispatcher(object): shared.reloadMyAddressHashes() return "success" + @command('enableAddress') + def HandleEnableAddress(self, address, enable=True): + """Enable or disable the address depending on the *enable* value""" + self._verifyAddress(address) + address = addBMIfNotPresent(address) + config.set(address, 'enabled', str(enable)) + self.config.save() + shared.reloadMyAddressHashes() + return "success" + @command('getAllInboxMessages') def HandleGetAllInboxMessages(self): """ diff --git a/src/tests/test_api.py b/src/tests/test_api.py index a1082383..fc0f4db2 100644 --- a/src/tests/test_api.py +++ b/src/tests/test_api.py @@ -413,6 +413,11 @@ class TestAPI(TestAPIProto): self.assertEqual(self.api.deleteAndVacuum(), 'done') self.assertIsNone(json.loads( self.api.getSentMessageById(sent_msgid))) + # Try sending from disabled address + self.assertEqual(self.api.enableAddress(addr, False), 'success') + result = self.api.sendBroadcast( + addr, base64.encodestring('test_subject'), msg) + self.assertRegexpMatches(result, r'^API Error 0014:') finally: self.assertEqual(self.api.deleteAddress(addr), 'success')