Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move some basic.t tests into more specific .t files
- Loading branch information
Showing
3 changed files
with
81 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use Test::More; | ||
use strict; | ||
use warnings; | ||
use Data::Dump qw(pp); | ||
|
||
use Test::Mojo; | ||
my $t = Test::Mojo->new('PowerDNS::API'); | ||
|
||
$Carp::Verbose = 1; | ||
|
||
use lib 't'; | ||
use TestUtils; | ||
|
||
$TestUtils::t = $t; | ||
|
||
my $r; | ||
|
||
my $domain = test_domain_name; | ||
|
||
my $schema = PowerDNS::API::schema(); | ||
ok(my $account = setup_user, 'setup account'); | ||
ok(my $account2 = setup_user, 'setup account 2'); | ||
|
||
$TestUtils::current_user = $account; | ||
|
||
ok($r = api_call(PUT => "domain/$domain", { user => $account }), 'setup new domain'); | ||
$t->status_is(201, 'ok, created'); | ||
|
||
ok($r = api_call(POST => "record/$domain", { type => 'NS', name => '', content => 'ns1.example.com' }), 'setup NS record'); | ||
$t->status_is(201); | ||
ok($r->{record}->{id}, 'got an ID'); | ||
is($r->{record}->{type}, 'NS', 'is an NS record'); | ||
|
||
ok($r = api_call(POST => "record/$domain", { type => 'SOA', name => '', content => '' }), 'Add a second SOA record'); | ||
$t->status_is(406); | ||
|
||
ok($r = api_call(POST => "record/$domain", { type => 'A', name => 'www', content => '10.0.0.1' }), 'setup A record'); | ||
ok($r->{record}->{id}, 'got an ID'); | ||
is($r->{record}->{content}, '10.0.0.1', 'correct content'); | ||
|
||
my $id = $r->{record}->{id}; | ||
|
||
ok($r = api_call(PUT => "record/$domain/$id", { content => '10.0.0.2' }), 'change A record'); | ||
is($r->{record}->{content}, '10.0.0.2', 'correct content'); | ||
|
||
|
||
ok( $r = api_call( | ||
POST => "record/$domain", | ||
{ type => 'TXT', | ||
name => '_spf', | ||
content => 'some text goes here', | ||
ttl => 600 | ||
} | ||
), | ||
'setup TXT record with TTL' | ||
); | ||
ok($r->{record}->{id}, 'got an ID'); | ||
is($r->{record}->{ttl}, 600, 'correct TTL'); | ||
|
||
ok($r = api_call(GET => "domain/$domain", { type => 'A', name => 'www' }), "Get records with filter"); | ||
ok($r->{domain}, "got domain back"); | ||
is($r->{domain}->{name}, $domain, 'got the right domain'); | ||
is($r->{records}->[0]->{name}, 'www', 'got the right record name'); | ||
|
||
ok($r = api_call(DELETE => "record/$domain/$id"), 'delete TXT record'); | ||
|
||
$id = $r->{record}->{id}; | ||
|
||
ok($account->delete, 'deleted account again'); | ||
ok($account2->delete, 'deleted second account'); | ||
|
||
done_testing(); | ||
exit; |
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