def test_no_xpath_no_roles_run_default(self): a = SAMLAuthenticator() a._valid_roles_in_assertion = unittest.mock.create_autospec( MagicMock(name='_valid_roles_in_assertion')) a.log.warning = MagicMock(name='warning') assert a._valid_config_and_roles(None, None) a._valid_roles_in_assertion.assert_not_called() a.log.warning.assert_not_called()
def test_xpath_roles_call_methods_false_return(self): a = SAMLAuthenticator() a._valid_roles_in_assertion = MagicMock( name='_valid_roles_in_assertion', return_value=False) a.log.warning = MagicMock(name='warning') a.allowed_roles = 'group1' a.xpath_role_location = 'value' assert a._valid_config_and_roles(None, None) == False a._valid_roles_in_assertion.assert_called_once_with(None, None) a.log.warning.assert_not_called()
def test_no_xpath_roles(self): a = SAMLAuthenticator() a.allowed_roles = 'value' a._valid_roles_in_assertion = unittest.mock.create_autospec( MagicMock(name='_valid_roles_in_assertion')) a.log.warning = MagicMock(name='warning') assert a._valid_config_and_roles(None, None) a._valid_roles_in_assertion.assert_not_called() print(a.log.warning.call_args_list) a.log.warning.assert_called() a.log.warning.assert_any_call(a._const_warn_explain) a.log.warning.assert_any_call(a._const_warn_no_role_xpath)