Commit 8938096f authored by kzangeli's avatar kzangeli
Browse files

HttpCtrl: parameterised-request stub matching keys on the exact path

The 'broker may append parameters' branch matched stubs by checking
that the urn segments of the stub's last path component appear
somewhere in the request URL — it never compared the path prefix. With
two stubs for the same entity id behind different prefixes
(/broker1/... and /broker2/..., the standard two-CSR redirect layout),
the first stub matched BOTH forwards: its count doubled, the sibling
stayed at 0, and the response merge received the first stub's body
twice (D010_01_red: 'Get Stub Count' 2/0 against expected 1/1, and
$.isParked2 absent).

The branch now requires the stub's path to equal the request's path
(query string ignored, percent-encoding normalised, trailing slashes
stripped) — same comparison the parameterless branch already uses.
parent 7649c37f
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -114,15 +114,18 @@ class HttpStubContainer(metaclass=Singleton):
                            return False
                    return True
                
                # we should check if an id is into the url
                if "urn" in stub.criteria.url:
                    stub_url = stub.criteria.url.split("/")
                    id = stub_url[-1].split(":")
                    for elements in id:
                        if elements not in (criteria.url):
                            return False
                # Stub registered without parameters; brokers may append
                # optional parameters to the forward (sysAttrs, pick, ...).
                # Match on the exact PATH, ignoring the request's query
                # string. The previous urn-segment heuristic never compared
                # the path prefix, so a /broker2/... request matched the
                # /broker1/... stub whenever both targeted the same entity
                # id -- the first stub swallowed every forward and its
                # sibling starved (D010_01_red counts 2/0, and the merge
                # never saw broker2's body).
                from urllib.parse import unquote
                if unquote(stub.criteria.url).rstrip("/") == unquote(criteria_url_components[0]).rstrip("/"):
                    return True
                else:
                return False
            
            # if the method is not GET, we should ignore parameters and check if the url is the same