diff options
Diffstat (limited to 'core/js')
28 files changed, 439 insertions, 3532 deletions
diff --git a/core/js/backgroundjobs.js b/core/js/backgroundjobs.js deleted file mode 100644 index f5061357f5c..00000000000 --- a/core/js/backgroundjobs.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* ownCloud -* -* @author Jakob Sack -* @copyright 2012 Jakob Sack owncloud@jakobsack.de -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ - -// start worker once page has loaded -window.addEventListener('DOMContentLoaded', function(){ - $.get( OC.getRootPath()+'/cron.php' ); - - $('.section .icon-info').tooltip({ - placement: 'right' - }); -}); diff --git a/core/js/core.json b/core/js/core.json index 40bb35dde9f..457656fdd08 100644 --- a/core/js/core.json +++ b/core/js/core.json @@ -3,7 +3,6 @@ "core-common.js" ], "modules": [ - "../core/js/public/publicpage.js", "../core/js/setupchecks.js", "../core/js/mimetype.js", "../core/js/mimetypelist.js" diff --git a/core/js/login/authpicker.js b/core/js/login/authpicker.js index 8aaaf3d7361..10b5d716d6a 100644 --- a/core/js/login/authpicker.js +++ b/core/js/login/authpicker.js @@ -1,3 +1,7 @@ +/** + * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ jQuery(document).ready(function() { $('#app-token-login').click(function (e) { e.preventDefault(); @@ -10,4 +14,6 @@ jQuery(document).ready(function() { e.preventDefault(); document.location.href = e.target.attributes.action.value }) + + $('#login-form input').removeAttr('disabled'); }) diff --git a/core/js/login/grant.js b/core/js/login/grant.js index c458bbbab84..c6134504421 100644 --- a/core/js/login/grant.js +++ b/core/js/login/grant.js @@ -1,9 +1,30 @@ -document.querySelector('form').addEventListener('submit', function(e) { +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +const form = document.querySelector('form') +form.addEventListener('submit', function(event) { const wrapper = document.getElementById('submit-wrapper') if (wrapper === null) { return } - wrapper.getElementsByClassName('icon-confirm-white').forEach(function(el) { + + if (OC.PasswordConfirmation.requiresPasswordConfirmation()) { + // stop the event + event.preventDefault() + event.stopPropagation() + + // handle password confirmation + OC.PasswordConfirmation.requirePasswordConfirmation(function () { + // when password is confirmed we submit the form + form.submit() + }) + + return false + } + + Array.from(wrapper.getElementsByClassName('icon-confirm-white')).forEach(function(el) { el.classList.remove('icon-confirm-white') el.classList.add(OCA.Theming && OCA.Theming.inverted ? 'icon-loading-small' : 'icon-loading-small-dark') el.disabled = true diff --git a/core/js/mimetype.js b/core/js/mimetype.js index 7f206548177..058d90ba509 100644 --- a/core/js/mimetype.js +++ b/core/js/mimetype.js @@ -1,21 +1,7 @@ /** - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2015 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ /** @@ -42,21 +28,21 @@ OC.MimeType = { var icon = mimeType.replace(new RegExp('/', 'g'), '-'); // Generate path - if (mimeType === 'dir' && $.inArray('folder', files) !== -1) { + if (mimeType === 'dir' && files.includes('folder')) { return 'folder'; - } else if (mimeType === 'dir-encrypted' && $.inArray('folder-encrypted', files) !== -1) { + } else if (mimeType === 'dir-encrypted' && files.includes('folder-encrypted')) { return 'folder-encrypted'; - } else if (mimeType === 'dir-shared' && $.inArray('folder-shared', files) !== -1) { + } else if (mimeType === 'dir-shared' && files.includes('folder-shared')) { return 'folder-shared'; - } else if (mimeType === 'dir-public' && $.inArray('folder-public', files) !== -1) { + } else if (mimeType === 'dir-public' && files.includes('folder-public')) { return 'folder-public'; - } else if ((mimeType === 'dir-external' || mimeType === 'dir-external-root') && $.inArray('folder-external', files) !== -1) { + } else if ((mimeType === 'dir-external' || mimeType === 'dir-external-root') && files.includes('folder-external')) { return 'folder-external'; - } else if ($.inArray(icon, files) !== -1) { + } else if (files.includes(icon)) { return icon; - } else if ($.inArray(icon.split('-')[0], files) !== -1) { + } else if (files.includes(icon.split('-')[0])) { return icon.split('-')[0]; - } else if ($.inArray('file', files) !== -1) { + } else if (files.includes('file')) { return 'file'; } @@ -70,13 +56,14 @@ OC.MimeType = { * @return {string} Url to the icon for mimeType */ getIconUrl: function(mimeType) { - if (_.isUndefined(mimeType)) { + if (typeof mimeType === 'undefined') { return undefined; } while (mimeType in OC.MimeTypeList.aliases) { mimeType = OC.MimeTypeList.aliases[mimeType]; } + if (mimeType in OC.MimeType._mimeTypeIcons) { return OC.MimeType._mimeTypeIcons[mimeType]; } @@ -84,7 +71,7 @@ OC.MimeType = { // First try to get the correct icon from the current theme var gotIcon = null; var path = ''; - if (OC.theme.folder !== '' && $.isArray(OC.MimeTypeList.themes[OC.theme.folder])) { + if (OC.theme.folder !== '' && Array.isArray(OC.MimeTypeList.themes[OC.theme.folder])) { path = OC.getRootPath() + '/themes/' + OC.theme.folder + '/core/img/filetypes/'; var icon = OC.MimeType._getFile(mimeType, OC.MimeTypeList.themes[OC.theme.folder]); diff --git a/core/js/mimetypelist.js b/core/js/mimetypelist.js index d861695c0ac..eb937c440cc 100644 --- a/core/js/mimetypelist.js +++ b/core/js/mimetypelist.js @@ -10,12 +10,15 @@ OC.MimeTypeList={ aliases: { "application/coreldraw": "image", "application/epub+zip": "text", - "application/font-sfnt": "image", - "application/font-woff": "image", + "application/font-sfnt": "font", + "application/font-woff": "font", "application/gpx+xml": "location", + "application/gzip": "package/x-generic", "application/illustrator": "image", + "application/internet-shortcut": "link", "application/javascript": "text/code", "application/json": "text/code", + "application/km": "mindmap", "application/msaccess": "file", "application/msexcel": "x-office/spreadsheet", "application/msonenote": "x-office/document", @@ -25,21 +28,22 @@ OC.MimeTypeList={ "application/postscript": "image", "application/rss+xml": "application/xml", "application/vnd.android.package-archive": "package/x-generic", - "application/vnd.lotus-wordpro": "x-office/document", + "application/vnd.excalidraw+json": "whiteboard", "application/vnd.garmin.tcx+xml": "location", "application/vnd.google-earth.kml+xml": "location", "application/vnd.google-earth.kmz": "location", - "application/vnd.ms-excel": "x-office/spreadsheet", + "application/vnd.lotus-wordpro": "x-office/document", "application/vnd.ms-excel.addin.macroEnabled.12": "x-office/spreadsheet", "application/vnd.ms-excel.sheet.binary.macroEnabled.12": "x-office/spreadsheet", "application/vnd.ms-excel.sheet.macroEnabled.12": "x-office/spreadsheet", "application/vnd.ms-excel.template.macroEnabled.12": "x-office/spreadsheet", - "application/vnd.ms-fontobject": "image", - "application/vnd.ms-powerpoint": "x-office/presentation", + "application/vnd.ms-excel": "x-office/spreadsheet", + "application/vnd.ms-fontobject": "font", "application/vnd.ms-powerpoint.addin.macroEnabled.12": "x-office/presentation", "application/vnd.ms-powerpoint.presentation.macroEnabled.12": "x-office/presentation", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12": "x-office/presentation", "application/vnd.ms-powerpoint.template.macroEnabled.12": "x-office/presentation", + "application/vnd.ms-powerpoint": "x-office/presentation", "application/vnd.ms-visio.drawing.macroEnabled.12": "application/vnd.visio", "application/vnd.ms-visio.drawing": "application/vnd.visio", "application/vnd.ms-visio.stencil.macroEnabled.12": "application/vnd.visio", @@ -48,39 +52,42 @@ OC.MimeTypeList={ "application/vnd.ms-visio.template": "application/vnd.visio", "application/vnd.ms-word.document.macroEnabled.12": "x-office/document", "application/vnd.ms-word.template.macroEnabled.12": "x-office/document", - "application/vnd.oasis.opendocument.presentation": "x-office/presentation", + "application/vnd.oasis.opendocument.graphics-flat-xml": "x-office/drawing", + "application/vnd.oasis.opendocument.graphics-template": "x-office/drawing", + "application/vnd.oasis.opendocument.graphics": "x-office/drawing", + "application/vnd.oasis.opendocument.presentation-flat-xml": "x-office/presentation", "application/vnd.oasis.opendocument.presentation-template": "x-office/presentation", - "application/vnd.oasis.opendocument.spreadsheet": "x-office/spreadsheet", + "application/vnd.oasis.opendocument.presentation": "x-office/presentation", + "application/vnd.oasis.opendocument.spreadsheet-flat-xml": "x-office/spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template": "x-office/spreadsheet", - "application/vnd.oasis.opendocument.text": "x-office/document", + "application/vnd.oasis.opendocument.spreadsheet": "x-office/spreadsheet", + "application/vnd.oasis.opendocument.text-flat-xml": "x-office/document", "application/vnd.oasis.opendocument.text-master": "x-office/document", "application/vnd.oasis.opendocument.text-template": "x-office/document", - "application/vnd.oasis.opendocument.graphics": "x-office/drawing", - "application/vnd.oasis.opendocument.graphics-template": "x-office/drawing", "application/vnd.oasis.opendocument.text-web": "x-office/document", - "application/vnd.oasis.opendocument.text-flat-xml": "x-office/document", - "application/vnd.oasis.opendocument.spreadsheet-flat-xml": "x-office/spreadsheet", - "application/vnd.oasis.opendocument.graphics-flat-xml": "x-office/drawing", - "application/vnd.oasis.opendocument.presentation-flat-xml": "x-office/presentation", + "application/vnd.oasis.opendocument.text": "x-office/document", "application/vnd.openxmlformats-officedocument.presentationml.presentation": "x-office/presentation", "application/vnd.openxmlformats-officedocument.presentationml.slideshow": "x-office/presentation", "application/vnd.openxmlformats-officedocument.presentationml.template": "x-office/presentation", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "x-office/spreadsheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template": "x-office/spreadsheet", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf": "x-office/form-template", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform": "x-office/form", "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "x-office/document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template": "x-office/document", "application/vnd.visio": "x-office/document", "application/vnd.wordperfect": "x-office/document", + "application/vnd.xmind.workbook": "mindmap", "application/x-7z-compressed": "package/x-generic", "application/x-bzip2": "package/x-generic", "application/x-cbr": "text", - "application/x-compressed": "package/x-generic", "application/x-dcraw": "image", "application/x-deb": "package/x-generic", "application/x-fictionbook+xml": "text", - "application/x-font": "image", + "application/x-font": "font", + "application/x-freemind": "mindmap", "application/x-gimp": "image", - "application/x-gzip": "package/x-generic", + "application/x-gzip": "application/gzip", "application/x-iwork-keynote-sffkey": "x-office/presentation", "application/x-iwork-numbers-sffnumbers": "x-office/spreadsheet", "application/x-iwork-pages-sffpages": "x-office/document", @@ -94,8 +101,11 @@ OC.MimeTypeList={ "application/xml": "text/html", "application/yaml": "text/code", "application/zip": "package/x-generic", + "application/zstd": "package/x-generic", "database": "file", "httpd/unix-directory": "dir", + "image/targa": "image/tga", + "image/x-emf": "image/emf", "text/css": "text/code", "text/csv": "x-office/spreadsheet", "text/html": "text/code", @@ -104,16 +114,11 @@ OC.MimeTypeList={ "text/x-h": "text/code", "text/x-java-source": "text/code", "text/x-ldif": "text/code", + "text/x-nfo": "text/code", "text/x-python": "text/code", + "text/x-rst": "text", "text/x-shellscript": "text/code", - "web": "text/code", - "application/internet-shortcut": "link", - "application/km": "mindmap", - "application/x-freemind": "mindmap", - "application/vnd.xmind.workbook": "mindmap", - "image/targa": "image/tga", - "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform": "x-office/form", - "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf": "x-office/form-template" + "web": "text/code" }, files: [ "application", @@ -127,6 +132,7 @@ OC.MimeTypeList={ "folder-public", "folder-shared", "folder-starred", + "font", "image", "link", "location", @@ -137,6 +143,7 @@ OC.MimeTypeList={ "text-code", "text-vcard", "video", + "whiteboard", "x-office-document", "x-office-drawing", "x-office-form", @@ -144,5 +151,130 @@ OC.MimeTypeList={ "x-office-presentation", "x-office-spreadsheet" ], - themes: [] + themes: [], + names: {'application/cmd': t('core', "Windows Command Script"), +'application/epub+zip': t('core', "Electronic book document"), +'application/font-sfnt': t('core', "TrueType Font Collection"), +'application/font-woff': t('core', "Web Open Font Format"), +'application/gpx+xml': t('core', "GPX geographic data"), +'application/gzip': t('core', "Gzip archive"), +'application/illustrator': t('core', "Adobe Illustrator document"), +'application/java': t('core', "Java source code"), +'application/javascript': t('core', "JavaScript source code"), +'application/json': t('core', "JSON document"), +'application/msaccess': t('core', "Microsoft Access database"), +'application/msonenote': t('core', "Microsoft OneNote document"), +'application/msword': t('core', "Microsoft Word document"), +'application/octet-stream': t('core', "Unknown"), +'application/pdf': t('core', "PDF document"), +'application/postscript': t('core', "PostScript document"), +'application/rss+xml': t('core', "RSS summary"), +'application/vnd.android.package-archive': t('core', "Android package"), +'application/vnd.google-earth.kml+xml': t('core', "KML geographic data"), +'application/vnd.google-earth.kmz': t('core', "KML geographic compressed data"), +'application/vnd.lotus-wordpro': t('core', "Lotus Word Pro document"), +'application/vnd.ms-excel': t('core', "Excel spreadsheet"), +'application/vnd.ms-excel.addin.macroEnabled.12': t('core', "Excel add-in"), +'application/vnd.ms-excel.sheet.binary.macroEnabled.12': t('core', "Excel 2007 binary spreadsheet"), +'application/vnd.ms-excel.sheet.macroEnabled.12': t('core', "Excel spreadsheet"), +'application/vnd.ms-excel.template.macroEnabled.12': t('core', "Excel spreadsheet template"), +'application/vnd.ms-outlook': t('core', "Outlook Message"), +'application/vnd.ms-powerpoint': t('core', "PowerPoint presentation"), +'application/vnd.ms-powerpoint.addin.macroEnabled.12': t('core', "PowerPoint add-in"), +'application/vnd.ms-powerpoint.presentation.macroEnabled.12': t('core', "PowerPoint presentation"), +'application/vnd.ms-powerpoint.slideshow.macroEnabled.12': t('core', "PowerPoint presentation"), +'application/vnd.ms-powerpoint.template.macroEnabled.12': t('core', "PowerPoint presentation template"), +'application/vnd.ms-word.document.macroEnabled.12': t('core', "Word document"), +'application/vnd.oasis.opendocument.formula': t('core', "ODF formula"), +'application/vnd.oasis.opendocument.graphics': t('core', "ODG drawing"), +'application/vnd.oasis.opendocument.graphics-flat-xml': t('core', "ODG drawing (Flat XML)"), +'application/vnd.oasis.opendocument.graphics-template': t('core', "ODG template"), +'application/vnd.oasis.opendocument.presentation': t('core', "ODP presentation"), +'application/vnd.oasis.opendocument.presentation-flat-xml': t('core', "ODP presentation (Flat XML)"), +'application/vnd.oasis.opendocument.presentation-template': t('core', "ODP template"), +'application/vnd.oasis.opendocument.spreadsheet': t('core', "ODS spreadsheet"), +'application/vnd.oasis.opendocument.spreadsheet-flat-xml': t('core', "ODS spreadsheet (Flat XML)"), +'application/vnd.oasis.opendocument.spreadsheet-template': t('core', "ODS template"), +'application/vnd.oasis.opendocument.text': t('core', "ODT document"), +'application/vnd.oasis.opendocument.text-flat-xml': t('core', "ODT document (Flat XML)"), +'application/vnd.oasis.opendocument.text-template': t('core', "ODT template"), +'application/vnd.openxmlformats-officedocument.presentationml.presentation': t('core', "PowerPoint 2007 presentation"), +'application/vnd.openxmlformats-officedocument.presentationml.slideshow': t('core', "PowerPoint 2007 show"), +'application/vnd.openxmlformats-officedocument.presentationml.template': t('core', "PowerPoint 2007 presentation template"), +'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': t('core', "Excel 2007 spreadsheet"), +'application/vnd.openxmlformats-officedocument.spreadsheetml.template': t('core', "Excel 2007 spreadsheet template"), +'application/vnd.openxmlformats-officedocument.wordprocessingml.document': t('core', "Word 2007 document"), +'application/vnd.openxmlformats-officedocument.wordprocessingml.template': t('core', "Word 2007 document template"), +'application/vnd.visio': t('core', "Microsoft Visio document"), +'application/vnd.wordperfect': t('core', "WordPerfect document"), +'application/x-7z-compressed': t('core', "7-zip archive"), +'application/x-blender': t('core', "Blender scene"), +'application/x-bzip2': t('core', "Bzip2 archive"), +'application/x-deb': t('core', "Debian package"), +'application/x-fictionbook+xml': t('core', "FictionBook document"), +'application/x-font': t('core', "Unknown font"), +'application/x-krita': t('core', "Krita document"), +'application/x-mobipocket-ebook': t('core', "Mobipocket e-book"), +'application/x-msi': t('core', "Windows Installer package"), +'application/x-perl': t('core', "Perl script"), +'application/x-php': t('core', "PHP script"), +'application/x-tar': t('core', "Tar archive"), +'application/xml': t('core', "XML document"), +'application/yaml': t('core', "YAML document"), +'application/zip': t('core', "Zip archive"), +'application/zstd': t('core', "Zstandard archive"), +'audio/aac': t('core', "AAC audio"), +'audio/flac': t('core', "FLAC audio"), +'audio/mp4': t('core', "MPEG-4 audio"), +'audio/mpeg': t('core', "MP3 audio"), +'audio/ogg': t('core', "Ogg audio"), +'audio/wav': t('core', "RIFF\/WAVe standard Audio"), +'audio/webm': t('core', "WebM audio"), +'audio/x-scpls': t('core', "MP3 ShoutCast playlist"), +'image/bmp': t('core', "Windows BMP image"), +'image/bpg': t('core', "Better Portable Graphics image"), +'image/emf': t('core', "EMF image"), +'image/gif': t('core', "GIF image"), +'image/heic': t('core', "HEIC image"), +'image/heif': t('core', "HEIF image"), +'image/jp2': t('core', "JPEG-2000 JP2 image"), +'image/jpeg': t('core', "JPEG image"), +'image/png': t('core', "PNG image"), +'image/svg+xml': t('core', "SVG image"), +'image/tga': t('core', "Truevision Targa image"), +'image/tiff': t('core', "TIFF image"), +'image/webp': t('core', "WebP image"), +'image/x-dcraw': t('core', "Digital raw image"), +'image/x-icon': t('core', "Windows Icon"), +'message/rfc822': t('core', "Email message"), +'text/calendar': t('core', "VCS\/ICS calendar"), +'text/css': t('core', "CSS stylesheet"), +'text/csv': t('core', "CSV document"), +'text/html': t('core', "HTML document"), +'text/markdown': t('core', "Markdown document"), +'text/org': t('core', "Org-mode file"), +'text/plain': t('core', "Plain text document"), +'text/rtf': t('core', "Rich Text document"), +'text/vcard': t('core', "Electronic business card"), +'text/x-c++src': t('core', "C++ source code"), +'text/x-java-source': t('core', "Java source code"), +'text/x-ldif': t('core', "LDIF address book"), +'text/x-nfo': t('core', "NFO document"), +'text/x-php': t('core', "PHP source"), +'text/x-python': t('core', "Python script"), +'text/x-rst': t('core', "ReStructuredText document"), +'video/3gpp': t('core', "3GPP multimedia file"), +'video/MP2T': t('core', "MPEG video"), +'video/dv': t('core', "DV video"), +'video/mp2t': t('core', "MPEG-2 transport stream"), +'video/mp4': t('core', "MPEG-4 video"), +'video/mpeg': t('core', "MPEG video"), +'video/ogg': t('core', "Ogg video"), +'video/quicktime': t('core', "QuickTime video"), +'video/webm': t('core', "WebM video"), +'video/x-flv': t('core', "Flash video"), +'video/x-matroska': t('core', "Matroska video"), +'video/x-ms-wmv': t('core', "Windows Media video"), +'video/x-msvideo': t('core', "AVI video"), +}, }; diff --git a/core/js/public/publicpage.js b/core/js/public/publicpage.js deleted file mode 100644 index adb1c4dd2fc..00000000000 --- a/core/js/public/publicpage.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net> - * - * @author Julius Härtl <jus@bitgrid.net> - * - * @license AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -window.addEventListener('DOMContentLoaded', function () { - - $('#body-public').find('.header-right .menutoggle').click(function() { - $(this).next('.popovermenu').toggleClass('open'); - }); - - $('#save-external-share').click(function () { - $('#external-share-menu-item').toggleClass('hidden') - $('#remote_address').focus(); - }); - - - $(document).mouseup(function(e) { - var toggle = $('#body-public').find('.header-right .menutoggle'); - var container = toggle.next('.popovermenu'); - - // if the target of the click isn't the menu toggle, nor a descendant of the - // menu toggle, nor the container nor a descendant of the container - if (!toggle.is(e.target) && toggle.has(e.target).length === 0 && - !container.is(e.target) && container.has(e.target).length === 0) { - container.removeClass('open'); - } - }); - -}); diff --git a/core/js/publicshareauth.js b/core/js/publicshareauth.js index 374d7e92e16..3408e6d7560 100644 --- a/core/js/publicshareauth.js +++ b/core/js/publicshareauth.js @@ -1,3 +1,7 @@ +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ function showEmailAddressPromptForm() { // Shows email prompt var emailInput = document.getElementById('email-input-form'); @@ -47,6 +51,8 @@ document.addEventListener('DOMContentLoaded', function() { // Adds functionality to the request password button var passwordRequestButton = document.getElementById('request-password-button-not-talk'); - passwordRequestButton.addEventListener('click', showEmailAddressPromptForm); + if (passwordRequestButton) { + passwordRequestButton.addEventListener('click', showEmailAddressPromptForm); + } }); diff --git a/core/js/select2-toggleselect.js b/core/js/select2-toggleselect.js index 4fada592a3b..286a57cae45 100644 --- a/core/js/select2-toggleselect.js +++ b/core/js/select2-toggleselect.js @@ -1,11 +1,6 @@ -/* - * Copyright (c) 2015 - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * +/** + * SPDX-FileCopyrightText: 2016 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later */ /* global Select2 */ diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index 67f8d70bd31..fc4d4ff6969 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -1,11 +1,7 @@ -/* - * Copyright (c) 2014 - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * +/** + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2014-2016 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later */ (function() { @@ -15,160 +11,6 @@ MESSAGE_TYPE_INFO:0, MESSAGE_TYPE_WARNING:1, MESSAGE_TYPE_ERROR:2, - /** - * Check whether the WebDAV connection works. - * - * @return $.Deferred object resolved with an array of error messages - */ - checkWebDAV: function() { - var deferred = $.Deferred(); - var afterCall = function(xhr) { - var messages = []; - if (xhr.status !== 207 && xhr.status !== 401) { - messages.push({ - msg: t('core', 'Your web server is not yet properly set up to allow file synchronization, because the WebDAV interface seems to be broken.'), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }); - } - deferred.resolve(messages); - }; - - $.ajax({ - type: 'PROPFIND', - url: OC.linkToRemoteBase('webdav'), - data: '<?xml version="1.0"?>' + - '<d:propfind xmlns:d="DAV:">' + - '<d:prop><d:resourcetype/></d:prop>' + - '</d:propfind>', - contentType: 'application/xml; charset=utf-8', - complete: afterCall, - allowAuthErrors: true - }); - return deferred.promise(); - }, - - /** - * Check whether the .well-known URLs works. - * - * @param url the URL to test - * @param placeholderUrl the placeholder URL - can be found at OC.theme.docPlaceholderUrl - * @param {boolean} runCheck if this is set to false the check is skipped and no error is returned - * @param {int|int[]} expectedStatus the expected HTTP status to be returned by the URL, 207 by default - * @return $.Deferred object resolved with an array of error messages - */ - checkWellKnownUrl: function(verb, url, placeholderUrl, runCheck, expectedStatus, checkCustomHeader) { - if (expectedStatus === undefined) { - expectedStatus = [207]; - } - - if (!Array.isArray(expectedStatus)) { - expectedStatus = [expectedStatus]; - } - - var deferred = $.Deferred(); - - if(runCheck === false) { - deferred.resolve([]); - return deferred.promise(); - } - var afterCall = function(xhr) { - var messages = []; - var customWellKnown = xhr.getResponseHeader('X-NEXTCLOUD-WELL-KNOWN') - if (expectedStatus.indexOf(xhr.status) === -1 || (checkCustomHeader && !customWellKnown)) { - var docUrl = placeholderUrl.replace('PLACEHOLDER', 'admin-setup-well-known-URL'); - messages.push({ - msg: t('core', 'Your web server is not properly set up to resolve "{url}". Further information can be found in the {linkstart}documentation ↗{linkend}.', { url: url }) - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + docUrl + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } - deferred.resolve(messages); - }; - - $.ajax({ - type: verb, - url: url, - complete: afterCall, - allowAuthErrors: true - }); - return deferred.promise(); - }, - - - /** - * Check whether the .well-known URLs works. - * - * @param url the URL to test - * @param placeholderUrl the placeholder URL - can be found at OC.theme.docPlaceholderUrl - * @param {boolean} runCheck if this is set to false the check is skipped and no error is returned - * - * @return $.Deferred object resolved with an array of error messages - */ - checkProviderUrl: function(url, placeholderUrl, runCheck) { - var expectedStatus = [200]; - var deferred = $.Deferred(); - - if(runCheck === false) { - deferred.resolve([]); - return deferred.promise(); - } - var afterCall = function(xhr) { - var messages = []; - if (expectedStatus.indexOf(xhr.status) === -1) { - var docUrl = placeholderUrl.replace('PLACEHOLDER', 'admin-nginx'); - messages.push({ - msg: t('core', 'Your web server is not properly set up to resolve "{url}". This is most likely related to a web server configuration that was not updated to deliver this folder directly. Please compare your configuration against the shipped rewrite rules in ".htaccess" for Apache or the provided one in the documentation for Nginx at it\'s {linkstart}documentation page ↗{linkend}. On Nginx those are typically the lines starting with "location ~" that need an update.', { docLink: docUrl, url: url }) - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + docUrl + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - deferred.resolve(messages); - }; - - $.ajax({ - type: 'GET', - url: url, - complete: afterCall, - allowAuthErrors: true - }); - return deferred.promise(); - }, - - - /** - * Check whether the WOFF2 URLs works. - * - * @param url the URL to test - * @param placeholderUrl the placeholder URL - can be found at OC.theme.docPlaceholderUrl - * @return $.Deferred object resolved with an array of error messages - */ - checkWOFF2Loading: function(url, placeholderUrl) { - var deferred = $.Deferred(); - - var afterCall = function(xhr) { - var messages = []; - if (xhr.status !== 200) { - var docUrl = placeholderUrl.replace('PLACEHOLDER', 'admin-nginx'); - messages.push({ - msg: t('core', 'Your web server is not properly set up to deliver .woff2 files. This is typically an issue with the Nginx configuration. For Nextcloud 15 it needs an adjustement to also deliver .woff2 files. Compare your Nginx configuration to the recommended configuration in our {linkstart}documentation ↗{linkend}.', { docLink: docUrl, url: url }) - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + docUrl + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - deferred.resolve(messages); - }; - - $.ajax({ - type: 'GET', - url: url, - complete: afterCall, - allowAuthErrors: true - }); - return deferred.promise(); - }, /** * Runs setup checks on the server side @@ -180,339 +22,16 @@ var afterCall = function(data, statusText, xhr) { var messages = []; if (xhr.status === 200 && data) { - if (!data.isGetenvServerWorking) { - messages.push({ - msg: t('core', 'PHP does not seem to be setup properly to query system environment variables. The test with getenv("PATH") only returns an empty response.') + ' ' + - t('core', 'Please check the {linkstart}installation documentation ↗{linkend} for PHP configuration notes and the PHP configuration of your server, especially when using php-fpm.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-php-fpm') + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - if (data.isReadOnlyConfig) { - messages.push({ - msg: t('core', 'The read-only config has been enabled. This prevents setting some configurations via the web-interface. Furthermore, the file needs to be made writable manually for every update.'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } - if (!data.wasEmailTestSuccessful) { - messages.push({ - msg: t('core', 'You have not set or verified your email server configuration, yet. Please head over to the {mailSettingsStart}Basic settings{mailSettingsEnd} in order to set them. Afterwards, use the "Send email" button below the form to verify your settings.',) - .replace('{mailSettingsStart}', '<a href="' + OC.generateUrl('/settings/admin') + '">') - .replace('{mailSettingsEnd}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } - if (!data.hasValidTransactionIsolationLevel) { - messages.push({ - msg: t('core', 'Your database does not run with "READ COMMITTED" transaction isolation level. This can cause problems when multiple actions are executed in parallel.'), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }); - } - if(!data.hasFileinfoInstalled) { - messages.push({ - msg: t('core', 'The PHP module "fileinfo" is missing. It is strongly recommended to enable this module to get the best results with MIME type detection.'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } - if(!data.hasWorkingFileLocking) { - messages.push({ - msg: t('core', 'Transactional file locking is disabled, this might lead to issues with race conditions. Enable "filelocking.enabled" in config.php to avoid these problems. See the {linkstart}documentation ↗{linkend} for more information.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-transactional-locking') + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - if (data.suggestedOverwriteCliURL !== '') { - messages.push({ - msg: t('core', 'Please make sure to set the "overwrite.cli.url" option in your config.php file to the URL that your users mainly use to access this Nextcloud. Suggestion: "{suggestedOverwriteCliURL}". Otherwise there might be problems with the URL generation via cron. (It is possible though that the suggested URL is not the URL that your users mainly use to access this Nextcloud. Best is to double check this in any case.)', {suggestedOverwriteCliURL: data.suggestedOverwriteCliURL}), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - if (!data.isDefaultPhoneRegionSet) { - messages.push({ - msg: t('core', 'Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add "default_phone_region" with the respective {linkstart}ISO 3166-1 code ↗{linkend} of the region to your config file.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } - if (data.cronErrors.length > 0) { - var listOfCronErrors = ""; - data.cronErrors.forEach(function(element){ - listOfCronErrors += '<li>'; - listOfCronErrors += element.error; - listOfCronErrors += ' '; - listOfCronErrors += element.hint; - listOfCronErrors += '</li>'; - }); - messages.push({ - msg: t('core', 'It was not possible to execute the cron job via CLI. The following technical errors have appeared:') + '<ul>' + listOfCronErrors + '</ul>', - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }) - } - if (data.cronInfo.diffInSeconds > 3600) { - messages.push({ - msg: t('core', 'Last background job execution ran {relativeTime}. Something seems wrong. {linkstart}Check the background job settings ↗{linkend}.', {relativeTime: data.cronInfo.relativeTime}) - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.cronInfo.backgroundJobsUrl + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }); - } - if (!data.isFairUseOfFreePushService) { - messages.push({ - msg: t('core', 'This is the unsupported community build of Nextcloud. Given the size of this instance, performance, reliability and scalability cannot be guaranteed. Push notifications are limited to avoid overloading our free service. Learn more about the benefits of Nextcloud Enterprise at {linkstart}https://nextcloud.com/enterprise{linkend}.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="https://nextcloud.com/enterprise">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }); - } - if (data.serverHasInternetConnectionProblems) { - messages.push({ - msg: t('core', 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - if(!data.isMemcacheConfigured) { - messages.push({ - msg: t('core', 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the {linkstart}documentation ↗{linkend}.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.memcacheDocs + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } - if(!data.isRandomnessSecure) { - messages.push({ - msg: t('core', 'No suitable source for randomness found by PHP which is highly discouraged for security reasons. Further information can be found in the {linkstart}documentation ↗{linkend}.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.securityDocs + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }); - } - if(data.isUsedTlsLibOutdated) { - messages.push({ - msg: data.isUsedTlsLibOutdated, - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - if (data.phpSupported && data.phpSupported.eol) { - messages.push({ - msg: t('core', 'You are currently running PHP {version}. Upgrade your PHP version to take advantage of {linkstart}performance and security updates provided by the PHP Group ↗{linkend} as soon as your distribution supports it.', { version: data.phpSupported.version }) - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="https://secure.php.net/supported-versions.php">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } - if(!data.forwardedForHeadersWorking) { - messages.push({ - msg: t('core', 'The reverse proxy header configuration is incorrect, or you are accessing Nextcloud from a trusted proxy. If not, this is a security issue and can allow an attacker to spoof their IP address as visible to the Nextcloud. Further information can be found in the {linkstart}documentation ↗{linkend}.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.reverseProxyDocs + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - if(!data.isCorrectMemcachedPHPModuleInstalled) { - messages.push({ - msg: t('core', 'Memcached is configured as distributed cache, but the wrong PHP module "memcache" is installed. \\OC\\Memcache\\Memcached only supports "memcached" and not "memcache". See the {linkstart}memcached wiki about both modules ↗{linkend}.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="https://code.google.com/p/memcached/wiki/PHPClientComparison">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING + if (Object.keys(data.generic).length > 0) { + Object.keys(data.generic).forEach(function(key){ + Object.keys(data.generic[key]).forEach(function(title){ + if (data.generic[key][title].severity != 'success') { + data.generic[key][title].pass = false; + OC.SetupChecks.addGenericSetupCheck(data.generic[key], title, messages); + } + }); }); } - if(!data.hasPassedCodeIntegrityCheck) { - messages.push({ - msg: t('core', 'Some files have not passed the integrity check. Further information on how to resolve this issue can be found in the {linkstart1}documentation ↗{linkend}. ({linkstart2}List of invalid files…{linkend} / {linkstart3}Rescan…{linkend})') - .replace('{linkstart1}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.codeIntegrityCheckerDocumentation + '">') - .replace('{linkstart2}', '<a href="' + OC.generateUrl('/settings/integrity/failed') + '">') - .replace('{linkstart3}', '<a href="' + OC.generateUrl('/settings/integrity/rescan?requesttoken={requesttoken}', {'requesttoken': OC.requestToken}) + '">') - .replace(/{linkend}/g, '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }); - } - if(data.OpcacheSetupRecommendations.length > 0) { - var listOfOPcacheRecommendations = ""; - data.OpcacheSetupRecommendations.forEach(function(element){ - listOfOPcacheRecommendations += '<li>' + element + '</li>'; - }); - messages.push({ - msg: t('core', 'The PHP OPcache module is not properly configured. See the {linkstart}documentation ↗{linkend} for more information.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-php-opcache') + '">') - .replace('{linkend}', '</a>') + '<ul>' + listOfOPcacheRecommendations + '</ul>', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } - if(!data.isSettimelimitAvailable) { - messages.push({ - msg: t('core', 'The PHP function "set_time_limit" is not available. This could result in scripts being halted mid-execution, breaking your installation. Enabling this function is strongly recommended.'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - if (!data.hasFreeTypeSupport) { - messages.push({ - msg: t('core', 'Your PHP does not have FreeType support, resulting in breakage of profile pictures and the settings interface.'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } - if (data.missingIndexes.length > 0) { - var listOfMissingIndexes = ""; - data.missingIndexes.forEach(function(element){ - listOfMissingIndexes += '<li>'; - listOfMissingIndexes += t('core', 'Missing index "{indexName}" in table "{tableName}".', element); - listOfMissingIndexes += '</li>'; - }); - messages.push({ - msg: t('core', 'The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running "occ db:add-missing-indices" those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster.') + '<ul>' + listOfMissingIndexes + '</ul>', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } - if (data.missingPrimaryKeys.length > 0) { - var listOfMissingPrimaryKeys = ""; - data.missingPrimaryKeys.forEach(function(element){ - listOfMissingPrimaryKeys += '<li>'; - listOfMissingPrimaryKeys += t('core', 'Missing primary key on table "{tableName}".', element); - listOfMissingPrimaryKeys += '</li>'; - }); - messages.push({ - msg: t('core', 'The database is missing some primary keys. Due to the fact that adding primary keys on big tables could take some time they were not added automatically. By running "occ db:add-missing-primary-keys" those missing primary keys could be added manually while the instance keeps running.') + '<ul>' + listOfMissingPrimaryKeys + '</ul>', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } - if (data.missingColumns.length > 0) { - var listOfMissingColumns = ""; - data.missingColumns.forEach(function(element){ - listOfMissingColumns += '<li>'; - listOfMissingColumns += t('core', 'Missing optional column "{columnName}" in table "{tableName}".', element); - listOfMissingColumns += '</li>'; - }); - messages.push({ - msg: t('core', 'The database is missing some optional columns. Due to the fact that adding columns on big tables could take some time they were not added automatically when they can be optional. By running "occ db:add-missing-columns" those missing columns could be added manually while the instance keeps running. Once the columns are added some features might improve responsiveness or usability.') + '<ul>' + listOfMissingColumns + '</ul>', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } - if (data.recommendedPHPModules.length > 0) { - var listOfRecommendedPHPModules = ""; - data.recommendedPHPModules.forEach(function(element){ - listOfRecommendedPHPModules += '<li>' + element + '</li>'; - }); - messages.push({ - msg: t('core', 'This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them.') + '<ul><code>' + listOfRecommendedPHPModules + '</code></ul>', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } - if (!data.isImagickEnabled) { - messages.push({ - msg: t( - 'core', - 'The PHP module "imagick" is not enabled although the theming app is. For favicon generation to work correctly, you need to install and enable this module.' - ), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } - if (!data.areWebauthnExtensionsEnabled) { - messages.push({ - msg: t( - 'core', - 'The PHP modules "gmp" and/or "bcmath" are not enabled. If you use WebAuthn passwordless authentication, these modules are required.' - ), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } - if (!data.is64bit) { - messages.push({ - msg: t( - 'core', - 'It seems like you are running a 32-bit PHP version. Nextcloud 26 and higher require 64-bit. Please upgrade your OS and PHP to 64-bit! For further details read {linkstart}the documentation page ↗{linkend} about this.' - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-system-requirements') + '">') - .replace('{linkend}', '</a>'), - ), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }) - } - if (data.imageMagickLacksSVGSupport) { - messages.push({ - msg: t('core', 'Module php-imagick in this instance has no SVG support. For better compatibility it is recommended to install it.'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } - if (data.pendingBigIntConversionColumns.length > 0) { - var listOfPendingBigIntConversionColumns = ""; - data.pendingBigIntConversionColumns.forEach(function(element){ - listOfPendingBigIntConversionColumns += '<li>' + element + '</li>'; - }); - messages.push({ - msg: t('core', 'Some columns in the database are missing a conversion to big int. Due to the fact that changing column types on big tables could take some time they were not changed automatically. By running "occ db:convert-filecache-bigint" those pending changes could be applied manually. This operation needs to be made while the instance is offline. For further details read {linkstart}the documentation page about this ↗{linkend}.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-bigint-conversion') + '">') - .replace('{linkend}', '</a>') + '<ul>' + listOfPendingBigIntConversionColumns + '</ul>', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } - if (data.isSqliteUsed) { - messages.push({ - msg: t('core', 'SQLite is currently being used as the backend database. For larger installations we recommend that you switch to a different database backend.') + ' ' + t('core', 'This is particularly recommended when using the desktop client for file synchronisation.') + ' ' + - t('core', 'To migrate to another database use the command line tool: "occ db:convert-type", or see the {linkstart}documentation ↗{linkend}.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.databaseConversionDocumentation + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }) - } - if (!data.isMemoryLimitSufficient) { - messages.push({ - msg: t('core', 'The PHP memory limit is below the recommended value of 512MB.'), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }) - } - - if(data.appDirsWithDifferentOwner && data.appDirsWithDifferentOwner.length > 0) { - var appDirsWithDifferentOwner = data.appDirsWithDifferentOwner.reduce( - function(appDirsWithDifferentOwner, directory) { - return appDirsWithDifferentOwner + '<li>' + directory + '</li>'; - }, - '' - ); - messages.push({ - msg: t('core', 'Some app directories are owned by a different user than the web server one. ' + - 'This may be the case if apps have been installed manually. ' + - 'Check the permissions of the following app directories:') - + '<ul>' + appDirsWithDifferentOwner + '</ul>', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - if (data.isMysqlUsedWithoutUTF8MB4) { - messages.push({ - msg: t('core', 'MySQL is used as database but does not support 4-byte characters. To be able to handle 4-byte characters (like emojis) without issues in filenames or comments for example it is recommended to enable the 4-byte support in MySQL. For further details read {linkstart}the documentation page about this ↗{linkend}.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-mysql-utf8mb4') + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }) - } - if (!data.isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed) { - messages.push({ - msg: t('core', 'This instance uses an S3 based object store as primary storage. The uploaded files are stored temporarily on the server and thus it is recommended to have 50 GB of free space available in the temp directory of PHP. Check the logs for full details about the path and the available space. To improve this please change the temporary directory in the php.ini or make more space available in that path.'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }) - } - if (!data.temporaryDirectoryWritable) { - messages.push({ - msg: t('core', 'The temporary directory of this instance points to an either non-existing or non-writable directory.'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }) - } - if (window.location.protocol === 'https:' && data.reverseProxyGeneratedURL.split('/')[0] !== 'https:') { - messages.push({ - msg: t('core', 'You are accessing your instance over a secure connection, however your instance is generating insecure URLs. This most likely means that you are behind a reverse proxy and the overwrite config variables are not set correctly. Please read {linkstart}the documentation page about this ↗{linkend}.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.reverseProxyDocs + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }) - } - - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset', messages) - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering', messages) - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat', messages) - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\CheckUserCertificates', messages) - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\SupportedDatabase', messages) - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\LdapInvalidUuids', messages) - } else { messages.push({ msg: t('core', 'Error occurred while checking server setup'), @@ -530,8 +49,41 @@ return deferred.promise(); }, + escapeHTML: function(text) { + return text.toString() + .split('&').join('&') + .split('<').join('<') + .split('>').join('>') + .split('"').join('"') + .split('\'').join(''') + }, + + /** + * @param message The message string containing placeholders. + * @param parameters An object with keys as placeholders and values as their replacements. + * + * @return The message with placeholders replaced by values. + */ + richToParsed: function (message, parameters) { + for (var [placeholder, parameter] of Object.entries(parameters)) { + var replacement; + if (parameter.type === 'user') { + replacement = '@' + this.escapeHTML(parameter.name); + } else if (parameter.type === 'file') { + replacement = this.escapeHTML(parameter.path) || this.escapeHTML(parameter.name); + } else if (parameter.type === 'highlight') { + replacement = '<a href="' + encodeURI(parameter.link) + '">' + this.escapeHTML(parameter.name) + '</a>'; + } else { + replacement = this.escapeHTML(parameter.name); + } + message = message.replace('{' + placeholder + '}', replacement); + } + + return message; + }, + addGenericSetupCheck: function(data, check, messages) { - var setupCheck = data[check] || { pass: true, description: '', severity: 'info', linkToDocumentation: null} + var setupCheck = data[check] || { pass: true, description: '', severity: 'info', linkToDoc: null} var type = OC.SetupChecks.MESSAGE_TYPE_INFO if (setupCheck.severity === 'warning') { @@ -541,9 +93,15 @@ } var message = setupCheck.description; - if (setupCheck.linkToDocumentation) { + if (message) { + message = this.escapeHTML(message) + } + if (setupCheck.descriptionParameters) { + message = this.richToParsed(message, setupCheck.descriptionParameters); + } + if (setupCheck.linkToDoc) { message += ' ' + t('core', 'For more details see the {linkstart}documentation ↗{linkend}.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + setupCheck.linkToDocumentation + '">') + .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + setupCheck.linkToDoc + '">') .replace('{linkend}', '</a>'); } if (setupCheck.elements) { @@ -563,176 +121,5 @@ }) } }, - - /** - * Runs generic checks on the server side, the difference to dedicated - * methods is that we use the same XHR object for all checks to save - * requests. - * - * @return $.Deferred object resolved with an array of error messages - */ - checkGeneric: function() { - var self = this; - var deferred = $.Deferred(); - var afterCall = function(data, statusText, xhr) { - var messages = []; - messages = messages.concat(self._checkSecurityHeaders(xhr)); - messages = messages.concat(self._checkSSL(xhr)); - deferred.resolve(messages); - }; - - $.ajax({ - type: 'GET', - url: OC.generateUrl('heartbeat'), - allowAuthErrors: true - }).then(afterCall, afterCall); - - return deferred.promise(); - }, - - checkDataProtected: function() { - var deferred = $.Deferred(); - if(oc_dataURL === false){ - return deferred.resolve([]); - } - var afterCall = function(xhr) { - var messages = []; - // .ocdata is an empty file in the data directory - if this is readable then the data dir is not protected - if (xhr.status === 200 && xhr.responseText === '') { - messages.push({ - msg: t('core', 'Your data directory and files are probably accessible from the internet. The .htaccess file is not working. It is strongly recommended that you configure your web server so that the data directory is no longer accessible, or move the data directory outside the web server document root.'), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }); - } - deferred.resolve(messages); - }; - - $.ajax({ - type: 'GET', - url: OC.linkTo('', oc_dataURL+'/.ocdata?t=' + (new Date()).getTime()), - complete: afterCall, - allowAuthErrors: true - }); - return deferred.promise(); - }, - - /** - * Runs check for some generic security headers on the server side - * - * @param {Object} xhr - * @return {Array} Array with error messages - */ - _checkSecurityHeaders: function(xhr) { - var messages = []; - - if (xhr.status === 200) { - var securityHeaders = { - 'X-Content-Type-Options': ['nosniff'], - 'X-Robots-Tag': ['none'], - 'X-Frame-Options': ['SAMEORIGIN', 'DENY'], - 'X-Permitted-Cross-Domain-Policies': ['none'], - }; - for (var header in securityHeaders) { - var option = securityHeaders[header][0]; - if(!xhr.getResponseHeader(header) || xhr.getResponseHeader(header).toLowerCase() !== option.toLowerCase()) { - var msg = t('core', 'The "{header}" HTTP header is not set to "{expected}". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', {header: header, expected: option}); - if(xhr.getResponseHeader(header) && securityHeaders[header].length > 1 && xhr.getResponseHeader(header).toLowerCase() === securityHeaders[header][1].toLowerCase()) { - msg = t('core', 'The "{header}" HTTP header is not set to "{expected}". Some features might not work correctly, as it is recommended to adjust this setting accordingly.', {header: header, expected: option}); - } - messages.push({ - msg: msg, - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - } - - var xssfields = xhr.getResponseHeader('X-XSS-Protection') ? xhr.getResponseHeader('X-XSS-Protection').split(';').map(function(item) { return item.trim(); }) : []; - if (xssfields.length === 0 || xssfields.indexOf('1') === -1 || xssfields.indexOf('mode=block') === -1) { - messages.push({ - msg: t('core', 'The "{header}" HTTP header does not contain "{expected}". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', - { - header: 'X-XSS-Protection', - expected: '1; mode=block' - }), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - - const referrerPolicy = xhr.getResponseHeader('Referrer-Policy') - if (referrerPolicy === null || !/(no-referrer(-when-downgrade)?|strict-origin(-when-cross-origin)?|same-origin)(,|$)/.test(referrerPolicy)) { - messages.push({ - msg: t('core', 'The "{header}" HTTP header is not set to "{val1}", "{val2}", "{val3}", "{val4}" or "{val5}". This can leak referer information. See the {linkstart}W3C Recommendation ↗{linkend}.', - { - header: 'Referrer-Policy', - val1: 'no-referrer', - val2: 'no-referrer-when-downgrade', - val3: 'strict-origin', - val4: 'strict-origin-when-cross-origin', - val5: 'same-origin' - }) - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="https://www.w3.org/TR/referrer-policy/">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } - } else { - messages.push({ - msg: t('core', 'Error occurred while checking server setup'), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }); - } - - return messages; - }, - - /** - * Runs check for some SSL configuration issues on the server side - * - * @param {Object} xhr - * @return {Array} Array with error messages - */ - _checkSSL: function(xhr) { - var messages = []; - - if (xhr.status === 200) { - var tipsUrl = OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-security'); - if(OC.getProtocol() === 'https') { - // Extract the value of 'Strict-Transport-Security' - var transportSecurityValidity = xhr.getResponseHeader('Strict-Transport-Security'); - if(transportSecurityValidity !== null && transportSecurityValidity.length > 8) { - var firstComma = transportSecurityValidity.indexOf(";"); - if(firstComma !== -1) { - transportSecurityValidity = transportSecurityValidity.substring(8, firstComma); - } else { - transportSecurityValidity = transportSecurityValidity.substring(8); - } - } - - var minimumSeconds = 15552000; - if(isNaN(transportSecurityValidity) || transportSecurityValidity <= (minimumSeconds - 1)) { - messages.push({ - msg: t('core', 'The "Strict-Transport-Security" HTTP header is not set to at least "{seconds}" seconds. For enhanced security, it is recommended to enable HSTS as described in the {linkstart}security tips ↗{linkend}.', {'seconds': minimumSeconds}) - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + tipsUrl + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - } else { - messages.push({ - msg: t('core', 'Accessing site insecurely via HTTP. You are strongly advised to set up your server to require HTTPS instead, as described in the {linkstart}security tips ↗{linkend}.') - .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + tipsUrl + '">') - .replace('{linkend}', '</a>'), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }); - } - } else { - messages.push({ - msg: t('core', 'Error occurred while checking server setup'), - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }); - } - - return messages; - } }; })(); diff --git a/core/js/tests/html-domparser.js b/core/js/tests/html-domparser.js index ea22f9b8752..945d4b1f441 100644 --- a/core/js/tests/html-domparser.js +++ b/core/js/tests/html-domparser.js @@ -1,10 +1,13 @@ -/* +/** * DOMParser HTML extension * 2012-09-04 * * By Eli Grey, http://eligrey.com * Public domain. * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. + * + * SPDX-FileCopyrightText: 2012 Eli Grey, http://eligrey.com + * SPDX-License-Identifier: CC0-1.0 */ /*! @source https://gist.github.com/1129031 */ @@ -13,10 +16,8 @@ (function(DOMParser) { "use strict"; - var - DOMParser_proto = DOMParser.prototype - , real_parseFromString = DOMParser_proto.parseFromString - ; + var DOMParser_proto = DOMParser.prototype; + var real_parseFromString = DOMParser_proto.parseFromString; // Firefox/Opera/IE throw errors on unsupported types try { @@ -29,15 +30,12 @@ DOMParser_proto.parseFromString = function(markup, type) { if (/^\s*text\/html\s*(?:;|$)/i.test(type)) { - var - doc = document.implementation.createHTMLDocument("") - ; - if (markup.toLowerCase().indexOf('<!doctype') > -1) { - doc.documentElement.innerHTML = markup; - } - else { - doc.body.innerHTML = markup; - } + var doc = document.implementation.createHTMLDocument(""); + if (markup.toLowerCase().indexOf('<!doctype') > -1) { + doc.documentElement.innerHTML = markup; + } else { + doc.body.innerHTML = markup; + } return doc; } else { return real_parseFromString.apply(this, arguments); diff --git a/core/js/tests/specHelper.js b/core/js/tests/specHelper.js index 498eed757d6..77958488df7 100644 --- a/core/js/tests/specHelper.js +++ b/core/js/tests/specHelper.js @@ -1,23 +1,8 @@ /** -* ownCloud -* -* @author Vincent Petry -* @copyright 2014 Vincent Petry <pvince81@owncloud.com> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2014 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later + */ /** * Simulate the variables that are normally set by PHP code @@ -95,11 +80,14 @@ window._oc_capabilities = { } // FIXME: OC.webroot is supposed to be only the path!!! -OC.webroot = location.href + '/'; -OC.appswebroots = { +window._oc_webroot = location.href + '/'; +window._oc_appswebroots = { "files": window.webroot + '/apps/files/', "files_sharing": window.webroot + '/apps/files_sharing/' }; + +window.OC ??= {}; + OC.config = { session_lifetime: 600 * 1000, session_keepalive: false, @@ -126,6 +114,10 @@ window.Snap.prototype = { window.isPhantom = /phantom/i.test(navigator.userAgent); document.documentElement.lang = navigator.language; +const el = document.createElement('input'); +el.id = 'initial-state-core-config'; +el.value = btoa(JSON.stringify(window.OC.config)) +document.body.append(el); // global setup for all tests (function setupTests() { diff --git a/core/js/tests/specs/appsSpec.js b/core/js/tests/specs/appsSpec.js deleted file mode 100644 index 3a4c413bbd3..00000000000 --- a/core/js/tests/specs/appsSpec.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* ownCloud -* -* @author Vincent Petry -* @copyright 2015 Vincent Petry <pvince81@owncloud.com> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ - -describe('Apps base tests', function() { - describe('Sidebar utility functions', function() { - beforeEach(function() { - $('#testArea').append('<div id="content"><div id="app-content">Content</div><div id="app-sidebar">The sidebar</div></div>'); - jQuery.fx.off = true; - }); - afterEach(function() { - jQuery.fx.off = false; - }); - it('shows sidebar', function() { - var $el = $('#app-sidebar'); - OC.Apps.showAppSidebar(); - expect($el.hasClass('disappear')).toEqual(false); - }); - it('hides sidebar', function() { - var $el = $('#app-sidebar'); - OC.Apps.showAppSidebar(); - OC.Apps.hideAppSidebar(); - expect($el.hasClass('disappear')).toEqual(true); - }); - it('triggers appresize event when visibility changed', function() { - var eventStub = sinon.stub(); - $('#content').on('appresized', eventStub); - OC.Apps.showAppSidebar(); - expect(eventStub.calledOnce).toEqual(true); - OC.Apps.hideAppSidebar(); - expect(eventStub.calledTwice).toEqual(true); - }); - }); -}); - diff --git a/core/js/tests/specs/contactsmenuSpec.js b/core/js/tests/specs/contactsmenuSpec.js deleted file mode 100644 index eea1df1a7cd..00000000000 --- a/core/js/tests/specs/contactsmenuSpec.js +++ /dev/null @@ -1,265 +0,0 @@ -/* global expect, sinon, _, spyOn, Promise */ - -/** - * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @license AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -describe('Contacts menu', function() { - var $triggerEl, - $menuEl, - menu; - - /** - * @private - * @returns {Promise} - */ - function openMenu() { - return menu.loadContacts(); - } - - beforeEach(function(done) { - $triggerEl = $('<div class="menutoggle">'); - $menuEl = $('<div class="menu">'); - - menu = new OC.ContactsMenu({ - el: $menuEl, - trigger: $triggerEl - }); - done(); - }); - - it('shows a loading message while data is being fetched', function() { - fakeServer.respondWith('GET', OC.generateUrl('/contactsmenu/contacts'), [ - 200, - {}, - '' - ]); - - openMenu(); - - expect($menuEl.html()).toContain('Loading your contacts …'); - }); - - it('shows an error message when loading the contacts data fails', function(done) { - spyOn(console, 'error'); - fakeServer.respondWith('GET', OC.generateUrl('/contactsmenu/contacts'), [ - 500, - {}, - '' - ]); - - var opening = openMenu(); - - expect($menuEl.html()).toContain('Loading your contacts …'); - fakeServer.respond(); - - opening.then(function() { - expect($menuEl.html()).toContain('Could not load your contacts'); - expect(console.error).toHaveBeenCalled(); - done(); - }, function(e) { - done.fail(e); - }); - }); - - it('loads data successfully', function(done) { - spyOn(menu, '_getContacts').and.returnValue(Promise.resolve({ - contacts: [ - { - id: null, - fullName: 'Acosta Lancaster', - topAction: { - title: 'Mail', - icon: 'icon-mail', - hyperlink: 'mailto:deboraoliver%40centrexin.com' - }, - actions: [ - { - title: 'Mail', - icon: 'icon-mail', - hyperlink: 'mailto:mathisholland%40virxo.com' - }, - { - title: 'Details', - icon: 'icon-info', - hyperlink: 'https:\/\/localhost\/index.php\/apps\/contacts' - } - ], - lastMessage: '' - }, - { - id: null, - fullName: 'Adeline Snider', - topAction: { - title: 'Mail', - icon: 'icon-mail', - hyperlink: 'mailto:ceciliasoto%40essensia.com' - }, - actions: [ - { - title: 'Mail', - icon: 'icon-mail', - hyperlink: 'mailto:pearliesellers%40inventure.com' - }, - { - title: 'Details', - icon: 'icon-info', - hyperlink: 'https://localhost\/index.php\/apps\/contacts' - } - ], - lastMessage: 'cu' - } - ], - contactsAppEnabled: true - })); - - openMenu().then(function() { - expect(menu._getContacts).toHaveBeenCalled(); - expect($menuEl.html()).toContain('Acosta Lancaster'); - expect($menuEl.html()).toContain('Adeline Snider'); - expect($menuEl.html()).toContain('Show all contacts …'); - done(); - }, function(e) { - done.fail(e); - }); - - }); - - it('doesn\'t show a link to the contacts app if it\'s disabled', function(done) { - spyOn(menu, '_getContacts').and.returnValue(Promise.resolve({ - contacts: [ - { - id: null, - fullName: 'Acosta Lancaster', - topAction: { - title: 'Mail', - icon: 'icon-mail', - hyperlink: 'mailto:deboraoliver%40centrexin.com' - }, - actions: [ - { - title: 'Mail', - icon: 'icon-mail', - hyperlink: 'mailto:mathisholland%40virxo.com' - }, - { - title: 'Details', - icon: 'icon-info', - hyperlink: 'https:\/\/localhost\/index.php\/apps\/contacts' - } - ], - lastMessage: '' - } - ], - contactsAppEnabled: false - })); - - openMenu().then(function() { - expect(menu._getContacts).toHaveBeenCalled(); - expect($menuEl.html()).not.toContain('Show all contacts …'); - done(); - }, function(e) { - done.fail(e); - }); - }); - - it('shows only one entry\'s action menu at a time', function(done) { - spyOn(menu, '_getContacts').and.returnValue(Promise.resolve({ - contacts: [ - { - id: null, - fullName: 'Acosta Lancaster', - topAction: { - title: 'Mail', - icon: 'icon-mail', - hyperlink: 'mailto:deboraoliver%40centrexin.com' - }, - actions: [ - { - title: 'Info', - icon: 'icon-info', - hyperlink: 'https:\/\/localhost\/index.php\/apps\/contacts' - }, - { - title: 'Details', - icon: 'icon-info', - hyperlink: 'https:\/\/localhost\/index.php\/apps\/contacts' - } - ], - lastMessage: '' - }, - { - id: null, - fullName: 'Adeline Snider', - topAction: { - title: 'Mail', - icon: 'icon-mail', - hyperlink: 'mailto:ceciliasoto%40essensia.com' - }, - actions: [ - { - title: 'Info', - icon: 'icon-info', - hyperlink: 'https://localhost\/index.php\/apps\/contacts' - }, - { - title: 'Details', - icon: 'icon-info', - hyperlink: 'https://localhost\/index.php\/apps\/contacts' - } - ], - lastMessage: 'cu' - } - ], - contactsAppEnabled: true - })); - - openMenu().then(function() { - expect(menu._getContacts).toHaveBeenCalled(); - expect($menuEl.html()).toContain('Adeline Snider'); - expect($menuEl.html()).toContain('Show all contacts …'); - - // Both menus are closed at the beginning - expect($menuEl.find('.contact').eq(0).find('.menu').is(':visible')).toBe(false); - expect($menuEl.find('.contact').eq(1).find('.menu').is(':visible')).toBe(false); - - // Open the first one - $menuEl.find('.contact').eq(0).find('.other-actions').click(); - expect($menuEl.find('.contact').eq(0).find('.menu').css('display')).toBe(''); - expect($menuEl.find('.contact').eq(1).find('.menu').css('display')).toBe('none'); - - // Open the second one - $menuEl.find('.contact').eq(1).find('.other-actions').click(); - expect($menuEl.find('.contact').eq(0).find('.menu').css('display')).toBe('none'); - expect($menuEl.find('.contact').eq(1).find('.menu').css('display')).toBe(''); - - // Close the second one - $menuEl.find('.contact').eq(1).find('.other-actions').click(); - expect($menuEl.find('.contact').eq(0).find('.menu').css('display')).toBe('none'); - expect($menuEl.find('.contact').eq(1).find('.menu').css('display')).toBe('none'); - - done(); - }, function(e) { - done.fail(e); - }); - }); - -}); diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index 93d282c5d5e..3cbd7623a47 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -1,23 +1,8 @@ /** -* ownCloud -* -* @author Vincent Petry -* @copyright 2014 Vincent Petry <pvince81@owncloud.com> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2014 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later + */ describe('Core base tests', function() { var debounceStub @@ -42,16 +27,16 @@ describe('Core base tests', function() { describe('Base values', function() { it('Sets webroots', function() { expect(OC.getRootPath()).toBeDefined(); - expect(OC.appswebroots).toBeDefined(); + expect(window._oc_appswebroots).toBeDefined(); }); }); describe('filePath', function() { beforeEach(function() { - OC.webroot = 'http://localhost'; - OC.appswebroots.files = OC.getRootPath() + '/apps3/files'; + window._oc_webroot = 'http://localhost'; + window._oc_appswebroots.files = OC.getRootPath() + '/apps3/files'; }); afterEach(function() { - delete OC.appswebroots.files; + delete window._oc_appswebroots.files; }); it('Uses a direct link for css and images,' , function() { @@ -70,11 +55,11 @@ describe('Core base tests', function() { var TESTAPP_ROOT = OC.getRootPath() + '/appsx/testapp'; beforeEach(function() { - OC.appswebroots[TESTAPP] = TESTAPP_ROOT; + window._oc_appswebroots[TESTAPP] = TESTAPP_ROOT; }); afterEach(function() { // restore original array - delete OC.appswebroots[TESTAPP]; + delete window._oc_appswebroots[TESTAPP]; }); it('Generates correct links for core apps', function() { expect(OC.linkTo('core', 'somefile.php')).toEqual(OC.getRootPath() + '/core/somefile.php'); @@ -134,93 +119,6 @@ describe('Core base tests', function() { })).toEqual('number=123'); }); }); - describe('Session heartbeat', function() { - var clock, - oldConfig, - counter; - - beforeEach(function() { - clock = sinon.useFakeTimers(); - oldConfig = OC.config; - counter = 0; - - fakeServer.autoRespond = true; - fakeServer.autoRespondAfter = 0; - fakeServer.respondWith(/\/csrftoken/, function(xhr) { - counter++; - xhr.respond(200, {'Content-Type': 'application/json'}, '{"token": "pgBEsb3MzTb1ZPd2mfDZbQ6/0j3OrXHMEZrghHcOkg8=:3khw5PSa+wKQVo4f26exFD3nplud9ECjJ8/Y5zk5/k4="}'); - }); - $(document).off('ajaxComplete'); // ignore previously registered heartbeats - }); - afterEach(function() { - clock.restore(); - /* jshint camelcase: false */ - OC.config = oldConfig; - $(document).off('ajaxError'); - $(document).off('ajaxComplete'); - }); - it('sends heartbeat half the session lifetime when heartbeat enabled', function() { - /* jshint camelcase: false */ - OC.config = { - session_keepalive: true, - session_lifetime: 300 - }; - window.initCore(); - - expect(counter).toEqual(0); - - // less than half, still nothing - clock.tick(100 * 1000); - expect(counter).toEqual(0); - - // reach past half (160), one call - clock.tick(55 * 1000); - expect(counter).toEqual(1); - - // almost there to the next, still one - clock.tick(140 * 1000); - expect(counter).toEqual(1); - - // past it, second call - clock.tick(20 * 1000); - expect(counter).toEqual(2); - }); - it('does not send heartbeat when heartbeat disabled', function() { - /* jshint camelcase: false */ - OC.config = { - session_keepalive: false, - session_lifetime: 300 - }; - window.initCore(); - - expect(counter).toEqual(0); - - clock.tick(1000000); - - // still nothing - expect(counter).toEqual(0); - }); - it('limits the heartbeat between one minute and one day', function() { - /* jshint camelcase: false */ - var setIntervalStub = sinon.stub(window, 'setInterval'); - OC.config = { - session_keepalive: true, - session_lifetime: 5 - }; - window.initCore(); - expect(setIntervalStub.getCall(0).args[1]).toEqual(60 * 1000); - setIntervalStub.reset(); - - OC.config = { - session_keepalive: true, - session_lifetime: 48 * 3600 - }; - window.initCore(); - expect(setIntervalStub.getCall(0).args[1]).toEqual(24 * 3600 * 1000); - - setIntervalStub.restore(); - }); - }); describe('Parse query string', function() { it('Parses query string from full URL', function() { var query = OC.parseQueryString('http://localhost/stuff.php?q=a&b=x'); @@ -374,7 +272,7 @@ describe('Core base tests', function() { // to make sure they run. var cit = window.isPhantom?xit:it; - // must provide the same results as \OC_Util::naturalSortCompare + // must provide the same results as \OCP\Util::naturalSortCompare it('sorts alphabetically', function() { var a = [ 'def', @@ -780,6 +678,7 @@ describe('Core base tests', function() { OC.currentUser = 'dummy'; clock = sinon.useFakeTimers(); reloadStub = sinon.stub(OC, 'reload'); + document.head.dataset.user = 'dummy' notificationStub = sinon.stub(OC.Notification, 'show'); // unstub the error processing method ajaxErrorStub = OC._processAjaxError; @@ -793,47 +692,6 @@ describe('Core base tests', function() { clock.restore(); }); - it('reloads current page in case of auth error', function() { - var dataProvider = [ - [200, false], - [400, false], - [0, false], - [401, true], - [302, true], - [303, true], - [307, true] - ]; - - for (var i = 0; i < dataProvider.length; i++) { - var xhr = { status: dataProvider[i][0] }; - var expectedCall = dataProvider[i][1]; - - reloadStub.reset(); - OC._reloadCalled = false; - - $(document).trigger(new $.Event('ajaxError'), xhr); - - // trigger timers - clock.tick(waitTimeMs); - - if (expectedCall) { - expect(reloadStub.calledOnce).toEqual(true); - } else { - expect(reloadStub.notCalled).toEqual(true); - } - } - }); - it('reload only called once in case of auth error', function() { - var xhr = { status: 401 }; - - $(document).trigger(new $.Event('ajaxError'), xhr); - $(document).trigger(new $.Event('ajaxError'), xhr); - - // trigger timers - clock.tick(waitTimeMs); - - expect(reloadStub.calledOnce).toEqual(true); - }); it('does not reload the page if the user was navigating away', function() { var xhr = { status: 0 }; OC._userIsNavigatingAway = true; @@ -844,16 +702,7 @@ describe('Core base tests', function() { clock.tick(waitTimeMs); expect(reloadStub.notCalled).toEqual(true); }); - it('displays notification', function() { - var xhr = { status: 401 }; - notificationUpdateStub = sinon.stub(OC.Notification, 'showUpdate'); - - $(document).trigger(new $.Event('ajaxError'), xhr); - - clock.tick(waitTimeMs); - expect(notificationUpdateStub.notCalled).toEqual(false); - }); it('shows a temporary notification if the connection is lost', function() { var xhr = { status: 0 }; spyOn(OC, '_ajaxConnectionLostHandler'); @@ -1295,65 +1144,4 @@ describe('Core base tests', function() { expect(snapperStub.close.calledTwice).toBe(true); }); }); - describe('Requires password confirmation', function () { - var stubMomentNow; - var stubJsPageLoadTime; - - afterEach(function () { - delete window.nc_pageLoad; - delete window.nc_lastLogin; - delete window.backendAllowsPasswordConfirmation; - - stubMomentNow.restore(); - stubJsPageLoadTime.restore(); - }); - - it('should not show the password confirmation dialog when server time is earlier than local time', function () { - // add server variables - window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 1, 15, 0).getTime() / 1000); - window.nc_lastLogin = parseInt(new Date(2018, 0, 3, 1, 0, 0).getTime() / 1000); - window.backendAllowsPasswordConfirmation = true; - - stubJsPageLoadTime = sinon.stub(OC.PasswordConfirmation, 'pageLoadTime').value(new Date(2018, 0, 3, 12, 15, 0).getTime()); - stubMomentNow = sinon.stub(moment, 'now').returns(new Date(2018, 0, 3, 12, 20, 0).getTime()); - - expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeFalsy(); - }); - - it('should show the password confirmation dialog when server time is earlier than local time', function () { - // add server variables - window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 1, 15, 0).getTime() / 1000); - window.nc_lastLogin = parseInt(new Date(2018, 0, 3, 1, 0, 0).getTime() / 1000); - window.backendAllowsPasswordConfirmation = true; - - stubJsPageLoadTime = sinon.stub(OC.PasswordConfirmation, 'pageLoadTime').value(new Date(2018, 0, 3, 12, 15, 0).getTime()); - stubMomentNow = sinon.stub(moment, 'now').returns(new Date(2018, 0, 3, 12, 31, 0).getTime()); - - expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeTruthy(); - }); - - it('should not show the password confirmation dialog when server time is later than local time', function () { - // add server variables - window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 23, 15, 0).getTime() / 1000); - window.nc_lastLogin = parseInt(new Date(2018, 0, 3, 23, 0, 0).getTime() / 1000); - window.backendAllowsPasswordConfirmation = true; - - stubJsPageLoadTime = sinon.stub(OC.PasswordConfirmation, 'pageLoadTime').value(new Date(2018, 0, 3, 12, 15, 0).getTime()); - stubMomentNow = sinon.stub(moment, 'now').returns(new Date(2018, 0, 3, 12, 20, 0).getTime()); - - expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeFalsy(); - }); - - it('should show the password confirmation dialog when server time is later than local time', function () { - // add server variables - window.nc_pageLoad = parseInt(new Date(2018, 0, 3, 23, 15, 0).getTime() / 1000); - window.nc_lastLogin = parseInt(new Date(2018, 0, 3, 23, 0, 0).getTime() / 1000); - window.backendAllowsPasswordConfirmation = true; - - stubJsPageLoadTime = sinon.stub(OC.PasswordConfirmation, 'pageLoadTime').value(new Date(2018, 0, 3, 12, 15, 0).getTime()); - stubMomentNow = sinon.stub(moment, 'now').returns(new Date(2018, 0, 3, 12, 31, 0).getTime()); - - expect(OC.PasswordConfirmation.requiresPasswordConfirmation()).toBeTruthy(); - }); - }); }); diff --git a/core/js/tests/specs/files/clientSpec.js b/core/js/tests/specs/files/clientSpec.js index 94d52bebacf..105af079ced 100644 --- a/core/js/tests/specs/files/clientSpec.js +++ b/core/js/tests/specs/files/clientSpec.js @@ -1,23 +1,8 @@ /** -* ownCloud -* -* @author Vincent Petry -* @copyright 2015 Vincent Petry <pvince81@owncloud.com> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2015 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later + */ /* global dav */ diff --git a/core/js/tests/specs/jquery.avatarSpec.js b/core/js/tests/specs/jquery.avatarSpec.js index 420c72d2e9b..c01cd9b9603 100644 --- a/core/js/tests/specs/jquery.avatarSpec.js +++ b/core/js/tests/specs/jquery.avatarSpec.js @@ -1,11 +1,7 @@ /** - * Copyright (c) 2015 Roeland Jago Douma <roeland@famdouma.nl> - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2015 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later */ describe('jquery.avatar tests', function() { diff --git a/core/js/tests/specs/jquery.contactsmenuSpec.js b/core/js/tests/specs/jquery.contactsmenuSpec.js index fb2514eb0de..62aaef89edc 100644 --- a/core/js/tests/specs/jquery.contactsmenuSpec.js +++ b/core/js/tests/specs/jquery.contactsmenuSpec.js @@ -1,11 +1,6 @@ /** - * Copyright (c) 2017 Georg Ehrke <oc.list@georgehrke.com> - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * + * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ describe('jquery.contactsMenu tests', function() { diff --git a/core/js/tests/specs/jquery.placeholderSpec.js b/core/js/tests/specs/jquery.placeholderSpec.js index 4937b99625f..436defdd703 100644 --- a/core/js/tests/specs/jquery.placeholderSpec.js +++ b/core/js/tests/specs/jquery.placeholderSpec.js @@ -1,11 +1,6 @@ /** - * Copyright (c) 2019 Serhii Shliakhov <shlyakhov.up@gmail.com> - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ describe('jquery.placeholder tests', function() { diff --git a/core/js/tests/specs/l10nSpec.js b/core/js/tests/specs/l10nSpec.js index 18c1adabea1..bd93a13fe74 100644 --- a/core/js/tests/specs/l10nSpec.js +++ b/core/js/tests/specs/l10nSpec.js @@ -1,22 +1,23 @@ /** - * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com> - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2014 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later */ describe('OC.L10N tests', function() { var TEST_APP = 'jsunittestapp'; beforeEach(function() { - OC.appswebroots[TEST_APP] = OC.getRootPath() + '/apps3/jsunittestapp'; + window._oc_appswebroots[TEST_APP] = OC.getRootPath() + '/apps3/jsunittestapp'; + + window.OC = window.OC ?? {} + window.OC.appswebroots = window.OC.appswebroots || {} + window.OC.appswebroots[TEST_APP] = OC.getRootPath() + '/apps3/jsunittestapp' }); afterEach(function() { OC.L10N._unregister(TEST_APP); - delete OC.appswebroots[TEST_APP]; + delete window._oc_appswebroots[TEST_APP]; + delete window.OC.appswebroots[TEST_APP]; }); describe('text translation', function() { @@ -109,63 +110,4 @@ describe('OC.L10N tests', function() { checkPlurals(); }); }); - describe('async loading of translations', function() { - it('loads bundle for given app and calls callback', function(done) { - var localeStub = sinon.stub(OC, 'getLocale').returns('zh_CN'); - var callbackStub = sinon.stub(); - var promiseStub = sinon.stub(); - var loading = OC.L10N.load(TEST_APP, callbackStub); - expect(callbackStub.notCalled).toEqual(true); - var req = fakeServer.requests[0]; - - loading - .then(promiseStub) - .then(function() { - expect(fakeServer.requests.length).toEqual(1); - expect(req.url).toEqual( - OC.getRootPath() + '/apps3/' + TEST_APP + '/l10n/zh_CN.json' - ); - - expect(callbackStub.calledOnce).toEqual(true); - expect(promiseStub.calledOnce).toEqual(true); - expect(t(TEST_APP, 'Hello world!')).toEqual('你好世界!'); - localeStub.restore(); - }) - .then(done); - - expect(promiseStub.notCalled).toEqual(true); - req.respond( - 200, - { 'Content-Type': 'application/json' }, - JSON.stringify({ - translations: {'Hello world!': '你好世界!'}, - pluralForm: 'nplurals=2; plural=(n != 1);' - }) - ); - }); - it('calls callback if translation already available', function(done) { - var callbackStub = sinon.stub(); - spyOn(console, 'warn'); - OC.L10N.register(TEST_APP, { - 'Hello world!': 'Hallo Welt!' - }); - OC.L10N.load(TEST_APP, callbackStub) - .then(function() { - expect(callbackStub.calledOnce).toEqual(true); - expect(fakeServer.requests.length).toEqual(0); - }) - .then(done); - - }); - it('calls callback if locale is en', function(done) { - var callbackStub = sinon.stub(); - OC.L10N.load(TEST_APP, callbackStub) - .then(function() { - expect(callbackStub.calledOnce).toEqual(true); - expect(fakeServer.requests.length).toEqual(0); - }) - .then(done) - .catch(done); - }); - }); }); diff --git a/core/js/tests/specs/mimeTypeSpec.js b/core/js/tests/specs/mimeTypeSpec.js index c9497a7c574..4fe5481541d 100644 --- a/core/js/tests/specs/mimeTypeSpec.js +++ b/core/js/tests/specs/mimeTypeSpec.js @@ -1,21 +1,7 @@ /** - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2015 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ describe('MimeType tests', function() { diff --git a/core/js/tests/specs/oc-backbone-webdavSpec.js b/core/js/tests/specs/oc-backbone-webdavSpec.js index 6f48d0c92d2..bf4d6eef6ca 100644 --- a/core/js/tests/specs/oc-backbone-webdavSpec.js +++ b/core/js/tests/specs/oc-backbone-webdavSpec.js @@ -1,23 +1,8 @@ /** -* ownCloud -* -* @author Vincent Petry -* @copyright 2014 Vincent Petry <pvince81@owncloud.com> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2014 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later + */ /* global dav */ diff --git a/core/js/tests/specs/public/commentsSpec.js b/core/js/tests/specs/public/commentsSpec.js index e77947bea9d..6e15ddca6a7 100644 --- a/core/js/tests/specs/public/commentsSpec.js +++ b/core/js/tests/specs/public/commentsSpec.js @@ -1,20 +1,7 @@ /** -* @copyright 2018 Joas Schilling <nickvergessen@owncloud.com> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ describe('OCP.Comments tests', function() { function dataProvider() { diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index 6df1659d7d3..9f75ad501d1 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -1,11 +1,7 @@ /** - * Copyright (c) 2015 Lukas Reschke <lukas@owncloud.com> - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2015 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later */ describe('OC.SetupChecks tests', function() { @@ -22,197 +18,6 @@ describe('OC.SetupChecks tests', function() { protocolStub.restore(); }); - describe('checkWebDAV', function() { - it('should fail with another response status code than 201 or 207', function(done) { - var async = OC.SetupChecks.checkWebDAV(); - - suite.server.requests[0].respond(200); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'Your web server is not yet properly set up to allow file synchronization, because the WebDAV interface seems to be broken.', - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }]); - done(); - }); - }); - - it('should return no error with a response status code of 207', function(done) { - var async = OC.SetupChecks.checkWebDAV(); - - suite.server.requests[0].respond(207); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return no error with a response status code of 401', function(done) { - var async = OC.SetupChecks.checkWebDAV(); - - suite.server.requests[0].respond(401); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - }); - - describe('checkWellKnownUrl', function() { - it('should fail with another response status code than the expected one', function(done) { - var async = OC.SetupChecks.checkWellKnownUrl('PROPFIND', '/.well-known/caldav', 'http://example.org/PLACEHOLDER', true, 207); - - suite.server.requests[0].respond(200); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'Your web server is not properly set up to resolve "/.well-known/caldav". Further information can be found in the <a target="_blank" rel="noreferrer noopener" class="external" href="http://example.org/admin-setup-well-known-URL">documentation ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); - done(); - }); - }); - - it('should return no error with the expected response status code', function(done) { - var async = OC.SetupChecks.checkWellKnownUrl('PROPFIND', '/.well-known/caldav', 'http://example.org/PLACEHOLDER', true, 207); - - suite.server.requests[0].respond(207); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return no error with the default expected response status code', function(done) { - var async = OC.SetupChecks.checkWellKnownUrl('PROPFIND', '/.well-known/caldav', 'http://example.org/PLACEHOLDER', true); - - suite.server.requests[0].respond(207); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return no error when no check should be run', function(done) { - var async = OC.SetupChecks.checkWellKnownUrl('PROPFIND', '/.well-known/caldav', 'http://example.org/PLACEHOLDER', false); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - }); - - describe('checkProviderUrl', function() { - it('should fail with another response status code than the expected one', function(done) { - var async = OC.SetupChecks.checkProviderUrl('/ocm-provider/', 'http://example.org/PLACEHOLDER', true); - - suite.server.requests[0].respond(302); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'Your web server is not properly set up to resolve "/ocm-provider/". This is most likely related to a web server configuration that was not updated to deliver this folder directly. Please compare your configuration against the shipped rewrite rules in ".htaccess" for Apache or the provided one in the documentation for Nginx at it\'s <a target="_blank" rel="noreferrer noopener" class="external" href="http://example.org/admin-nginx">documentation page ↗</a>. On Nginx those are typically the lines starting with "location ~" that need an update.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - - it('should return no error with the expected response status code', function(done) { - var async = OC.SetupChecks.checkProviderUrl('/ocm-provider/', 'http://example.org/PLACEHOLDER', true); - - suite.server.requests[0].respond(200); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return no error when no check should be run', function(done) { - var async = OC.SetupChecks.checkProviderUrl('/ocm-provider/', 'http://example.org/PLACEHOLDER', false); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - }); - - describe('checkWOFF2Loading', function() { - it('should fail with another response status code than the expected one', function(done) { - var async = OC.SetupChecks.checkWOFF2Loading(OC.filePath('core', '', 'fonts/NotoSans-Regular-latin.woff2'), 'http://example.org/PLACEHOLDER'); - - suite.server.requests[0].respond(302); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'Your web server is not properly set up to deliver .woff2 files. This is typically an issue with the Nginx configuration. For Nextcloud 15 it needs an adjustement to also deliver .woff2 files. Compare your Nginx configuration to the recommended configuration in our <a target="_blank" rel="noreferrer noopener" class="external" href="http://example.org/admin-nginx">documentation ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - - it('should return no error with the expected response status code', function(done) { - var async = OC.SetupChecks.checkWOFF2Loading(OC.filePath('core', '', 'fonts/NotoSans-Regular-latin.woff2'), 'http://example.org/PLACEHOLDER'); - - suite.server.requests[0].respond(200); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - }); - - describe('checkDataProtected', function() { - - oc_dataURL = "data"; - - it('should return an error if data directory is not protected', function(done) { - var async = OC.SetupChecks.checkDataProtected(); - - suite.server.requests[0].respond(200, {'Content-Type': 'text/plain'}, ''); - - async.done(function( data, s, x ){ - expect(data).toEqual([ - { - msg: 'Your data directory and files are probably accessible from the internet. The .htaccess file is not working. It is strongly recommended that you configure your web server so that the data directory is no longer accessible, or move the data directory outside the web server document root.', - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }]); - done(); - }); - }); - - it('should not return an error if data directory is protected', function(done) { - var async = OC.SetupChecks.checkDataProtected(); - - suite.server.requests[0].respond(403); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return an error if data directory is a boolean', function(done) { - - oc_dataURL = false; - - var async = OC.SetupChecks.checkDataProtected(); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - }); - describe('checkSetup', function() { it('should return an error if server has no internet connection', function(done) { var async = OC.SetupChecks.checkSetup(); @@ -223,42 +28,15 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json' }, JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: true, - memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance', - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 + generic: { + network: { + "Internet connectivity": { + severity: "warning", + description: 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.', + linkToDoc: null + } + }, }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, }) ); @@ -267,10 +45,8 @@ describe('OC.SetupChecks tests', function() { { msg: 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.', type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }, { - msg: 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.nextcloud.com/server/go.php?to=admin-performance">documentation ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); + }, + ]); done(); }); }); @@ -284,42 +60,15 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json' }, JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: true, - memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance', - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 + generic: { + network: { + "Internet connectivity": { + severity: "warning", + description: 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.', + linkToDoc: null + } + }, }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, }) ); @@ -329,10 +78,7 @@ describe('OC.SetupChecks tests', function() { msg: 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.', type: OC.SetupChecks.MESSAGE_TYPE_WARNING }, - { - msg: 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.nextcloud.com/server/go.php?to=admin-performance">documentation ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); + ]); done(); }); }); @@ -346,42 +92,15 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: true, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 + generic: { + network: { + "Internet connectivity": { + severity: "warning", + description: 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.', + linkToDoc: null + } + }, }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, }) ); @@ -396,356 +115,6 @@ describe('OC.SetupChecks tests', function() { }); }); - it('should return an error if /dev/urandom is not accessible', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: false, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'No suitable source for randomness found by PHP which is highly discouraged for security reasons. Further information can be found in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.nextcloud.com/myDocs.html">documentation ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }]); - done(); - }); - }); - - it('should return an error if the wrong memcache PHP module is installed', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: false, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'Memcached is configured as distributed cache, but the wrong PHP module "memcache" is installed. \\OC\\Memcache\\Memcached only supports "memcached" and not "memcache". See the <a target="_blank" rel="noreferrer noopener" class="external" href="https://code.google.com/p/memcached/wiki/PHPClientComparison">memcached wiki about both modules ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - - it('should return an info if the mail server config was not set or verified, yet', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json' - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: false, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'You have not set or verified your email server configuration, yet. Please head over to the <a href="http://localhost/index.php/settings/admin">Basic settings</a> in order to set them. Afterwards, use the "Send email" button below the form to verify your settings.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); - done(); - }); - }); - - it('should return a warning if there are app directories with wrong permissions', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [ - '/some/path' - ], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'Some app directories are owned by a different user than the web server one. This may be the case if apps have been installed manually. Check the permissions of the following app directories:<ul><li>/some/path</li></ul>', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - - it('should return an error if the forwarded for headers are not working', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: false, - reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'The reverse proxy header configuration is incorrect, or you are accessing Nextcloud from a trusted proxy. If not, this is a security issue and can allow an attacker to spoof their IP address as visible to the Nextcloud. Further information can be found in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.nextcloud.com/foo/bar.html">documentation ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - - it('should return an error if set_time_limit is unavailable', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: false, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'The PHP function "set_time_limit" is not available. This could result in scripts being halted mid-execution, breaking your installation. Enabling this function is strongly recommended.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - it('should return a warning if the memory limit is below the recommended value', function(done) { var async = OC.SetupChecks.checkSetup(); @@ -755,43 +124,27 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + php: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + }, + "PHP memory limit": { + severity: "error", + description: "The PHP memory limit is below the recommended value of 512MB.", + linkToDoc: null + }, + }, }, - isMemoryLimitSufficient: false, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, }) ); @@ -833,293 +186,34 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - phpSupported: {eol: true, version: '5.4.0'}, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'You are currently running PHP 5.4.0. Upgrade your PHP version to take advantage of <a target="_blank" rel="noreferrer noopener" class="external" href="https://secure.php.net/supported-versions.php">performance and security updates provided by the PHP Group ↗</a> as soon as your distribution supports it.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); - done(); - }); - }); - - it('should return an info if server has no proper opcache', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json' - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: ['recommendation1', 'recommendation2'], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'The PHP OPcache module is not properly configured. See the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-php-opcache">documentation ↗</a> for more information.<ul><li>recommendation1</li><li>recommendation2</li></ul>', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); - done(); - }); - }); - - it('should return an info if server has no FreeType support', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json' - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: false, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + security: { + "Checking for PHP version": { + severity: "warning", + description: "You are currently running PHP 8.0.30. PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to one of the officially supported PHP versions provided by the PHP Group as soon as possible.", + linkToDoc: "https://secure.php.net/supported-versions.php" + } + }, }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, }) ); async.done(function( data, s, x ){ expect(data).toEqual([{ - msg: 'Your PHP does not have FreeType support, resulting in breakage of profile pictures and the settings interface.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); - done(); - }); - }); - - it('should return an error if the php version is no longer supported', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: true, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'MySQL is used as database but does not support 4-byte characters. To be able to handle 4-byte characters (like emojis) without issues in filenames or comments for example it is recommended to enable the 4-byte support in MySQL. For further details read <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-mysql-utf8mb4">the documentation page about this ↗</a>.', + msg: 'You are currently running PHP 8.0.30. PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to one of the officially supported PHP versions provided by the PHP Group as soon as possible. For more details see the <a target="_blank" rel="noreferrer noopener" class="external" href="https://secure.php.net/supported-versions.php">documentation ↗</a>.', type: OC.SetupChecks.MESSAGE_TYPE_WARNING }]); done(); }); }); - // THe following test is invalid as the code in core/js/setupchecks.js is calling - // window.location.protocol which always return http during tests - // if there is a way to trick window.location.protocol during test, then we could re-activate it - /* - it('should return an error if the protocol is https but the server generates http links', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', - reverseProxyGeneratedURL: 'http://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'You are accessing your instance over a secure connection, however your instance is generating insecure URLs. This most likely means that you are behind a reverse proxy and the overwrite config variables are not set correctly. Please read <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.nextcloud.com/foo/bar.html">the documentation page about this ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - */ it('should not return an error if the protocol is http and the server generates http links', function(done) { var async = OC.SetupChecks.checkSetup(); @@ -1129,44 +223,15 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', - reverseProxyGeneratedURL: 'http://server', - temporaryDirectoryWritable: true, }) ); @@ -1176,240 +241,6 @@ describe('OC.SetupChecks tests', function() { }); }); - it('should return an error if there is not enough free space in the temp directory', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: false, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'This instance uses an S3 based object store as primary storage. The uploaded files are stored temporarily on the server and thus it is recommended to have 50 GB of free space available in the temp directory of PHP. Check the logs for full details about the path and the available space. To improve this please change the temporary directory in the php.ini or make more space available in that path.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - - - it('should return an error if imagick is not enabled', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: false, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'The PHP module "imagick" is not enabled although the theming app is. For favicon generation to work correctly, you need to install and enable this module.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); - done(); - }); - }); - - - it('should return an error if gmp or bcmath are not enabled', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: false, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'The PHP modules "gmp" and/or "bcmath" are not enabled. If you use WebAuthn passwordless authentication, these modules are required.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); - done(); - }); - }); - - it('should return an error for 32bit instances', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: false, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'It seems like you are running a 32-bit PHP version. Nextcloud 26 and higher require 64-bit. Please upgrade your OS and PHP to 64-bit! For further details read <a href="https://docs.example.org/admin-system-requirements" class="external" rel="noreferrer noopener">the documentation page ↗</a> about this.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - it('should return an info if there is no default phone region', function(done) { var async = OC.SetupChecks.checkSetup(); @@ -1419,695 +250,32 @@ describe('OC.SetupChecks tests', function() { 'Content-Type': 'application/json', }, JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 + generic: { + network: { + "Internet connectivity": { + severity: "success", + description: null, + linkToDoc: null + } + }, + config: { + "Checking for default phone region": { + severity: "info", + description: "Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add \"default_phone_region\" with the respective ISO 3166-1 code of the region to your config file.", + linkToDoc: "https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements" + }, + }, }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: false, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, }) ); async.done(function( data, s, x ){ expect(data).toEqual([{ - msg: 'Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add "default_phone_region" with the respective <a target="_blank" rel="noreferrer noopener" class="external" href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements">ISO 3166-1 code ↗</a> of the region to your config file.', + msg: 'Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add "default_phone_region" with the respective ISO 3166-1 code of the region to your config file. For more details see the <a target="_blank" rel="noreferrer noopener" class="external" href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements">documentation ↗</a>.', type: OC.SetupChecks.MESSAGE_TYPE_INFO }]); done(); }); }); - - it('should return an info if the temporary directory is either non-existent or non-writable', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - hasFileinfoInstalled: true, - isGetenvServerWorking: true, - isReadOnlyConfig: false, - wasEmailTestSuccessful: true, - hasWorkingFileLocking: true, - hasValidTransactionIsolationLevel: true, - suggestedOverwriteCliURL: '', - isRandomnessSecure: true, - securityDocs: 'https://docs.nextcloud.com/myDocs.html', - isFairUseOfFreePushService: true, - serverHasInternetConnectionProblems: false, - isMemcacheConfigured: true, - forwardedForHeadersWorking: true, - isCorrectMemcachedPHPModuleInstalled: true, - hasPassedCodeIntegrityCheck: true, - OpcacheSetupRecommendations: [], - isSettimelimitAvailable: true, - hasFreeTypeSupport: true, - missingIndexes: [], - missingPrimaryKeys: [], - missingColumns: [], - cronErrors: [], - cronInfo: { - diffInSeconds: 0 - }, - isMemoryLimitSufficient: true, - appDirsWithDifferentOwner: [], - isImagickEnabled: true, - areWebauthnExtensionsEnabled: true, - is64bit: true, - recommendedPHPModules: [], - pendingBigIntConversionColumns: [], - isMysqlUsedWithoutUTF8MB4: false, - isDefaultPhoneRegionSet: true, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: false, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'The temporary directory of this instance points to an either non-existing or non-writable directory.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - }); - - describe('checkGeneric', function() { - it('should return an error if the response has no statuscode 200', function(done) { - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond( - 500, - { - 'Content-Type': 'application/json' - } - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'Error occurred while checking server setup', - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - },{ - msg: 'Error occurred while checking server setup', - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }]); - done(); - }); - }); - - it('should return all errors if all headers are missing', function(done) { - protocolStub.returns('https'); - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - 'Strict-Transport-Security': 'max-age=15768000' - }, - '{}' - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([ - { - msg: 'The "X-Content-Type-Options" HTTP header is not set to "nosniff". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }, { - msg: 'The "X-Robots-Tag" HTTP header is not set to "none". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }, { - msg: 'The "X-Frame-Options" HTTP header is not set to "SAMEORIGIN". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }, { - msg: 'The "X-Permitted-Cross-Domain-Policies" HTTP header is not set to "none". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }, { - msg: 'The "X-XSS-Protection" HTTP header does not contain "1; mode=block". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }, { - msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin", "strict-origin-when-cross-origin" or "same-origin". This can leak referer information. See the <a target="_blank" rel="noreferrer noopener" class="external" href="https://www.w3.org/TR/referrer-policy/">W3C Recommendation ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - } - ]); - done(); - }); - }); - - it('should return only some errors if just some headers are missing', function(done) { - protocolStub.returns('https'); - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond( - 200, - { - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'Strict-Transport-Security': 'max-age=15768000;preload', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - } - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([ - { - msg: 'The "X-Content-Type-Options" HTTP header is not set to "nosniff". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }, { - msg: 'The "X-XSS-Protection" HTTP header does not contain "1; mode=block". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING, - } - ]); - done(); - }); - }); - - it('should return none errors if all headers are there', function(done) { - protocolStub.returns('https'); - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond( - 200, - { - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'Strict-Transport-Security': 'max-age=15768000', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer' - } - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - describe('check X-XSS-Protection header', function() { - it('should return no message if X-XSS-Protection is set to 1; mode=block; report=https://example.com', function(done) { - protocolStub.returns('https'); - var result = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '1; mode=block; report=https://example.com', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - }); - - result.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return no message if X-XSS-Protection is set to 1; mode=block', function(done) { - protocolStub.returns('https'); - var result = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - }); - - result.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return a message if X-XSS-Protection is set to 1', function(done) { - protocolStub.returns('https'); - var result = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '1', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - }); - - result.done(function( data, s, x ){ - expect(data).toEqual([ - { - msg: 'The "X-XSS-Protection" HTTP header does not contain "1; mode=block". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - } - ]); - done(); - }); - }); - - it('should return a message if X-XSS-Protection is set to 0', function(done) { - protocolStub.returns('https'); - var result = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '0', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - }); - - result.done(function( data, s, x ){ - expect(data).toEqual([ - { - msg: 'The "X-XSS-Protection" HTTP header does not contain "1; mode=block". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - } - ]); - done(); - }); - }); - }); - - describe('check Referrer-Policy header', function() { - it('should return no message if Referrer-Policy is set to no-referrer', function(done) { - protocolStub.returns('https'); - var result = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - }); - - result.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return no message if Referrer-Policy is set to no-referrer-when-downgrade', function(done) { - protocolStub.returns('https'); - var result = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer-when-downgrade', - }); - - result.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return no message if Referrer-Policy is set to strict-origin', function(done) { - protocolStub.returns('https'); - var result = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'strict-origin', - }); - - result.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return no message if Referrer-Policy is set to strict-origin-when-cross-origin', function(done) { - protocolStub.returns('https'); - var result = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'strict-origin-when-cross-origin', - }); - - result.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return no message if Referrer-Policy is set to same-origin', function(done) { - protocolStub.returns('https'); - var result = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'same-origin', - }); - - result.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return a message if Referrer-Policy is set to origin', function(done) { - protocolStub.returns('https'); - var result = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'origin', - }); - - result.done(function( data, s, x ){ - expect(data).toEqual([ - { - msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin", "strict-origin-when-cross-origin" or "same-origin". This can leak referer information. See the <a target="_blank" rel="noreferrer noopener" class="external" href="https://www.w3.org/TR/referrer-policy/">W3C Recommendation ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - } - ]); - done(); - }); - }); - - it('should return a message if Referrer-Policy is set to origin-when-cross-origin', function(done) { - protocolStub.returns('https'); - var result = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'origin-when-cross-origin', - }); - - result.done(function( data, s, x ){ - expect(data).toEqual([ - { - msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin", "strict-origin-when-cross-origin" or "same-origin". This can leak referer information. See the <a target="_blank" rel="noreferrer noopener" class="external" href="https://www.w3.org/TR/referrer-policy/">W3C Recommendation ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - } - ]); - done(); - }); - }); - - it('should return a message if Referrer-Policy is set to unsafe-url', function(done) { - protocolStub.returns('https'); - var result = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'unsafe-url', - }); - - result.done(function( data, s, x ){ - expect(data).toEqual([ - { - msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin", "strict-origin-when-cross-origin" or "same-origin". This can leak referer information. See the <a target="_blank" rel="noreferrer noopener" class="external" href="https://www.w3.org/TR/referrer-policy/">W3C Recommendation ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - } - ]); - done(); - }); - }); - }); - }); - - it('should return a SSL warning if HTTPS is not used', function(done) { - protocolStub.returns('http'); - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, - { - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - } - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'Accessing site insecurely via HTTP. You are strongly advised to set up your server to require HTTPS instead, as described in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-security">security tips ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - - it('should return an error if the response has no statuscode 200', function(done) { - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond( - 500, - { - 'Content-Type': 'application/json' - }, - JSON.stringify({data: {serverHasInternetConnectionProblems: true}}) - ); - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'Error occurred while checking server setup', - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }, { - msg: 'Error occurred while checking server setup', - type: OC.SetupChecks.MESSAGE_TYPE_ERROR - }]); - done(); - }); - }); - - it('should return a SSL warning if SSL used without Strict-Transport-Security-Header', function(done) { - protocolStub.returns('https'); - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, - { - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - } - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-security">security tips ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - - it('should return a SSL warning if SSL used with to small Strict-Transport-Security-Header', function(done) { - protocolStub.returns('https'); - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, - { - 'Strict-Transport-Security': 'max-age=15551999', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - } - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-security">security tips ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - - it('should return a SSL warning if SSL used with to a bogus Strict-Transport-Security-Header', function(done) { - protocolStub.returns('https'); - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, - { - 'Strict-Transport-Security': 'iAmABogusHeader342', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - } - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-security">security tips ↗</a>.', - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }]); - done(); - }); - }); - - it('should return no SSL warning if SSL used with to exact the minimum Strict-Transport-Security-Header', function(done) { - protocolStub.returns('https'); - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=15768000', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - }); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header', function(done) { - protocolStub.returns('https'); - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=99999999', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - }); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header and includeSubDomains parameter', function(done) { - protocolStub.returns('https'); - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=99999999; includeSubDomains', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - }); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); - }); - - it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header and includeSubDomains and preload parameter', function(done) { - protocolStub.returns('https'); - var async = OC.SetupChecks.checkGeneric(); - - suite.server.requests[0].respond(200, { - 'Strict-Transport-Security': 'max-age=99999999; preload; includeSubDomains', - 'X-XSS-Protection': '1; mode=block', - 'X-Content-Type-Options': 'nosniff', - 'X-Robots-Tag': 'none', - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Permitted-Cross-Domain-Policies': 'none', - 'Referrer-Policy': 'no-referrer', - }); - - async.done(function( data, s, x ){ - expect(data).toEqual([]); - done(); - }); }); }); diff --git a/core/js/tests/specs/systemtags/systemtagsSpec.js b/core/js/tests/specs/systemtags/systemtagsSpec.js index 376a25c7d83..52fe954f454 100644 --- a/core/js/tests/specs/systemtags/systemtagsSpec.js +++ b/core/js/tests/specs/systemtags/systemtagsSpec.js @@ -1,23 +1,8 @@ /** -* ownCloud -* -* @author Joas Schilling -* @copyright 2016 Joas Schilling <nickvergessen@owncloud.com> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later + */ describe('OC.SystemTags tests', function() { it('describes non existing tag', function() { diff --git a/core/js/tests/specs/systemtags/systemtagscollectionSpec.js b/core/js/tests/specs/systemtags/systemtagscollectionSpec.js index 6f2d8361754..f2a3bd067a5 100644 --- a/core/js/tests/specs/systemtags/systemtagscollectionSpec.js +++ b/core/js/tests/specs/systemtags/systemtagscollectionSpec.js @@ -1,23 +1,7 @@ /** -* ownCloud -* -* @author Vincent Petry -* @copyright 2016 Vincent Petry <pvince81@owncloud.com> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * SPDX-FileCopyrightText: 2016 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later + */ describe('OC.SystemTags.SystemTagsCollection tests', function() { var collection; diff --git a/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js b/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js index b69054e647e..988bcfc8c24 100644 --- a/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js +++ b/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js @@ -1,23 +1,8 @@ /** -* ownCloud -* -* @author Vincent Petry -* @copyright 2016 Vincent Petry <pvince81@owncloud.com> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later + */ describe('OC.SystemTags.SystemTagsInputField tests', function() { var view, select2Stub, clock; diff --git a/core/js/update.js b/core/js/update.js index 2132dc9c578..419ab65449f 100644 --- a/core/js/update.js +++ b/core/js/update.js @@ -1,11 +1,7 @@ -/* - * Copyright (c) 2014 - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * +/** + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2014 ownCloud Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later */ (function() { |