diff options
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/config.php | 1 | ||||
-rw-r--r-- | core/js/setupchecks.js | 29 | ||||
-rw-r--r-- | core/js/tests/specs/setupchecksSpec.js | 27 |
3 files changed, 57 insertions, 0 deletions
diff --git a/core/js/config.php b/core/js/config.php index c975c6db2dc..7216c50afa9 100644 --- a/core/js/config.php +++ b/core/js/config.php @@ -166,6 +166,7 @@ $array = array( 'baseUrl' => $defaults->getBaseUrl(), 'syncClientUrl' => $defaults->getSyncClientUrl(), 'docBaseUrl' => $defaults->getDocBaseUrl(), + 'docPlaceholderUrl' => $defaults->buildDocLinkToKey('PLACEHOLDER'), 'slogan' => $defaults->getSlogan(), 'logoClaim' => $defaults->getLogoClaim(), 'shortFooter' => $defaults->getShortFooter(), diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index 8763ec1c71b..b1b8dd358d2 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -47,6 +47,35 @@ }, /** + * Check whether the .well-known URLs works. + * + * @param url the URL to test + * @param placeholderUrl the placeholder URL - can be found at oc_defaults.docPlaceholderUrl + * @return $.Deferred object resolved with an array of error messages + */ + checkWellKnownUrl: function(url, placeholderUrl) { + var deferred = $.Deferred(); + var afterCall = function(xhr) { + var messages = []; + if (xhr.status !== 207) { + var docUrl = placeholderUrl.replace('PLACEHOLDER', 'admin-setup-well-known-URL'); + messages.push({ + msg: t('core', 'Your web server is not set up properly to resolve "{url}". Further information can be found in our <a target="_blank" href="{docLink}">documentation</a>.', { docLink: docUrl, url: url }), + type: OC.SetupChecks.MESSAGE_TYPE_ERROR + }); + } + deferred.resolve(messages); + }; + + $.ajax({ + type: 'PROPFIND', + url: url, + complete: afterCall + }); + return deferred.promise(); + }, + + /** * Runs setup checks on the server side * * @return $.Deferred object resolved with an array of error messages diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index c5f1aa5effe..18ba44ac61b 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -60,6 +60,33 @@ describe('OC.SetupChecks tests', function() { }); }); + describe('checkWellKnownUrl', function() { + it('should fail with another response status code than 207', function(done) { + var async = OC.SetupChecks.checkWellKnownUrl('/.well-known/caldav/', 'http://example.org/PLACEHOLDER'); + + suite.server.requests[0].respond(200); + + async.done(function( data, s, x ){ + expect(data).toEqual([{ + msg: 'Your web server is not set up properly to resolve "/.well-known/caldav/". Further information can be found in our <a target="_blank" href="http://example.org/admin-setup-well-known-URL">documentation</a>.', + 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('/.well-known/caldav/', 'http://example.org/PLACEHOLDER'); + + suite.server.requests[0].respond(207); + + 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(); |