Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into appdata_location
Browse files Browse the repository at this point in the history
  • Loading branch information
summersab committed Feb 9, 2023
2 parents ad10170 + 674f4e8 commit e4e1ca8
Show file tree
Hide file tree
Showing 267 changed files with 1,037 additions and 867 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/phpunit-32bits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: PHPUnit

on:
workflow_dispatch:
schedule:
- cron: "15 1 * * 1-6"

permissions:
contents: read

concurrency:
group: phpunit-32bits-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
phpunit-32bits:
runs-on: ubuntu-latest
container: shivammathur/node:latest-i386

strategy:
matrix:
php-versions: ['8.0']

steps:
- name: Checkout server
uses: actions/checkout@v3
with:
submodules: true

- name: Install tools
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg imagemagick libmagickcore-6.q16-3-extra
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype, curl, dom, fileinfo, gd, imagick, intl, json, mbstring, openssl, pdo_sqlite, posix, sqlite, xml, zip, apcu
tools: phpunit:9
coverage: none
ini-values:
apc.enabled=on,
apc.enable_cli=on
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=autotest --database-pass=rootpassword --admin-user admin --admin-pass admin
php -f index.php
- name: PHPUnit
working-directory: tests
run: phpunit --configuration phpunit-autotest.xml --exclude-group PRIMARY-azure,PRIMARY-s3,PRIMARY-swift,Memcached,Redis,RoutingWeirdness
32 changes: 20 additions & 12 deletions .github/workflows/smb-kerberos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ on:
- stable*
paths:
- 'apps/files_external/**'
- '.github/workflows/smb-kerberos.yml'
pull_request:
paths:
- 'apps/files_external/**'
- '.github/workflows/smb-kerberos.yml'

jobs:
smb-kerberos-tests:
runs-on: ubuntu-latest

name: kerberos
name: smb-kerberos-sso

