Skip to content

Commit

Permalink
chore: add tsig tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bennetgallein committed May 11, 2024
1 parent 388e974 commit 19dd12c
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/functional/TSIGKeysTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
namespace Exonet\Powerdns\tests\functional;

use Exonet\Powerdns\Resources\TSIGKey as TSIGKeyResource;
use Exonet\Powerdns\TSIGKeyAlgorithms;

/**
* @internal
*/
class TSIGKeysTest extends FunctionalTestCase {

public function testCreateTSIGKey(): void {

$name = "test-key";

$manager = $this->powerdns->tsigkeys();
$resource = new TSIGKeyResource();

$resource->setName($name);
$resource->setAlgorithm(TSIGKeyAlgorithms::HMAC_SHA512);

$key = $manager->create($resource);

$this->assertSame(1, $key->count());

$created = $key->offsetGet(0);
$this->assertNotEquals("", $created->getKey());

// cleanup
$manager->delete($created);

}

public function testCreateWithNonUrlFriendlyName(): void {
$name = "this/is/not/aa-_412'aur\\asd-url-friendly";

$manager = $this->powerdns->tsigkeys();
$resource = new TSIGKeyResource();

$resource->setName($name);
$resource->setAlgorithm(TSIGKeyAlgorithms::HMAC_SHA512);

$key = $manager->create($resource);

$this->assertSame(1, $key->count());

$created = $key->offsetGet(0);
$this->assertNotEquals("", $created->getKey());

// cleanup
$manager->delete($created);
}

}

0 comments on commit 19dd12c

Please sign in to comment.