Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

setupchecksSpec.js 60KB

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