-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure plugin updates are not offered in UI if plugin admin is disabl…
…ed in config (#22538)
- Loading branch information
Showing
18 changed files
with
180 additions
and
87 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
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
43 changes: 43 additions & 0 deletions
43
plugins/CorePluginsAdmin/tests/Fixtures/PluginUpdatesFixture.php
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,43 @@ | ||
<?php | ||
|
||
/** | ||
* Matomo - free/libre analytics platform | ||
* | ||
* @link https://matomo.org | ||
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
*/ | ||
|
||
namespace Piwik\Plugins\CorePluginsAdmin\tests\Fixtures; | ||
|
||
use Piwik\Tests\Framework\Fixture; | ||
|
||
/** | ||
* Fixture that fakes plugin updates to be available | ||
*/ | ||
class PluginUpdatesFixture extends Fixture | ||
{ | ||
public $idSite = 1; | ||
public function setUp(): void | ||
{ | ||
Fixture::createSuperUser(); | ||
$this->setUpWebsites(); | ||
} | ||
|
||
private function setUpWebsites() | ||
{ | ||
if (!self::siteCreated($idSite = 1)) { | ||
self::createWebsite('2024-01-01'); | ||
} | ||
} | ||
|
||
public function provideContainerConfig() | ||
{ | ||
$updates = <<<JSON | ||
{"DeviceDetectorCache":{"name":"DeviceDetectorCache","displayName":"Device Detector Cache","owner":"matomo-org","description":"Makes tracking faster by detecting many devices, operating systems, bots, and browsers from a cache.","homepage":"https:\/\/matomo.org","createdDateTime":"2019-10-23 20:14:04","donate":[],"support":[{"name":"Issues \/ Bugs","key":"issues","value":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache\/issues","type":"url"}],"isTheme":false,"keywords":["performance","tracking","device","detector"],"basePrice":0,"authors":[{"name":"Matomo","email":"[email protected]","homepage":"https:\/\/matomo.org"}],"repositoryUrl":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache","lastUpdated":"2024-04-22 05:58:02","latestVersion":"5.0.3","numDownloads":22896,"screenshots":[],"coverImage":"https:\/\/plugins.matomo.org\/img\/categories\/database.png","previews":[],"activity":{"numCommits":"148","numContributors":"20","lastCommitDate":"2024-08-15 06:18:49"},"featured":false,"isFree":true,"isPaid":false,"isBundle":false,"isCustomPlugin":false,"shop":null,"bundle":{"plugins":[]},"specialOffer":"","category":"database","versions":[{"name":"5.0.0","release":"2023-05-05 00:28:03","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":67,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/DeviceDetectorCache\/5.0.0\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache\/commits\/5.0.0-b1","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/DeviceDetectorCache\/download\/5.0.0"},{"name":"5.0.1","release":"2023-10-03 04:32:03","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":96,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/DeviceDetectorCache\/5.0.1\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache\/commits\/5.0.1","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/DeviceDetectorCache\/download\/5.0.1"},{"name":"5.0.2","release":"2023-11-21 00:40:03","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":2058,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/DeviceDetectorCache\/5.0.2\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache\/commits\/5.0.2","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/DeviceDetectorCache\/download\/5.0.2"},{"name":"5.0.3","release":"2024-04-22 05:58:02","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":2403,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/DeviceDetectorCache\/5.0.3\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache\/commits\/5.0.3","readmeHtml":{"description":"Dummy Plugin Description"},"download":"\/api\/2.0\/plugins\/DeviceDetectorCache\/download\/5.0.3"}],"isDownloadable":true,"changelog":{"url":"https:\/\/plugins.matomo.org\/DeviceDetectorCache\/changelog?matomoversion=5"},"consumer":{"license":null},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-DeviceDetectorCache\/compare\/5.0.2...5.0.3","currentVersion":"5.0.2","isActivated":false,"missingRequirements":[]},"QueuedTracking":{"name":"QueuedTracking","displayName":"Queued Tracking","owner":"matomo-org","description":"Scale your large traffic Matomo service by queuing tracking requests in Redis or MySQL for better performance and reliability when experiencing peaks.","homepage":"https:\/\/matomo.org","createdDateTime":"2015-01-05 23:28:04","donate":[],"support":[{"name":"Wiki","key":"wiki","value":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/wiki","type":"url"},{"name":"Forum","key":"forum","value":"https:\/\/forum.matomo.org","type":"url"},{"name":"Email","key":"email","value":"[email protected]","type":"email"},{"name":"Issues \/ Bugs","key":"issues","value":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/issues","type":"url"},{"name":"Source","key":"source","value":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking","type":"url"}],"isTheme":false,"keywords":["tracker","tracking","queue","redis"],"basePrice":0,"authors":[{"name":"Matomo","email":"[email protected]","homepage":"https:\/\/matomo.org"}],"repositoryUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking","lastUpdated":"2024-08-26 04:30:04","latestVersion":"5.0.7","numDownloads":603565,"screenshots":["https:\/\/plugins.matomo.org\/QueuedTracking\/images\/5.0.7\/Settings.png"],"coverImage":"https:\/\/plugins.matomo.org\/img\/categories\/development.png","previews":[],"activity":{"numCommits":"362","numContributors":"38","lastCommitDate":"2024-08-26 04:29:16"},"featured":false,"isFree":true,"isPaid":false,"isBundle":false,"isCustomPlugin":false,"shop":null,"bundle":{"plugins":[]},"specialOffer":"","category":"development","versions":[{"name":"5.0.0","release":"2023-05-05 05:36:06","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":2237,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.0\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.0-b1","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.0"},{"name":"5.0.1","release":"2023-08-08 22:40:03","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":0,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.1\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.0-b2","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.1"},{"name":"5.0.2","release":"2023-08-09 02:24:03","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":107207,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.2\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.0-b2","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.2"},{"name":"5.0.3","release":"2024-03-11 04:08:03","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":2329,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.3\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.3","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.3"},{"name":"5.0.4","release":"2024-04-22 07:14:04","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":3560,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.4\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.4","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.4"},{"name":"5.0.5","release":"2024-06-27 06:50:49","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":1305,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.5\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.5","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.5"},{"name":"5.0.6","release":"2024-07-31 02:46:04","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":1447,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.6\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.6","readmeHtml":{"description":"","faq":"","changelog":"","documentation":""},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.6"},{"name":"5.0.7","release":"2024-08-26 04:30:04","requires":{"matomo":">=5.0.0-b1,<6.0.0-b1"},"wordPressCompatible":true,"onPremiseCompatible":true,"numDownloads":227,"license":{"name":"GPL v3+","url":"https:\/\/plugins.matomo.org\/QueuedTracking\/5.0.7\/license"},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/commits\/5.0.7","readmeHtml":{"description":"Dummy README content"},"download":"\/api\/2.0\/plugins\/QueuedTracking\/download\/5.0.7"}],"isDownloadable":true,"changelog":{"url":"https:\/\/plugins.matomo.org\/QueuedTracking\/changelog?matomoversion=5"},"consumer":{"license":null},"repositoryChangelogUrl":"https:\/\/github.com\/matomo-org\/plugin-QueuedTracking\/compare\/5.0.6...5.0.7","currentVersion":"5.0.6","isActivated":false,"missingRequirements":[{"requirement":"php","actualVersion":"7.2.24","requiredVersion":">=7.3.0","causedBy":">=7.3.0"}]}} | ||
JSON; | ||
|
||
return [ | ||
'dev.forced_plugin_update_result' => json_decode($updates, true) | ||
]; | ||
} | ||
} |
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,56 @@ | ||
/*! | ||
* Matomo - free/libre analytics platform | ||
* | ||
* Screenshot integration tests. | ||
* | ||
* @link https://matomo.org | ||
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
*/ | ||
|
||
describe("PluginsAdmin", function () { | ||
|
||
this.fixture = "Piwik\\Plugins\\CorePluginsAdmin\\tests\\Fixtures\\PluginUpdatesFixture" | ||
|
||
var generalParams = 'idSite=1&period=year&date=2024-08-09'; | ||
|
||
async function screenshotPageWrap() { | ||
const pageWrap = await page.$('.pageWrap'); | ||
const screenshot = await pageWrap.screenshot(); | ||
return screenshot; | ||
} | ||
|
||
it('should load the themes admin page correctly', async function () { | ||
await page.goto("?" + generalParams + "&module=CorePluginsAdmin&action=themes"); | ||
|
||
expect(await screenshotPageWrap()).to.matchImage('themes'); | ||
}); | ||
|
||
it('should load the plugins admin page correctly', async function () { | ||
await page.goto("?" + generalParams + "&module=CorePluginsAdmin&action=plugins"); | ||
|
||
expect(await screenshotPageWrap()).to.matchImage('plugins'); | ||
}); | ||
|
||
it('should load the plugins admin page correctly when internet disabled', async function () { | ||
testEnvironment.overrideConfig('General', { | ||
enable_internet_features: 0 | ||
}); | ||
testEnvironment.save(); | ||
|
||
await page.goto("?" + generalParams + "&module=CorePluginsAdmin&action=plugins"); | ||
|
||
expect(await screenshotPageWrap()).to.matchImage('plugins_no_internet'); | ||
}); | ||
|
||
it('should load the plugins admin page correctly when admin disabled', async function () { | ||
testEnvironment.overrideConfig('General', { | ||
enable_plugins_admin: 0 | ||
}); | ||
testEnvironment.save(); | ||
|
||
await page.goto("?" + generalParams + "&module=CorePluginsAdmin&action=plugins"); | ||
|
||
expect(await screenshotPageWrap()).to.matchImage('plugins_admin_disabled'); | ||
}); | ||
|
||
}); |
3 changes: 3 additions & 0 deletions
3
plugins/CorePluginsAdmin/tests/UI/expected-screenshots/PluginsAdmin_plugins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ginsAdmin/tests/UI/expected-screenshots/PluginsAdmin_plugins_admin_disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...PluginsAdmin/tests/UI/expected-screenshots/PluginsAdmin_plugins_no_internet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
plugins/CorePluginsAdmin/tests/UI/expected-screenshots/PluginsAdmin_themes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.