setupchecksSpec.js 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595
  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('/.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 href="http://example.org/admin-setup-well-known-URL" rel="noreferrer noopener">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('/.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('/.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('/.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 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.',
  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 href="http://example.org/admin-nginx" rel="noreferrer noopener">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. hasWorkingFileLocking: true,
  179. hasValidTransactionIsolationLevel: true,
  180. suggestedOverwriteCliURL: '',
  181. isRandomnessSecure: true,
  182. serverHasInternetConnection: false,
  183. memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance',
  184. forwardedForHeadersWorking: true,
  185. isCorrectMemcachedPHPModuleInstalled: true,
  186. hasPassedCodeIntegrityCheck: true,
  187. isOpcacheProperlySetup: true,
  188. hasOpcacheLoaded: true,
  189. isSettimelimitAvailable: true,
  190. hasFreeTypeSupport: true,
  191. missingIndexes: [],
  192. cronErrors: [],
  193. cronInfo: {
  194. diffInSeconds: 0
  195. },
  196. isMemoryLimitSufficient: true,
  197. appDirsWithDifferentOwner: [],
  198. recommendedPHPModules: [],
  199. pendingBigIntConversionColumns: [],
  200. isMysqlUsedWithoutUTF8MB4: false,
  201. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  202. })
  203. );
  204. async.done(function( data, s, x ){
  205. expect(data).toEqual([
  206. {
  207. 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.',
  208. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  209. }, {
  210. msg: 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the <a href="https://docs.nextcloud.com/server/go.php?to=admin-performance" rel="noreferrer noopener">documentation</a>.',
  211. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  212. }]);
  213. done();
  214. });
  215. });
  216. it('should return an error if server has no internet connection and data directory is not protected', function(done) {
  217. var async = OC.SetupChecks.checkSetup();
  218. suite.server.requests[0].respond(
  219. 200,
  220. {
  221. 'Content-Type': 'application/json'
  222. },
  223. JSON.stringify({
  224. hasFileinfoInstalled: true,
  225. isGetenvServerWorking: true,
  226. isReadOnlyConfig: false,
  227. hasWorkingFileLocking: true,
  228. hasValidTransactionIsolationLevel: true,
  229. suggestedOverwriteCliURL: '',
  230. isRandomnessSecure: true,
  231. serverHasInternetConnection: false,
  232. memcacheDocs: 'https://docs.nextcloud.com/server/go.php?to=admin-performance',
  233. forwardedForHeadersWorking: true,
  234. isCorrectMemcachedPHPModuleInstalled: true,
  235. hasPassedCodeIntegrityCheck: true,
  236. isOpcacheProperlySetup: true,
  237. hasOpcacheLoaded: true,
  238. isSettimelimitAvailable: true,
  239. hasFreeTypeSupport: true,
  240. missingIndexes: [],
  241. cronErrors: [],
  242. cronInfo: {
  243. diffInSeconds: 0
  244. },
  245. isMemoryLimitSufficient: true,
  246. appDirsWithDifferentOwner: [],
  247. recommendedPHPModules: [],
  248. pendingBigIntConversionColumns: [],
  249. isMysqlUsedWithoutUTF8MB4: false,
  250. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  251. })
  252. );
  253. async.done(function( data, s, x ){
  254. expect(data).toEqual([
  255. {
  256. 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.',
  257. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  258. },
  259. {
  260. msg: 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the <a href="https://docs.nextcloud.com/server/go.php?to=admin-performance" rel="noreferrer noopener">documentation</a>.',
  261. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  262. }]);
  263. done();
  264. });
  265. });
  266. it('should return an error if server has no internet connection and data directory is not protected and memcache is available', function(done) {
  267. var async = OC.SetupChecks.checkSetup();
  268. suite.server.requests[0].respond(
  269. 200,
  270. {
  271. 'Content-Type': 'application/json',
  272. },
  273. JSON.stringify({
  274. hasFileinfoInstalled: true,
  275. isGetenvServerWorking: true,
  276. isReadOnlyConfig: false,
  277. hasWorkingFileLocking: true,
  278. hasValidTransactionIsolationLevel: true,
  279. suggestedOverwriteCliURL: '',
  280. isRandomnessSecure: true,
  281. serverHasInternetConnection: false,
  282. isMemcacheConfigured: true,
  283. forwardedForHeadersWorking: true,
  284. isCorrectMemcachedPHPModuleInstalled: true,
  285. hasPassedCodeIntegrityCheck: true,
  286. isOpcacheProperlySetup: true,
  287. hasOpcacheLoaded: true,
  288. isSettimelimitAvailable: true,
  289. hasFreeTypeSupport: true,
  290. missingIndexes: [],
  291. cronErrors: [],
  292. cronInfo: {
  293. diffInSeconds: 0
  294. },
  295. isMemoryLimitSufficient: true,
  296. appDirsWithDifferentOwner: [],
  297. recommendedPHPModules: [],
  298. pendingBigIntConversionColumns: [],
  299. isMysqlUsedWithoutUTF8MB4: false,
  300. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  301. })
  302. );
  303. async.done(function( data, s, x ){
  304. expect(data).toEqual([
  305. {
  306. 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.',
  307. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  308. }
  309. ]);
  310. done();
  311. });
  312. });
  313. it('should return an error if /dev/urandom is not accessible', function(done) {
  314. var async = OC.SetupChecks.checkSetup();
  315. suite.server.requests[0].respond(
  316. 200,
  317. {
  318. 'Content-Type': 'application/json',
  319. },
  320. JSON.stringify({
  321. hasFileinfoInstalled: true,
  322. isGetenvServerWorking: true,
  323. isReadOnlyConfig: false,
  324. hasWorkingFileLocking: true,
  325. hasValidTransactionIsolationLevel: true,
  326. suggestedOverwriteCliURL: '',
  327. isRandomnessSecure: false,
  328. securityDocs: 'https://docs.owncloud.org/myDocs.html',
  329. serverHasInternetConnection: true,
  330. isMemcacheConfigured: true,
  331. forwardedForHeadersWorking: true,
  332. isCorrectMemcachedPHPModuleInstalled: true,
  333. hasPassedCodeIntegrityCheck: true,
  334. isOpcacheProperlySetup: true,
  335. hasOpcacheLoaded: true,
  336. isSettimelimitAvailable: true,
  337. hasFreeTypeSupport: true,
  338. missingIndexes: [],
  339. cronErrors: [],
  340. cronInfo: {
  341. diffInSeconds: 0
  342. },
  343. isMemoryLimitSufficient: true,
  344. appDirsWithDifferentOwner: [],
  345. recommendedPHPModules: [],
  346. pendingBigIntConversionColumns: [],
  347. isMysqlUsedWithoutUTF8MB4: false,
  348. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  349. })
  350. );
  351. async.done(function( data, s, x ){
  352. expect(data).toEqual([{
  353. msg: 'No suitable source for randomness found by PHP which is highly discouraged for security reasons. Further information can be found in the <a href="https://docs.owncloud.org/myDocs.html" rel="noreferrer noopener">documentation</a>.',
  354. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  355. }]);
  356. done();
  357. });
  358. });
  359. it('should return an error if the wrong memcache PHP module is installed', function(done) {
  360. var async = OC.SetupChecks.checkSetup();
  361. suite.server.requests[0].respond(
  362. 200,
  363. {
  364. 'Content-Type': 'application/json',
  365. },
  366. JSON.stringify({
  367. hasFileinfoInstalled: true,
  368. isGetenvServerWorking: true,
  369. isReadOnlyConfig: false,
  370. hasWorkingFileLocking: true,
  371. hasValidTransactionIsolationLevel: true,
  372. suggestedOverwriteCliURL: '',
  373. isRandomnessSecure: true,
  374. securityDocs: 'https://docs.owncloud.org/myDocs.html',
  375. serverHasInternetConnection: true,
  376. isMemcacheConfigured: true,
  377. forwardedForHeadersWorking: true,
  378. isCorrectMemcachedPHPModuleInstalled: false,
  379. hasPassedCodeIntegrityCheck: true,
  380. isOpcacheProperlySetup: true,
  381. hasOpcacheLoaded: true,
  382. isSettimelimitAvailable: true,
  383. hasFreeTypeSupport: true,
  384. missingIndexes: [],
  385. cronErrors: [],
  386. cronInfo: {
  387. diffInSeconds: 0
  388. },
  389. isMemoryLimitSufficient: true,
  390. appDirsWithDifferentOwner: [],
  391. recommendedPHPModules: [],
  392. pendingBigIntConversionColumns: [],
  393. isMysqlUsedWithoutUTF8MB4: false,
  394. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  395. })
  396. );
  397. async.done(function( data, s, x ){
  398. expect(data).toEqual([{
  399. 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 href="https://code.google.com/p/memcached/wiki/PHPClientComparison" rel="noreferrer noopener">memcached wiki about both modules</a>.',
  400. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  401. }]);
  402. done();
  403. });
  404. });
  405. it('should return a warning if there are app directories with wrong permissions', function(done) {
  406. var async = OC.SetupChecks.checkSetup();
  407. suite.server.requests[0].respond(
  408. 200,
  409. {
  410. 'Content-Type': 'application/json',
  411. },
  412. JSON.stringify({
  413. hasFileinfoInstalled: true,
  414. isGetenvServerWorking: true,
  415. isReadOnlyConfig: false,
  416. hasWorkingFileLocking: true,
  417. hasValidTransactionIsolationLevel: true,
  418. suggestedOverwriteCliURL: '',
  419. isRandomnessSecure: true,
  420. securityDocs: 'https://docs.owncloud.org/myDocs.html',
  421. serverHasInternetConnection: true,
  422. isMemcacheConfigured: true,
  423. forwardedForHeadersWorking: true,
  424. isCorrectMemcachedPHPModuleInstalled: true,
  425. hasPassedCodeIntegrityCheck: true,
  426. isOpcacheProperlySetup: true,
  427. hasOpcacheLoaded: true,
  428. isSettimelimitAvailable: true,
  429. hasFreeTypeSupport: true,
  430. missingIndexes: [],
  431. cronErrors: [],
  432. cronInfo: {
  433. diffInSeconds: 0
  434. },
  435. isMemoryLimitSufficient: true,
  436. appDirsWithDifferentOwner: [
  437. '/some/path'
  438. ],
  439. recommendedPHPModules: [],
  440. pendingBigIntConversionColumns: [],
  441. isMysqlUsedWithoutUTF8MB4: false,
  442. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  443. })
  444. );
  445. async.done(function( data, s, x ){
  446. expect(data).toEqual([{
  447. 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>',
  448. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  449. }]);
  450. done();
  451. });
  452. });
  453. it('should return an error if the forwarded for headers are not working', function(done) {
  454. var async = OC.SetupChecks.checkSetup();
  455. suite.server.requests[0].respond(
  456. 200,
  457. {
  458. 'Content-Type': 'application/json',
  459. },
  460. JSON.stringify({
  461. hasFileinfoInstalled: true,
  462. isGetenvServerWorking: true,
  463. isReadOnlyConfig: false,
  464. hasWorkingFileLocking: true,
  465. hasValidTransactionIsolationLevel: true,
  466. suggestedOverwriteCliURL: '',
  467. isRandomnessSecure: true,
  468. serverHasInternetConnection: true,
  469. isMemcacheConfigured: true,
  470. forwardedForHeadersWorking: false,
  471. reverseProxyDocs: 'https://docs.owncloud.org/foo/bar.html',
  472. isCorrectMemcachedPHPModuleInstalled: true,
  473. hasPassedCodeIntegrityCheck: true,
  474. isOpcacheProperlySetup: true,
  475. hasOpcacheLoaded: true,
  476. isSettimelimitAvailable: true,
  477. hasFreeTypeSupport: true,
  478. missingIndexes: [],
  479. cronErrors: [],
  480. cronInfo: {
  481. diffInSeconds: 0
  482. },
  483. isMemoryLimitSufficient: true,
  484. appDirsWithDifferentOwner: [],
  485. recommendedPHPModules: [],
  486. pendingBigIntConversionColumns: [],
  487. isMysqlUsedWithoutUTF8MB4: false,
  488. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  489. })
  490. );
  491. async.done(function( data, s, x ){
  492. expect(data).toEqual([{
  493. 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 href="https://docs.owncloud.org/foo/bar.html" rel="noreferrer noopener">documentation</a>.',
  494. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  495. }]);
  496. done();
  497. });
  498. });
  499. it('should return an error if set_time_limit is unavailable', 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. hasWorkingFileLocking: true,
  511. hasValidTransactionIsolationLevel: true,
  512. suggestedOverwriteCliURL: '',
  513. isRandomnessSecure: true,
  514. serverHasInternetConnection: true,
  515. isMemcacheConfigured: true,
  516. forwardedForHeadersWorking: true,
  517. reverseProxyDocs: 'https://docs.owncloud.org/foo/bar.html',
  518. isCorrectMemcachedPHPModuleInstalled: true,
  519. hasPassedCodeIntegrityCheck: true,
  520. isOpcacheProperlySetup: true,
  521. hasOpcacheLoaded: true,
  522. isSettimelimitAvailable: false,
  523. hasFreeTypeSupport: true,
  524. missingIndexes: [],
  525. cronErrors: [],
  526. cronInfo: {
  527. diffInSeconds: 0
  528. },
  529. isMemoryLimitSufficient: true,
  530. appDirsWithDifferentOwner: [],
  531. recommendedPHPModules: [],
  532. pendingBigIntConversionColumns: [],
  533. isMysqlUsedWithoutUTF8MB4: false,
  534. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  535. })
  536. );
  537. async.done(function( data, s, x ){
  538. expect(data).toEqual([{
  539. 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.',
  540. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  541. }]);
  542. done();
  543. });
  544. });
  545. it('should return a warning if the memory limit is below the recommended value', function(done) {
  546. var async = OC.SetupChecks.checkSetup();
  547. suite.server.requests[0].respond(
  548. 200,
  549. {
  550. 'Content-Type': 'application/json',
  551. },
  552. JSON.stringify({
  553. hasFileinfoInstalled: true,
  554. isGetenvServerWorking: true,
  555. isReadOnlyConfig: false,
  556. hasWorkingFileLocking: true,
  557. hasValidTransactionIsolationLevel: true,
  558. suggestedOverwriteCliURL: '',
  559. isRandomnessSecure: true,
  560. serverHasInternetConnection: true,
  561. isMemcacheConfigured: true,
  562. forwardedForHeadersWorking: true,
  563. reverseProxyDocs: 'https://docs.owncloud.org/foo/bar.html',
  564. isCorrectMemcachedPHPModuleInstalled: true,
  565. hasPassedCodeIntegrityCheck: true,
  566. isOpcacheProperlySetup: true,
  567. hasOpcacheLoaded: true,
  568. isSettimelimitAvailable: true,
  569. hasFreeTypeSupport: true,
  570. missingIndexes: [],
  571. cronErrors: [],
  572. cronInfo: {
  573. diffInSeconds: 0
  574. },
  575. isMemoryLimitSufficient: false,
  576. appDirsWithDifferentOwner: [],
  577. recommendedPHPModules: [],
  578. pendingBigIntConversionColumns: [],
  579. isMysqlUsedWithoutUTF8MB4: false,
  580. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  581. })
  582. );
  583. async.done(function( data, s, x ){
  584. expect(data).toEqual([{
  585. msg: 'The PHP memory limit is below the recommended value of 512MB.',
  586. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  587. }]);
  588. done();
  589. });
  590. });
  591. it('should return an error if the response has no statuscode 200', function(done) {
  592. var async = OC.SetupChecks.checkSetup();
  593. suite.server.requests[0].respond(
  594. 500,
  595. {
  596. 'Content-Type': 'application/json'
  597. },
  598. JSON.stringify({data: {serverHasInternetConnection: false}})
  599. );
  600. async.done(function( data, s, x ){
  601. expect(data).toEqual([{
  602. msg: 'Error occurred while checking server setup',
  603. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  604. }]);
  605. done();
  606. });
  607. });
  608. it('should return an error if the php version is no longer supported', function(done) {
  609. var async = OC.SetupChecks.checkSetup();
  610. suite.server.requests[0].respond(
  611. 200,
  612. {
  613. 'Content-Type': 'application/json',
  614. },
  615. JSON.stringify({
  616. hasFileinfoInstalled: true,
  617. isGetenvServerWorking: true,
  618. isReadOnlyConfig: false,
  619. hasWorkingFileLocking: true,
  620. hasValidTransactionIsolationLevel: true,
  621. suggestedOverwriteCliURL: '',
  622. isRandomnessSecure: true,
  623. securityDocs: 'https://docs.owncloud.org/myDocs.html',
  624. serverHasInternetConnection: true,
  625. isMemcacheConfigured: true,
  626. forwardedForHeadersWorking: true,
  627. phpSupported: {eol: true, version: '5.4.0'},
  628. isCorrectMemcachedPHPModuleInstalled: true,
  629. hasPassedCodeIntegrityCheck: true,
  630. isOpcacheProperlySetup: true,
  631. hasOpcacheLoaded: true,
  632. isSettimelimitAvailable: true,
  633. hasFreeTypeSupport: true,
  634. missingIndexes: [],
  635. cronErrors: [],
  636. cronInfo: {
  637. diffInSeconds: 0
  638. },
  639. isMemoryLimitSufficient: true,
  640. appDirsWithDifferentOwner: [],
  641. recommendedPHPModules: [],
  642. pendingBigIntConversionColumns: [],
  643. isMysqlUsedWithoutUTF8MB4: false,
  644. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  645. })
  646. );
  647. async.done(function( data, s, x ){
  648. expect(data).toEqual([{
  649. msg: 'You are currently running PHP 5.4.0. Upgrade your PHP version to take advantage of <a href="https://secure.php.net/supported-versions.php" rel="noreferrer noopener">performance and security updates provided by the PHP Group</a> as soon as your distribution supports it.',
  650. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  651. }]);
  652. done();
  653. });
  654. });
  655. it('should return an info if server has no proper opcache', function(done) {
  656. var async = OC.SetupChecks.checkSetup();
  657. suite.server.requests[0].respond(
  658. 200,
  659. {
  660. 'Content-Type': 'application/json'
  661. },
  662. JSON.stringify({
  663. hasFileinfoInstalled: true,
  664. isGetenvServerWorking: true,
  665. isReadOnlyConfig: false,
  666. hasWorkingFileLocking: true,
  667. hasValidTransactionIsolationLevel: true,
  668. suggestedOverwriteCliURL: '',
  669. isRandomnessSecure: true,
  670. securityDocs: 'https://docs.owncloud.org/myDocs.html',
  671. serverHasInternetConnection: true,
  672. isMemcacheConfigured: true,
  673. forwardedForHeadersWorking: true,
  674. isCorrectMemcachedPHPModuleInstalled: true,
  675. hasPassedCodeIntegrityCheck: true,
  676. isOpcacheProperlySetup: false,
  677. hasOpcacheLoaded: true,
  678. phpOpcacheDocumentation: 'https://example.org/link/to/doc',
  679. isSettimelimitAvailable: true,
  680. hasFreeTypeSupport: true,
  681. missingIndexes: [],
  682. cronErrors: [],
  683. cronInfo: {
  684. diffInSeconds: 0
  685. },
  686. isMemoryLimitSufficient: true,
  687. appDirsWithDifferentOwner: [],
  688. recommendedPHPModules: [],
  689. pendingBigIntConversionColumns: [],
  690. isMysqlUsedWithoutUTF8MB4: false,
  691. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  692. })
  693. );
  694. async.done(function( data, s, x ){
  695. expect(data).toEqual([{
  696. msg: 'The PHP OPcache is not properly configured. <a href="https://example.org/link/to/doc" rel="noreferrer noopener">For better performance it is recommended</a> to use the following settings in the <code>php.ini</code>:' + "<pre><code>opcache.enable=1\nopcache.interned_strings_buffer=8\nopcache.max_accelerated_files=10000\nopcache.memory_consumption=128\nopcache.save_comments=1\nopcache.revalidate_freq=1</code></pre>",
  697. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  698. }]);
  699. done();
  700. });
  701. });
  702. it('should return an info if server has no opcache at all', function(done) {
  703. var async = OC.SetupChecks.checkSetup();
  704. suite.server.requests[0].respond(
  705. 200,
  706. {
  707. 'Content-Type': 'application/json'
  708. },
  709. JSON.stringify({
  710. hasFileinfoInstalled: true,
  711. isGetenvServerWorking: true,
  712. isReadOnlyConfig: false,
  713. hasWorkingFileLocking: true,
  714. hasValidTransactionIsolationLevel: true,
  715. suggestedOverwriteCliURL: '',
  716. isRandomnessSecure: true,
  717. securityDocs: 'https://docs.owncloud.org/myDocs.html',
  718. serverHasInternetConnection: true,
  719. isMemcacheConfigured: true,
  720. forwardedForHeadersWorking: true,
  721. isCorrectMemcachedPHPModuleInstalled: true,
  722. hasPassedCodeIntegrityCheck: true,
  723. isOpcacheProperlySetup: true,
  724. hasOpcacheLoaded: false,
  725. phpOpcacheDocumentation: 'https://example.org/link/to/doc',
  726. isSettimelimitAvailable: true,
  727. hasFreeTypeSupport: true,
  728. missingIndexes: [],
  729. cronErrors: [],
  730. cronInfo: {
  731. diffInSeconds: 0
  732. },
  733. isMemoryLimitSufficient: true,
  734. appDirsWithDifferentOwner: [],
  735. recommendedPHPModules: [],
  736. pendingBigIntConversionColumns: [],
  737. isMysqlUsedWithoutUTF8MB4: false,
  738. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  739. })
  740. );
  741. async.done(function( data, s, x ){
  742. expect(data).toEqual([{
  743. msg: 'The PHP OPcache module is not loaded. <a href="https://example.org/link/to/doc" rel="noreferrer noopener">For better performance it is recommended</a> to load it into your PHP installation.',
  744. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  745. }]);
  746. done();
  747. });
  748. });
  749. it('should return an info if server has no FreeType support', function(done) {
  750. var async = OC.SetupChecks.checkSetup();
  751. suite.server.requests[0].respond(
  752. 200,
  753. {
  754. 'Content-Type': 'application/json'
  755. },
  756. JSON.stringify({
  757. hasFileinfoInstalled: true,
  758. isGetenvServerWorking: true,
  759. isReadOnlyConfig: false,
  760. hasWorkingFileLocking: true,
  761. hasValidTransactionIsolationLevel: true,
  762. suggestedOverwriteCliURL: '',
  763. isRandomnessSecure: true,
  764. securityDocs: 'https://docs.owncloud.org/myDocs.html',
  765. serverHasInternetConnection: true,
  766. isMemcacheConfigured: true,
  767. forwardedForHeadersWorking: true,
  768. isCorrectMemcachedPHPModuleInstalled: true,
  769. hasPassedCodeIntegrityCheck: true,
  770. isOpcacheProperlySetup: true,
  771. hasOpcacheLoaded: true,
  772. phpOpcacheDocumentation: 'https://example.org/link/to/doc',
  773. isSettimelimitAvailable: true,
  774. hasFreeTypeSupport: false,
  775. missingIndexes: [],
  776. cronErrors: [],
  777. cronInfo: {
  778. diffInSeconds: 0
  779. },
  780. isMemoryLimitSufficient: true,
  781. appDirsWithDifferentOwner: [],
  782. recommendedPHPModules: [],
  783. pendingBigIntConversionColumns: [],
  784. isMysqlUsedWithoutUTF8MB4: false,
  785. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  786. })
  787. );
  788. async.done(function( data, s, x ){
  789. expect(data).toEqual([{
  790. msg: 'Your PHP does not have FreeType support, resulting in breakage of profile pictures and the settings interface.',
  791. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  792. }]);
  793. done();
  794. });
  795. });
  796. it('should return an error if the php version is no longer supported', function(done) {
  797. var async = OC.SetupChecks.checkSetup();
  798. suite.server.requests[0].respond(
  799. 200,
  800. {
  801. 'Content-Type': 'application/json',
  802. },
  803. JSON.stringify({
  804. hasFileinfoInstalled: true,
  805. isGetenvServerWorking: true,
  806. isReadOnlyConfig: false,
  807. hasWorkingFileLocking: true,
  808. hasValidTransactionIsolationLevel: true,
  809. suggestedOverwriteCliURL: '',
  810. isRandomnessSecure: true,
  811. securityDocs: 'https://docs.owncloud.org/myDocs.html',
  812. serverHasInternetConnection: true,
  813. isMemcacheConfigured: true,
  814. forwardedForHeadersWorking: true,
  815. isCorrectMemcachedPHPModuleInstalled: true,
  816. hasPassedCodeIntegrityCheck: true,
  817. isOpcacheProperlySetup: true,
  818. hasOpcacheLoaded: true,
  819. isSettimelimitAvailable: true,
  820. hasFreeTypeSupport: true,
  821. missingIndexes: [],
  822. cronErrors: [],
  823. cronInfo: {
  824. diffInSeconds: 0
  825. },
  826. isMemoryLimitSufficient: true,
  827. appDirsWithDifferentOwner: [],
  828. recommendedPHPModules: [],
  829. pendingBigIntConversionColumns: [],
  830. isMysqlUsedWithoutUTF8MB4: true,
  831. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true
  832. })
  833. );
  834. async.done(function( data, s, x ){
  835. expect(data).toEqual([{
  836. 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 href="https://docs.example.org/admin-mysql-utf8mb4" rel="noreferrer noopener">the documentation page about this</a>.',
  837. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  838. }]);
  839. done();
  840. });
  841. });
  842. it('should return an error if there is not enough free space in the temp directory', function(done) {
  843. var async = OC.SetupChecks.checkSetup();
  844. suite.server.requests[0].respond(
  845. 200,
  846. {
  847. 'Content-Type': 'application/json',
  848. },
  849. JSON.stringify({
  850. hasFileinfoInstalled: true,
  851. isGetenvServerWorking: true,
  852. isReadOnlyConfig: false,
  853. hasWorkingFileLocking: true,
  854. hasValidTransactionIsolationLevel: true,
  855. suggestedOverwriteCliURL: '',
  856. isRandomnessSecure: true,
  857. securityDocs: 'https://docs.owncloud.org/myDocs.html',
  858. serverHasInternetConnection: true,
  859. isMemcacheConfigured: true,
  860. forwardedForHeadersWorking: true,
  861. isCorrectMemcachedPHPModuleInstalled: true,
  862. hasPassedCodeIntegrityCheck: true,
  863. isOpcacheProperlySetup: true,
  864. hasOpcacheLoaded: true,
  865. isSettimelimitAvailable: true,
  866. hasFreeTypeSupport: true,
  867. missingIndexes: [],
  868. cronErrors: [],
  869. cronInfo: {
  870. diffInSeconds: 0
  871. },
  872. isMemoryLimitSufficient: true,
  873. appDirsWithDifferentOwner: [],
  874. recommendedPHPModules: [],
  875. pendingBigIntConversionColumns: [],
  876. isMysqlUsedWithoutUTF8MB4: false,
  877. isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: false
  878. })
  879. );
  880. async.done(function( data, s, x ){
  881. expect(data).toEqual([{
  882. 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.',
  883. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  884. }]);
  885. done();
  886. });
  887. });
  888. });
  889. describe('checkGeneric', function() {
  890. it('should return an error if the response has no statuscode 200', function(done) {
  891. var async = OC.SetupChecks.checkGeneric();
  892. suite.server.requests[0].respond(
  893. 500,
  894. {
  895. 'Content-Type': 'application/json'
  896. }
  897. );
  898. async.done(function( data, s, x ){
  899. expect(data).toEqual([{
  900. msg: 'Error occurred while checking server setup',
  901. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  902. },{
  903. msg: 'Error occurred while checking server setup',
  904. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  905. }]);
  906. done();
  907. });
  908. });
  909. it('should return all errors if all headers are missing', function(done) {
  910. protocolStub.returns('https');
  911. var async = OC.SetupChecks.checkGeneric();
  912. suite.server.requests[0].respond(
  913. 200,
  914. {
  915. 'Content-Type': 'application/json',
  916. 'Strict-Transport-Security': 'max-age=15768000'
  917. }
  918. );
  919. async.done(function( data, s, x ){
  920. expect(data).toEqual([
  921. {
  922. 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.',
  923. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  924. }, {
  925. 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.',
  926. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  927. }, {
  928. 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.',
  929. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  930. }, {
  931. msg: 'The "X-Download-Options" HTTP header is not set to "noopen". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.',
  932. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  933. }, {
  934. 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.',
  935. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  936. }, {
  937. 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.',
  938. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  939. }, {
  940. 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 href="https://www.w3.org/TR/referrer-policy/" rel="noreferrer noopener">W3C Recommendation ↗</a>.',
  941. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  942. }
  943. ]);
  944. done();
  945. });
  946. });
  947. it('should return only some errors if just some headers are missing', function(done) {
  948. protocolStub.returns('https');
  949. var async = OC.SetupChecks.checkGeneric();
  950. suite.server.requests[0].respond(
  951. 200,
  952. {
  953. 'X-Robots-Tag': 'none',
  954. 'X-Frame-Options': 'SAMEORIGIN',
  955. 'Strict-Transport-Security': 'max-age=15768000;preload',
  956. 'X-Download-Options': 'noopen',
  957. 'X-Permitted-Cross-Domain-Policies': 'none',
  958. 'Referrer-Policy': 'no-referrer',
  959. }
  960. );
  961. async.done(function( data, s, x ){
  962. expect(data).toEqual([
  963. {
  964. 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.',
  965. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  966. }, {
  967. 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.',
  968. type: OC.SetupChecks.MESSAGE_TYPE_WARNING,
  969. }
  970. ]);
  971. done();
  972. });
  973. });
  974. it('should return none errors if all headers are there', function(done) {
  975. protocolStub.returns('https');
  976. var async = OC.SetupChecks.checkGeneric();
  977. suite.server.requests[0].respond(
  978. 200,
  979. {
  980. 'X-XSS-Protection': '1; mode=block',
  981. 'X-Content-Type-Options': 'nosniff',
  982. 'X-Robots-Tag': 'none',
  983. 'X-Frame-Options': 'SAMEORIGIN',
  984. 'Strict-Transport-Security': 'max-age=15768000',
  985. 'X-Download-Options': 'noopen',
  986. 'X-Permitted-Cross-Domain-Policies': 'none',
  987. 'Referrer-Policy': 'no-referrer'
  988. }
  989. );
  990. async.done(function( data, s, x ){
  991. expect(data).toEqual([]);
  992. done();
  993. });
  994. });
  995. describe('check X-XSS-Protection header', function() {
  996. it('should return no message if X-XSS-Protection is set to 1; mode=block; report=https://example.com', function(done) {
  997. protocolStub.returns('https');
  998. var result = OC.SetupChecks.checkGeneric();
  999. suite.server.requests[0].respond(200, {
  1000. 'Strict-Transport-Security': 'max-age=15768000',
  1001. 'X-XSS-Protection': '1; mode=block; report=https://example.com',
  1002. 'X-Content-Type-Options': 'nosniff',
  1003. 'X-Robots-Tag': 'none',
  1004. 'X-Frame-Options': 'SAMEORIGIN',
  1005. 'X-Download-Options': 'noopen',
  1006. 'X-Permitted-Cross-Domain-Policies': 'none',
  1007. 'Referrer-Policy': 'no-referrer',
  1008. });
  1009. result.done(function( data, s, x ){
  1010. expect(data).toEqual([]);
  1011. done();
  1012. });
  1013. });
  1014. it('should return no message if X-XSS-Protection is set to 1; mode=block', function(done) {
  1015. protocolStub.returns('https');
  1016. var result = OC.SetupChecks.checkGeneric();
  1017. suite.server.requests[0].respond(200, {
  1018. 'Strict-Transport-Security': 'max-age=15768000',
  1019. 'X-XSS-Protection': '1; mode=block',
  1020. 'X-Content-Type-Options': 'nosniff',
  1021. 'X-Robots-Tag': 'none',
  1022. 'X-Frame-Options': 'SAMEORIGIN',
  1023. 'X-Download-Options': 'noopen',
  1024. 'X-Permitted-Cross-Domain-Policies': 'none',
  1025. 'Referrer-Policy': 'no-referrer',
  1026. });
  1027. result.done(function( data, s, x ){
  1028. expect(data).toEqual([]);
  1029. done();
  1030. });
  1031. });
  1032. it('should return a message if X-XSS-Protection is set to 1', function(done) {
  1033. protocolStub.returns('https');
  1034. var result = OC.SetupChecks.checkGeneric();
  1035. suite.server.requests[0].respond(200, {
  1036. 'Strict-Transport-Security': 'max-age=15768000',
  1037. 'X-XSS-Protection': '1',
  1038. 'X-Content-Type-Options': 'nosniff',
  1039. 'X-Robots-Tag': 'none',
  1040. 'X-Frame-Options': 'SAMEORIGIN',
  1041. 'X-Download-Options': 'noopen',
  1042. 'X-Permitted-Cross-Domain-Policies': 'none',
  1043. 'Referrer-Policy': 'no-referrer',
  1044. });
  1045. result.done(function( data, s, x ){
  1046. expect(data).toEqual([
  1047. {
  1048. 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.',
  1049. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1050. }
  1051. ]);
  1052. done();
  1053. });
  1054. });
  1055. it('should return a message if X-XSS-Protection is set to 0', function(done) {
  1056. protocolStub.returns('https');
  1057. var result = OC.SetupChecks.checkGeneric();
  1058. suite.server.requests[0].respond(200, {
  1059. 'Strict-Transport-Security': 'max-age=15768000',
  1060. 'X-XSS-Protection': '0',
  1061. 'X-Content-Type-Options': 'nosniff',
  1062. 'X-Robots-Tag': 'none',
  1063. 'X-Frame-Options': 'SAMEORIGIN',
  1064. 'X-Download-Options': 'noopen',
  1065. 'X-Permitted-Cross-Domain-Policies': 'none',
  1066. 'Referrer-Policy': 'no-referrer',
  1067. });
  1068. result.done(function( data, s, x ){
  1069. expect(data).toEqual([
  1070. {
  1071. 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.',
  1072. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1073. }
  1074. ]);
  1075. done();
  1076. });
  1077. });
  1078. });
  1079. describe('check Referrer-Policy header', function() {
  1080. it('should return no message if Referrer-Policy is set to no-referrer', function(done) {
  1081. protocolStub.returns('https');
  1082. var result = OC.SetupChecks.checkGeneric();
  1083. suite.server.requests[0].respond(200, {
  1084. 'Strict-Transport-Security': 'max-age=15768000',
  1085. 'X-XSS-Protection': '1; mode=block',
  1086. 'X-Content-Type-Options': 'nosniff',
  1087. 'X-Robots-Tag': 'none',
  1088. 'X-Frame-Options': 'SAMEORIGIN',
  1089. 'X-Download-Options': 'noopen',
  1090. 'X-Permitted-Cross-Domain-Policies': 'none',
  1091. 'Referrer-Policy': 'no-referrer',
  1092. });
  1093. result.done(function( data, s, x ){
  1094. expect(data).toEqual([]);
  1095. done();
  1096. });
  1097. });
  1098. it('should return no message if Referrer-Policy is set to no-referrer-when-downgrade', function(done) {
  1099. protocolStub.returns('https');
  1100. var result = OC.SetupChecks.checkGeneric();
  1101. suite.server.requests[0].respond(200, {
  1102. 'Strict-Transport-Security': 'max-age=15768000',
  1103. 'X-XSS-Protection': '1; mode=block',
  1104. 'X-Content-Type-Options': 'nosniff',
  1105. 'X-Robots-Tag': 'none',
  1106. 'X-Frame-Options': 'SAMEORIGIN',
  1107. 'X-Download-Options': 'noopen',
  1108. 'X-Permitted-Cross-Domain-Policies': 'none',
  1109. 'Referrer-Policy': 'no-referrer-when-downgrade',
  1110. });
  1111. result.done(function( data, s, x ){
  1112. expect(data).toEqual([]);
  1113. done();
  1114. });
  1115. });
  1116. it('should return no message if Referrer-Policy is set to strict-origin', function(done) {
  1117. protocolStub.returns('https');
  1118. var result = OC.SetupChecks.checkGeneric();
  1119. suite.server.requests[0].respond(200, {
  1120. 'Strict-Transport-Security': 'max-age=15768000',
  1121. 'X-XSS-Protection': '1; mode=block',
  1122. 'X-Content-Type-Options': 'nosniff',
  1123. 'X-Robots-Tag': 'none',
  1124. 'X-Frame-Options': 'SAMEORIGIN',
  1125. 'X-Download-Options': 'noopen',
  1126. 'X-Permitted-Cross-Domain-Policies': 'none',
  1127. 'Referrer-Policy': 'strict-origin',
  1128. });
  1129. result.done(function( data, s, x ){
  1130. expect(data).toEqual([]);
  1131. done();
  1132. });
  1133. });
  1134. it('should return no message if Referrer-Policy is set to strict-origin-when-cross-origin', function(done) {
  1135. protocolStub.returns('https');
  1136. var result = OC.SetupChecks.checkGeneric();
  1137. suite.server.requests[0].respond(200, {
  1138. 'Strict-Transport-Security': 'max-age=15768000',
  1139. 'X-XSS-Protection': '1; mode=block',
  1140. 'X-Content-Type-Options': 'nosniff',
  1141. 'X-Robots-Tag': 'none',
  1142. 'X-Frame-Options': 'SAMEORIGIN',
  1143. 'X-Download-Options': 'noopen',
  1144. 'X-Permitted-Cross-Domain-Policies': 'none',
  1145. 'Referrer-Policy': 'strict-origin-when-cross-origin',
  1146. });
  1147. result.done(function( data, s, x ){
  1148. expect(data).toEqual([]);
  1149. done();
  1150. });
  1151. });
  1152. it('should return no message if Referrer-Policy is set to same-origin', function(done) {
  1153. protocolStub.returns('https');
  1154. var result = OC.SetupChecks.checkGeneric();
  1155. suite.server.requests[0].respond(200, {
  1156. 'Strict-Transport-Security': 'max-age=15768000',
  1157. 'X-XSS-Protection': '1; mode=block',
  1158. 'X-Content-Type-Options': 'nosniff',
  1159. 'X-Robots-Tag': 'none',
  1160. 'X-Frame-Options': 'SAMEORIGIN',
  1161. 'X-Download-Options': 'noopen',
  1162. 'X-Permitted-Cross-Domain-Policies': 'none',
  1163. 'Referrer-Policy': 'same-origin',
  1164. });
  1165. result.done(function( data, s, x ){
  1166. expect(data).toEqual([]);
  1167. done();
  1168. });
  1169. });
  1170. it('should return a message if Referrer-Policy is set to origin', function(done) {
  1171. protocolStub.returns('https');
  1172. var result = OC.SetupChecks.checkGeneric();
  1173. suite.server.requests[0].respond(200, {
  1174. 'Strict-Transport-Security': 'max-age=15768000',
  1175. 'X-XSS-Protection': '1; mode=block',
  1176. 'X-Content-Type-Options': 'nosniff',
  1177. 'X-Robots-Tag': 'none',
  1178. 'X-Frame-Options': 'SAMEORIGIN',
  1179. 'X-Download-Options': 'noopen',
  1180. 'X-Permitted-Cross-Domain-Policies': 'none',
  1181. 'Referrer-Policy': 'origin',
  1182. });
  1183. result.done(function( data, s, x ){
  1184. expect(data).toEqual([
  1185. {
  1186. 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 href="https://www.w3.org/TR/referrer-policy/" rel="noreferrer noopener">W3C Recommendation ↗</a>.',
  1187. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  1188. }
  1189. ]);
  1190. done();
  1191. });
  1192. });
  1193. it('should return a message if Referrer-Policy is set to origin-when-cross-origin', function(done) {
  1194. protocolStub.returns('https');
  1195. var result = OC.SetupChecks.checkGeneric();
  1196. suite.server.requests[0].respond(200, {
  1197. 'Strict-Transport-Security': 'max-age=15768000',
  1198. 'X-XSS-Protection': '1; mode=block',
  1199. 'X-Content-Type-Options': 'nosniff',
  1200. 'X-Robots-Tag': 'none',
  1201. 'X-Frame-Options': 'SAMEORIGIN',
  1202. 'X-Download-Options': 'noopen',
  1203. 'X-Permitted-Cross-Domain-Policies': 'none',
  1204. 'Referrer-Policy': 'origin-when-cross-origin',
  1205. });
  1206. result.done(function( data, s, x ){
  1207. expect(data).toEqual([
  1208. {
  1209. 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 href="https://www.w3.org/TR/referrer-policy/" rel="noreferrer noopener">W3C Recommendation ↗</a>.',
  1210. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  1211. }
  1212. ]);
  1213. done();
  1214. });
  1215. });
  1216. it('should return a message if Referrer-Policy is set to unsafe-url', function(done) {
  1217. protocolStub.returns('https');
  1218. var result = OC.SetupChecks.checkGeneric();
  1219. suite.server.requests[0].respond(200, {
  1220. 'Strict-Transport-Security': 'max-age=15768000',
  1221. 'X-XSS-Protection': '1; mode=block',
  1222. 'X-Content-Type-Options': 'nosniff',
  1223. 'X-Robots-Tag': 'none',
  1224. 'X-Frame-Options': 'SAMEORIGIN',
  1225. 'X-Download-Options': 'noopen',
  1226. 'X-Permitted-Cross-Domain-Policies': 'none',
  1227. 'Referrer-Policy': 'unsafe-url',
  1228. });
  1229. result.done(function( data, s, x ){
  1230. expect(data).toEqual([
  1231. {
  1232. 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 href="https://www.w3.org/TR/referrer-policy/" rel="noreferrer noopener">W3C Recommendation ↗</a>.',
  1233. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  1234. }
  1235. ]);
  1236. done();
  1237. });
  1238. });
  1239. });
  1240. });
  1241. it('should return a SSL warning if HTTPS is not used', function(done) {
  1242. protocolStub.returns('http');
  1243. var async = OC.SetupChecks.checkGeneric();
  1244. suite.server.requests[0].respond(200,
  1245. {
  1246. 'X-XSS-Protection': '1; mode=block',
  1247. 'X-Content-Type-Options': 'nosniff',
  1248. 'X-Robots-Tag': 'none',
  1249. 'X-Frame-Options': 'SAMEORIGIN',
  1250. 'X-Download-Options': 'noopen',
  1251. 'X-Permitted-Cross-Domain-Policies': 'none',
  1252. 'Referrer-Policy': 'no-referrer',
  1253. }
  1254. );
  1255. async.done(function( data, s, x ){
  1256. expect(data).toEqual([{
  1257. msg: 'Accessing site insecurely via HTTP. You are strongly adviced to set up your server to require HTTPS instead, as described in the <a href="https://docs.example.org/admin-security">security tips ↗</a>.',
  1258. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1259. }]);
  1260. done();
  1261. });
  1262. });
  1263. it('should return an error if the response has no statuscode 200', function(done) {
  1264. var async = OC.SetupChecks.checkGeneric();
  1265. suite.server.requests[0].respond(
  1266. 500,
  1267. {
  1268. 'Content-Type': 'application/json'
  1269. },
  1270. JSON.stringify({data: {serverHasInternetConnection: false}})
  1271. );
  1272. async.done(function( data, s, x ){
  1273. expect(data).toEqual([{
  1274. msg: 'Error occurred while checking server setup',
  1275. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  1276. }, {
  1277. msg: 'Error occurred while checking server setup',
  1278. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  1279. }]);
  1280. done();
  1281. });
  1282. });
  1283. it('should return a SSL warning if SSL used without Strict-Transport-Security-Header', function(done) {
  1284. protocolStub.returns('https');
  1285. var async = OC.SetupChecks.checkGeneric();
  1286. suite.server.requests[0].respond(200,
  1287. {
  1288. 'X-XSS-Protection': '1; mode=block',
  1289. 'X-Content-Type-Options': 'nosniff',
  1290. 'X-Robots-Tag': 'none',
  1291. 'X-Frame-Options': 'SAMEORIGIN',
  1292. 'X-Download-Options': 'noopen',
  1293. 'X-Permitted-Cross-Domain-Policies': 'none',
  1294. 'Referrer-Policy': 'no-referrer',
  1295. }
  1296. );
  1297. async.done(function( data, s, x ){
  1298. expect(data).toEqual([{
  1299. 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 rel="noreferrer noopener" href="https://docs.example.org/admin-security">security tips ↗</a>.',
  1300. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1301. }]);
  1302. done();
  1303. });
  1304. });
  1305. it('should return a SSL warning if SSL used with to small Strict-Transport-Security-Header', function(done) {
  1306. protocolStub.returns('https');
  1307. var async = OC.SetupChecks.checkGeneric();
  1308. suite.server.requests[0].respond(200,
  1309. {
  1310. 'Strict-Transport-Security': 'max-age=15551999',
  1311. 'X-XSS-Protection': '1; mode=block',
  1312. 'X-Content-Type-Options': 'nosniff',
  1313. 'X-Robots-Tag': 'none',
  1314. 'X-Frame-Options': 'SAMEORIGIN',
  1315. 'X-Download-Options': 'noopen',
  1316. 'X-Permitted-Cross-Domain-Policies': 'none',
  1317. 'Referrer-Policy': 'no-referrer',
  1318. }
  1319. );
  1320. async.done(function( data, s, x ){
  1321. expect(data).toEqual([{
  1322. 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 rel="noreferrer noopener" href="https://docs.example.org/admin-security">security tips ↗</a>.',
  1323. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1324. }]);
  1325. done();
  1326. });
  1327. });
  1328. it('should return a SSL warning if SSL used with to a bogus Strict-Transport-Security-Header', function(done) {
  1329. protocolStub.returns('https');
  1330. var async = OC.SetupChecks.checkGeneric();
  1331. suite.server.requests[0].respond(200,
  1332. {
  1333. 'Strict-Transport-Security': 'iAmABogusHeader342',
  1334. 'X-XSS-Protection': '1; mode=block',
  1335. 'X-Content-Type-Options': 'nosniff',
  1336. 'X-Robots-Tag': 'none',
  1337. 'X-Frame-Options': 'SAMEORIGIN',
  1338. 'X-Download-Options': 'noopen',
  1339. 'X-Permitted-Cross-Domain-Policies': 'none',
  1340. 'Referrer-Policy': 'no-referrer',
  1341. }
  1342. );
  1343. async.done(function( data, s, x ){
  1344. expect(data).toEqual([{
  1345. 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 rel="noreferrer noopener" href="https://docs.example.org/admin-security">security tips ↗</a>.',
  1346. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  1347. }]);
  1348. done();
  1349. });
  1350. });
  1351. it('should return no SSL warning if SSL used with to exact the minimum Strict-Transport-Security-Header', function(done) {
  1352. protocolStub.returns('https');
  1353. var async = OC.SetupChecks.checkGeneric();
  1354. suite.server.requests[0].respond(200, {
  1355. 'Strict-Transport-Security': 'max-age=15768000',
  1356. 'X-XSS-Protection': '1; mode=block',
  1357. 'X-Content-Type-Options': 'nosniff',
  1358. 'X-Robots-Tag': 'none',
  1359. 'X-Frame-Options': 'SAMEORIGIN',
  1360. 'X-Download-Options': 'noopen',
  1361. 'X-Permitted-Cross-Domain-Policies': 'none',
  1362. 'Referrer-Policy': 'no-referrer',
  1363. });
  1364. async.done(function( data, s, x ){
  1365. expect(data).toEqual([]);
  1366. done();
  1367. });
  1368. });
  1369. it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header', function(done) {
  1370. protocolStub.returns('https');
  1371. var async = OC.SetupChecks.checkGeneric();
  1372. suite.server.requests[0].respond(200, {
  1373. 'Strict-Transport-Security': 'max-age=99999999',
  1374. 'X-XSS-Protection': '1; mode=block',
  1375. 'X-Content-Type-Options': 'nosniff',
  1376. 'X-Robots-Tag': 'none',
  1377. 'X-Frame-Options': 'SAMEORIGIN',
  1378. 'X-Download-Options': 'noopen',
  1379. 'X-Permitted-Cross-Domain-Policies': 'none',
  1380. 'Referrer-Policy': 'no-referrer',
  1381. });
  1382. async.done(function( data, s, x ){
  1383. expect(data).toEqual([]);
  1384. done();
  1385. });
  1386. });
  1387. it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header and includeSubDomains parameter', function(done) {
  1388. protocolStub.returns('https');
  1389. var async = OC.SetupChecks.checkGeneric();
  1390. suite.server.requests[0].respond(200, {
  1391. 'Strict-Transport-Security': 'max-age=99999999; includeSubDomains',
  1392. 'X-XSS-Protection': '1; mode=block',
  1393. 'X-Content-Type-Options': 'nosniff',
  1394. 'X-Robots-Tag': 'none',
  1395. 'X-Frame-Options': 'SAMEORIGIN',
  1396. 'X-Download-Options': 'noopen',
  1397. 'X-Permitted-Cross-Domain-Policies': 'none',
  1398. 'Referrer-Policy': 'no-referrer',
  1399. });
  1400. async.done(function( data, s, x ){
  1401. expect(data).toEqual([]);
  1402. done();
  1403. });
  1404. });
  1405. 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) {
  1406. protocolStub.returns('https');
  1407. var async = OC.SetupChecks.checkGeneric();
  1408. suite.server.requests[0].respond(200, {
  1409. 'Strict-Transport-Security': 'max-age=99999999; preload; includeSubDomains',
  1410. 'X-XSS-Protection': '1; mode=block',
  1411. 'X-Content-Type-Options': 'nosniff',
  1412. 'X-Robots-Tag': 'none',
  1413. 'X-Frame-Options': 'SAMEORIGIN',
  1414. 'X-Download-Options': 'noopen',
  1415. 'X-Permitted-Cross-Domain-Policies': 'none',
  1416. 'Referrer-Policy': 'no-referrer',
  1417. });
  1418. async.done(function( data, s, x ){
  1419. expect(data).toEqual([]);
  1420. done();
  1421. });
  1422. });
  1423. });