Commit graph

116 commits

Author SHA1 Message Date
Richard Hansen
c71f6f6eae Prefetch the data relevant to the use* strategies
This is a preparatory step to improving the deduplication of queries.
It also makes possible future improvements to config validation and
help usage output.
2024-09-06 18:53:14 -04:00
Richard Hansen
5ed43a2e4c tests: Factor out duplicate HTTP server code 2024-09-06 18:44:19 -04:00
Richard Hansen
62f3759c54 tests: Factor out duplicate IPv6 support detection code 2024-09-06 18:41:37 -04:00
Richard Hansen
9c7c0e55c1 tests: Refine module loads
* Wrap all conditional loads in `BEGIN {}` to be closer to the
    behavior of `use`.
  * Add missing `Test::Warnings`, `HTTP::Request` loads.
  * Sort by module name, except load `Test::More` first and
    `Test::Warnings` immediately after to maximize checking
    effectiveness.
  * Return truthy from `eval` block to prevent the `or` case from
    executing if the loaded module does not have a final truthy
    statement.  (Except for `ddclient` because we want to test that it
    does have a final truthy statement.)
2024-09-06 18:41:33 -04:00
Richard Hansen
dd7ad1ccf4 tests: dnsexit2: Use reserved IP addresses and domain names 2024-09-06 15:47:05 -04:00
Richard Hansen
d38fcbddb8 tests: dnsexit2: Rename variables to follow got, want pattern 2024-09-06 15:47:05 -04:00
Richard Hansen
d0eb899fc8 tests: dnsexit2: Localize changes to %config 2024-09-06 15:47:05 -04:00
Richard Hansen
e8d79d842c tests: dnsexit2: Inline unnecessary helper function
for readability
2024-09-06 15:47:05 -04:00
Richard Hansen
7653f60058 tests: dnsexit2: Move request to a variable
for readability
2024-09-06 15:46:59 -04:00
Richard Hansen
c768f1350b tests: dnsexit2: Check number of requests 2024-09-06 15:24:16 -04:00
Richard Hansen
e9029b85d5 tests: dnsexit2: Simplify request check 2024-09-06 15:22:55 -04:00
Richard Hansen
bd1e42ac6c tests: dnsexit2: Declare @requests where used
for readability
2024-09-06 15:22:55 -04:00
Richard Hansen
d7861b6d61 tests: Do use parent -norequire instead of modifying ISA 2024-09-06 15:22:55 -04:00
Richard Hansen
6c33ccaa25 tests: Always have a truthy final expression in modules
This ensures that `eval { require Module; } or ...` doesn't execute
the `or` case when loading is successful.
2024-09-06 15:22:55 -04:00
Richard Hansen
2ccdd3b19e tests: Delete obsolete debugging comments
All log output goes to stderr, so turning on `debug` or `verbose` will
not interfere with TAP.  A better way to debug is to add the following
to whatever scope you think is appropriate:

    local $ddclient::globals{debug} = 1;
    local $ddclient::globals{verbose} = 1;
2024-09-06 15:22:55 -04:00
Richard Hansen
8b7581287c tests: update_nics: Test number of web* queries
This will be used in a future commit to test deduplication of of
`use*` strategies.
2024-09-06 15:22:46 -04:00
Richard Hansen
b6ac0e6d05 tests: update_nics: Support multiple hosts
This will be used in a future commit to test deduplication of `use*`
strategies.
2024-09-06 15:22:37 -04:00
Richard Hansen
f32f7fc29a tests: update_nics: Fix tracking of update calls
The tests weren't failing because there was only one host being
updated at a time, but this will change in a future commit.
2024-09-06 15:22:18 -04:00
Richard Hansen
695c3c4be8 Separate recap variables from configuration variables 2024-09-02 03:55:09 -04:00
Richard Hansen
1e3bebc60d Object-oriented protocol definitions
This improves readability and will make it easier to refactor to fix
issues or add features.
2024-09-02 03:55:09 -04:00
Richard Hansen
268369a05e Write update status to %recap, not %config
Status is not configuration so it doesn't belong in `%config`.

