예제 #1
0
    def test_encrypt_decrypt(self):
        raw = '900:123456789:DEPARTMENT OF DEFENSE,USER:33'
        token = VistaToken.encrypt(raw)
        self.assertEqual(88, len(token))

        expected = TokenParams(
            site_id='900',
            fed_id='123456789',
            username='******',
            duz='33'
        )
        params = VistaToken.decrypt(token)
        self.assertEqual(expected, params)
예제 #2
0
    def _set_vista_params(self):
        import json
        with open("controllers/config.json") as cfg_file:
            data = json.load(cfg_file)

        self.host = data['vista']['host']
        self.port = data['vista']['port']
        token = data['vista']['token']
        vparams = VistaToken.decrypt(token)
        if vparams.site_id != data['vista']['site_id']:
            raise RpcException('Invalid vparams')
        self.user = {
            "fed_id": vparams.fed_id,
            "user_name": vparams.username,
            "source_name": data['vista']['site_name'],
            "source_id": vparams.site_id,
            "uid": vparams.duz,
            "phone": 'No phone'
        }
        self.cps = data['control_points']