Пример #1
0
    def test_authentication_with_data_denied_srai(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            security:
                authentication:
                    classname: programy.security.authenticate.passthrough.PassThroughAuthenticationService
                    denied_srai: AUTHENTICATION_FAILED
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        services_config = yaml.get_section("security", brain_config)
        self.assertIsNotNone(services_config)

        service_config = BrainSecurityConfiguration("authentication")
        service_config.load_config_section(yaml, services_config, ".")

        self.assertEqual(
            "programy.security.authenticate.passthrough.PassThroughAuthenticationService",
            service_config.classname)
        self.assertEqual("AUTHENTICATION_FAILED", service_config.denied_srai)
        self.assertEqual(BrainSecurityConfiguration.DEFAULT_ACCESS_DENIED,
                         service_config.denied_text)
Пример #2
0
class BrainSecuritiesConfiguration(BaseSectionConfigurationData):
    def __init__(self):
        BaseSectionConfigurationData.__init__(self, "security")
        self._authorisation = None
        self._authentication = None

    @property
    def authorisation(self):
        return self._authorisation

    @property
    def authentication(self):
        return self._authentication

    def load_config_section(self, configuration_file, configuration, bot_root):
        securities = configuration_file.get_section(self.section_name,
                                                    configuration)
        if securities is not None:
            self._authentication = BrainSecurityConfiguration("authentication")
            self._authentication.load_config_section(configuration_file,
                                                     securities, bot_root)

            self._authorisation = BrainSecurityConfiguration("authorisation")
            self._authorisation.load_config_section(configuration_file,
                                                    securities, bot_root)
Пример #3
0
    def test_authorisation_with_data_denied_text(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            security:
                authorisation:
                    classname: programy.security.authorise.passthrough.PassThroughAuthorisationService
                    denied_text: Authorisation Failed
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        services_config = yaml.get_section("security", brain_config)
        self.assertIsNotNone(services_config)

        service_config = BrainSecurityConfiguration("authorisation")
        service_config.load_config_section(yaml, services_config, ".")

        self.assertEqual(
            "programy.security.authorise.passthrough.PassThroughAuthorisationService",
            service_config.classname)
        self.assertEqual("Authorisation Failed", service_config.denied_text)
        self.assertIsNone(service_config.denied_srai)