Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/lint-eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ jobs:
PUPPETEER_SKIP_DOWNLOAD: true
run: npm ci

- name: Install dependencies
env:
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_DOWNLOAD: true
# Replace locally linked npm packages with the ones from the Nextcloud server repository
# in order to ensure linting works with the same versions as in the server repository.
# https://github.com/nextcloud/server/blob/stable30/package.json
run: npm install @mdi/js@^7.4.47 @nextcloud/vue@^8.26.1 [email protected]

- name: Lint
run: npm run lint

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-audit-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
branches: ['main', 'master', 'stable29', 'stable28', 'stable27']
branches: ['main', 'master', 'stable30', 'stable31']

name: npm-audit-fix-${{ matrix.branches }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
php-versions: ['8.3']
server-versions: ['master', 'stable29']
server-versions: ['stable30', 'stable31']

services:
mysql:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
php-versions: ['8.3']
server-versions: ['master', 'stable29']
server-versions: ['stable30', 'stable31']

services:
postgres:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
php-versions: ['8.3']
server-versions: ['master', 'stable29']
server-versions: ['stable30', 'stable31']

steps:
- name: Set app env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-nextcloud-ocp-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
branches: ['main']
target: ['stable29']
target: ['stable30', 'stable31']

name: update-nextcloud-ocp-${{ matrix.branches }}

Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<category>tools</category>
<bugs>https://github.com/IONOS-Productivity/nc-simple-settings</bugs>
<dependencies>
<nextcloud min-version="29" max-version="31"/>
<nextcloud min-version="30" max-version="31"/>
</dependencies>
<!--
- no navigations configured, we'll redirect from the /app/settings path
Expand Down
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* SPDX-FileLicenseText: 2024 Thomas Lehmann <[email protected]>
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"php": "^8.1"
},
"require-dev": {
"nextcloud/ocp": "dev-stable29",
"nextcloud/ocp": "v31.0.5",
"roave/security-advisories": "dev-latest"
},
"config": {
Expand Down
430 changes: 286 additions & 144 deletions composer.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* SPDX-FileLicenseText: 2024 Thomas Lehmann <[email protected]>
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
1 change: 1 addition & 0 deletions lib/Controller/AuthSettingsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
Expand Down
9 changes: 5 additions & 4 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* SPDX-FileLicenseText: 2024 Thomas Lehmann <[email protected]>
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down Expand Up @@ -54,7 +55,7 @@ class PageController extends Controller {
private IInitialState $initialState;
private IUserSession $userSession;
private ISession $session;
private string|null $uid;
private ?string $uid;
private $helper;

public function __construct(
Expand All @@ -66,7 +67,7 @@ public function __construct(
IInitialState $initialState,
IUserSession $userSession,
?string $UserId,
\OC_Helper $helper
\OC_Helper $helper,
) {
$this->config = $config;
$this->userManager = $userManager;
Expand Down Expand Up @@ -176,7 +177,7 @@ private function getLanguageMap(IUser $user): array {
foreach ($combinedLanguages as &$language) {
if (isset($language['name'])) {
$language['name'] = preg_replace('/\s*\(.*?\)\s*/', '', $language['name']);
}
}
}

$userLangIndex = array_search($userConfLang, array_column($combinedLanguages, 'code'));
Expand Down Expand Up @@ -217,7 +218,7 @@ public function getStorageInfo(
$path,
$rootInfo = null,
$includeMountPoints = true,
$useCache = true
$useCache = true,
): array {
return $this->helper::getStorageInfo($path, $rootInfo, $includeMountPoints, $useCache);
}
Expand Down
4 changes: 3 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<psalm
phpVersion="8.0"
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All @@ -9,6 +8,9 @@
findUnusedBaselineEntry="true"
findUnusedCode="true"
>
<stubs>
<file name="tests/stub.phpstub" preloadClasses="true"/>
</stubs>
<projectFiles>
<directory name="lib" />
<ignoreFiles>
Expand Down
3 changes: 2 additions & 1 deletion tests/Controller/AuthSettingsControllerTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
Expand Down Expand Up @@ -60,7 +61,7 @@ class AuthSettingsControllerTest extends TestCase {
private $tokenProvider;
/** @var ISession|MockObject */
private $session;
/**@var IUserSession|MockObject */
/** @var IUserSession|MockObject */
private $userSession;
/** @var ISecureRandom|MockObject */
private $secureRandom;
Expand Down
67 changes: 34 additions & 33 deletions tests/Controller/PageControllerTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* SPDX-FileLicenseText: 2024 Thomas Lehmann <[email protected]>
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down Expand Up @@ -49,7 +50,7 @@ protected function setUp(): void {
$this->session = $this->createMock(ISession::class);
$this->initialState = $this->createMock(IInitialState::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->uid = "mock-user-id-123";
$this->uid = 'mock-user-id-123';
$this->helper = $this->createMock(\OC_Helper::class);
$this->controller = $this->getMockBuilder(PageController::class)
->setConstructorArgs([
Expand All @@ -66,7 +67,7 @@ protected function setUp(): void {
->onlyMethods(['getStorageInfo', 'humanFileSize'])
->getMock();

$mockCurrentSessionId = "mock-session-id-123";
$mockCurrentSessionId = 'mock-session-id-123';

$mockCurrentSessionTokenId = 1;
$mockOtherSessionTokenIdNotWiped = 2;
Expand All @@ -76,11 +77,11 @@ protected function setUp(): void {
$mockCurrentSessionTokenId,
[
// true to detect change to false
"canDelete" => true,
"canRename" => true,
"type" => IToken::TEMPORARY_TOKEN,
'canDelete' => true,
'canRename' => true,
'type' => IToken::TEMPORARY_TOKEN,
// false to detect change to true
"current" => false,
'current' => false,
]
);

Expand Down Expand Up @@ -111,24 +112,24 @@ protected function setUp(): void {
$this->createMockAppToken(
$mockOtherSessionTokenIdNotWiped,
[
"canDelete" => false,
'canDelete' => false,
// Wiped sessions can not be renamed; expect true, make false to detect change
"canRename" => false,
"type" => IToken::TEMPORARY_TOKEN,
'canRename' => false,
'type' => IToken::TEMPORARY_TOKEN,
// Would not change, expect false too
"current" => false,
'current' => false,
]
),
$this->createMockAppToken(
$mockOtherSessionTokenIdWiped,
[
// Other sessions can be deleted; expect true, make false to detect change
"canDelete" => false,
'canDelete' => false,
// Wiped sessions can not be renamed; expect false, make true to detect change
"canRename" => true,
"type" => IToken::WIPE_TOKEN,
'canRename' => true,
'type' => IToken::WIPE_TOKEN,
// Would not change, expect true too
"current" => true,
'current' => true,
]
),
];
Expand Down Expand Up @@ -233,29 +234,29 @@ private function createMockAppToken(int $id, array $serializedJson = []): IToken
public function testIndexProvidesInitialStateWithAppTokens() {
$expectedAppTokensRegisteredAsInitialState = [
[
"canDelete" => false,
"canRename" => false,
"type" => IToken::TEMPORARY_TOKEN,
"current" => true,
'canDelete' => false,
'canRename' => false,
'type' => IToken::TEMPORARY_TOKEN,
'current' => true,
],
[
"canDelete" => true,
"canRename" => true,
"type" => IToken::TEMPORARY_TOKEN,
"current" => false,
'canDelete' => true,
'canRename' => true,
'type' => IToken::TEMPORARY_TOKEN,
'current' => false,
],
[
"canDelete" => true,
"canRename" => false,
"type" => IToken::WIPE_TOKEN,
"current" => true,
'canDelete' => true,
'canRename' => false,
'type' => IToken::WIPE_TOKEN,
'current' => true,
],
];

$this->initialState->expects($this->exactly(4))
->method('provideInitialState')
->willReturnCallback(function ($stateName, $stateValue) use ($expectedAppTokensRegisteredAsInitialState) {
if ($stateName == "app_tokens") {
if ($stateName == 'app_tokens') {
$this->assertEquals($expectedAppTokensRegisteredAsInitialState, $stateValue);
}
});
Expand All @@ -271,12 +272,12 @@ public function testIndexProvidesInitialStateWithCanCreateAppTokensFalse() {

$this->userSession->expects($this->exactly(1))
->method('getImpersonatingUserID')
->willReturn("some-user-id-is-not-null");
->willReturn('some-user-id-is-not-null');

$this->initialState->expects($this->exactly(4))
->method('provideInitialState')
->willReturnCallback(function ($stateName, $stateValue) {
if ($stateName == "can_create_app_token") {
if ($stateName == 'can_create_app_token') {
$this->assertEquals(false, $stateValue);
}
});
Expand All @@ -295,7 +296,7 @@ public function testIndexProvidesInitialStateWithCanCreateAppTokensTrue() {
$this->initialState->expects($this->exactly(4))
->method('provideInitialState')
->willReturnCallback(function ($stateName, $stateValue) {
if ($stateName == "can_create_app_token") {
if ($stateName == 'can_create_app_token') {
$this->assertEquals(true, $stateValue);
}
});
Expand All @@ -309,7 +310,7 @@ private function configureInitialStateLanguageMock($expectedActiveLanguage) {
$this->initialState->expects($this->exactly(4))
->method('provideInitialState')
->willReturnCallback(function ($stateName, $stateValue) use ($expectedActiveLanguage, $mockAvailableLanguages) {
if ($stateName == "personalInfoParameters") {
if ($stateName == 'personalInfoParameters') {
$this->assertEquals([
'languageMap' => [
'activeLanguage' => $expectedActiveLanguage,
Expand All @@ -336,7 +337,7 @@ public function testIndexProvidesInitialStateWithLanguagesLanguageForced() {
$this->initialState->expects($this->exactly(4))
->method('provideInitialState')
->willReturnCallback(function ($stateName, $stateValue) {
if ($stateName == "personalInfoParameters") {
if ($stateName == 'personalInfoParameters') {
$this->assertEquals([
'languageMap' => [],
'totalSpace' => 'mocked-human-file-size',
Expand Down Expand Up @@ -382,7 +383,7 @@ public function testIndexProvidesInitialStateWithCustomClientURLs() {
$this->initialState->expects($this->exactly(4))
->method('provideInitialState')
->willReturnCallback(function ($stateName, $stateValue) use ($expectedCustomClientsURLs) {
if ($stateName == "customClientURL") {
if ($stateName == 'customClientURL') {
$this->assertEquals($expectedCustomClientsURLs, $stateValue);
}
});
Expand Down
54 changes: 54 additions & 0 deletions tests/stub.phpstub
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

/**
* Collection of useful functions
*
* @psalm-type StorageInfo = array{
* free: float|int,
* mountPoint: string,
* mountType: string,
* owner: string,
* ownerDisplayName: string,
* quota: float|int,
* relative: float|int,
* total: float|int,
* used: float|int,
* }
*/
/**
* Methods copy of the OC_Helper class from the core.
* https://github.com/nextcloud/server/blob/stable30/lib/private/legacy/OC_Helper.php
*/
class OC_Helper {
/**
* Calculate the disc space for the given path
*
* BEWARE: this requires that Util::setupFS() was called
* already !
*
* @param string $path
* @param \OCP\Files\FileInfo $rootInfo (optional)
* @param bool $includeMountPoints whether to include mount points in the size calculation
* @param bool $useCache whether to use the cached quota values
* @psalm-suppress LessSpecificReturnStatement Legacy code outputs weird types - manually validated that they are correct
* @return StorageInfo
* @throws \OCP\Files\NotFoundException
*/
public static function getStorageInfo($path, $rootInfo = null, $includeMountPoints = true, $useCache = true) {
}
/**
* Make a human file size
* @param int|float $bytes file size in bytes
* @return string a human readable file size
*
* Makes 2048 to 2 kB.
*/
public static function humanFileSize(int|float $bytes): string {
}
}
Loading
Loading