summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-12-14 15:56:07 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-12-16 13:13:05 +0100
commit6995223b1ed202c7f8e920e83cb5b53efd7ce761 (patch)
tree76e839b9c3de3b4751a993f24f35f0cb93c0dbbd /core/js
parentd37034f1612279b07c78284771ac73fbd5a2a407 (diff)
downloadnextcloud-server-6995223b1ed202c7f8e920e83cb5b53efd7ce761.tar.gz
nextcloud-server-6995223b1ed202c7f8e920e83cb5b53efd7ce761.zip
Add well known handlers API
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'core/js')
-rw-r--r--core/js/setupchecks.js7
-rw-r--r--core/js/tests/specs/setupchecksSpec.js8
2 files changed, 8 insertions, 7 deletions
diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js
index 22c8589f73b..fb01a91b30e 100644
--- a/core/js/setupchecks.js
+++ b/core/js/setupchecks.js
@@ -56,7 +56,7 @@
* @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(url, placeholderUrl, runCheck, expectedStatus) {
+ checkWellKnownUrl: function(verb, url, placeholderUrl, runCheck, expectedStatus, checkCustomHeader) {
if (expectedStatus === undefined) {
expectedStatus = [207];
}
@@ -73,7 +73,8 @@
}
var afterCall = function(xhr) {
var messages = [];
- if (expectedStatus.indexOf(xhr.status) === -1) {
+ 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 <a target="_blank" rel="noreferrer noopener" href="{docLink}">documentation</a>.', { docLink: docUrl, url: url }),
@@ -84,7 +85,7 @@
};
$.ajax({
- type: 'PROPFIND',
+ type: verb,
url: url,
complete: afterCall,
allowAuthErrors: true
diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js
index c3cddb88a9d..3f02302ee80 100644
--- a/core/js/tests/specs/setupchecksSpec.js
+++ b/core/js/tests/specs/setupchecksSpec.js
@@ -62,7 +62,7 @@ describe('OC.SetupChecks tests', function() {
describe('checkWellKnownUrl', function() {
it('should fail with another response status code than the expected one', function(done) {
- var async = OC.SetupChecks.checkWellKnownUrl('/.well-known/caldav', 'http://example.org/PLACEHOLDER', true, 207);
+ var async = OC.SetupChecks.checkWellKnownUrl('PROPFIND', '/.well-known/caldav', 'http://example.org/PLACEHOLDER', true, 207);
suite.server.requests[0].respond(200);
@@ -76,7 +76,7 @@ describe('OC.SetupChecks tests', function() {
});
it('should return no error with the expected response status code', function(done) {
- var async = OC.SetupChecks.checkWellKnownUrl('/.well-known/caldav', 'http://example.org/PLACEHOLDER', true, 207);
+ var async = OC.SetupChecks.checkWellKnownUrl('PROPFIND', '/.well-known/caldav', 'http://example.org/PLACEHOLDER', true, 207);
suite.server.requests[0].respond(207);
@@ -87,7 +87,7 @@ describe('OC.SetupChecks tests', function() {
});
it('should return no error with the default expected response status code', function(done) {
- var async = OC.SetupChecks.checkWellKnownUrl('/.well-known/caldav', 'http://example.org/PLACEHOLDER', true);
+ var async = OC.SetupChecks.checkWellKnownUrl('PROPFIND', '/.well-known/caldav', 'http://example.org/PLACEHOLDER', true);
suite.server.requests[0].respond(207);
@@ -98,7 +98,7 @@ describe('OC.SetupChecks tests', function() {
});
it('should return no error when no check should be run', function(done) {
- var async = OC.SetupChecks.checkWellKnownUrl('/.well-known/caldav', 'http://example.org/PLACEHOLDER', false);
+ var async = OC.SetupChecks.checkWellKnownUrl('PROPFIND', '/.well-known/caldav', 'http://example.org/PLACEHOLDER', false);
async.done(function( data, s, x ){
expect(data).toEqual([]);