steps:
- name: Checkout server
Expand All @@ -28,9 +30,12 @@ jobs:
docker pull icewind1991/samba-krb-test-client
- name: Setup AD-DC
run: |
cp apps/files_external/tests/*.sh .
mkdir data
sudo chown -R 33 data apps config
apps/files_external/tests/setup-krb.sh
DC_IP=$(./start-dc.sh)
./start-apache.sh $DC_IP $PWD
echo "DC_IP=$DC_IP" >> $GITHUB_ENV
- name: Set up Nextcloud
run: |
docker exec --user 33 apache ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
Expand All @@ -39,7 +44,8 @@ jobs:
# setup user_saml
docker exec --user 33 apache ./occ app:enable user_saml --force
docker exec --user 33 apache ./occ config:app:set user_saml type --value 'environment-variable'
docker exec --user 33 apache ./occ config:app:set user_saml general-uid_mapping --value REMOTE_USER
docker exec --user 33 apache ./occ saml:config:create
docker exec --user 33 apache ./occ saml:config:set 1 --general-uid_mapping=REMOTE_USER
# setup external storage
docker exec --user 33 apache ./occ app:enable files_external --force
Expand All @@ -49,16 +55,18 @@ jobs:
docker exec --user 33 apache ./occ files_external:list
- name: Test SSO
run: |
mkdir cookies
chmod 0777 cookies
mkdir /tmp/shared/cookies
chmod 0777 /tmp/shared/cookies
DC_IP=$(docker inspect dc --format '{{.NetworkSettings.IPAddress}}')
echo "SAML login"
docker run --rm --name client -v $PWD/cookies:/cookies -v /tmp/shared:/shared --dns $DC_IP --hostname client.domain.test icewind1991/samba-krb-test-client \
curl -c /cookies/jar --negotiate -u testuser@DOMAIN.TEST: --delegation always http://httpd.domain.test/index.php/apps/user_saml/saml/login
./client-cmd.sh ${{ env.DC_IP }} curl -c /shared/cookies/jar -s --negotiate -u testuser@DOMAIN.TEST: --delegation always http://httpd.domain.test/index.php/apps/user_saml/saml/login
echo "Check we are logged in"
CONTENT=$(docker run --rm --name client -v $PWD/cookies:/cookies -v /tmp/shared:/shared --dns $DC_IP --hostname client.domain.test icewind1991/samba-krb-test-client \
curl -b /cookies/jar -s --negotiate -u testuser@DOMAIN.TEST: --delegation always http://httpd.domain.test/remote.php/webdav/smb/test.txt)
echo $CONTENT
CONTENT=$(echo $CONTENT | tr -d '[:space:]')
CONTENT=$(./client-cmd.sh ${{ env.DC_IP }} curl -b /shared/cookies/jar -s --negotiate -u testuser@DOMAIN.TEST: --delegation always http://httpd.domain.test/remote.php/webdav/smb/test.txt)
CONTENT=$(echo $CONTENT | head -n 1 | tr -d '[:space:]')
[[ $CONTENT == "testfile" ]]
- name: Show logs
if: failure()
run: |
docker exec --user 33 apache ./occ log:file
FILEPATH=$(docker exec --user 33 apache ./occ log:file | grep "Log file:" | cut -d' ' -f3)
docker exec --user 33 apache cat $FILEPATH
3 changes: 3 additions & 0 deletions apps/dav/l10n/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ OC.L10N.register(
"Where: %s" : "Kde: %s",
"%1$s via %2$s" : "%1$s prostřednictvím %2$s",
"Cancelled: %1$s" : "Zrušeno: %1$s",
"\"%1$s\" has been canceled" : "„%1$s“ bylo zrušeno",
"Re: %1$s" : "Odp.: %1$s",
"%1$s has responded your invitation" : "%1$s odpověděl(a) na vaši pozvánku",
"Invitation: %1$s" : "Pozvánka: %1$s",
"%1$s would like to invite you to \"%2$s\"" : "%1$s by vás ráda pozval(a) na „%2$s“",
"Organizer:" : "Organizátor:",
"Attendees:" : "Účastníci:",
"Title:" : "Název:",
Expand Down
3 changes: 3 additions & 0 deletions apps/dav/l10n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@
"Where: %s" : "Kde: %s",
"%1$s via %2$s" : "%1$s prostřednictvím %2$s",
"Cancelled: %1$s" : "Zrušeno: %1$s",
"\"%1$s\" has been canceled" : "„%1$s“ bylo zrušeno",
"Re: %1$s" : "Odp.: %1$s",
"%1$s has responded your invitation" : "%1$s odpověděl(a) na vaši pozvánku",
"Invitation: %1$s" : "Pozvánka: %1$s",
"%1$s would like to invite you to \"%2$s\"" : "%1$s by vás ráda pozval(a) na „%2$s“",
"Organizer:" : "Organizátor:",
"Attendees:" : "Účastníci:",
"Title:" : "Název:",
Expand Down
48 changes: 23 additions & 25 deletions apps/dav/lib/CalDAV/BirthdayService.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,33 +207,26 @@ public function buildDateFromContact(string $cardData,
} catch (InvalidDataException $e) {
return null;
}
if ($dateParts['year'] !== null) {
$parameters = $birthday->parameters();
$omitYear = (isset($parameters['X-APPLE-OMIT-YEAR'])
&& $parameters['X-APPLE-OMIT-YEAR'] === $dateParts['year']);
// 'X-APPLE-OMIT-YEAR' is not always present, at least iOS 12.4 uses the hard coded date of 1604 (the start of the gregorian calendar) when the year is unknown
if ($omitYear || (int)$dateParts['year'] === 1604) {
$dateParts['year'] = null;
}
}

$unknownYear = false;
$originalYear = null;
if (!$dateParts['year']) {
$birthday = '1970-' . $dateParts['month'] . '-' . $dateParts['date'];
if ($dateParts['year'] !== null) {
$originalYear = (int)$dateParts['year'];
}

$unknownYear = true;
} else {
$parameters = $birthday->parameters();
if (isset($parameters['X-APPLE-OMIT-YEAR'])) {
$omitYear = $parameters['X-APPLE-OMIT-YEAR'];
if ($dateParts['year'] === $omitYear) {
$birthday = '1970-' . $dateParts['month'] . '-' . $dateParts['date'];
$unknownYear = true;
}
} else {
$originalYear = (int)$dateParts['year'];
// 'X-APPLE-OMIT-YEAR' is not always present, at least iOS 12.4 uses the hard coded date of 1604 (the start of the gregorian calendar) when the year is unknown
if ($originalYear == 1604) {
$originalYear = null;
$unknownYear = true;
$birthday = '1970-' . $dateParts['month'] . '-' . $dateParts['date'];
}
if ($originalYear < 1970) {
$birthday = '1970-' . $dateParts['month'] . '-' . $dateParts['date'];
}
}
$leapDay = ((int)$dateParts['month'] === 2
&& (int)$dateParts['date'] === 29);
if ($dateParts['year'] === null || $originalYear < 1970) {
$birthday = ($leapDay ? '1972-' : '1970-')
. $dateParts['month'] . '-' . $dateParts['date'];
}

try {
Expand Down Expand Up @@ -268,10 +261,15 @@ public function buildDateFromContact(string $cardData,
$vEvent->DTEND['VALUE'] = 'DATE';
$vEvent->{'UID'} = $doc->UID . $postfix;
$vEvent->{'RRULE'} = 'FREQ=YEARLY';
if ($leapDay) {
/* Sabre\VObject supports BYMONTHDAY only if BYMONTH
* is also set */
$vEvent->{'RRULE'} = 'FREQ=YEARLY;BYMONTH=2;BYMONTHDAY=-1';
}
$vEvent->{'SUMMARY'} = $summary;
$vEvent->{'TRANSP'} = 'TRANSPARENT';
$vEvent->{'X-NEXTCLOUD-BC-FIELD-TYPE'} = $dateField;
$vEvent->{'X-NEXTCLOUD-BC-UNKNOWN-YEAR'} = $unknownYear ? '1' : '0';
$vEvent->{'X-NEXTCLOUD-BC-UNKNOWN-YEAR'} = $dateParts['year'] === null ? '1' : '0';
if ($originalYear !== null) {
$vEvent->{'X-NEXTCLOUD-BC-YEAR'} = (string) $originalYear;
}
Expand Down
26 changes: 12 additions & 14 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -120,7 +119,6 @@
* @package OCA\DAV\CalDAV
*/
class CalDavBackend extends AbstractBackend implements SyncSupport, SubscriptionSupport, SchedulingSupport {

use TTransactional;

public const CALENDAR_TYPE_CALENDAR = 0;
Expand Down Expand Up @@ -346,7 +344,7 @@ public function getCalendarsForUser($principalUri) {
$row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}

$calendar = [
Expand Down Expand Up @@ -420,7 +418,7 @@ public function getCalendarsForUser($principalUri) {
$row['displayname'] = $row['displayname'] . ' (' . ($this->userManager->getDisplayName($name) ?? ($name ?? '')) . ')';
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}
$calendar = [
'id' => $row['id'],
Expand Down Expand Up @@ -469,7 +467,7 @@ public function getUsersOwnCalendars($principalUri) {
$row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}
$calendar = [
'id' => $row['id'],
Expand Down Expand Up @@ -521,7 +519,7 @@ public function getPublicCalendars() {
$row['displayname'] = $row['displayname'] . "($name)";
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}
$calendar = [
'id' => $row['id'],
Expand Down Expand Up @@ -586,7 +584,7 @@ public function getPublicCalendar($uri) {
$row['displayname'] = $row['displayname'] . ' ' . "($name)";
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}
$calendar = [
'id' => $row['id'],
Expand Down Expand Up @@ -639,7 +637,7 @@ public function getCalendarByUri($principal, $uri) {
$row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}

$calendar = [
Expand Down Expand Up @@ -687,7 +685,7 @@ public function getCalendarById(int $calendarId): ?array {
$row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}

$calendar = [
Expand Down Expand Up @@ -779,7 +777,7 @@ public function createCalendar($principalUri, $calendarUri, array $properties) {
if (!($properties[$sccs] instanceof SupportedCalendarComponentSet)) {
throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
}
$values['components'] = implode(',',$properties[$sccs]->getValue());
$values['components'] = implode(',', $properties[$sccs]->getValue());
} elseif (isset($properties['components'])) {
// Allow to provide components internally without having
// to create a SupportedCalendarComponentSet object
Expand All @@ -797,7 +795,7 @@ public function createCalendar($principalUri, $calendarUri, array $properties) {
}
}

[$calendarId, $calendarData] = $this->atomic(function() use ($values) {
[$calendarId, $calendarData] = $this->atomic(function () use ($values) {
$query = $this->db->getQueryBuilder();
$query->insert('calendars');
foreach ($values as $column => $value) {
Expand Down Expand Up @@ -1712,7 +1710,7 @@ public function calendarSearch($principalUri, array $filters, $limit = null, $of
$query->expr()->eq('c.calendarid',
$query->createNamedParameter($id)),
$query->expr()->eq('c.calendartype',
$query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
$query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
}
foreach ($sharedCalendars as $id) {
$calendarExpressions[] = $query->expr()->andX(
Expand Down Expand Up @@ -1860,7 +1858,7 @@ public function search(array $calendarInfo, $pattern, array $searchProperties,
}
}

if(isset($options['uid'])) {
if (isset($options['uid'])) {
$outerQuery->andWhere($outerQuery->expr()->eq('uid', $outerQuery->createNamedParameter($options['uid'])));
}

Expand Down Expand Up @@ -2435,7 +2433,7 @@ public function createSubscription($principalUri, $uri, array $properties) {
}
}

[$subscriptionId, $subscriptionRow] = $this->atomic(function() use ($values) {
[$subscriptionId, $subscriptionRow] = $this->atomic(function () use ($values) {
$valuesToInsert = [];
$query = $this->db->getQueryBuilder();
foreach (array_keys($values) as $name) {
Expand Down
3 changes: 0 additions & 3 deletions apps/dav/lib/Connector/Sabre/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,11 @@ protected function validateUserPass($username, $password) {
if ($this->userSession->isLoggedIn() &&
$this->isDavAuthenticated($this->userSession->getUser()->getUID())
) {
\OC_Util::setupFS($this->userSession->getUser()->getUID());
$this->session->close();
return true;
} else {
\OC_Util::setupFS(); //login hooks may need early access to the filesystem
try {
if ($this->userSession->logClientIn($username, $password, $this->request, $this->throttler)) {
\OC_Util::setupFS($this->userSession->getUser()->getUID());
$this->session->set(self::DAV_AUTHENTICATED, $this->userSession->getUser()->getUID());
$this->session->close();
return true;
Expand Down
5 changes: 1 addition & 4 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function __construct(View $view, FileInfo $info, IManager $shareManager =
public function put($data) {
try {
$exists = $this->fileView->file_exists($this->path);
if ($this->info && $exists && !$this->info->isUpdateable()) {
if ($exists && !$this->info->isUpdateable()) {
throw new Forbidden();
}
} catch (StorageNotAvailableException $e) {
Expand Down Expand Up @@ -759,9 +759,6 @@ private function convertToSabreException(\Exception $e) {
* @return string|null
*/
public function getChecksum() {
if (!$this->info) {
return null;
}
return $this->info->getChecksum();
}

Expand Down
Loading

0 comments on commit e4e1ca8

Please sign in to comment.