Check for object type in returned values from some TestMethodsV2 methods used in Test Cases#1427
Conversation
|
Actually, the output of Applying my review suggestions gives a more correct output from zonemaster-cli: |
Methods 'Zonemaster::Engine::TestMethodsV2::get_{zone,del}_ns_names_and_ips()' can return a mix of Zonemaster::Engine::Nameserver or Zonemaster::Engine::DNSName objects, depending on whether the name could be resolved into an IP address.
Due to a previous oversight, this can cause issues in Test Cases that use them. We can filter Zonemaster::Engine::DNSName objects out since they can't be queried.
bbc63a5
2c82dd3 to
bbc63a5
Compare
|
@mattias-p @marc-vanderwal @matsduf I've rebased on latest |
|
Most test cases only use name servers by IP address. If a name server only has a name and no address it will be disregarded. The name is only needed to make the messages more readable, a nice feature for the users. The PR adds the same code to two test cases to filter out name servers without address. I feel it is wrong approach. We would then need a scenario for each test case to make sure this filtering is done correctly. And the test case code get more complex. It would be a better solution if MethodsV2 methods provide the name servers twice, one set of IP addresses, and one set of name/IP pairs. In that way we lower the risk of errors and make the test case code simpler. Maybe even a method that provide the combination of delegation and zone, which is what we use in most test cases (no separation is needed). If an update of the MethodsV2 specification is needed, we can take that time. I am willing to work on that. |
|
I agree that the MethodV2 return types aren't the most ergonomic. AFAICT this is partly a consequence of how MethodsV2 are specified. I thought about how the situation could be improved and updated zonemaster/zonemaster#1345 with a design proposal that would allow nicer programmatic interfaces. One of the ideas is that methods should return lists of homogenous types that can be deduplicated using List::Util::uniq instead of arrayrefs of sometimes heterogeneous types. |
|
As discussed in the work group and previous comments, this PR will be merged as-is until a more long-term solution is provided, probably based on zonemaster/zonemaster#1345. |
Purpose
Methods
Zonemaster::Engine::TestMethodsV2::get_{zone,del}_ns_names_and_ips()can return a mix ofZonemaster::Engine::NameserverorZonemaster::Engine::DNSNameobjects, depending on whether the name could be resolved into an IP address. Due to a previous oversight, this can cause issues in Test Cases that use them. We can filterZonemaster::Engine::DNSNameobjects out since they can't be queried.Moreover it also fixes a buggy ternary expression in the same place (see #1427 (comment) below).
Context
Fixes #1426
Changes
Zonemaster::Engine::Nameserverobjects out of the list of to-be-queried name servers in Test CasesHow to test this PR
Unit tests could be created but they are kind of out of scope for either the TestMethodsV2 or the Test Cases themselves.
Manual testing (from #1426):