Merge pull request #21562 from owncloud/properly-check-for-well-known-redirect

Add check for .well-known URL in the root of the webservers URL
This commit is contained in:
Thomas Müller 2016-01-09 17:42:11 +01:00
commit c5b2b3a124
4 changed files with 59 additions and 0 deletions

View file

@ -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(),

View file

@ -46,6 +46,35 @@
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_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
*

View file

@ -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();

View file

@ -168,6 +168,8 @@ $(document).ready(function(){
// run setup checks then gather error messages
$.when(
OC.SetupChecks.checkWebDAV(),
OC.SetupChecks.checkWellKnownUrl('/.well-known/caldav/', oc_defaults.docPlaceholderUrl),
OC.SetupChecks.checkWellKnownUrl('/.well-known/carddav/', oc_defaults.docPlaceholderUrl),
OC.SetupChecks.checkSetup(),
OC.SetupChecks.checkGeneric()
).then(function(check1, check2, check3) {