diff --git a/README.md b/README.md index 7a83486..6084e12 100644 --- a/README.md +++ b/README.md @@ -6,20 +6,16 @@ 6. [DynDNS](#6-dyndns) 7. [Conclusion](#7-conclusion) +I'm currently in the process to convert this to a symfony app with a UX Turbo interface. + +Don't use this code right now. + +Use the latest release instead. + + NOTICE: This documentation is not current as of September 2022. After I finished the refactoring I'll upgrade it. - -// important: Migration to v2022.2 - -ALTER TABLE `panels` ADD `self` INT NOT NULL DEFAULT '0' AFTER `apikey`; -ALTER TABLE `panels` CHANGE `self` `self` BOOLEAN NOT NULL DEFAULT FALSE; - -ALTER TABLE `panels` ADD `apikey_prefix` VARCHAR(8) NOT NULL AFTER `apikey`; - - - - # 1. Overview diff --git a/src/Controller/ApiKeys.php b/src/Controller/ApiKeys.php deleted file mode 100644 index e887b14..0000000 --- a/src/Controller/ApiKeys.php +++ /dev/null @@ -1,20 +0,0 @@ -setFormatter(formatter: $formatter); - - $this->log = new Logger(name: 'bindAPI'); - $this->log->pushHandler(handler: $stream); - - $this->localZoneFile = '/etc/bind/local.zones'; - $this->localZonesDir = '/etc/bind/zones/'; - $this->namedConfLocalFile = '/etc/bind/named.conf.local'; - //$this->zoneCachePath = '/var/cache/bind/'; - - // read config TODO use .env file instead? - $configFile = dirname(path: __DIR__, levels: 3) . "/config.json"; - $configJSON = file_get_contents(filename: $configFile); - $config = json_decode(json: $configJSON, associative: true); - - $containerBuilder = new ContainerBuilder(); - $containerBuilder->addDefinitions([ - DatabaseConnection::class => autowire()->constructorParameter(parameter: 'config', value: $config), - DomainController::class => autowire() - ->constructorParameter(parameter: 'config', value: $config) - ->constructorParameter(parameter: 'log', value: $this->log), - DomainRepository::class => autowire() - ->constructorParameter(parameter: 'config', value: $config) - ->constructorParameter(parameter: 'log', value: $this->log), - - ]); - $this->container = $containerBuilder->build(); - - $this->domainRepository = $this->container->get(name: DomainRepository::class); - $this->domainController = $this->container->get(name: DomainController::class); - } - - - public function setUp(): void - { - $this->log->info(message: 'Started DomainRepositoryTest'); - } - - public function tearDown(): void - { - $this->log->info(message: 'Finished DomainRepositoryTest'); - } - - /** - * @throws \DI\NotFoundException - * @throws \DI\DependencyException - */ - public function testInsert() - { - $domain = new Domain(name: 'inserttest.org', a: '1.2.3.4', aaaa: '1bad::babe'); - $this->domainRepository->insert(domain: $domain); - $this->domainController->createSlaveZoneFile(domain: $domain); - - // now get the persisted domain with id - $domainTest = $this->domainRepository->findByName(name: 'inserttest.org'); - - $this->assertIsNotBool(actual: $domainTest); - $this->assertEquals(expected: 'inserttest.org', actual: $domainTest->getName()); - - - if ($namedConfLocal = file_get_contents(filename: $this->namedConfLocalFile)) { - $this->assertStringContainsString(needle: $this->localZoneFile, haystack: $namedConfLocal); - } else { - $this->fail(message: 'No permissions: ' . $this->namedConfLocalFile); - } - - $this->assertNotFalse(condition: fileperms(filename: $this->localZoneFile)); - - $localZones = file_get_contents(filename: $this->localZoneFile); - $this->assertStringContainsString(needle: $domainTest->getName(), haystack: $localZones); - - $zoneFile = $this->localZonesDir . $domain->getName(); - - $this->assertFileExists(filename: $zoneFile); - - - // clean up - $this->domainRepository->delete(domain: $domainTest); - } - - - /** - * @throws \DI\NotFoundException - * @throws \DI\DependencyException - */ - public function testDelete() - { - $domain = new Domain(name: 'inserttest.org', a: '1.2.3.4', aaaa: '1bad::babe'); - $this->domainRepository->insert(domain: $domain); - $this->domainController->createSlaveZoneFile(domain: $domain); - - $domainTest = $this->domainRepository->findByName(name: 'inserttest.org'); - $this->assertIsNotBool(actual: $domainTest); - $this->assertEquals(expected: 'inserttest.org', actual: $domainTest->getName()); - - // domain is valid and created - - // now delete and check for cleanup - $this->domainRepository->delete(domain: $domainTest); - - $this->domainController->deleteZone(domain: $domainTest); - - // check zone is removed - - $this->assertNotFalse(condition: fileperms(filename: $this->localZoneFile)); - - $localZones = file_get_contents(filename: $this->localZoneFile); - $this->assertStringNotContainsString(needle: $domainTest->getName(), haystack: $localZones); - - $zoneFile = $this->localZonesDir . $domain->getName(); - - $this->assertFileDoesNotExist(filename: $zoneFile); - - } - -} diff --git a/tests/App/Repository/NameserverRepositoryTest.php b/tests/App/Repository/NameserverRepositoryTest.php deleted file mode 100644 index 2695e49..0000000 --- a/tests/App/Repository/NameserverRepositoryTest.php +++ /dev/null @@ -1,61 +0,0 @@ -addDefinitions([ - DatabaseConnection::class => autowire()->constructorParameter(parameter: 'config', value: $config), - ]); - $this->container = $containerBuilder->build(); - - $this->nameserverRepository = $this->container->get(name: NameserverRepository::class); - - } - - - /** - * @throws \DI\NotFoundException - * @throws \DI\DependencyException - */ - public function testInsert() - { - $nameserver = new Nameserver(name: 'inserttest.org', a: '1.2.3.4', aaaa: '1bad::babe'); - $this->nameserverRepository->insert(nameserver: $nameserver); - - $nameservertest = $this->nameserverRepository->findByName(name: 'inserttest.org'); - $this->assertIsNotBool(actual: $nameserver); - $this->assertEquals(expected: 'inserttest.org', actual: $nameservertest->getName()); - // clean up - $this->nameserverRepository->delete(id: $nameservertest->getId()); - } - -} diff --git a/tests/App/Repository/PanelRepositoryTest.php b/tests/App/Repository/PanelRepositoryTest.php deleted file mode 100644 index ddc9f59..0000000 --- a/tests/App/Repository/PanelRepositoryTest.php +++ /dev/null @@ -1,25 +0,0 @@ -getConfig(configKey: 'debug'); + if ($debug) { + $stream = new StreamHandler(stream: dirname(path: __DIR__, levels: 3) . '/bindAPI.test.log', level: Level::Debug); + } else { + $stream = new StreamHandler(stream: dirname(path: __DIR__, levels: 3) . '/bindAPI.test.log', level: Level::Info); + } + $stream->setFormatter(formatter: $formatter); + + $this->logger = new Logger(name: 'bindAPI'); + $this->logger->pushHandler(handler: $stream); + $this->logger->debug(message: 'bindAPI started'); + + + $containerBuilder = new ContainerBuilder(); + $containerBuilder->addDefinitions([ + //DatabaseConnection::class => autowire()->constructorParameter(parameter: 'config', value: $config), + DomainController::class => autowire() + ->constructorParameter(parameter: 'logger', value: $this->logger), + DomainRepository::class => autowire() + ->constructorParameter(parameter: 'logger', value: $this->logger), + + ]); + $this->container = $containerBuilder->build(); + + $this->nameserverRepository = $this->container->get(name: NameserverRepository::class); + $this->domainRepository = $this->container->get(name: DomainRepository::class); + $this->domainController = $this->container->get(name: DomainController::class); + + } + + + public function testFoo(): void + { + self::assertEquals(expected: true, actual: true); + + } +} \ No newline at end of file diff --git a/tests/Unit/Controller/BindApiTestController.php b/tests/Unit/Controller/BindApiTestController.php deleted file mode 100644 index 05265db..0000000 --- a/tests/Unit/Controller/BindApiTestController.php +++ /dev/null @@ -1,44 +0,0 @@ -addDefinitions([ - DatabaseConnection::class => autowire()->constructorParameter(parameter: 'config', value: $config), - ]); - $this->container = $containerBuilder->build(); - - $this->nameserverRepository = $this->container->get(name: NameserverRepository::class); - - } -} \ No newline at end of file