Example #1
0
class TestAgentSecurity(unittest.TestCase):
    def setUp(self):
        self.agent = DiskAgent("127.0.0.1", [])
        #### Sign the agent
        binstr = cPickle.dumps(self.agent.compLocal, 1)
        _privkey = getPrivateKey(self.agent.masterip)
        _pubkey = getPublicKey(self.agent.masterip)
        self.agent.serverSignature = _privkey.sign(binstr, b"")[0]

    def test_execution(self):
        self.assertGreater(self.agent.compute(), 0)

    def test_security_on_code_change(self):
        newagent = MaliciousAgent("127.0.0.51", [])
        self.agent.compLocal = newagent.compLocal
        self.assertEqual(self.agent.compute(), -1)
Example #2
0
class TestAgentFunctionality(unittest.TestCase):
    def setUp(self):
        self.agent = DiskAgent("127.0.0.1", [])
        #### Sign the agent
        binstr = cPickle.dumps(self.agent.compLocal, 1)
        _privkey = getPrivateKey(self.agent.masterip)
        _pubkey = getPublicKey(self.agent.masterip)
        self.agent.serverSignature = _privkey.sign(binstr, b"")[0]

    def test_compLocal(self):
        self.assertGreater(self.agent.compute(), 0)
Example #3
0
from DiskAgent import * 
import cPickle
import rsa

#### create new agent
#agentx = DiskAgent(masterip,groute)
agentx = DiskAgent(0, [])
#### Sign the agent
binstr = cPickle.dumps(agentx.compLocal, 1)
(pub, priv) = rsa.newkeys(512)
agentx.serverSignature = rsa.sign(binstr, priv, 'MD5')
agentx.serverPubKey = pub
agentx.compute()