summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2019-02-20 15:32:38 +0100
committerGitHub <noreply@github.com>2019-02-20 15:32:38 +0100
commitbeba18224898777b559f3a657d890c0e9bdd7864 (patch)
tree6172de82eb66d11bfa10cd5da1204391b11d2dff /core
parent0becd88feb63de6ac02b495ad1440d8bd7cdcbd2 (diff)
parentfaef05730a2fca6ca019f645685ad6a08839d71c (diff)
downloadnextcloud-server-beba18224898777b559f3a657d890c0e9bdd7864.tar.gz
nextcloud-server-beba18224898777b559f3a657d890c0e9bdd7864.zip
Merge pull request #14255 from nextcloud/fix-ocm-discovery
Fix ocm end-point discovery discovery
Diffstat (limited to 'core')
-rw-r--r--core/js/setupchecks.js40
-rw-r--r--core/js/tests/specs/setupchecksSpec.js36
2 files changed, 76 insertions, 0 deletions
diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js
index 4aa60912c37..7582b062d52 100644
--- a/core/js/setupchecks.js
+++ b/core/js/setupchecks.js
@@ -91,6 +91,46 @@
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
+ * @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 <a target="_blank" rel="noreferrer noopener" href="{docLink}">documentation page</a>. On Nginx those are typically the lines starting with "location ~" that need an update.', { docLink: docUrl, url: url }),
+ 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.
*
diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js
index 6ea7d812d9a..e2c0053aa71 100644
--- a/core/js/tests/specs/setupchecksSpec.js
+++ b/core/js/tests/specs/setupchecksSpec.js
@@ -107,6 +107,42 @@ describe('OC.SetupChecks tests', function() {
});
});
+ 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 href="http://example.org/admin-nginx" rel="noreferrer noopener">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/Nunito-Regular.woff2'), 'http://example.org/PLACEHOLDER');