Example #1
0
    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!"
        state = State(urlstate, enc_key)
        assert state["my_dict_frontend"] == my_dict_frontend
        assert state["my_dict_consent"] == my_dict_consent
        assert state["my_dict_hash"] == my_dict_hash
        assert state["my_dict_router"] == my_dict_router
        assert state["my_dict_backend"] == my_dict_backend
Example #2
0
    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!"
        state = State(urlstate, enc_key)
        assert state["my_dict_frontend"] == my_dict_frontend
        assert state["my_dict_consent"] == my_dict_consent
        assert state["my_dict_hash"] == my_dict_hash
        assert state["my_dict_router"] == my_dict_router
        assert state["my_dict_backend"] == my_dict_backend
Example #3
0
def test_simple_test():
    """
    Performs a test that the state class works as intended.

    :return:
    """
    enc_key = "Ireallyliketoencryptthisdictionary!"
    state = State()
    my_dict_frontend = get_dict(10, get_str(10), get_str(10))
    my_dict_frontend["resp_attr"] = get_str(100)
    assert len(my_dict_frontend) == 11, "The dictionary is not correct!"
    my_dict_consent = get_dict(1, get_str(10), get_str(100))
    assert len(my_dict_consent) == 1, "The dictionary is not correct!"
    my_dict_hash = get_dict(1, get_str(10), get_str(15))
    assert len(my_dict_hash) == 1, "The dictionary is not correct!"
    my_dict_router = get_dict(1, get_str(10), get_str(10))
    assert len(my_dict_router) == 1, "The dictionary is not correct!"
    my_dict_backend = get_dict(10, get_str(10), get_str(10))
    assert len(my_dict_backend) == 10, "The dictionary is not correct!"
    state.add("my_dict_frontend", my_dict_frontend)
    state.add("my_dict_consent", my_dict_consent)
    state.add("my_dict_hash", my_dict_hash)
    state.add("my_dict_router", my_dict_router)
    state.add("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!"
    state = State(urlstate, enc_key)
    tmp_dict_frontend = state.get("my_dict_frontend")
    tmp_dict_consent = state.get("my_dict_consent")
    tmp_dict_hash = state.get("my_dict_hash")
    tmp_dict_router = state.get("my_dict_router")
    tmp_dict_backend = state.get("my_dict_backend")
    compare_dict(tmp_dict_frontend, my_dict_frontend)
    compare_dict(tmp_dict_consent, my_dict_consent)
    compare_dict(tmp_dict_hash, my_dict_hash)
    compare_dict(tmp_dict_router, my_dict_router)
    compare_dict(tmp_dict_backend, my_dict_backend)
Example #4
0
def test_simple_test():
    """
    Performs a test that the state class works as intended.

    :return:
    """
    enc_key = "Ireallyliketoencryptthisdictionary!"
    state = State()
    my_dict_frontend = get_dict(10, get_str(10), get_str(10))
    my_dict_frontend["resp_attr"] = get_str(100)
    assert len(my_dict_frontend) == 11, "The dictionary is not correct!"
    my_dict_consent = get_dict(1, get_str(10), get_str(100))
    assert len(my_dict_consent) == 1, "The dictionary is not correct!"
    my_dict_hash = get_dict(1, get_str(10), get_str(15))
    assert len(my_dict_hash) == 1, "The dictionary is not correct!"
    my_dict_router = get_dict(1, get_str(10), get_str(10))
    assert len(my_dict_router) == 1, "The dictionary is not correct!"
    my_dict_backend = get_dict(10, get_str(10), get_str(10))
    assert len(my_dict_backend) == 10, "The dictionary is not correct!"
    state.add("my_dict_frontend", my_dict_frontend)
    state.add("my_dict_consent", my_dict_consent)
    state.add("my_dict_hash", my_dict_hash)
    state.add("my_dict_router", my_dict_router)
    state.add("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!"
    state = State(urlstate, enc_key)
    tmp_dict_frontend = state.get("my_dict_frontend")
    tmp_dict_consent = state.get("my_dict_consent")
    tmp_dict_hash = state.get("my_dict_hash")
    tmp_dict_router = state.get("my_dict_router")
    tmp_dict_backend = state.get("my_dict_backend")
    compare_dict(tmp_dict_frontend, my_dict_frontend)
    compare_dict(tmp_dict_consent, my_dict_consent)
    compare_dict(tmp_dict_hash, my_dict_hash)
    compare_dict(tmp_dict_router, my_dict_router)
    compare_dict(tmp_dict_backend, my_dict_backend)