def test_login_valid(self): self.cxn.connect() self.assertTrue(self.cxn.is_connected) user = RpcUser() user.access_code = self.config.get('Test Doctor', 'access_code') user.verify_code = self.config.get('Test Doctor', 'verify_code') uid, greeting = user._login(self.cxn) self.assertEqual('31', uid) self.assertTrue(greeting.find(self.config.get('Test Doctor', 'name')))
def test_valid_context(self): self.cxn.connect() self.assertTrue(self.cxn.is_connected) user = RpcUser() user.access_code = self.config.get('Test Doctor', 'access_code') user.verify_code = self.config.get('Test Doctor', 'verify_code') user.context = self.config.get('Rpc Contexts', 'CPRS_CONTEXT') uid, greeting = user._login(self.cxn) user._set_context(self.cxn) self.assertEqual('31', uid) self.assertTrue(greeting.find(self.config.get('Test Doctor', 'name')))
def test_login_change_verify_code(self): self.cxn.connect() self.assertTrue(self.cxn.is_connected) user = RpcUser() user.access_code = self.config.get('Test Sysadmin', 'access_code') user.verify_code = self.config.get('Test Sysadmin', 'verify_code') try: uid, greeting = user._login(self.cxn) self.fail('Expected exception, got greeting: %s' % greeting) except RpcError as e: self.assertEqual('VERIFY CODE must be changed before continued use.', str(e)) finally: self.cxn.disconnect()
def test_login_failed(self): self.cxn.connect() self.assertTrue(self.cxn.is_connected) user = RpcUser() user.access_code = self.config.get('Test Programmer', 'access_code') user.verify_code = self.config.get('Test Programmer', 'verify_code') try: uid, greeting = user._login(self.cxn) self.fail('Expected exception, got greeting: %s' % greeting) except RpcError as e: self.assertEqual('Not a valid ACCESS CODE/VERIFY CODE pair.', str(e)) finally: self.cxn.disconnect()
def test_invalid_context(self): self.cxn.connect() self.assertTrue(self.cxn.is_connected) user = RpcUser() user.access_code = self.config.get('Test Doctor', 'access_code') user.verify_code = self.config.get('Test Doctor', 'verify_code') user.context = self.config.get('Rpc Contexts', 'VISITOR_CONTEXT') try: uid, greeting = user._login(self.cxn) user._set_context(self.cxn) self.fail('Expected exception, got greeting: %s' % greeting) except RpcError as e: self.assertEqual('VistA SECURITY error: User ALEXANDER,ROBERT does not have access to option DVBA CAPRI GUI', str(e)) finally: self.cxn.disconnect()