def _login(self, cxn): rpc = Rpc.create('XUS SIGNON SETUP') response = cxn.execute(rpc) if response is None: raise RpcError('Unable to setup login') param = [RpcParameter( RpcParameter.ENCRYPTED, ';'.join([self.access_code, self.verify_code]), self.encryption_indexes )] rpc = Rpc.create('XUS AV CODE', param) response = cxn.execute(rpc) if response is None: raise RpcError('No response to login request') return self._load_login(response)
def test_connect_rpc(self): expected = "[XWB]10304\x0ATCPConnect50013192.168.1.107f00010f0022LAPTOP2.v11.med.va.govf\x04" params = [ RpcParameter(RpcParameter.LITERAL, "192.168.1.107"), RpcParameter(RpcParameter.LITERAL, "LAPTOP2.v11.med.va.gov"), ] actual = Rpc.create("HELLO", params) self.assertEqual(expected, actual)
def set_pay_run_ien(self, cxn): arg = '$O(^PRST(459,"B","%02d-%02d",1))' % (self.fy, self.pay_period) param = RpcParameter(RpcParameter.REFERENCE, arg) rpc = Rpc.create('XWB GET VARIABLE VALUE', [param]) response = cxn.execute(rpc) try: self.ien = int(response) except: raise RpcError('No record for this pay period')
def _set_context(self, cxn): if not self.context: raise RpcError('Context has not been declared') param = [RpcParameter( RpcParameter.ENCRYPTED, self.context, self.encryption_indexes)] rpc = Rpc.create('XWB CREATE CONTEXT', param) response = cxn.execute(rpc) if response != '1': raise RpcError(response)
def fed_login(self, cxn): if not self.has_federated_credentials(): raise RpcError('Invalid federated user credentials') param = [RpcParameter( RpcParameter.LITERAL, '^'.join([ '-31^DVBA_', self.fed_id, self.name, self.auth_system.site_name, self.auth_system.site_id, self.uid, self.phone ]) )] rpc = Rpc.create('XUS SIGNON SETUP', param) response = cxn.execute(rpc) flds = response.split("\r\n") if flds[5] != '1': raise RpcError('Unable to fed login at system ' + cxn.site_id) self._set_context(cxn) uid = self._getUid(cxn) return uid, 'OK'
def _getUid(self, cxn): arg = '$O(^VA(200,"SSN",{},0))'.format(self.fed_id) param = [RpcParameter(RpcParameter.REFERENCE, arg)] rpc = Rpc.create('XWB GET VARIABLE VALUE', param) return cxn.execute(rpc)
def test_get_variable_value_rpc(self): arg = "$P($G(^DIC(3.1,1362,0)),U,1)" expected = "[XWB]11302\x051.108\x16XWB GET VARIABLE VALUE51028$P($G(^DIC(3.1,1362,0)),U,1)f\x04" param = RpcParameter(RpcParameter.REFERENCE, arg) actual = Rpc.create("XWB GET VARIABLE VALUE", [param]) self.assertEqual(expected, actual)
def test_set_context_rpc(self): expected = "[XWB]11302\x051.108\x12XWB CREATE CONTEXT50019(&y?#jy<?x:=?#68y].f\x04" param = RpcParameter(RpcParameter.ENCRYPTED, "OR CPRS GUI CHART", [8, 14]) actual = Rpc.create("XWB CREATE CONTEXT", [param]) self.assertEqual(expected, actual)
def test_login_rpc(self): expected = "[XWB]11302\x051.108\x0BXUS AV CODE50017.r v11k3}!r&sAgP$f\x04" param = RpcParameter(RpcParameter.ENCRYPTED, "ijr773;Akiba12.", [14, 4]) actual = Rpc.create("XUS AV CODE", [param]) self.assertEqual(expected, actual)
def test_setup_login_rpc(self): expected = "[XWB]11302\x051.108\x10XUS SIGNON SETUP54f\x04" actual = Rpc.create("XUS SIGNON SETUP") self.assertEqual(expected, actual)
def test_into_msg_rpc(self): expected = "[XWB]11302\x051.108\x0DXUS INTRO MSG54f\x04" actual = Rpc.create("XUS INTRO MSG") self.assertEqual(expected, actual)
def test_disconnect_rpc(self): expected = "[XWB]10304\x05#BYE#\x04" actual = Rpc.create("BYE") self.assertEqual(expected, actual)