forked from ddclient/ddclient
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use Test::More; | ||
# Your test dependencies go here. | ||
|
||
SKIP: { eval { require Test::Warnings; } or skip($@, 1); } | ||
eval { require 'ddclient'; } or BAIL_OUT($@); | ||
BEGIN { | ||
eval { require ddclient::t::HTTPD; 1; } or plan(skip_all => $@); | ||
ddclient::t::HTTPD->import(); | ||
} | ||
|
||
httpd()->run(sub { | ||
my ($req) = @_; | ||
diag('=============================================================================='); | ||
diag("Test server received request:\n" . $req->as_string()); | ||
return undef if $req->uri()->path() eq '/control'; | ||
return [401, [@$textplain, 'www-authenticate' => 'Basic realm="realm", charset="UTF-8"'], | ||
['authentication required']] if ($req->header('authorization') // '') ne $wantauthn; | ||
return [400, $textplain, ['invalid method: ' . $req->method()]] if $req->method() ne 'GET'; | ||
return undef; | ||
}); | ||
|
||
local %ddclient::config = ( | ||
'host.my.example.com' => { | ||
'protocol' => 'ionos', | ||
'password' => 'mytestingpassword', | ||
'server' => httpd()->endpoint(), | ||
'wantip' => '1.2.3.4', | ||
}); | ||
|
||
ddclient::nic_ionos_update(undef, 'host.my.example.com'); | ||
|
||
my @requests = httpd()->reset(); | ||
is(scalar(@requests), 1, "$tc->{desc}: single update request"); | ||
|
||
my $req = shift(@requests); | ||
is($req->uri()->path(), '/dns/v1/dyndns', "$tc->{desc}: request path"); | ||
is($req->uri()->query(), 'q=mytestingpassword', "$tc->{desc}: request query"); | ||
|
||
done_testing(); |