How to use the satosa.state.State function in SATOSA

To help you get started, we’ve selected a few SATOSA examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IdentityPython / SATOSA / tests / satosa / test_id_hash.py View on Github external
def _get_id(requester, user_id, hash_type):
    state = State()

    internal_request = InternalRequest(hash_type, requester)

    UserIdHasher.save_state(internal_request, state)

    return UserIdHasher.hash_id(SALT, user_id, requester, state)
github IdentityPython / SATOSA / tests / satosa / frontends / test_saml2.py View on Github external
def test_load_idp_dynamic_entity_id(self, idp_conf):
        state = State()
        state[self.frontend.name] = {"target_entity_id": self.TARGET_ENTITY_ID}
        idp = self.frontend._load_idp_dynamic_entity_id(state)
        assert idp.config.entityid == "{}/{}".format(idp_conf["entityid"], self.TARGET_ENTITY_ID)
github IdentityPython / SATOSA / tests / satosa / test_state.py View on Github external
def test_state_to_cookie_produces_cookie_without_max_age_for_state_that_should_be_deleted(self):
        state_key = "27614gjkrn"
        saved_data = "data"
        state = State()
        state[state_key] = saved_data
        state.delete = True

        cookie_name = "state_cookie"
        path = "/"
        encrypt_key = "2781y4hef90"

        cookie = state_to_cookie(state, cookie_name, path, encrypt_key)
        cookie_str = cookie[cookie_name].OutputString()

        parsed_cookie = SimpleCookie(cookie_str)
        assert not parsed_cookie[cookie_name].value
        assert parsed_cookie[cookie_name]["max-age"] == '0'
github IdentityPython / SATOSA / tests / satosa / test_state.py View on Github external
def test_contains(self):
        state = State()
        state["foo"] = "bar"
        assert "foo" in state
        del state["foo"]
        assert "foo" not in state
github IdentityPython / SATOSA / tests / satosa / test_state.py View on Github external
def test_urlstate_length_should_fit_in_browser_cookie(self):
        """
        Performs a test that the state class works as intended.

        :return:
        """
        enc_key = "Ireallyliketoencryptthisdictionary!"
        state = State()
        my_dict_frontend = get_dict(11, get_str(10), get_str(10))
        my_dict_consent = get_dict(1, get_str(10), get_str(100))
        my_dict_hash = get_dict(1, get_str(10), get_str(15))
        my_dict_router = get_dict(1, get_str(10), get_str(10))
        my_dict_backend = get_dict(10, get_str(10), get_str(10))
        state["my_dict_frontend"] = my_dict_frontend
        state["my_dict_consent"] = my_dict_consent
        state["my_dict_hash"] = my_dict_hash
        state["my_dict_router"] = my_dict_router
        state["my_dict_backend"] = my_dict_backend
        urlstate = state.urlstate(enc_key)
        # Some browsers only support 2000bytes, and since state is not the only parameter it should
        # not be greater then half that size.
        urlstate_len = len(quote_plus(urlstate))
        print("Size of state on the url is:%s" % urlstate_len)
        assert urlstate_len < 1000, "Urlstate is way to long!"
github IdentityPython / SATOSA / tests / satosa / test_state.py View on Github external
def test_encode_decode_of_state(self):
        """
        Test that the state can be converted between cookie and state
        """
        state_key = "27614gjkrn"
        saved_data = "data"
        state = State()
        state[state_key] = saved_data

        cookie_name = "state_cookie"
        path = "/"
        encrypt_key = "2781y4hef90"

        cookie = state_to_cookie(state, cookie_name, path, encrypt_key)
        cookie_str = cookie[cookie_name].OutputString()
        loaded_state = cookie_to_state(cookie_str, cookie_name, encrypt_key)

        assert loaded_state[state_key] == saved_data