Esempio n. 1
0
    def test_handle_failed_connection(self):
        exception = requests.ConnectionError("No connection")
        responses.add(responses.GET,
                      "%s/get_id" % self.account_linking_config['rest_uri'],
                      body=exception)
        account_linking = AccountLinkingModule(
            SATOSAConfig(self.satosa_config), self.callback_func)

        with pytest.raises(SATOSAAuthenticationError):
            account_linking.manage_al(self.context, self.internal_response)
Esempio n. 2
0
 def test_store_existing_uuid_in_internal_attributes(self):
     uuid = "uuid"
     responses.add(responses.GET,
                   "%s/get_id" % self.account_linking_config['rest_uri'],
                   status=200,
                   body=uuid,
                   content_type='text/html')
     account_linking = AccountLinkingModule(
         SATOSAConfig(self.satosa_config), self.callback_func)
     account_linking.manage_al(self.context, self.internal_response)
     assert self.internal_response.get_user_id() == uuid
Esempio n. 3
0
 def test_account_link_does_not_exists(self):
     ticket = "ticket"
     responses.add(responses.GET,
                   "%s/get_id" % self.account_linking_config['rest_uri'],
                   status=404,
                   body=ticket,
                   content_type='text/html')
     account_linking = AccountLinkingModule(
         SATOSAConfig(self.satosa_config), self.callback_func)
     result = account_linking.manage_al(self.context,
                                        self.internal_response)
     assert isinstance(result, Redirect)
     assert self.account_linking_config["redirect"] in result.message
Esempio n. 4
0
    def __init__(self, config):
        """
        Creates a satosa proxy base

        :type config: satosa.satosa_config.SATOSAConfig

        :param config: satosa proxy config
        """
        if config is None:
            raise ValueError("Missing configuration")

        self.config = config
        LOGGER.info("Loading backend modules...")
        backends = load_backends(self.config, self._auth_resp_callback_func,
                                 self.config.INTERNAL_ATTRIBUTES)
        LOGGER.info("Loading frontend modules...")
        frontends = load_frontends(self.config, self._auth_req_callback_func,
                                   self.config.INTERNAL_ATTRIBUTES)
        self.consent_module = ConsentModule(config,
                                            self._consent_resp_callback_func)
        self.account_linking_module = AccountLinkingModule(
            config, self._account_linking_callback_func)
        # TODO register consent_module endpoints to module_router. Just add to backend list?
        if self.consent_module.enabled:
            backends["consent"] = self.consent_module
        if self.account_linking_module.enabled:
            backends["account_linking"] = self.account_linking_module

        LOGGER.info("Loading micro services...")
        self.request_micro_services = None
        self.response_micro_services = None
        if "MICRO_SERVICES" in self.config:
            self.request_micro_services, self.response_micro_services = load_micro_services(
                self.config.PLUGIN_PATH, self.config.MICRO_SERVICES,
                self.config.INTERNAL_ATTRIBUTES)
        self.module_router = ModuleRouter(frontends, backends)
Esempio n. 5
0
 def test_disable_account_linking(self):
     self.account_linking_config['enable'] = False
     config = SATOSAConfig(self.satosa_config)
     account_linking = AccountLinkingModule(config, self.callback_func)
     account_linking.manage_al(None, None)
     assert self.callback_func.called