summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-10-09 21:17:40 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2020-10-09 22:15:03 +0200
commit8a203a329c1bfae84e7204bd0fda452c6ad11903 (patch)
tree2c811f4355c43b9dcef7868e4dcbeb1ac971127f
parent39f539f97589eff6789e1edcafb82685b48188ff (diff)
Fix minor issues, prepare for foreign keys and check feeds
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
-rw-r--r--.github/workflows/integration-tests.yml37
-rw-r--r--Makefile4
-rwxr-xr-xbin/tools/check_feeds.sh14
-rw-r--r--composer.lock12
-rw-r--r--lib/Migration/MigrateConfig.php14
-rw-r--r--lib/Migration/Version150004Date20201009183830.php74
6 files changed, 138 insertions, 17 deletions
diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml
index 171c6d43b..bdd35cca9 100644
--- a/.github/workflows/integration-tests.yml
+++ b/.github/workflows/integration-tests.yml
@@ -96,23 +96,44 @@ jobs:
app: 'news'
check-code: true
- - name: Functional tests
+ - name: Functional tests maintenance
+ working-directory: ../server
run: |
- cd ../server
./occ migrations:migrate news
./occ maintenance:repair
- ./occ news:generate-explore --votes 100 "https://nextcloud.com/blog/feed/"
+
+ - name: Functional tests explore
+ working-directory: ../server
+ run: ./occ news:generate-explore --votes 100 "https://nextcloud.com/blog/feed/"
+
+ - name: Functional tests folder
+ working-directory: ../server
+ run: |
./occ news:folder:add 'admin' 'Something'
./occ news:folder:list 'admin' | grep 'Something'
+
+ - name: Functional tests feed
+ working-directory: ../server
+ run: |
./occ news:feed:add 'admin' "https://nextcloud.com/blog/feed/"
./occ news:feed:list 'admin' | grep 'nextcloud\.com'
- ./occ news:opml:export 'admin' | grep 'nextcloud\.com'
+
+ - name: Functional tests opml
+ working-directory: ../server
+ run: ./occ news:opml:export 'admin' | grep 'nextcloud\.com'
+
+ - name: Functional tests cleanup
+ working-directory: ../server
+ run: |
./occ news:folder:delete 'admin' $(./occ news:folder:list 'admin' | grep 'Something' -1 | head -1 | grep -oE '[0-9]*')
./occ news:feed:delete 'admin' $(./occ news:feed:list 'admin' | grep 'nextcloud\.com' -1 | head -1 | grep -oE '[0-9]*')
- name: Prep PHP tests
- run: cd ../server/apps/news && make php-test-dependencies
+ working-directory: ../server/apps/news
+ run: make php-test-dependencies
- name: Integration tests
- run: cd ../server/apps/news && make integration-test
-
-
+ working-directory: ../server/apps/news
+ run: make integration-test
+ - name: Feed tests
+ working-directory: ../server/apps/news
+ run: make feed-test \ No newline at end of file
diff --git a/Makefile b/Makefile
index c6194206e..e1bda0fde 100644
--- a/Makefile
+++ b/Makefile
@@ -214,3 +214,7 @@ test: php-test-dependencies
$(MAKE) phpstan
$(MAKE) js-test
./bin/tools/generate_authors.php
+
+.PHONY: feed-test
+feed-test:
+ ./bin/tools/check_feeds.sh \ No newline at end of file
diff --git a/bin/tools/check_feeds.sh b/bin/tools/check_feeds.sh
new file mode 100755
index 000000000..8d5e41a55
--- /dev/null
+++ b/bin/tools/check_feeds.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+feeds=$(cat ./lib/Explore/feeds/feeds.en.json | jq -r .[][0].feed)
+
+for feed in ${feeds} ; do
+ if [[ $feed == "http://"* ]]; then
+ echo "Insecure feed $feed"
+ exit 1;
+ fi
+ if ! curl --fail --silent "$feed" > /dev/null; then
+ echo "Failed to fetch $feed"
+ exit 1;
+ fi
+done \ No newline at end of file
diff --git a/composer.lock b/composer.lock
index c1592f761..5789cb80c 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1968,16 +1968,16 @@
},
{
"name": "sebastian/type",
- "version": "2.2.2",
+ "version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
- "reference": "e494dcaeb89d1458c9ccd8c819745245a1669aea"
+ "reference": "fa592377f3923946cb90bf1f6a71ba2e5f229909"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/e494dcaeb89d1458c9ccd8c819745245a1669aea",
- "reference": "e494dcaeb89d1458c9ccd8c819745245a1669aea",
+ "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fa592377f3923946cb90bf1f6a71ba2e5f229909",
+ "reference": "fa592377f3923946cb90bf1f6a71ba2e5f229909",
"shasum": ""
},
"require": {
@@ -1989,7 +1989,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.2-dev"
+ "dev-master": "2.3-dev"
}
},
"autoload": {
@@ -2016,7 +2016,7 @@
"type": "github"
}
],
- "time": "2020-09-28T06:01:38+00:00"
+ "time": "2020-10-06T08:41:03+00:00"
},
{
"name": "sebastian/version",
diff --git a/lib/Migration/MigrateConfig.php b/lib/Migration/MigrateConfig.php
index 50d335892..9f3b32291 100644
--- a/lib/Migration/MigrateConfig.php
+++ b/lib/Migration/MigrateConfig.php
@@ -31,6 +31,13 @@ class MigrateConfig implements IRepairStep
private $iConfig;
/**
+ * Array of defaults
+ *
+ * @var array
+ */
+ private $defaults;
+
+ /**
* @param LegacyConfig $config
* @param IConfig $iConfig
* @param Application $application To make sure the class is found below
@@ -39,6 +46,7 @@ class MigrateConfig implements IRepairStep
{
$this->config = $config;
$this->iConfig = $iConfig;
+ $this->defaults = $application::DEFAULT_SETTINGS;
}
public function getName()
@@ -53,15 +61,15 @@ class MigrateConfig implements IRepairStep
return;
}
- $app_keys = $this->iConfig->getAppKeys(Application::NAME);
+ $app_keys = $this->iConfig->getAppKeys('news');
foreach ($this->config as $key => $value) {
- if (!isset(Application::DEFAULT_SETTINGS[$key])) {
+ if (!isset($this->defaults[$key])) {
continue;
}
if (in_array($key, $app_keys)) {
continue;
}
- $this->iConfig->setAppValue(Application::NAME, $key, $value);
+ $this->iConfig->setAppValue('news', $key, $value);
}
}
}
diff --git a/lib/Migration/Version150004Date20201009183830.php b/lib/Migration/Version150004Date20201009183830.php
new file mode 100644
index 000000000..c6267ac04
--- /dev/null
+++ b/lib/Migration/Version150004Date20201009183830.php
@@ -0,0 +1,74 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OCA\News\Migration;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\IDBConnection;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+/**
+ * Auto-generated migration step: Please modify to your needs!
+ */
+class Version150004Date20201009183830 extends SimpleMigrationStep {
+
+ protected $connection;
+
+ public function __construct(IDBConnection $connection)
+ {
+ $this->connection = $connection;
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ */
+ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ if ($schema->hasTable('news_items') &&
+ $schema->getTable('news_items')->hasColumn('feed_id')) {
+ $schema->getTable('news_items')
+ ->getColumn('feed_id')
+ ->setNotnull(true)
+ ->setUnsigned(true);
+ }
+ if ($schema->hasTable('news_feeds') &&
+ $schema->getTable('news_feeds')->hasColumn('folder_id')) {
+ $schema->getTable('news_feeds')
+ ->getColumn('folder_id')
+ ->setUnsigned(true)
+ ->setNotnull(false)
+ ->setDefault(null);
+ }
+
+ return $schema;
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ */
+ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
+ $item_name = $this->connection->getQueryBuilder()->getTableName('news_items');
+ $feed_name = $this->connection->getQueryBuilder()->getTableName('news_feeds');
+
+ $items_query = "DELETE FROM ${item_name} WHERE ${item_name}.`feed_id` NOT IN (SELECT DISTINCT id FROM ${feed_name})";
+ $this->connection->executeQuery($items_query);
+ }
+}