@@ -93,3 +93,113 @@ async def test_search_anywhere_by_string(
9393
9494 assert sorted (node_ids ) == sorted ([person_john_main .id , person_jane_main .id ])
9595 assert sorted (node_kinds ) == sorted ([person_john_main .get_kind (), person_jane_main .get_kind ()])
96+
97+
98+ async def test_search_ipv6_address_extended_format (
99+ db : InfrahubDatabase ,
100+ ip_dataset_01 ,
101+ branch : Branch ,
102+ ):
103+ gql_params = prepare_graphql_params (db = db , include_subscription = False , branch = branch )
104+
105+ res_collapsed = await graphql (
106+ schema = gql_params .schema ,
107+ source = SEARCH_QUERY ,
108+ context_value = gql_params .context ,
109+ root_value = None ,
110+ variable_values = {"search" : "2001:db8::" },
111+ )
112+
113+ res_extended = await graphql (
114+ schema = gql_params .schema ,
115+ source = SEARCH_QUERY ,
116+ context_value = gql_params .context ,
117+ root_value = None ,
118+ variable_values = {"search" : "2001:0db8:0000:0000:0000:0000:0000:0000" },
119+ )
120+
121+ assert (
122+ res_extended .data ["InfrahubSearchAnywhere" ]["count" ]
123+ == res_collapsed .data ["InfrahubSearchAnywhere" ]["count" ]
124+ == 2
125+ )
126+
127+ assert (
128+ res_extended .data ["InfrahubSearchAnywhere" ]["edges" ][0 ]["node" ]["id" ]
129+ == res_collapsed .data ["InfrahubSearchAnywhere" ]["edges" ][0 ]["node" ]["id" ]
130+ )
131+
132+ assert (
133+ res_extended .data ["InfrahubSearchAnywhere" ]["edges" ][1 ]["node" ]["id" ]
134+ == res_collapsed .data ["InfrahubSearchAnywhere" ]["edges" ][1 ]["node" ]["id" ]
135+ )
136+
137+
138+ async def test_search_ipv6_network_extended_format (
139+ db : InfrahubDatabase ,
140+ ip_dataset_01 ,
141+ branch : Branch ,
142+ ):
143+ gql_params = prepare_graphql_params (db = db , include_subscription = False , branch = branch )
144+
145+ res_collapsed = await graphql (
146+ schema = gql_params .schema ,
147+ source = SEARCH_QUERY ,
148+ context_value = gql_params .context ,
149+ root_value = None ,
150+ variable_values = {"search" : "2001:db8::/48" },
151+ )
152+
153+ res_extended = await graphql (
154+ schema = gql_params .schema ,
155+ source = SEARCH_QUERY ,
156+ context_value = gql_params .context ,
157+ root_value = None ,
158+ variable_values = {"search" : "2001:0db8:0000:0000:0000:0000:0000:0000/48" },
159+ )
160+
161+ assert (
162+ res_extended .data ["InfrahubSearchAnywhere" ]["count" ]
163+ == res_collapsed .data ["InfrahubSearchAnywhere" ]["count" ]
164+ == 1
165+ )
166+
167+ assert (
168+ res_extended .data ["InfrahubSearchAnywhere" ]["edges" ][0 ]["node" ]["id" ]
169+ == res_collapsed .data ["InfrahubSearchAnywhere" ]["edges" ][0 ]["node" ]["id" ]
170+ )
171+
172+
173+ async def test_search_ipv4 (
174+ db : InfrahubDatabase ,
175+ ip_dataset_01 ,
176+ branch : Branch ,
177+ ):
178+ gql_params = prepare_graphql_params (db = db , include_subscription = False , branch = branch )
179+
180+ result_address = await graphql (
181+ schema = gql_params .schema ,
182+ source = SEARCH_QUERY ,
183+ context_value = gql_params .context ,
184+ root_value = None ,
185+ variable_values = {"search" : "10.0.0.0" },
186+ )
187+
188+ result_network = await graphql (
189+ schema = gql_params .schema ,
190+ source = SEARCH_QUERY ,
191+ context_value = gql_params .context ,
192+ root_value = None ,
193+ variable_values = {"search" : "10.0.0.0/8" },
194+ )
195+
196+ assert (
197+ result_address .data ["InfrahubSearchAnywhere" ]["count" ]
198+ == result_network .data ["InfrahubSearchAnywhere" ]["count" ]
199+ == 1
200+ )
201+
202+ assert (
203+ result_address .data ["InfrahubSearchAnywhere" ]["edges" ][0 ]["node" ]["id" ]
204+ == result_network .data ["InfrahubSearchAnywhere" ]["edges" ][0 ]["node" ]["id" ]
205+ )
0 commit comments