`wantip`, `wantipv4`, and `wantipv6` are still passed along in
`%config` because `group_hosts_by` needs access to them like other
settings.
2024-09-02 03:55:09 -04:00
Richard Hansen
25fac765a0 nic_updateable: Move clearing of update to write_recap
for readability (the logic that uses the `update` boolean should be
responsible for clearing it).
2024-09-01 20:08:44 -04:00
Richard Hansen
5256a1d02c update_nics: Move legacy protocol support to an adapter function 2024-09-01 20:08:27 -04:00
Richard Hansen
f2c9ef6641 read_recap: Scrub recap values without var declarations 2024-09-01 20:05:40 -04:00
Richard Hansen
70e2b51377 read_recap: Don't copy non-recap values to %config 2024-09-01 20:04:45 -04:00
Richard Hansen
989f8be8c3 read_recap: Delete from %config any status values missing from recap 2024-09-01 20:02:58 -04:00
Richard Hansen
c9cdb96086 read_recap: Fix copying of recap values into %config 2024-09-01 20:02:34 -04:00
Richard Hansen
35cbc8d200 read_recap: Reference %recap directly (for readability)
There's no need to pass a reference to `%recap` as an argument when
that is the only way `read_recap` is ever used.
2024-09-01 18:08:10 -04:00
Richard Hansen
ce1bcaa68b nic_updateable: Set warned-min-* in %config, not %recap
Currently the semantics of recap variables are that values are updated
in `%config` and propagate to `%recap`.  Before this commit,
`warned-min-interval` and `warned-min-error-interval` were set in
`%recap` instead of `%config`, meaning if they followed the semantics
they would be overwritten or deleted when synced with `%config`.  Now
the values are set in `%config` to match the behavior of other recap
variables.
2024-09-01 18:08:10 -04:00
Richard Hansen
c943d7c0d9 tests: Add some unit tests for read_recap 2024-09-01 18:05:53 -04:00
Richard Hansen
0a9ee106e4 tests: Debug log when in protocol update callback 2024-09-01 02:44:05 -04:00
Richard Hansen
de5d894c91 Fix handling of legacy status value
When a legacy protocol implementation returns, move its `status` and
`ip` results to the new `status-ipv4` and `ipv4` (or `status-ipv6` and
`ipv6`) properties.

Also remove the now-unused `status` variable definition, and remove
`ip` from the recap.
2024-08-22 02:08:39 -04:00
Richard Hansen
a21e215ada Reduce unnecessary values in %config and %recap
* Delete values from `$config{$h}` and `$recap{$h}` when resetting
    values (as opposed to setting a falsy value).
  * Delete values from `$config{$h}` and `$recap{$h}` when they are no
    longer needed.

This is mostly done to improve the tests in `t/update_nics.pl`.
2024-08-22 02:08:39 -04:00
Richard Hansen
f024bcce34 Dynamically compute default for use based on usev4, usev6
This is mostly to simplify tests, but it also improves readability.

The infrastructure changes in this commit also make it possible to
introduce a new `url` variable that defaults to `opt('server', $h)`
concatenated with `opt('script', $h)` so that we can start migrating
away from those user-unfriendly variables.
2024-08-22 02:08:39 -04:00
Richard Hansen
46bd2f1771 tests: Also test default() return value 2024-08-22 02:08:39 -04:00
Richard Hansen
555359dc98 tests: Add unit tests for legacy protocol handling in nic_updateable 2024-08-22 02:08:39 -04:00
Richard Hansen
912bc6291a group_hosts_by: Treat undef as unset for consistency with opt
The `opt` function falls back to global/default if the value is
undefined, even if it is explicitly set to `undef`.  `group_hosts_by`
should behave the same.
2024-08-18 01:21:40 -04:00
Richard Hansen
270a82dd58 parse_assignments: Support newlines
Allow newlines to be in values, but stop searching for assignments
once an unescaped/unquoted newline is discovered.  This is preparation
to using `parse_assignments` to process the `--options` command-line
argument, which might have embedded newlines.
2024-08-18 00:41:28 -04:00
Richard Hansen
4c7634855b Move *_env processing to parse_assignment
This makes the behavior transparent to the rest of ddclient, which
will make it possible for a future commit to simplify option
processing.
2024-08-18 00:41:28 -04:00
Richard Hansen
ed2afde72d check_value: die if the value is invalid
This makes it possible to convey details about why the value was
deemed invalid.  It also allows `undef` to be treated as a valid
value.
2024-08-18 00:41:28 -04:00
Richard Hansen
0c094f6ee8 tests: Fix verbose option for dnsexit2 protocol tests
The `verbose` option is a global option, not a per-host option.
2024-08-18 00:35:44 -04:00
Richard Hansen
a136ba4cdc tests: Fix ssl option for dnsexit2 protocol tests
The `ssl` option is a global option, not a per-host option.  This
commit could instead do:

    local $ddclient::globals{ssl} = 0;

but it's more straightforward to include `http://` in the `server`
option, and it tests that `server` supports the inclusion of the
scheme.
2024-08-18 00:35:44 -04:00
Jeff Rego
959b5ddc37 Add support for Directnic provider 2024-08-07 00:06:25 -04:00
Jeff Rego
d497422bf9 Add T_URL type for config properties 2024-08-07 00:06:25 -04:00
Richard Hansen
2330543cc8 dyndns2: Add comment explaining why keys are listed in test 2024-08-05 19:57:18 -04:00
Richard Hansen
eb281ea47b dnsexit2: Rename test file for consistency 2024-08-03 03:32:35 -04:00
Richard Hansen
3d345ff08b dyndns2: Add tests 2024-08-03 03:32:35 -04:00
Richard Hansen
15db76f739 Logger: Accept an arrayref of contexts for ctx parameter 2024-08-02 20:42:36 -04:00
Richard Hansen
f36c2f45aa Logger: Always use STDERR as output filehandle
There's no good reason for the caller of the `log` method to control
the output filehandle.
2024-08-02 17:03:56 -04:00
Richard Hansen
439b0fd0e1 Logger: Minimize STDERR override in tests 2024-08-02 17:00:00 -04:00