Пример #1
0
    def test_position_in_dict_ignored(self):
        a = Request(target=None, body={"a": 1, "b": 2})
        b = Request(target=None, body={"b": 2, "a": 1})
        c = Request(target=None, body={"a": 2, "b": 1})

        assert Amf.get_representation(a) == Amf.get_representation(b)
        assert Amf.get_representation(a) != Amf.get_representation(c)
Пример #2
0
    def test_limit_recursive_calls(self):
        a = CustomObject()
        a.secret = a

        encoded = generate_amf_request(request_body=[a])
        decoded = decode(BytesIO(encoded))
        try:
            Amf.get_representation(decoded)
            assert False, "should not be called"
        except Exception as e:
            assert "maximum number of calls reached" in str(e)
Пример #3
0
    def test_can_parse_custom_object(self):
        a = CustomObject()
        a.secret = "a"

        encoded = generate_amf_request(request_body=[a])
        decoded = decode(BytesIO(encoded))

        assert Amf.get_representation(decoded) == \
               '<Envelope>[<Request target=UserService>[<CustomObject>{"secret": "a"}</CustomObject>]</Request>]</Envelope>'
Пример #4
0
    def amf_parse(self, string, environ):
        try:
            res = decode(BytesIO(string))
            return urlencode({"request": Amf.get_representation(res)})

        except Exception as e:
            import traceback
            traceback.print_exc()
            print(e)
            return None
Пример #5
0
    def amf_parse(self, string, environ):
        try:
            res = decode(BytesIO(string))
            return urlencode({"request": Amf.get_representation(res)})

        except Exception as e:
            import traceback
            traceback.print_exc()
            print(e)
            return None
Пример #6
0
    def test_order_of_array_preserved(self):
        a = Request(target=None, body=[1, 2])
        b = Request(target=None, body=[2, 1])

        assert Amf.get_representation(a) != Amf.get_representation(b)
Пример #7
0
 def test_parse_flex_request_with_envelope(self):
     encoded = generate_flex_request([{"the": "body"}])
     decoded = decode(BytesIO(encoded))
     assert Amf.get_representation(decoded) == \
            '<Envelope>[<Request target=UserService>[<RemotingMessage operation=retrieveUser>[{"the": "body"}]</RemotingMessage>]</Request>]</Envelope>'
Пример #8
0
 def test_parse_amf_request_with_envelope(self):
     encoded = generate_amf_request([{"the": "body"}])
     decoded = decode(BytesIO(encoded))
     assert Amf.get_representation(decoded) == \
            '<Envelope>[<Request target=UserService>[{"the": "body"}]</Request>]</Envelope>'