Skip to content

Commit 2dee1a0

Browse files
committed
test(go): pin the admitted-id set of the widened scope guard
#436 widened the Neo4j point-lookup guard to admit <app>/@external/ beside <app>/go/, since a library stand-in is this application's node. These pin what that did and did not open: the three own-node shapes are admitted, and all three foreign axes still refuse -- foreign namespace, foreign application (both separator-extended 'svc-extra' and bare 'svcX'), and sibling language -- as do the look-alike segments a prefix test could confuse ('gopher', '@externalish', and either bare segment with no trailing separator). Refs #436
1 parent 89b7411 commit 2dee1a0

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

‎tests/analysis/go/test_go_neo4j_multi_application_scope.py‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,40 @@ def test_point_lookup_rejects_foreign_owner_or_language_before_query(uri):
8282
with pytest.raises(ValueError, match="scope"):
8383
backend.get_class(uri)
8484
assert len(driver.statements) == before
85+
86+
87+
# python-sdk#436 widened the guard to admit `<app>/@external/` alongside `<app>/go/`, because a
88+
# library stand-in is this application's node: the projector mints it under this prefix and it
89+
# carries this application's L4 ports. The admitted set is the subject of these two tests -- the
90+
# widening must not have opened an owner or language axis, and the cases below are the three axes
91+
# plus the look-alike segments a prefix test could confuse.
92+
@pytest.mark.parametrize(
93+
"uri",
94+
[
95+
"can://one/svc/go/server.go/T", # own project node
96+
"can://one/svc/@external/database/sql/DB.Query", # own stand-in -- the widening
97+
"can://one/svc/@external/database/sql/DB.Query@formal_in:1", # own stand-in's vertex
98+
],
99+
)
100+
def test_this_applications_own_nodes_are_admitted(uri):
101+
backend = GoNeo4jBackend._from_driver(Driver(), application_name="svc", namespace="one")
102+
assert backend._in_scope(uri) is True
103+
104+
105+
@pytest.mark.parametrize(
106+
"uri,why",
107+
[
108+
("can://two/svc/@external/bytes/Buffer.Read", "foreign namespace"),
109+
("can://one/svc-extra/@external/bytes/Buffer.Read", "foreign application, separator-extended"),
110+
("can://one/svcX/@external/bytes/Buffer.Read", "foreign application, no separator"),
111+
("can://one/svc/java/Foo.java/T", "sibling language"),
112+
("can://one/svc/typescript/a.ts/T", "sibling language"),
113+
("can://one/svc/gopher/server.go/T", "'go' as the prefix of a different segment"),
114+
("can://one/svc/@externalish/x", "'@external' as the prefix of a different segment"),
115+
("can://one/svc/@external", "the bare segment, no trailing separator"),
116+
("can://one/svc/go", "the bare language segment, no trailing separator"),
117+
],
118+
)
119+
def test_the_widened_guard_still_refuses_every_foreign_axis(uri, why):
120+
backend = GoNeo4jBackend._from_driver(Driver(), application_name="svc", namespace="one")
121+
assert backend._in_scope(uri) is False, why

0 commit comments

Comments
 (0)