You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

setupchecksSpec.js 70KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034
  1. /**
  2. * Copyright (c) 2015 Lukas Reschke <lukas@owncloud.com>
  3. *
  4. * This file is licensed under the Affero General Public License version 3
  5. * or later.
  6. *
  7. * See the COPYING-README file.
  8. *
  9. */
  10. describe('OC.SetupChecks tests', function() {
  11. var suite = this;
  12. var protocolStub;
  13. beforeEach( function(){
  14. protocolStub = sinon.stub(OC, 'getProtocol');
  15. suite.server = sinon.fakeServer.create();
  16. });
  17. afterEach( function(){
  18. suite.server.restore();
  19. protocolStub.restore();
  20. });
  21. describe('checkWebDAV', function() {
  22. it('should fail with another response status code than 201 or 207', function(done) {
  23. var async = OC.SetupChecks.checkWebDAV();
  24. suite.server.requests[0].respond(200);
  25. async.done(function( data, s, x ){
  26. expect(data).toEqual([{
  27. msg: 'Your web server is not yet properly set up to allow file synchronization, because the WebDAV interface seems to be broken.',
  28. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  29. }]);
  30. done();
  31. });
  32. });
  33. it('should return no error with a response status code of 207', function(done) {
  34. var async = OC.SetupChecks.checkWebDAV();
  35. suite.server.requests[0].respond(207);
  36. async.done(function( data, s, x ){
  37. expect(data).toEqual([]);
  38. done();
  39. });
  40. });
  41. it('should return no error with a response status code of 401', function(done) {
  42. var async = OC.SetupChecks.checkWebDAV();
  43. suite.server.requests[0].respond(401);
  44. async.done(function( data, s, x ){
  45. expect(data).toEqual([]);
  46. done();
  47. });
  48. });
  49. });
  50. describe('checkWellKnownUrl', function() {
  51. it('should fail with another response status code than the expected one', function(done) {
  52. var async = OC.SetupChecks.checkWellKnownUrl('PROPFIND', '/.well-known/caldav', 'http://example.org/PLACEHOLDER', true, 207);
  53. suite.server.requests[0].respond(200);
  54. async.done(function( data, s, x ){
  55. expect(data).toEqual([{
  56. msg: 'Your web server is not properly set up to resolve "/.well-known/caldav". Further information can be found in the <a target="_blank" rel="noreferrer noopener" class="external" href="http://example.org/admin-setup-well-known-URL">documentation ↗</a>.',
  57. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  58. }]);
  59. done();
  60. });
  61. });
  62. it('should return no error with the expected response status code', function(done) {
  63. var async = OC.SetupChecks.checkWellKnownUrl('PROPFIND', '/.well-known/caldav', 'http://example.org/PLACEHOLDER', true, 207);
  64. suite.server.requests[0].respond(207);
  65. async.done(function( data, s, x ){
  66. expect(data).toEqual([]);
  67. done();
  68. });
  69. });
  70. it('should return no error with the default expected response status code', function(done) {
  71. var async = OC.SetupChecks.checkWellKnownUrl('PROPFIND', '/.well-known/caldav', 'http://example.org/PLACEHOLDER', true);
  72. suite.server.requests[0].respond(207);
  73. async.done(function( data, s, x ){
  74. expect(data).toEqual([]);
  75. done();
  76. });
  77. });
  78. it('should return no error when no check should be run', function(done) {
  79. var async = OC.SetupChecks.checkWellKnownUrl('PROPFIND', '/.well-known/caldav', 'http://example.org/PLACEHOLDER', false);
  80. async.done(function( data, s, x ){
  81. expect(data).toEqual([]);
  82. done();
  83. });
  84. });
  85. });
  86. describe('checkProviderUrl', function() {
  87. it('should fail with another response status code than the expected one', function(done) {
  88. var async = OC.SetupChecks.checkProviderUrl('/ocm-provider/', 'http://example.org/PLACEHOLDER', true);
  89. suite.server.requests[0].respond(302);
  90. async.done(function( data, s, x ){
  91. expect(data).toEqual([{
  92. 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 target="_blank" rel="noreferrer noopener" class="external" href="http://example.org/admin-nginx">documentation page ↗</a>. On Nginx those are typically the lines starting with "location ~" that need an update.',
  93. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  94. }]);
  95. done();
  96. });
  97. });
  98. it('should return no error with the expected response status code', function(done) {
  99. var async = OC.SetupChecks.checkProviderUrl('/ocm-provider/', 'http://example.org/PLACEHOLDER', true);
  100. suite.server.requests[0].respond(200);
  101. async.done(function( data, s, x ){
  102. expect(data).toEqual([]);
  103. done();
  104. });
  105. });
  106. it('should return no error when no check should be run', function(done) {
  107. var async = OC.SetupChecks.checkProviderUrl('/ocm-provider/', 'http://example.org/PLACEHOLDER', false);
  108. async.done(function( data, s, x ){
  109. expect(data).toEqual([]);
  110. done();
  111. });
  112. });
  113. });
  114. describe('checkWOFF2Loading', function() {
  115. it('should fail with another response status code than the expected one', function(done) {
  116. var async = OC.SetupChecks.checkWOFF2Loading(OC.filePath('core', '', 'fonts/NotoSans-Regular-latin.woff2'), 'http://example.org/PLACEHOLDER');
  117. suite.server.requests[0].respond(302);
  118. async.done(function( data, s, x ){
  119. expect(data).toEqual([{
  120. 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 target="_blank" rel="noreferrer noopener" class="external" href="http://example.org/admin-nginx">documentation ↗</a>.',
  121. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  122. }]);
  123. done();
  124. });
  125. });
  126. it('should return no error with the expected response status code', function(done) {
  127. var async = OC.SetupChecks.checkWOFF2Loading(OC.filePath('core', '', 'fonts/NotoSans-Regular-latin.woff2'), 'http://example.org/PLACEHOLDER');
  128. suite.server.requests[0].respond(200);
  129. async.done(function( data, s, x ){
  130. expect(data).toEqual([]);
  131. done();
  132. });
  133. });
  134. });
  135. describe('checkDataProtected', function() {
  136. oc_dataURL = "data";
  137. it('should return an error if data directory is not protected', function(done) {
  138. var async = OC.SetupChecks.checkDataProtected();
  139. suite.server.requests[0].respond(200, {'Content-Type': 'text/plain'}, '');
  140. async.done(function( data, s, x ){
  141. expect(data).toEqual([
  142. {
  143. msg: 'Your data directory and files are probably accessible from the internet. The .htaccess file is not working. It is strongly recommended that you configure your web server so that the data directory is no longer accessible, or move the data directory outside the web server document root.',
  144. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  145. }]);
  146. done();
  147. });
  148. });
  149. it('should not return an error if data directory is protected', function(done) {
  150. var async = OC.SetupChecks.checkDataProtected();
  151. suite.server.requests[0].respond(403);
  152. async.done(function( data, s, x ){
  153. expect(data).toEqual([]);
  154. done();
  155. });
  156. });
  157. it('should return an error if data directory is a boolean', function(done) {
  158. oc_dataURL = false;
  159. var async = OC.SetupChecks.checkDataProtected();
  160. async.done(function( data, s, x ){
  161. expect(data).toEqual([]);
  162. done();
  163. });
  164. });
  165. });
  166. describe('checkSetup', function() {
  167. it('should return an error if server has no internet connection', function(done) {
  168. var async = OC.SetupChecks.checkSetup();
  169. suite.server.requests[0].respond(
  170. 200,
  171. {
  172. 'Content-Type': 'application/json'
  173. },
  174. JSON.stringify({
  175. hasFileinfoInstalled: true,
  176. isGetenvServerWorking: true,
  177. isReadOnlyConfig: false,
  178. wasEmailTestSuccessful: true,
  179. hasWorkingFileLocking: true,
  180. hasValidTransactionIsolationLevel: true,
  181. suggestedOverwriteCliURL: '',
  182. isRandomnessSecure: true,
  183. isFairUseOfFreePushService: true,
  184. serverHasInternetConnectionProblems: true,
  185. memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance',
  186. forwardedForHeadersWorking: true,
  187. isCorrectMemcachedPHPModuleInstalled: true,
  188. hasPassedCodeIntegrityCheck: true,
  189. OpcacheSetupRecommendations: [],
  190. isSettimelimitAvailable: true,
  191. hasFreeTypeSupport: true,
  192. missingIndexes: [],
  193. missingPrimaryKeys: [],
  194. missingColumns: [],
  195. cronErrors: [],
  196. cronInfo: {
  197. diffInSeconds: 0
  198. },
  199. isMemoryLimitSufficient: true,
  200. appDirsWithDifferentOwner: [],
  201. isImagickEnabled: true,
  202. areWebauthnExtensionsEnabled: true,
  203. recommendedPHPModules: [],
  204. pendingBigIntConversionColumns: [],
  205. isMysqlUsedWithoutUTF8MB4: false,
  206. isDefaultPhoneRegionSet: true,
  207. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  208. reverseProxyGeneratedURL: 'https://server',
  209. temporaryDirectoryWritable: true,
  210. })
  211. );
  212. async.done(function( data, s, x ){
  213. expect(data).toEqual([
  214. {
  215. msg: 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.',
  216. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  217. }, {
  218. msg: 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.nextcloud.com/server/go.php?to=admin-performance">documentation ↗</a>.',
  219. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  220. }]);
  221. done();
  222. });
  223. });
  224. it('should return an error if server has no internet connection and data directory is not protected', function(done) {
  225. var async = OC.SetupChecks.checkSetup();
  226. suite.server.requests[0].respond(
  227. 200,
  228. {
  229. 'Content-Type': 'application/json'
  230. },
  231. JSON.stringify({
  232. hasFileinfoInstalled: true,
  233. isGetenvServerWorking: true,
  234. isReadOnlyConfig: false,
  235. wasEmailTestSuccessful: true,
  236. hasWorkingFileLocking: true,
  237. hasValidTransactionIsolationLevel: true,
  238. suggestedOverwriteCliURL: '',
  239. isRandomnessSecure: true,
  240. isFairUseOfFreePushService: true,
  241. serverHasInternetConnectionProblems: true,
  242. memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance',
  243. forwardedForHeadersWorking: true,
  244. isCorrectMemcachedPHPModuleInstalled: true,
  245. hasPassedCodeIntegrityCheck: true,
  246. OpcacheSetupRecommendations: [],
  247. isSettimelimitAvailable: true,
  248. hasFreeTypeSupport: true,
  249. missingIndexes: [],
  250. missingPrimaryKeys: [],
  251. missingColumns: [],
  252. cronErrors: [],
  253. cronInfo: {
  254. diffInSeconds: 0
  255. },
  256. isMemoryLimitSufficient: true,
  257. appDirsWithDifferentOwner: [],
  258. isImagickEnabled: true,
  259. areWebauthnExtensionsEnabled: true,
  260. recommendedPHPModules: [],
  261. pendingBigIntConversionColumns: [],
  262. isMysqlUsedWithoutUTF8MB4: false,
  263. isDefaultPhoneRegionSet: true,
  264. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  265. reverseProxyGeneratedURL: 'https://server',
  266. temporaryDirectoryWritable: true,
  267. })
  268. );
  269. async.done(function( data, s, x ){
  270. expect(data).toEqual([
  271. {
  272. msg: 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.',
  273. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  274. },
  275. {
  276. msg: 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.nextcloud.com/server/go.php?to=admin-performance">documentation ↗</a>.',
  277. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  278. }]);
  279. done();
  280. });
  281. });
  282. it('should return an error if server has no internet connection and data directory is not protected and memcache is available', function(done) {
  283. var async = OC.SetupChecks.checkSetup();
  284. suite.server.requests[0].respond(
  285. 200,
  286. {
  287. 'Content-Type': 'application/json',
  288. },
  289. JSON.stringify({
  290. hasFileinfoInstalled: true,
  291. isGetenvServerWorking: true,
  292. isReadOnlyConfig: false,
  293. wasEmailTestSuccessful: true,
  294. hasWorkingFileLocking: true,
  295. hasValidTransactionIsolationLevel: true,
  296. suggestedOverwriteCliURL: '',
  297. isRandomnessSecure: true,
  298. isFairUseOfFreePushService: true,
  299. serverHasInternetConnectionProblems: true,
  300. isMemcacheConfigured: true,
  301. forwardedForHeadersWorking: true,
  302. isCorrectMemcachedPHPModuleInstalled: true,
  303. hasPassedCodeIntegrityCheck: true,
  304. OpcacheSetupRecommendations: [],
  305. isSettimelimitAvailable: true,
  306. hasFreeTypeSupport: true,
  307. missingIndexes: [],
  308. missingPrimaryKeys: [],
  309. missingColumns: [],
  310. cronErrors: [],
  311. cronInfo: {
  312. diffInSeconds: 0
  313. },
  314. isMemoryLimitSufficient: true,
  315. appDirsWithDifferentOwner: [],
  316. isImagickEnabled: true,
  317. areWebauthnExtensionsEnabled: true,
  318. recommendedPHPModules: [],
  319. pendingBigIntConversionColumns: [],
  320. isMysqlUsedWithoutUTF8MB4: false,
  321. isDefaultPhoneRegionSet: true,
  322. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  323. reverseProxyGeneratedURL: 'https://server',
  324. temporaryDirectoryWritable: true,
  325. })
  326. );
  327. async.done(function( data, s, x ){
  328. expect(data).toEqual([
  329. {
  330. msg: 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.',
  331. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  332. }
  333. ]);
  334. done();
  335. });
  336. });
  337. it('should return an error if /dev/urandom is not accessible', function(done) {
  338. var async = OC.SetupChecks.checkSetup();
  339. suite.server.requests[0].respond(
  340. 200,
  341. {
  342. 'Content-Type': 'application/json',
  343. },
  344. JSON.stringify({
  345. hasFileinfoInstalled: true,
  346. isGetenvServerWorking: true,
  347. isReadOnlyConfig: false,
  348. wasEmailTestSuccessful: true,
  349. hasWorkingFileLocking: true,
  350. hasValidTransactionIsolationLevel: true,
  351. suggestedOverwriteCliURL: '',
  352. isRandomnessSecure: false,
  353. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  354. isFairUseOfFreePushService: true,
  355. serverHasInternetConnectionProblems: false,
  356. isMemcacheConfigured: true,
  357. forwardedForHeadersWorking: true,
  358. isCorrectMemcachedPHPModuleInstalled: true,
  359. hasPassedCodeIntegrityCheck: true,
  360. OpcacheSetupRecommendations: [],
  361. isSettimelimitAvailable: true,
  362. hasFreeTypeSupport: true,
  363. missingIndexes: [],
  364. missingPrimaryKeys: [],
  365. missingColumns: [],
  366. cronErrors: [],
  367. cronInfo: {
  368. diffInSeconds: 0
  369. },
  370. isMemoryLimitSufficient: true,
  371. appDirsWithDifferentOwner: [],
  372. isImagickEnabled: true,
  373. areWebauthnExtensionsEnabled: true,
  374. recommendedPHPModules: [],
  375. pendingBigIntConversionColumns: [],
  376. isMysqlUsedWithoutUTF8MB4: false,
  377. isDefaultPhoneRegionSet: true,
  378. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  379. reverseProxyGeneratedURL: 'https://server',
  380. temporaryDirectoryWritable: true,
  381. })
  382. );
  383. async.done(function( data, s, x ){
  384. expect(data).toEqual([{
  385. msg: 'No suitable source for randomness found by PHP which is highly discouraged for security reasons. Further information can be found in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.nextcloud.com/myDocs.html">documentation ↗</a>.',
  386. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  387. }]);
  388. done();
  389. });
  390. });
  391. it('should return an error if the wrong memcache PHP module is installed', function(done) {
  392. var async = OC.SetupChecks.checkSetup();
  393. suite.server.requests[0].respond(
  394. 200,
  395. {
  396. 'Content-Type': 'application/json',
  397. },
  398. JSON.stringify({
  399. hasFileinfoInstalled: true,
  400. isGetenvServerWorking: true,
  401. isReadOnlyConfig: false,
  402. wasEmailTestSuccessful: true,
  403. hasWorkingFileLocking: true,
  404. hasValidTransactionIsolationLevel: true,
  405. suggestedOverwriteCliURL: '',
  406. isRandomnessSecure: true,
  407. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  408. isFairUseOfFreePushService: true,
  409. serverHasInternetConnectionProblems: false,
  410. isMemcacheConfigured: true,
  411. forwardedForHeadersWorking: true,
  412. isCorrectMemcachedPHPModuleInstalled: false,
  413. hasPassedCodeIntegrityCheck: true,
  414. OpcacheSetupRecommendations: [],
  415. isSettimelimitAvailable: true,
  416. hasFreeTypeSupport: true,
  417. missingIndexes: [],
  418. missingPrimaryKeys: [],
  419. missingColumns: [],
  420. cronErrors: [],
  421. cronInfo: {
  422. diffInSeconds: 0
  423. },
  424. isMemoryLimitSufficient: true,
  425. appDirsWithDifferentOwner: [],
  426. isImagickEnabled: true,
  427. areWebauthnExtensionsEnabled: true,
  428. recommendedPHPModules: [],
  429. pendingBigIntConversionColumns: [],
  430. isMysqlUsedWithoutUTF8MB4: false,
  431. isDefaultPhoneRegionSet: true,
  432. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  433. reverseProxyGeneratedURL: 'https://server',
  434. temporaryDirectoryWritable: true,
  435. })
  436. );
  437. async.done(function( data, s, x ){
  438. expect(data).toEqual([{
  439. msg: 'Memcached is configured as distributed cache, but the wrong PHP module "memcache" is installed. \\OC\\Memcache\\Memcached only supports "memcached" and not "memcache". See the <a target="_blank" rel="noreferrer noopener" class="external" href="https://code.google.com/p/memcached/wiki/PHPClientComparison">memcached wiki about both modules ↗</a>.',
  440. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  441. }]);
  442. done();
  443. });
  444. });
  445. it('should return an info if the mail server config was not set or verified, yet', function(done) {
  446. var async = OC.SetupChecks.checkSetup();
  447. suite.server.requests[0].respond(
  448. 200,
  449. {
  450. 'Content-Type': 'application/json'
  451. },
  452. JSON.stringify({
  453. hasFileinfoInstalled: true,
  454. isGetenvServerWorking: true,
  455. isReadOnlyConfig: false,
  456. wasEmailTestSuccessful: false,
  457. hasWorkingFileLocking: true,
  458. hasValidTransactionIsolationLevel: true,
  459. suggestedOverwriteCliURL: '',
  460. isRandomnessSecure: true,
  461. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  462. isFairUseOfFreePushService: true,
  463. serverHasInternetConnectionProblems: false,
  464. isMemcacheConfigured: true,
  465. forwardedForHeadersWorking: true,
  466. isCorrectMemcachedPHPModuleInstalled: true,
  467. hasPassedCodeIntegrityCheck: true,
  468. OpcacheSetupRecommendations: [],
  469. isSettimelimitAvailable: true,
  470. hasFreeTypeSupport: true,
  471. missingIndexes: [],
  472. missingPrimaryKeys: [],
  473. missingColumns: [],
  474. cronErrors: [],
  475. cronInfo: {
  476. diffInSeconds: 0
  477. },
  478. isMemoryLimitSufficient: true,
  479. appDirsWithDifferentOwner: [],
  480. isImagickEnabled: true,
  481. areWebauthnExtensionsEnabled: true,
  482. recommendedPHPModules: [],
  483. pendingBigIntConversionColumns: [],
  484. isMysqlUsedWithoutUTF8MB4: false,
  485. isDefaultPhoneRegionSet: true,
  486. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  487. reverseProxyGeneratedURL: 'https://server',
  488. temporaryDirectoryWritable: true,
  489. })
  490. );
  491. async.done(function( data, s, x ){
  492. expect(data).toEqual([{
  493. msg: 'You have not set or verified your email server configuration, yet. Please head over to the <a href="http://localhost/index.php/settings/admin">Basic settings</a> in order to set them. Afterwards, use the "Send email" button below the form to verify your settings.',
  494. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  495. }]);
  496. done();
  497. });
  498. });
  499. it('should return a warning if there are app directories with wrong permissions', function(done) {
  500. var async = OC.SetupChecks.checkSetup();
  501. suite.server.requests[0].respond(
  502. 200,
  503. {
  504. 'Content-Type': 'application/json',
  505. },
  506. JSON.stringify({
  507. hasFileinfoInstalled: true,
  508. isGetenvServerWorking: true,
  509. isReadOnlyConfig: false,
  510. wasEmailTestSuccessful: true,
  511. hasWorkingFileLocking: true,
  512. hasValidTransactionIsolationLevel: true,
  513. suggestedOverwriteCliURL: '',
  514. isRandomnessSecure: true,
  515. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  516. isFairUseOfFreePushService: true,
  517. serverHasInternetConnectionProblems: false,
  518. isMemcacheConfigured: true,
  519. forwardedForHeadersWorking: true,
  520. isCorrectMemcachedPHPModuleInstalled: true,
  521. hasPassedCodeIntegrityCheck: true,
  522. OpcacheSetupRecommendations: [],
  523. isSettimelimitAvailable: true,
  524. hasFreeTypeSupport: true,
  525. missingIndexes: [],
  526. missingPrimaryKeys: [],
  527. missingColumns: [],
  528. cronErrors: [],
  529. cronInfo: {
  530. diffInSeconds: 0
  531. },
  532. isMemoryLimitSufficient: true,
  533. appDirsWithDifferentOwner: [
  534. '/some/path'
  535. ],
  536. isImagickEnabled: true,
  537. areWebauthnExtensionsEnabled: true,
  538. recommendedPHPModules: [],
  539. pendingBigIntConversionColumns: [],
  540. isMysqlUsedWithoutUTF8MB4: false,
  541. isDefaultPhoneRegionSet: true,
  542. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  543. reverseProxyGeneratedURL: 'https://server',
  544. temporaryDirectoryWritable: true,
  545. })
  546. );
  547. async.done(function( data, s, x ){
  548. expect(data).toEqual([{
  549. msg: 'Some app directories are owned by a different user than the web server one. This may be the case if apps have been installed manually. Check the permissions of the following app directories:<ul><li>/some/path</li></ul>',
  550. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  551. }]);
  552. done();
  553. });
  554. });
  555. it('should return an error if the forwarded for headers are not working', function(done) {
  556. var async = OC.SetupChecks.checkSetup();
  557. suite.server.requests[0].respond(
  558. 200,
  559. {
  560. 'Content-Type': 'application/json',
  561. },
  562. JSON.stringify({
  563. hasFileinfoInstalled: true,
  564. isGetenvServerWorking: true,
  565. isReadOnlyConfig: false,
  566. wasEmailTestSuccessful: true,
  567. hasWorkingFileLocking: true,
  568. hasValidTransactionIsolationLevel: true,
  569. suggestedOverwriteCliURL: '',
  570. isRandomnessSecure: true,
  571. isFairUseOfFreePushService: true,
  572. serverHasInternetConnectionProblems: false,
  573. isMemcacheConfigured: true,
  574. forwardedForHeadersWorking: false,
  575. reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
  576. isCorrectMemcachedPHPModuleInstalled: true,
  577. hasPassedCodeIntegrityCheck: true,
  578. OpcacheSetupRecommendations: [],
  579. isSettimelimitAvailable: true,
  580. hasFreeTypeSupport: true,
  581. missingIndexes: [],
  582. missingPrimaryKeys: [],
  583. missingColumns: [],
  584. cronErrors: [],
  585. cronInfo: {
  586. diffInSeconds: 0
  587. },
  588. isMemoryLimitSufficient: true,
  589. appDirsWithDifferentOwner: [],
  590. isImagickEnabled: true,
  591. areWebauthnExtensionsEnabled: true,
  592. recommendedPHPModules: [],
  593. pendingBigIntConversionColumns: [],
  594. isMysqlUsedWithoutUTF8MB4: false,
  595. isDefaultPhoneRegionSet: true,
  596. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  597. reverseProxyGeneratedURL: 'https://server',
  598. temporaryDirectoryWritable: true,
  599. })
  600. );
  601. async.done(function( data, s, x ){
  602. expect(data).toEqual([{
  603. msg: 'The reverse proxy header configuration is incorrect, or you are accessing Nextcloud from a trusted proxy. If not, this is a security issue and can allow an attacker to spoof their IP address as visible to the Nextcloud. Further information can be found in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.nextcloud.com/foo/bar.html">documentation ↗</a>.',
  604. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  605. }]);
  606. done();
  607. });
  608. });
  609. it('should return an error if set_time_limit is unavailable', function(done) {
  610. var async = OC.SetupChecks.checkSetup();
  611. suite.server.requests[0].respond(
  612. 200,
  613. {
  614. 'Content-Type': 'application/json',
  615. },
  616. JSON.stringify({
  617. hasFileinfoInstalled: true,
  618. isGetenvServerWorking: true,
  619. isReadOnlyConfig: false,
  620. wasEmailTestSuccessful: true,
  621. hasWorkingFileLocking: true,
  622. hasValidTransactionIsolationLevel: true,
  623. suggestedOverwriteCliURL: '',
  624. isRandomnessSecure: true,
  625. isFairUseOfFreePushService: true,
  626. serverHasInternetConnectionProblems: false,
  627. isMemcacheConfigured: true,
  628. forwardedForHeadersWorking: true,
  629. reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
  630. isCorrectMemcachedPHPModuleInstalled: true,
  631. hasPassedCodeIntegrityCheck: true,
  632. OpcacheSetupRecommendations: [],
  633. isSettimelimitAvailable: false,
  634. hasFreeTypeSupport: true,
  635. missingIndexes: [],
  636. missingPrimaryKeys: [],
  637. missingColumns: [],
  638. cronErrors: [],
  639. cronInfo: {
  640. diffInSeconds: 0
  641. },
  642. isMemoryLimitSufficient: true,
  643. appDirsWithDifferentOwner: [],
  644. isImagickEnabled: true,
  645. areWebauthnExtensionsEnabled: true,
  646. recommendedPHPModules: [],
  647. pendingBigIntConversionColumns: [],
  648. isMysqlUsedWithoutUTF8MB4: false,
  649. isDefaultPhoneRegionSet: true,
  650. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  651. reverseProxyGeneratedURL: 'https://server',
  652. temporaryDirectoryWritable: true,
  653. })
  654. );
  655. async.done(function( data, s, x ){
  656. expect(data).toEqual([{
  657. msg: 'The PHP function "set_time_limit" is not available. This could result in scripts being halted mid-execution, breaking your installation. Enabling this function is strongly recommended.',
  658. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  659. }]);
  660. done();
  661. });
  662. });
  663. it('should return a warning if the memory limit is below the recommended value', function(done) {
  664. var async = OC.SetupChecks.checkSetup();
  665. suite.server.requests[0].respond(
  666. 200,
  667. {
  668. 'Content-Type': 'application/json',
  669. },
  670. JSON.stringify({
  671. hasFileinfoInstalled: true,
  672. isGetenvServerWorking: true,
  673. isReadOnlyConfig: false,
  674. wasEmailTestSuccessful: true,
  675. hasWorkingFileLocking: true,
  676. hasValidTransactionIsolationLevel: true,
  677. suggestedOverwriteCliURL: '',
  678. isRandomnessSecure: true,
  679. isFairUseOfFreePushService: true,
  680. serverHasInternetConnectionProblems: false,
  681. isMemcacheConfigured: true,
  682. forwardedForHeadersWorking: true,
  683. reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
  684. isCorrectMemcachedPHPModuleInstalled: true,
  685. hasPassedCodeIntegrityCheck: true,
  686. OpcacheSetupRecommendations: [],
  687. isSettimelimitAvailable: true,
  688. hasFreeTypeSupport: true,
  689. missingIndexes: [],
  690. missingPrimaryKeys: [],
  691. missingColumns: [],
  692. cronErrors: [],
  693. cronInfo: {
  694. diffInSeconds: 0
  695. },
  696. isMemoryLimitSufficient: false,
  697. appDirsWithDifferentOwner: [],
  698. isImagickEnabled: true,
  699. areWebauthnExtensionsEnabled: true,
  700. recommendedPHPModules: [],
  701. pendingBigIntConversionColumns: [],
  702. isMysqlUsedWithoutUTF8MB4: false,
  703. isDefaultPhoneRegionSet: true,
  704. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  705. reverseProxyGeneratedURL: 'https://server',
  706. temporaryDirectoryWritable: true,
  707. })
  708. );
  709. async.done(function( data, s, x ){
  710. expect(data).toEqual([{
  711. msg: 'The PHP memory limit is below the recommended value of 512MB.',
  712. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  713. }]);
  714. done();
  715. });
  716. });
  717. it('should return an error if the response has no statuscode 200', function(done) {
  718. var async = OC.SetupChecks.checkSetup();
  719. suite.server.requests[0].respond(
  720. 500,
  721. {
  722. 'Content-Type': 'application/json'
  723. },
  724. JSON.stringify({data: {serverHasInternetConnectionProblems: true}})
  725. );
  726. async.done(function( data, s, x ){
  727. expect(data).toEqual([{
  728. msg: 'Error occurred while checking server setup',
  729. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  730. }]);
  731. done();
  732. });
  733. });
  734. it('should return an error if the php version is no longer supported', function(done) {
  735. var async = OC.SetupChecks.checkSetup();
  736. suite.server.requests[0].respond(
  737. 200,
  738. {
  739. 'Content-Type': 'application/json',
  740. },
  741. JSON.stringify({
  742. hasFileinfoInstalled: true,
  743. isGetenvServerWorking: true,
  744. isReadOnlyConfig: false,
  745. wasEmailTestSuccessful: true,
  746. hasWorkingFileLocking: true,
  747. hasValidTransactionIsolationLevel: true,
  748. suggestedOverwriteCliURL: '',
  749. isRandomnessSecure: true,
  750. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  751. isFairUseOfFreePushService: true,
  752. serverHasInternetConnectionProblems: false,
  753. isMemcacheConfigured: true,
  754. forwardedForHeadersWorking: true,
  755. phpSupported: {eol: true, version: '5.4.0'},
  756. isCorrectMemcachedPHPModuleInstalled: true,
  757. hasPassedCodeIntegrityCheck: true,
  758. OpcacheSetupRecommendations: [],
  759. isSettimelimitAvailable: true,
  760. hasFreeTypeSupport: true,
  761. missingIndexes: [],
  762. missingPrimaryKeys: [],
  763. missingColumns: [],
  764. cronErrors: [],
  765. cronInfo: {
  766. diffInSeconds: 0
  767. },
  768. isMemoryLimitSufficient: true,
  769. appDirsWithDifferentOwner: [],
  770. isImagickEnabled: true,
  771. areWebauthnExtensionsEnabled: true,
  772. recommendedPHPModules: [],
  773. pendingBigIntConversionColumns: [],
  774. isMysqlUsedWithoutUTF8MB4: false,
  775. isDefaultPhoneRegionSet: true,
  776. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  777. reverseProxyGeneratedURL: 'https://server',
  778. temporaryDirectoryWritable: true,
  779. })
  780. );
  781. async.done(function( data, s, x ){
  782. expect(data).toEqual([{
  783. msg: 'You are currently running PHP 5.4.0. Upgrade your PHP version to take advantage of <a target="_blank" rel="noreferrer noopener" class="external" href="https://secure.php.net/supported-versions.php">performance and security updates provided by the PHP Group ↗</a> as soon as your distribution supports it.',
  784. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  785. }]);
  786. done();
  787. });
  788. });
  789. it('should return an info if server has no proper opcache', function(done) {
  790. var async = OC.SetupChecks.checkSetup();
  791. suite.server.requests[0].respond(
  792. 200,
  793. {
  794. 'Content-Type': 'application/json'
  795. },
  796. JSON.stringify({
  797. hasFileinfoInstalled: true,
  798. isGetenvServerWorking: true,
  799. isReadOnlyConfig: false,
  800. wasEmailTestSuccessful: true,
  801. hasWorkingFileLocking: true,
  802. hasValidTransactionIsolationLevel: true,
  803. suggestedOverwriteCliURL: '',
  804. isRandomnessSecure: true,
  805. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  806. isFairUseOfFreePushService: true,
  807. serverHasInternetConnectionProblems: false,
  808. isMemcacheConfigured: true,
  809. forwardedForHeadersWorking: true,
  810. isCorrectMemcachedPHPModuleInstalled: true,
  811. hasPassedCodeIntegrityCheck: true,
  812. OpcacheSetupRecommendations: ['recommendation1', 'recommendation2'],
  813. isSettimelimitAvailable: true,
  814. hasFreeTypeSupport: true,
  815. missingIndexes: [],
  816. missingPrimaryKeys: [],
  817. missingColumns: [],
  818. cronErrors: [],
  819. cronInfo: {
  820. diffInSeconds: 0
  821. },
  822. isMemoryLimitSufficient: true,
  823. appDirsWithDifferentOwner: [],
  824. isImagickEnabled: true,
  825. areWebauthnExtensionsEnabled: true,
  826. recommendedPHPModules: [],
  827. pendingBigIntConversionColumns: [],
  828. isMysqlUsedWithoutUTF8MB4: false,
  829. isDefaultPhoneRegionSet: true,
  830. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  831. reverseProxyGeneratedURL: 'https://server',
  832. temporaryDirectoryWritable: true,
  833. })
  834. );
  835. async.done(function( data, s, x ){
  836. expect(data).toEqual([{
  837. msg: 'The PHP OPcache module is not properly configured. See the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-php-opcache">documentation ↗</a> for more information.<ul><li>recommendation1</li><li>recommendation2</li></ul>',
  838. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  839. }]);
  840. done();
  841. });
  842. });
  843. it('should return an info if server has no FreeType support', function(done) {
  844. var async = OC.SetupChecks.checkSetup();
  845. suite.server.requests[0].respond(
  846. 200,
  847. {
  848. 'Content-Type': 'application/json'
  849. },
  850. JSON.stringify({
  851. hasFileinfoInstalled: true,
  852. isGetenvServerWorking: true,
  853. isReadOnlyConfig: false,
  854. wasEmailTestSuccessful: true,
  855. hasWorkingFileLocking: true,
  856. hasValidTransactionIsolationLevel: true,
  857. suggestedOverwriteCliURL: '',
  858. isRandomnessSecure: true,
  859. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  860. isFairUseOfFreePushService: true,
  861. serverHasInternetConnectionProblems: false,
  862. isMemcacheConfigured: true,
  863. forwardedForHeadersWorking: true,
  864. isCorrectMemcachedPHPModuleInstalled: true,
  865. hasPassedCodeIntegrityCheck: true,
  866. OpcacheSetupRecommendations: [],
  867. isSettimelimitAvailable: true,
  868. hasFreeTypeSupport: false,
  869. missingIndexes: [],
  870. missingPrimaryKeys: [],
  871. missingColumns: [],
  872. cronErrors: [],
  873. cronInfo: {
  874. diffInSeconds: 0
  875. },
  876. isMemoryLimitSufficient: true,
  877. appDirsWithDifferentOwner: [],
  878. isImagickEnabled: true,
  879. areWebauthnExtensionsEnabled: true,
  880. recommendedPHPModules: [],
  881. pendingBigIntConversionColumns: [],
  882. isMysqlUsedWithoutUTF8MB4: false,
  883. isDefaultPhoneRegionSet: true,
  884. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  885. reverseProxyGeneratedURL: 'https://server',
  886. temporaryDirectoryWritable: true,
  887. })
  888. );
  889. async.done(function( data, s, x ){
  890. expect(data).toEqual([{
  891. msg: 'Your PHP does not have FreeType support, resulting in breakage of profile pictures and the settings interface.',
  892. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  893. }]);
  894. done();
  895. });
  896. });
  897. it('should return an error if the php version is no longer supported', function(done) {
  898. var async = OC.SetupChecks.checkSetup();
  899. suite.server.requests[0].respond(
  900. 200,
  901. {
  902. 'Content-Type': 'application/json',
  903. },
  904. JSON.stringify({
  905. hasFileinfoInstalled: true,
  906. isGetenvServerWorking: true,
  907. isReadOnlyConfig: false,
  908. wasEmailTestSuccessful: true,
  909. hasWorkingFileLocking: true,
  910. hasValidTransactionIsolationLevel: true,
  911. suggestedOverwriteCliURL: '',
  912. isRandomnessSecure: true,
  913. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  914. isFairUseOfFreePushService: true,
  915. serverHasInternetConnectionProblems: false,
  916. isMemcacheConfigured: true,
  917. forwardedForHeadersWorking: true,
  918. isCorrectMemcachedPHPModuleInstalled: true,
  919. hasPassedCodeIntegrityCheck: true,
  920. OpcacheSetupRecommendations: [],
  921. isSettimelimitAvailable: true,
  922. hasFreeTypeSupport: true,
  923. missingIndexes: [],
  924. missingPrimaryKeys: [],
  925. missingColumns: [],
  926. cronErrors: [],
  927. cronInfo: {
  928. diffInSeconds: 0
  929. },
  930. isMemoryLimitSufficient: true,
  931. appDirsWithDifferentOwner: [],
  932. isImagickEnabled: true,
  933. areWebauthnExtensionsEnabled: true,
  934. recommendedPHPModules: [],
  935. pendingBigIntConversionColumns: [],
  936. isMysqlUsedWithoutUTF8MB4: true,
  937. isDefaultPhoneRegionSet: true,
  938. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  939. reverseProxyGeneratedURL: 'https://server',
  940. temporaryDirectoryWritable: true,
  941. })
  942. );
  943. async.done(function( data, s, x ){
  944. expect(data).toEqual([{
  945. msg: 'MySQL is used as database but does not support 4-byte characters. To be able to handle 4-byte characters (like emojis) without issues in filenames or comments for example it is recommended to enable the 4-byte support in MySQL. For further details read <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-mysql-utf8mb4">the documentation page about this ↗</a>.',
  946. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  947. }]);
  948. done();
  949. });
  950. });
  951. // THe following test is invalid as the code in core/js/setupchecks.js is calling
  952. // window.location.protocol which always return http during tests
  953. // if there is a way to trick window.location.protocol during test, then we could re-activate it
  954. /*
  955. it('should return an error if the protocol is https but the server generates http links', function(done) {
  956. var async = OC.SetupChecks.checkSetup();
  957. suite.server.requests[0].respond(
  958. 200,
  959. {
  960. 'Content-Type': 'application/json',
  961. },
  962. JSON.stringify({
  963. hasFileinfoInstalled: true,
  964. isGetenvServerWorking: true,
  965. isReadOnlyConfig: false,
  966. wasEmailTestSuccessful: true,
  967. hasWorkingFileLocking: true,
  968. hasValidTransactionIsolationLevel: true,
  969. suggestedOverwriteCliURL: '',
  970. isRandomnessSecure: true,
  971. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  972. isFairUseOfFreePushService: true,
  973. serverHasInternetConnectionProblems: false,
  974. isMemcacheConfigured: true,
  975. forwardedForHeadersWorking: true,
  976. isCorrectMemcachedPHPModuleInstalled: true,
  977. hasPassedCodeIntegrityCheck: true,
  978. OpcacheSetupRecommendations: [],
  979. isSettimelimitAvailable: true,
  980. hasFreeTypeSupport: true,
  981. missingIndexes: [],
  982. missingPrimaryKeys: [],
  983. missingColumns: [],
  984. cronErrors: [],
  985. cronInfo: {
  986. diffInSeconds: 0
  987. },
  988. isMemoryLimitSufficient: true,
  989. appDirsWithDifferentOwner: [],
  990. isImagickEnabled: true,
  991. areWebauthnExtensionsEnabled: true,
  992. recommendedPHPModules: [],
  993. pendingBigIntConversionColumns: [],
  994. isMysqlUsedWithoutUTF8MB4: false,
  995. isDefaultPhoneRegionSet: true,
  996. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  997. reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
  998. reverseProxyGeneratedURL: 'http://server',
  999. temporaryDirectoryWritable: true,
  1000. })
  1001. );
  1002. async.done(function( data, s, x ){
  1003. expect(data).toEqual([{
  1004. msg: 'You are accessing your instance over a secure connection, however your instance is generating insecure URLs. This most likely means that you are behind a reverse proxy and the overwrite config variables are not set correctly. Please read <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.nextcloud.com/foo/bar.html">the documentation page about this ↗</a>.',
  1005. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1006. }]);
  1007. done();
  1008. });
  1009. });
  1010. */
  1011. it('should not return an error if the protocol is http and the server generates http links', function(done) {
  1012. var async = OC.SetupChecks.checkSetup();
  1013. suite.server.requests[0].respond(
  1014. 200,
  1015. {
  1016. 'Content-Type': 'application/json',
  1017. },
  1018. JSON.stringify({
  1019. hasFileinfoInstalled: true,
  1020. isGetenvServerWorking: true,
  1021. isReadOnlyConfig: false,
  1022. wasEmailTestSuccessful: true,
  1023. hasWorkingFileLocking: true,
  1024. hasValidTransactionIsolationLevel: true,
  1025. suggestedOverwriteCliURL: '',
  1026. isRandomnessSecure: true,
  1027. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  1028. isFairUseOfFreePushService: true,
  1029. serverHasInternetConnectionProblems: false,
  1030. isMemcacheConfigured: true,
  1031. forwardedForHeadersWorking: true,
  1032. isCorrectMemcachedPHPModuleInstalled: true,
  1033. hasPassedCodeIntegrityCheck: true,
  1034. OpcacheSetupRecommendations: [],
  1035. isSettimelimitAvailable: true,
  1036. hasFreeTypeSupport: true,
  1037. missingIndexes: [],
  1038. missingPrimaryKeys: [],
  1039. missingColumns: [],
  1040. cronErrors: [],
  1041. cronInfo: {
  1042. diffInSeconds: 0
  1043. },
  1044. isMemoryLimitSufficient: true,
  1045. appDirsWithDifferentOwner: [],
  1046. isImagickEnabled: true,
  1047. areWebauthnExtensionsEnabled: true,
  1048. recommendedPHPModules: [],
  1049. pendingBigIntConversionColumns: [],
  1050. isMysqlUsedWithoutUTF8MB4: false,
  1051. isDefaultPhoneRegionSet: true,
  1052. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  1053. reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
  1054. reverseProxyGeneratedURL: 'http://server',
  1055. temporaryDirectoryWritable: true,
  1056. })
  1057. );
  1058. async.done(function( data, s, x ){
  1059. expect(data).toEqual([]);
  1060. done();
  1061. });
  1062. });
  1063. it('should return an error if there is not enough free space in the temp directory', function(done) {
  1064. var async = OC.SetupChecks.checkSetup();
  1065. suite.server.requests[0].respond(
  1066. 200,
  1067. {
  1068. 'Content-Type': 'application/json',
  1069. },
  1070. JSON.stringify({
  1071. hasFileinfoInstalled: true,
  1072. isGetenvServerWorking: true,
  1073. isReadOnlyConfig: false,
  1074. wasEmailTestSuccessful: true,
  1075. hasWorkingFileLocking: true,
  1076. hasValidTransactionIsolationLevel: true,
  1077. suggestedOverwriteCliURL: '',
  1078. isRandomnessSecure: true,
  1079. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  1080. isFairUseOfFreePushService: true,
  1081. serverHasInternetConnectionProblems: false,
  1082. isMemcacheConfigured: true,
  1083. forwardedForHeadersWorking: true,
  1084. isCorrectMemcachedPHPModuleInstalled: true,
  1085. hasPassedCodeIntegrityCheck: true,
  1086. OpcacheSetupRecommendations: [],
  1087. isSettimelimitAvailable: true,
  1088. hasFreeTypeSupport: true,
  1089. missingIndexes: [],
  1090. missingPrimaryKeys: [],
  1091. missingColumns: [],
  1092. cronErrors: [],
  1093. cronInfo: {
  1094. diffInSeconds: 0
  1095. },
  1096. isMemoryLimitSufficient: true,
  1097. appDirsWithDifferentOwner: [],
  1098. isImagickEnabled: true,
  1099. areWebauthnExtensionsEnabled: true,
  1100. recommendedPHPModules: [],
  1101. pendingBigIntConversionColumns: [],
  1102. isMysqlUsedWithoutUTF8MB4: false,
  1103. isDefaultPhoneRegionSet: true,
  1104. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: false,
  1105. reverseProxyGeneratedURL: 'https://server',
  1106. temporaryDirectoryWritable: true,
  1107. })
  1108. );
  1109. async.done(function( data, s, x ){
  1110. expect(data).toEqual([{
  1111. msg: 'This instance uses an S3 based object store as primary storage. The uploaded files are stored temporarily on the server and thus it is recommended to have 50 GB of free space available in the temp directory of PHP. Check the logs for full details about the path and the available space. To improve this please change the temporary directory in the php.ini or make more space available in that path.',
  1112. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1113. }]);
  1114. done();
  1115. });
  1116. });
  1117. it('should return an error if imagick is not enabled', function(done) {
  1118. var async = OC.SetupChecks.checkSetup();
  1119. suite.server.requests[0].respond(
  1120. 200,
  1121. {
  1122. 'Content-Type': 'application/json',
  1123. },
  1124. JSON.stringify({
  1125. hasFileinfoInstalled: true,
  1126. isGetenvServerWorking: true,
  1127. isReadOnlyConfig: false,
  1128. wasEmailTestSuccessful: true,
  1129. hasWorkingFileLocking: true,
  1130. hasValidTransactionIsolationLevel: true,
  1131. suggestedOverwriteCliURL: '',
  1132. isRandomnessSecure: true,
  1133. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  1134. isFairUseOfFreePushService: true,
  1135. serverHasInternetConnectionProblems: false,
  1136. isMemcacheConfigured: true,
  1137. forwardedForHeadersWorking: true,
  1138. isCorrectMemcachedPHPModuleInstalled: true,
  1139. hasPassedCodeIntegrityCheck: true,
  1140. OpcacheSetupRecommendations: [],
  1141. isSettimelimitAvailable: true,
  1142. hasFreeTypeSupport: true,
  1143. missingIndexes: [],
  1144. missingPrimaryKeys: [],
  1145. missingColumns: [],
  1146. cronErrors: [],
  1147. cronInfo: {
  1148. diffInSeconds: 0
  1149. },
  1150. isMemoryLimitSufficient: true,
  1151. appDirsWithDifferentOwner: [],
  1152. isImagickEnabled: false,
  1153. areWebauthnExtensionsEnabled: true,
  1154. recommendedPHPModules: [],
  1155. pendingBigIntConversionColumns: [],
  1156. isMysqlUsedWithoutUTF8MB4: false,
  1157. isDefaultPhoneRegionSet: true,
  1158. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  1159. reverseProxyGeneratedURL: 'https://server',
  1160. temporaryDirectoryWritable: true,
  1161. })
  1162. );
  1163. async.done(function( data, s, x ){
  1164. expect(data).toEqual([{
  1165. msg: 'The PHP module "imagick" is not enabled although the theming app is. For favicon generation to work correctly, you need to install and enable this module.',
  1166. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  1167. }]);
  1168. done();
  1169. });
  1170. });
  1171. it('should return an error if gmp or bcmath are not enabled', function(done) {
  1172. var async = OC.SetupChecks.checkSetup();
  1173. suite.server.requests[0].respond(
  1174. 200,
  1175. {
  1176. 'Content-Type': 'application/json',
  1177. },
  1178. JSON.stringify({
  1179. hasFileinfoInstalled: true,
  1180. isGetenvServerWorking: true,
  1181. isReadOnlyConfig: false,
  1182. wasEmailTestSuccessful: true,
  1183. hasWorkingFileLocking: true,
  1184. hasValidTransactionIsolationLevel: true,
  1185. suggestedOverwriteCliURL: '',
  1186. isRandomnessSecure: true,
  1187. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  1188. isFairUseOfFreePushService: true,
  1189. serverHasInternetConnectionProblems: false,
  1190. isMemcacheConfigured: true,
  1191. forwardedForHeadersWorking: true,
  1192. isCorrectMemcachedPHPModuleInstalled: true,
  1193. hasPassedCodeIntegrityCheck: true,
  1194. OpcacheSetupRecommendations: [],
  1195. isSettimelimitAvailable: true,
  1196. hasFreeTypeSupport: true,
  1197. missingIndexes: [],
  1198. missingPrimaryKeys: [],
  1199. missingColumns: [],
  1200. cronErrors: [],
  1201. cronInfo: {
  1202. diffInSeconds: 0
  1203. },
  1204. isMemoryLimitSufficient: true,
  1205. appDirsWithDifferentOwner: [],
  1206. isImagickEnabled: true,
  1207. areWebauthnExtensionsEnabled: false,
  1208. recommendedPHPModules: [],
  1209. pendingBigIntConversionColumns: [],
  1210. isMysqlUsedWithoutUTF8MB4: false,
  1211. isDefaultPhoneRegionSet: true,
  1212. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  1213. reverseProxyGeneratedURL: 'https://server',
  1214. temporaryDirectoryWritable: true,
  1215. })
  1216. );
  1217. async.done(function( data, s, x ){
  1218. expect(data).toEqual([{
  1219. msg: 'The PHP modules "gmp" and/or "bcmath" are not enabled. If you use WebAuthn passwordless authentication, these modules are required.',
  1220. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  1221. }]);
  1222. done();
  1223. });
  1224. });
  1225. it('should return an info if there is no default phone region', function(done) {
  1226. var async = OC.SetupChecks.checkSetup();
  1227. suite.server.requests[0].respond(
  1228. 200,
  1229. {
  1230. 'Content-Type': 'application/json',
  1231. },
  1232. JSON.stringify({
  1233. hasFileinfoInstalled: true,
  1234. isGetenvServerWorking: true,
  1235. isReadOnlyConfig: false,
  1236. wasEmailTestSuccessful: true,
  1237. hasWorkingFileLocking: true,
  1238. hasValidTransactionIsolationLevel: true,
  1239. suggestedOverwriteCliURL: '',
  1240. isRandomnessSecure: true,
  1241. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  1242. isFairUseOfFreePushService: true,
  1243. serverHasInternetConnectionProblems: false,
  1244. isMemcacheConfigured: true,
  1245. forwardedForHeadersWorking: true,
  1246. isCorrectMemcachedPHPModuleInstalled: true,
  1247. hasPassedCodeIntegrityCheck: true,
  1248. OpcacheSetupRecommendations: [],
  1249. isSettimelimitAvailable: true,
  1250. hasFreeTypeSupport: true,
  1251. missingIndexes: [],
  1252. missingPrimaryKeys: [],
  1253. missingColumns: [],
  1254. cronErrors: [],
  1255. cronInfo: {
  1256. diffInSeconds: 0
  1257. },
  1258. isMemoryLimitSufficient: true,
  1259. appDirsWithDifferentOwner: [],
  1260. isImagickEnabled: true,
  1261. areWebauthnExtensionsEnabled: true,
  1262. recommendedPHPModules: [],
  1263. pendingBigIntConversionColumns: [],
  1264. isMysqlUsedWithoutUTF8MB4: false,
  1265. isDefaultPhoneRegionSet: false,
  1266. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  1267. reverseProxyGeneratedURL: 'https://server',
  1268. temporaryDirectoryWritable: true,
  1269. })
  1270. );
  1271. async.done(function( data, s, x ){
  1272. expect(data).toEqual([{
  1273. msg: 'Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add "default_phone_region" with the respective <a target="_blank" rel="noreferrer noopener" class="external" href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements">ISO 3166-1 code ↗</a> of the region to your config file.',
  1274. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  1275. }]);
  1276. done();
  1277. });
  1278. });
  1279. it('should return an info if the temporary directory is either non-existent or non-writable', function(done) {
  1280. var async = OC.SetupChecks.checkSetup();
  1281. suite.server.requests[0].respond(
  1282. 200,
  1283. {
  1284. 'Content-Type': 'application/json',
  1285. },
  1286. JSON.stringify({
  1287. hasFileinfoInstalled: true,
  1288. isGetenvServerWorking: true,
  1289. isReadOnlyConfig: false,
  1290. wasEmailTestSuccessful: true,
  1291. hasWorkingFileLocking: true,
  1292. hasValidTransactionIsolationLevel: true,
  1293. suggestedOverwriteCliURL: '',
  1294. isRandomnessSecure: true,
  1295. securityDocs: 'https://docs.nextcloud.com/myDocs.html',
  1296. isFairUseOfFreePushService: true,
  1297. serverHasInternetConnectionProblems: false,
  1298. isMemcacheConfigured: true,
  1299. forwardedForHeadersWorking: true,
  1300. isCorrectMemcachedPHPModuleInstalled: true,
  1301. hasPassedCodeIntegrityCheck: true,
  1302. OpcacheSetupRecommendations: [],
  1303. isSettimelimitAvailable: true,
  1304. hasFreeTypeSupport: true,
  1305. missingIndexes: [],
  1306. missingPrimaryKeys: [],
  1307. missingColumns: [],
  1308. cronErrors: [],
  1309. cronInfo: {
  1310. diffInSeconds: 0
  1311. },
  1312. isMemoryLimitSufficient: true,
  1313. appDirsWithDifferentOwner: [],
  1314. isImagickEnabled: true,
  1315. areWebauthnExtensionsEnabled: true,
  1316. recommendedPHPModules: [],
  1317. pendingBigIntConversionColumns: [],
  1318. isMysqlUsedWithoutUTF8MB4: false,
  1319. isDefaultPhoneRegionSet: true,
  1320. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
  1321. reverseProxyGeneratedURL: 'https://server',
  1322. temporaryDirectoryWritable: false,
  1323. })
  1324. );
  1325. async.done(function( data, s, x ){
  1326. expect(data).toEqual([{
  1327. msg: 'The temporary directory of this instance points to an either non-existing or non-writable directory.',
  1328. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1329. }]);
  1330. done();
  1331. });
  1332. });
  1333. });
  1334. describe('checkGeneric', function() {
  1335. it('should return an error if the response has no statuscode 200', function(done) {
  1336. var async = OC.SetupChecks.checkGeneric();
  1337. suite.server.requests[0].respond(
  1338. 500,
  1339. {
  1340. 'Content-Type': 'application/json'
  1341. }
  1342. );
  1343. async.done(function( data, s, x ){
  1344. expect(data).toEqual([{
  1345. msg: 'Error occurred while checking server setup',
  1346. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  1347. },{
  1348. msg: 'Error occurred while checking server setup',
  1349. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  1350. }]);
  1351. done();
  1352. });
  1353. });
  1354. it('should return all errors if all headers are missing', function(done) {
  1355. protocolStub.returns('https');
  1356. var async = OC.SetupChecks.checkGeneric();
  1357. suite.server.requests[0].respond(
  1358. 200,
  1359. {
  1360. 'Content-Type': 'application/json',
  1361. 'Strict-Transport-Security': 'max-age=15768000'
  1362. },
  1363. '{}'
  1364. );
  1365. async.done(function( data, s, x ){
  1366. expect(data).toEqual([
  1367. {
  1368. msg: 'The "X-Content-Type-Options" HTTP header is not set to "nosniff". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.',
  1369. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1370. }, {
  1371. msg: 'The "X-Robots-Tag" HTTP header is not set to "none". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.',
  1372. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1373. }, {
  1374. msg: 'The "X-Frame-Options" HTTP header is not set to "SAMEORIGIN". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.',
  1375. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1376. }, {
  1377. msg: 'The "X-Permitted-Cross-Domain-Policies" HTTP header is not set to "none". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.',
  1378. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1379. }, {
  1380. msg: 'The "X-XSS-Protection" HTTP header doesn\'t contain "1; mode=block". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.',
  1381. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1382. }, {
  1383. msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin", "strict-origin-when-cross-origin" or "same-origin". This can leak referer information. See the <a target="_blank" rel="noreferrer noopener" class="external" href="https://www.w3.org/TR/referrer-policy/">W3C Recommendation ↗</a>.',
  1384. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  1385. }
  1386. ]);
  1387. done();
  1388. });
  1389. });
  1390. it('should return only some errors if just some headers are missing', function(done) {
  1391. protocolStub.returns('https');
  1392. var async = OC.SetupChecks.checkGeneric();
  1393. suite.server.requests[0].respond(
  1394. 200,
  1395. {
  1396. 'X-Robots-Tag': 'none',
  1397. 'X-Frame-Options': 'SAMEORIGIN',
  1398. 'Strict-Transport-Security': 'max-age=15768000;preload',
  1399. 'X-Permitted-Cross-Domain-Policies': 'none',
  1400. 'Referrer-Policy': 'no-referrer',
  1401. }
  1402. );
  1403. async.done(function( data, s, x ){
  1404. expect(data).toEqual([
  1405. {
  1406. msg: 'The "X-Content-Type-Options" HTTP header is not set to "nosniff". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.',
  1407. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1408. }, {
  1409. msg: 'The "X-XSS-Protection" HTTP header doesn\'t contain "1; mode=block". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.',
  1410. type: OC.SetupChecks.MESSAGE_TYPE_WARNING,
  1411. }
  1412. ]);
  1413. done();
  1414. });
  1415. });
  1416. it('should return none errors if all headers are there', function(done) {
  1417. protocolStub.returns('https');
  1418. var async = OC.SetupChecks.checkGeneric();
  1419. suite.server.requests[0].respond(
  1420. 200,
  1421. {
  1422. 'X-XSS-Protection': '1; mode=block',
  1423. 'X-Content-Type-Options': 'nosniff',
  1424. 'X-Robots-Tag': 'none',
  1425. 'X-Frame-Options': 'SAMEORIGIN',
  1426. 'Strict-Transport-Security': 'max-age=15768000',
  1427. 'X-Permitted-Cross-Domain-Policies': 'none',
  1428. 'Referrer-Policy': 'no-referrer'
  1429. }
  1430. );
  1431. async.done(function( data, s, x ){
  1432. expect(data).toEqual([]);
  1433. done();
  1434. });
  1435. });
  1436. describe('check X-XSS-Protection header', function() {
  1437. it('should return no message if X-XSS-Protection is set to 1; mode=block; report=https://example.com', function(done) {
  1438. protocolStub.returns('https');
  1439. var result = OC.SetupChecks.checkGeneric();
  1440. suite.server.requests[0].respond(200, {
  1441. 'Strict-Transport-Security': 'max-age=15768000',
  1442. 'X-XSS-Protection': '1; mode=block; report=https://example.com',
  1443. 'X-Content-Type-Options': 'nosniff',
  1444. 'X-Robots-Tag': 'none',
  1445. 'X-Frame-Options': 'SAMEORIGIN',
  1446. 'X-Permitted-Cross-Domain-Policies': 'none',
  1447. 'Referrer-Policy': 'no-referrer',
  1448. });
  1449. result.done(function( data, s, x ){
  1450. expect(data).toEqual([]);
  1451. done();
  1452. });
  1453. });
  1454. it('should return no message if X-XSS-Protection is set to 1; mode=block', function(done) {
  1455. protocolStub.returns('https');
  1456. var result = OC.SetupChecks.checkGeneric();
  1457. suite.server.requests[0].respond(200, {
  1458. 'Strict-Transport-Security': 'max-age=15768000',
  1459. 'X-XSS-Protection': '1; mode=block',
  1460. 'X-Content-Type-Options': 'nosniff',
  1461. 'X-Robots-Tag': 'none',
  1462. 'X-Frame-Options': 'SAMEORIGIN',
  1463. 'X-Permitted-Cross-Domain-Policies': 'none',
  1464. 'Referrer-Policy': 'no-referrer',
  1465. });
  1466. result.done(function( data, s, x ){
  1467. expect(data).toEqual([]);
  1468. done();
  1469. });
  1470. });
  1471. it('should return a message if X-XSS-Protection is set to 1', function(done) {
  1472. protocolStub.returns('https');
  1473. var result = OC.SetupChecks.checkGeneric();
  1474. suite.server.requests[0].respond(200, {
  1475. 'Strict-Transport-Security': 'max-age=15768000',
  1476. 'X-XSS-Protection': '1',
  1477. 'X-Content-Type-Options': 'nosniff',
  1478. 'X-Robots-Tag': 'none',
  1479. 'X-Frame-Options': 'SAMEORIGIN',
  1480. 'X-Permitted-Cross-Domain-Policies': 'none',
  1481. 'Referrer-Policy': 'no-referrer',
  1482. });
  1483. result.done(function( data, s, x ){
  1484. expect(data).toEqual([
  1485. {
  1486. msg: 'The "X-XSS-Protection" HTTP header doesn\'t contain "1; mode=block". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.',
  1487. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1488. }
  1489. ]);
  1490. done();
  1491. });
  1492. });
  1493. it('should return a message if X-XSS-Protection is set to 0', function(done) {
  1494. protocolStub.returns('https');
  1495. var result = OC.SetupChecks.checkGeneric();
  1496. suite.server.requests[0].respond(200, {
  1497. 'Strict-Transport-Security': 'max-age=15768000',
  1498. 'X-XSS-Protection': '0',
  1499. 'X-Content-Type-Options': 'nosniff',
  1500. 'X-Robots-Tag': 'none',
  1501. 'X-Frame-Options': 'SAMEORIGIN',
  1502. 'X-Permitted-Cross-Domain-Policies': 'none',
  1503. 'Referrer-Policy': 'no-referrer',
  1504. });
  1505. result.done(function( data, s, x ){
  1506. expect(data).toEqual([
  1507. {
  1508. msg: 'The "X-XSS-Protection" HTTP header doesn\'t contain "1; mode=block". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.',
  1509. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1510. }
  1511. ]);
  1512. done();
  1513. });
  1514. });
  1515. });
  1516. describe('check Referrer-Policy header', function() {
  1517. it('should return no message if Referrer-Policy is set to no-referrer', function(done) {
  1518. protocolStub.returns('https');
  1519. var result = OC.SetupChecks.checkGeneric();
  1520. suite.server.requests[0].respond(200, {
  1521. 'Strict-Transport-Security': 'max-age=15768000',
  1522. 'X-XSS-Protection': '1; mode=block',
  1523. 'X-Content-Type-Options': 'nosniff',
  1524. 'X-Robots-Tag': 'none',
  1525. 'X-Frame-Options': 'SAMEORIGIN',
  1526. 'X-Permitted-Cross-Domain-Policies': 'none',
  1527. 'Referrer-Policy': 'no-referrer',
  1528. });
  1529. result.done(function( data, s, x ){
  1530. expect(data).toEqual([]);
  1531. done();
  1532. });
  1533. });
  1534. it('should return no message if Referrer-Policy is set to no-referrer-when-downgrade', function(done) {
  1535. protocolStub.returns('https');
  1536. var result = OC.SetupChecks.checkGeneric();
  1537. suite.server.requests[0].respond(200, {
  1538. 'Strict-Transport-Security': 'max-age=15768000',
  1539. 'X-XSS-Protection': '1; mode=block',
  1540. 'X-Content-Type-Options': 'nosniff',
  1541. 'X-Robots-Tag': 'none',
  1542. 'X-Frame-Options': 'SAMEORIGIN',
  1543. 'X-Permitted-Cross-Domain-Policies': 'none',
  1544. 'Referrer-Policy': 'no-referrer-when-downgrade',
  1545. });
  1546. result.done(function( data, s, x ){
  1547. expect(data).toEqual([]);
  1548. done();
  1549. });
  1550. });
  1551. it('should return no message if Referrer-Policy is set to strict-origin', function(done) {
  1552. protocolStub.returns('https');
  1553. var result = OC.SetupChecks.checkGeneric();
  1554. suite.server.requests[0].respond(200, {
  1555. 'Strict-Transport-Security': 'max-age=15768000',
  1556. 'X-XSS-Protection': '1; mode=block',
  1557. 'X-Content-Type-Options': 'nosniff',
  1558. 'X-Robots-Tag': 'none',
  1559. 'X-Frame-Options': 'SAMEORIGIN',
  1560. 'X-Permitted-Cross-Domain-Policies': 'none',
  1561. 'Referrer-Policy': 'strict-origin',
  1562. });
  1563. result.done(function( data, s, x ){
  1564. expect(data).toEqual([]);
  1565. done();
  1566. });
  1567. });
  1568. it('should return no message if Referrer-Policy is set to strict-origin-when-cross-origin', function(done) {
  1569. protocolStub.returns('https');
  1570. var result = OC.SetupChecks.checkGeneric();
  1571. suite.server.requests[0].respond(200, {
  1572. 'Strict-Transport-Security': 'max-age=15768000',
  1573. 'X-XSS-Protection': '1; mode=block',
  1574. 'X-Content-Type-Options': 'nosniff',
  1575. 'X-Robots-Tag': 'none',
  1576. 'X-Frame-Options': 'SAMEORIGIN',
  1577. 'X-Permitted-Cross-Domain-Policies': 'none',
  1578. 'Referrer-Policy': 'strict-origin-when-cross-origin',
  1579. });
  1580. result.done(function( data, s, x ){
  1581. expect(data).toEqual([]);
  1582. done();
  1583. });
  1584. });
  1585. it('should return no message if Referrer-Policy is set to same-origin', function(done) {
  1586. protocolStub.returns('https');
  1587. var result = OC.SetupChecks.checkGeneric();
  1588. suite.server.requests[0].respond(200, {
  1589. 'Strict-Transport-Security': 'max-age=15768000',
  1590. 'X-XSS-Protection': '1; mode=block',
  1591. 'X-Content-Type-Options': 'nosniff',
  1592. 'X-Robots-Tag': 'none',
  1593. 'X-Frame-Options': 'SAMEORIGIN',
  1594. 'X-Permitted-Cross-Domain-Policies': 'none',
  1595. 'Referrer-Policy': 'same-origin',
  1596. });
  1597. result.done(function( data, s, x ){
  1598. expect(data).toEqual([]);
  1599. done();
  1600. });
  1601. });
  1602. it('should return a message if Referrer-Policy is set to origin', function(done) {
  1603. protocolStub.returns('https');
  1604. var result = OC.SetupChecks.checkGeneric();
  1605. suite.server.requests[0].respond(200, {
  1606. 'Strict-Transport-Security': 'max-age=15768000',
  1607. 'X-XSS-Protection': '1; mode=block',
  1608. 'X-Content-Type-Options': 'nosniff',
  1609. 'X-Robots-Tag': 'none',
  1610. 'X-Frame-Options': 'SAMEORIGIN',
  1611. 'X-Permitted-Cross-Domain-Policies': 'none',
  1612. 'Referrer-Policy': 'origin',
  1613. });
  1614. result.done(function( data, s, x ){
  1615. expect(data).toEqual([
  1616. {
  1617. msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin", "strict-origin-when-cross-origin" or "same-origin". This can leak referer information. See the <a target="_blank" rel="noreferrer noopener" class="external" href="https://www.w3.org/TR/referrer-policy/">W3C Recommendation ↗</a>.',
  1618. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  1619. }
  1620. ]);
  1621. done();
  1622. });
  1623. });
  1624. it('should return a message if Referrer-Policy is set to origin-when-cross-origin', function(done) {
  1625. protocolStub.returns('https');
  1626. var result = OC.SetupChecks.checkGeneric();
  1627. suite.server.requests[0].respond(200, {
  1628. 'Strict-Transport-Security': 'max-age=15768000',
  1629. 'X-XSS-Protection': '1; mode=block',
  1630. 'X-Content-Type-Options': 'nosniff',
  1631. 'X-Robots-Tag': 'none',
  1632. 'X-Frame-Options': 'SAMEORIGIN',
  1633. 'X-Permitted-Cross-Domain-Policies': 'none',
  1634. 'Referrer-Policy': 'origin-when-cross-origin',
  1635. });
  1636. result.done(function( data, s, x ){
  1637. expect(data).toEqual([
  1638. {
  1639. msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin", "strict-origin-when-cross-origin" or "same-origin". This can leak referer information. See the <a target="_blank" rel="noreferrer noopener" class="external" href="https://www.w3.org/TR/referrer-policy/">W3C Recommendation ↗</a>.',
  1640. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  1641. }
  1642. ]);
  1643. done();
  1644. });
  1645. });
  1646. it('should return a message if Referrer-Policy is set to unsafe-url', function(done) {
  1647. protocolStub.returns('https');
  1648. var result = OC.SetupChecks.checkGeneric();
  1649. suite.server.requests[0].respond(200, {
  1650. 'Strict-Transport-Security': 'max-age=15768000',
  1651. 'X-XSS-Protection': '1; mode=block',
  1652. 'X-Content-Type-Options': 'nosniff',
  1653. 'X-Robots-Tag': 'none',
  1654. 'X-Frame-Options': 'SAMEORIGIN',
  1655. 'X-Permitted-Cross-Domain-Policies': 'none',
  1656. 'Referrer-Policy': 'unsafe-url',
  1657. });
  1658. result.done(function( data, s, x ){
  1659. expect(data).toEqual([
  1660. {
  1661. msg: 'The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin", "strict-origin-when-cross-origin" or "same-origin". This can leak referer information. See the <a target="_blank" rel="noreferrer noopener" class="external" href="https://www.w3.org/TR/referrer-policy/">W3C Recommendation ↗</a>.',
  1662. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  1663. }
  1664. ]);
  1665. done();
  1666. });
  1667. });
  1668. });
  1669. });
  1670. it('should return a SSL warning if HTTPS is not used', function(done) {
  1671. protocolStub.returns('http');
  1672. var async = OC.SetupChecks.checkGeneric();
  1673. suite.server.requests[0].respond(200,
  1674. {
  1675. 'X-XSS-Protection': '1; mode=block',
  1676. 'X-Content-Type-Options': 'nosniff',
  1677. 'X-Robots-Tag': 'none',
  1678. 'X-Frame-Options': 'SAMEORIGIN',
  1679. 'X-Permitted-Cross-Domain-Policies': 'none',
  1680. 'Referrer-Policy': 'no-referrer',
  1681. }
  1682. );
  1683. async.done(function( data, s, x ){
  1684. expect(data).toEqual([{
  1685. msg: 'Accessing site insecurely via HTTP. You are strongly advised to set up your server to require HTTPS instead, as described in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-security">security tips ↗</a>.',
  1686. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1687. }]);
  1688. done();
  1689. });
  1690. });
  1691. it('should return an error if the response has no statuscode 200', function(done) {
  1692. var async = OC.SetupChecks.checkGeneric();
  1693. suite.server.requests[0].respond(
  1694. 500,
  1695. {
  1696. 'Content-Type': 'application/json'
  1697. },
  1698. JSON.stringify({data: {serverHasInternetConnectionProblems: true}})
  1699. );
  1700. async.done(function( data, s, x ){
  1701. expect(data).toEqual([{
  1702. msg: 'Error occurred while checking server setup',
  1703. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  1704. }, {
  1705. msg: 'Error occurred while checking server setup',
  1706. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  1707. }]);
  1708. done();
  1709. });
  1710. });
  1711. it('should return a SSL warning if SSL used without Strict-Transport-Security-Header', function(done) {
  1712. protocolStub.returns('https');
  1713. var async = OC.SetupChecks.checkGeneric();
  1714. suite.server.requests[0].respond(200,
  1715. {
  1716. 'X-XSS-Protection': '1; mode=block',
  1717. 'X-Content-Type-Options': 'nosniff',
  1718. 'X-Robots-Tag': 'none',
  1719. 'X-Frame-Options': 'SAMEORIGIN',
  1720. 'X-Permitted-Cross-Domain-Policies': 'none',
  1721. 'Referrer-Policy': 'no-referrer',
  1722. }
  1723. );
  1724. async.done(function( data, s, x ){
  1725. expect(data).toEqual([{
  1726. msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-security">security tips ↗</a>.',
  1727. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1728. }]);
  1729. done();
  1730. });
  1731. });
  1732. it('should return a SSL warning if SSL used with to small Strict-Transport-Security-Header', function(done) {
  1733. protocolStub.returns('https');
  1734. var async = OC.SetupChecks.checkGeneric();
  1735. suite.server.requests[0].respond(200,
  1736. {
  1737. 'Strict-Transport-Security': 'max-age=15551999',
  1738. 'X-XSS-Protection': '1; mode=block',
  1739. 'X-Content-Type-Options': 'nosniff',
  1740. 'X-Robots-Tag': 'none',
  1741. 'X-Frame-Options': 'SAMEORIGIN',
  1742. 'X-Permitted-Cross-Domain-Policies': 'none',
  1743. 'Referrer-Policy': 'no-referrer',
  1744. }
  1745. );
  1746. async.done(function( data, s, x ){
  1747. expect(data).toEqual([{
  1748. msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-security">security tips ↗</a>.',
  1749. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1750. }]);
  1751. done();
  1752. });
  1753. });
  1754. it('should return a SSL warning if SSL used with to a bogus Strict-Transport-Security-Header', function(done) {
  1755. protocolStub.returns('https');
  1756. var async = OC.SetupChecks.checkGeneric();
  1757. suite.server.requests[0].respond(200,
  1758. {
  1759. 'Strict-Transport-Security': 'iAmABogusHeader342',
  1760. 'X-XSS-Protection': '1; mode=block',
  1761. 'X-Content-Type-Options': 'nosniff',
  1762. 'X-Robots-Tag': 'none',
  1763. 'X-Frame-Options': 'SAMEORIGIN',
  1764. 'X-Permitted-Cross-Domain-Policies': 'none',
  1765. 'Referrer-Policy': 'no-referrer',
  1766. }
  1767. );
  1768. async.done(function( data, s, x ){
  1769. expect(data).toEqual([{
  1770. msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-security">security tips ↗</a>.',
  1771. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1772. }]);
  1773. done();
  1774. });
  1775. });
  1776. it('should return no SSL warning if SSL used with to exact the minimum Strict-Transport-Security-Header', function(done) {
  1777. protocolStub.returns('https');
  1778. var async = OC.SetupChecks.checkGeneric();
  1779. suite.server.requests[0].respond(200, {
  1780. 'Strict-Transport-Security': 'max-age=15768000',
  1781. 'X-XSS-Protection': '1; mode=block',
  1782. 'X-Content-Type-Options': 'nosniff',
  1783. 'X-Robots-Tag': 'none',
  1784. 'X-Frame-Options': 'SAMEORIGIN',
  1785. 'X-Permitted-Cross-Domain-Policies': 'none',
  1786. 'Referrer-Policy': 'no-referrer',
  1787. });
  1788. async.done(function( data, s, x ){
  1789. expect(data).toEqual([]);
  1790. done();
  1791. });
  1792. });
  1793. it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header', function(done) {
  1794. protocolStub.returns('https');
  1795. var async = OC.SetupChecks.checkGeneric();
  1796. suite.server.requests[0].respond(200, {
  1797. 'Strict-Transport-Security': 'max-age=99999999',
  1798. 'X-XSS-Protection': '1; mode=block',
  1799. 'X-Content-Type-Options': 'nosniff',
  1800. 'X-Robots-Tag': 'none',
  1801. 'X-Frame-Options': 'SAMEORIGIN',
  1802. 'X-Permitted-Cross-Domain-Policies': 'none',
  1803. 'Referrer-Policy': 'no-referrer',
  1804. });
  1805. async.done(function( data, s, x ){
  1806. expect(data).toEqual([]);
  1807. done();
  1808. });
  1809. });
  1810. it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header and includeSubDomains parameter', function(done) {
  1811. protocolStub.returns('https');
  1812. var async = OC.SetupChecks.checkGeneric();
  1813. suite.server.requests[0].respond(200, {
  1814. 'Strict-Transport-Security': 'max-age=99999999; includeSubDomains',
  1815. 'X-XSS-Protection': '1; mode=block',
  1816. 'X-Content-Type-Options': 'nosniff',
  1817. 'X-Robots-Tag': 'none',
  1818. 'X-Frame-Options': 'SAMEORIGIN',
  1819. 'X-Permitted-Cross-Domain-Policies': 'none',
  1820. 'Referrer-Policy': 'no-referrer',
  1821. });
  1822. async.done(function( data, s, x ){
  1823. expect(data).toEqual([]);
  1824. done();
  1825. });
  1826. });
  1827. it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header and includeSubDomains and preload parameter', function(done) {
  1828. protocolStub.returns('https');
  1829. var async = OC.SetupChecks.checkGeneric();
  1830. suite.server.requests[0].respond(200, {
  1831. 'Strict-Transport-Security': 'max-age=99999999; preload; includeSubDomains',
  1832. 'X-XSS-Protection': '1; mode=block',
  1833. 'X-Content-Type-Options': 'nosniff',
  1834. 'X-Robots-Tag': 'none',
  1835. 'X-Frame-Options': 'SAMEORIGIN',
  1836. 'X-Permitted-Cross-Domain-Policies': 'none',
  1837. 'Referrer-Policy': 'no-referrer',
  1838. });
  1839. async.done(function( data, s, x ){
  1840. expect(data).toEqual([]);
  1841. done();
  1842. });
  1843. });
  1844. });