Ejemplo n.º 1
0
    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')))
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
    def testHasLoginCredentials(self):
        user = RpcUser()
        self.assertFalse(user.has_login_credentials())

        user.access_code = 'the_access_code'
        self.assertFalse(user.has_login_credentials())

        user.access_code = None
        user.verify_code = 'the_verify_code'
        self.assertFalse(user.has_login_credentials())

        user.access_code = 'the_access_code'
        self.assertTrue(user.has_login_credentials())
Ejemplo n.º 5
0
    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')))
Ejemplo n.º 6
0
    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()
Ejemplo n.º 7
0
 def test_successful_fed_login(self):
     user = RpcUser()
     user.fed_id = self.config.get('Test Visitor', 'fed_id')
     user.name = self.config.get('Test Visitor', 'user_name')
     user.auth_system = RpcService()
     user.auth_system.site_name = self.config.get('My Test Vista', 'site_name')
     user.auth_system.site_id = self.config.get('My Test Vista', 'site_id')
     user.uid = self.config.get('Test Visitor', 'uid')
     self.cxn.connect()
     self.assertTrue(self.cxn.is_connected)
     uid, greeting = user.fed_login(self.cxn)
     self.cxn.disconnect()
     self.assertEqual('33', uid)
     self.assertEqual('OK', greeting)
Ejemplo n.º 8
0
    def test_failed_fed_login(self):
        user = RpcUser()
        user.fed_id = ''
        user.user_name = ''
        user.auth_system = RpcService()
        user.auth_system.site_name = ''
        user.auth_system.site_id = ''
        user.uid = ''
        user.phone =  ''

        self.cxn.connect()
        self.assertTrue(self.cxn.is_connected)
        uid, greeting = None, None
        try:
            uid, greeting = user.fed_login(self.cxn)
            self.fail("Visit should not succeed")
        except RpcError as e:
            self.assertEqual('Invalid federated user credentials', str(e))
            self.assertIsNone(uid)
            self.assertIsNone(greeting)
        finally:
            self.cxn.disconnect()
Ejemplo n.º 9
0
    def testHasFederatedCredentials(self):
        user = RpcUser()
        self.assertFalse(user.has_federated_credentials())

        user.auth_system = RpcService()
        user.auth_system.site_id = 1
        self.assertFalse(user.has_federated_credentials())

        user.auth_system.site_name = 'the_site_name'
        self.assertFalse(user.has_federated_credentials())

        user.fed_id = '123456789'
        self.assertFalse(user.has_federated_credentials())

        user.name = 'SomeName'
        self.assertFalse(user.has_federated_credentials())

        user.uid = '31'
        self.assertTrue(user.has_federated_credentials())
Ejemplo n.º 10
0
 def testSetFedId(self):
     user = RpcUser()
     user.fed_id = '123456789'
     self.assertEqual('A0E7B1D461C45908CEB1042BFE53B7FDB1E8E486DF00725E14530101650A595C', user._federated_id)
     self.assertEqual('123456789', user.fed_id)