Add check for missing .woff2 rule in Nginx via setup check
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
3242c602f6
commit
f5894b653d
3 changed files with 61 additions and 2 deletions
|
@ -87,6 +87,37 @@
|
||||||
return deferred.promise();
|
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_defaults.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 <a target="_blank" rel="noreferrer noopener" href="{docLink}">documentation</a>.', { 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();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs setup checks on the server side
|
* Runs setup checks on the server side
|
||||||
*
|
*
|
||||||
|
|
|
@ -107,6 +107,33 @@ describe('OC.SetupChecks tests', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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');
|
||||||
|
|
||||||
|
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 href="http://example.org/admin-nginx" rel="noreferrer noopener">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/Nunito-Regular.woff2'), 'http://example.org/PLACEHOLDER');
|
||||||
|
|
||||||
|
suite.server.requests[0].respond(200);
|
||||||
|
|
||||||
|
async.done(function( data, s, x ){
|
||||||
|
expect(data).toEqual([]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('checkDataProtected', function() {
|
describe('checkDataProtected', function() {
|
||||||
|
|
||||||
oc_dataURL = "data";
|
oc_dataURL = "data";
|
||||||
|
|
|
@ -250,9 +250,10 @@ $(document).ready(function(){
|
||||||
OC.SetupChecks.checkWellKnownUrl('/.well-known/carddav', oc_defaults.docPlaceholderUrl, $('#postsetupchecks').data('check-wellknown') === true),
|
OC.SetupChecks.checkWellKnownUrl('/.well-known/carddav', oc_defaults.docPlaceholderUrl, $('#postsetupchecks').data('check-wellknown') === true),
|
||||||
OC.SetupChecks.checkSetup(),
|
OC.SetupChecks.checkSetup(),
|
||||||
OC.SetupChecks.checkGeneric(),
|
OC.SetupChecks.checkGeneric(),
|
||||||
|
OC.SetupChecks.checkWOFF2Loading(OC.filePath('core', '', 'fonts/Nunito-Regular.woff2'), oc_defaults.docPlaceholderUrl),
|
||||||
OC.SetupChecks.checkDataProtected()
|
OC.SetupChecks.checkDataProtected()
|
||||||
).then(function(check1, check2, check3, check4, check5, check6, check7) {
|
).then(function(check1, check2, check3, check4, check5, check6, check7, check8) {
|
||||||
var messages = [].concat(check1, check2, check3, check4, check5, check6, check7);
|
var messages = [].concat(check1, check2, check3, check4, check5, check6, check7, check8);
|
||||||
var $el = $('#postsetupchecks');
|
var $el = $('#postsetupchecks');
|
||||||
$('#security-warning-state-loading').addClass('hidden');
|
$('#security-warning-state-loading').addClass('hidden');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue