Exemple #1
0
    def testConstructorAndCheckSumName(self):
        rd1 = restDriver.RestDriver('', checkSumAlgoName='sha1')
        self.assertEqual(rd1.getCheckSumAlgoName(), 'sha1')
        self.assertEqual(rd1.getBaseUrl(), 'http://127.0.0.1:8000')

        rd2 = restDriver.RestDriver('', checkSumAlgoName='md5')
        self.assertEqual(rd2.getCheckSumAlgoName(), 'md5')
        self.assertEqual(rd2.getBaseUrl(), 'http://127.0.0.1:8000')
Exemple #2
0
def main():
    restObj = restDriver.RestDriver(ip='http://192.168.1.112')
    while 1:
        line_in = get_line(sys.stdin)
        if line_in == EOF:
            return
        cmd, argDict = tokenizer(line_in)
        if cmd:
            write_line(sys.stdout, apply_f(restObj, cmd, argDict))
Exemple #3
0
    def addDriver(self, host, port):
        hostMap = self.___mapAddrToDriver.setdefault(host, {})
        retr = hostMap.get(port, None)
        if not isinstance(retr, restDriver.RestDriver):
            retr = restDriver.RestDriver(host, port)
            print('\033[92mFresh restDriver at host: %s port: %s\033[00m'%(
                                                                      host, port))
            hostMap[port] = retr

        return retr
Exemple #4
0
    def testSecretKeyInit(self):
        rd1 = restDriver.RestDriver('', secretKey=__file__)

        items = (
            1234,
            'abcdEFGH',
            b'458485',
            None,
            self,
            '',
            rd1,
            restDriver,
        )
        signedR1 = rd1.signItems(outputPlainBytes=False, *items)
        self.assertEqual(len(signedR1), len(items))
        for sres1 in signedR1:
            # Expecting sre1 to be hexdigest ie str
            self.assertEqual(isinstance(sres1, str), True)

        signedR2 = rd1.signItems(outputPlainBytes=True, *items)
        self.assertEqual(len(signedR2), len(items))
        for sres2 in signedR2:
            # Expecting sre2 to be plain bytes
            self.assertEqual(isinstance(sres2, bytes), True)
Exemple #5
0
 def setUp(self):
     self.rd = restDriver.RestDriver(None, None)
     self.assertEqual(self.rd.getBaseUrl(), 'http://127.0.0.1:8000')
Exemple #6
0
    def testConstructorWithNoArgs(self):
        rd = restDriver.RestDriver(None, None)
        self.assertEqual(rd.getBaseUrl(), 'http://127.0.0.1:8000')

        rd = restDriver.RestDriver('', '')
        self.assertEqual(rd.getBaseUrl(), 'http://127.0.0.1:8000')