diff --git a/CHANGELOG.md b/CHANGELOG.md index cb2e8fd2..804566e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [1.4.4 - 2023-12-xx] + +### Fixed + +- invalid default Nextcloud URL, incorrect url with slash at the end processing. #169 + ## [1.4.3 - 2023-12-18] ### Added diff --git a/lib/Command/Daemon/ListDaemons.php b/lib/Command/Daemon/ListDaemons.php index 88474260..3bf9228f 100644 --- a/lib/Command/Daemon/ListDaemons.php +++ b/lib/Command/Daemon/ListDaemons.php @@ -43,11 +43,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Registered ExApp daemon configs:'); $table = new Table($output); - $table->setHeaders(['Default', 'Name', 'Display name', 'Accepts Deploy ID', 'Protocol', 'Host']); + $table->setHeaders(['Def', 'Name', 'Display name', 'Deploy ID', 'Protocol', 'Host', 'NC Url']); $rows = []; foreach ($daemonConfigs as $daemon) { - $rows[] = [$daemon->getName() === $defaultDaemonName ? '*' : '', $daemon->getName(), $daemon->getDisplayName(), $daemon->getAcceptsDeployId(), $daemon->getProtocol(), $daemon->getHost()]; + $rows[] = [ + $daemon->getName() === $defaultDaemonName ? '*' : '', + $daemon->getName(), $daemon->getDisplayName(), + $daemon->getAcceptsDeployId(), + $daemon->getProtocol(), + $daemon->getHost(), + $daemon->getDeployConfig()['nextcloud_url'] + ]; } $table->setRows($rows); diff --git a/lib/Service/DaemonConfigService.php b/lib/Service/DaemonConfigService.php index 3c3ffd76..30f15752 100644 --- a/lib/Service/DaemonConfigService.php +++ b/lib/Service/DaemonConfigService.php @@ -39,6 +39,7 @@ public function registerDaemonConfig(array $params): ?DaemonConfig { return null; } } + $params['deploy_config']['nextcloud_url'] = rtrim($params['deploy_config']['nextcloud_url'], '/'); try { $daemonConfig = $this->mapper->insert(new DaemonConfig([ 'name' => $params['name'], diff --git a/src/components/DaemonConfig/RegisterDaemonConfigModal.vue b/src/components/DaemonConfig/RegisterDaemonConfigModal.vue index 687df8f4..f11c77be 100644 --- a/src/components/DaemonConfig/RegisterDaemonConfigModal.vue +++ b/src/components/DaemonConfig/RegisterDaemonConfigModal.vue @@ -168,7 +168,8 @@ export default { protocol: 'unix-socket', protocols: ['unix-socket', 'http', 'https'], host: '/var/run/docker.sock', - nextcloud_url: window.location.origin + generateUrl(''), + // replace last slash with empty string + nextcloud_url: window.location.origin + generateUrl('').slice(0, -1), deployConfigSettingsOpened: false, deployConfig: { net: 'host', diff --git a/tests/test_occ_commands_docker.py b/tests/test_occ_commands_docker.py index b77429b9..62db2156 100644 --- a/tests/test_occ_commands_docker.py +++ b/tests/test_occ_commands_docker.py @@ -6,10 +6,19 @@ ) -def register_daemon(): +def register_daemon(nextcloud_url: str): run( "php occ app_api:daemon:register docker_local_sock " - "Docker docker-install unix-socket /var/run/docker.sock http://127.0.0.1:8080/index.php".split(), + f"Docker docker-install unix-socket /var/run/docker.sock {nextcloud_url}".split(), + stderr=DEVNULL, + stdout=DEVNULL, + check=True, + ) + + +def unregister_daemon(): + run( + "php occ app_api:daemon:unregister docker_local_sock".split(), stderr=DEVNULL, stdout=DEVNULL, check=True, @@ -32,7 +41,21 @@ def deploy_register(): if __name__ == "__main__": - register_daemon() + # nextcloud_url should be without slash at the end + register_daemon("http://127.0.0.1:8080/") + r = run("php occ app_api:daemon:list".split(), stdout=PIPE, stderr=PIPE, check=True) + assert not r.stderr.decode("UTF-8") + r_output = r.stdout.decode("UTF-8") + assert r_output.find("http://127.0.0.1:8080/") == -1 + assert r_output.find("http://127.0.0.1:8080") != -1 + unregister_daemon() + # nextcloud_url should be without slash at the end but with "index.php" + register_daemon("http://127.0.0.1:8080/index.php/") + r = run("php occ app_api:daemon:list".split(), stdout=PIPE, stderr=PIPE, check=True) + assert not r.stderr.decode("UTF-8") + r_output = r.stdout.decode("UTF-8") + assert r_output.find("http://127.0.0.1:8080/index.php/") == -1 + assert r_output.find("http://127.0.0.1:8080/index.php") != -1 # silent should not fail, as there are not such ExApp r = run("php occ app_api:app:unregister skeleton --silent".split(), stdout=PIPE, stderr=PIPE, check=True) assert not r.stderr.decode("UTF-8")