Add enableAddress API command and a check for sending from disabled address
This commit is contained in:
parent
b25ed553bc
commit
20ce69b337
10
src/api.py
10
src/api.py
|
@ -883,6 +883,16 @@ class BMRPCDispatcher(object):
|
||||||
shared.reloadMyAddressHashes()
|
shared.reloadMyAddressHashes()
|
||||||
return "success"
|
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')
|
@command('getAllInboxMessages')
|
||||||
def HandleGetAllInboxMessages(self):
|
def HandleGetAllInboxMessages(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -413,6 +413,11 @@ class TestAPI(TestAPIProto):
|
||||||
self.assertEqual(self.api.deleteAndVacuum(), 'done')
|
self.assertEqual(self.api.deleteAndVacuum(), 'done')
|
||||||
self.assertIsNone(json.loads(
|
self.assertIsNone(json.loads(
|
||||||
self.api.getSentMessageById(sent_msgid)))
|
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:
|
finally:
|
||||||
self.assertEqual(self.api.deleteAddress(addr), 'success')
|
self.assertEqual(self.api.deleteAddress(addr), 'success')
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user