setupchecksSpec.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  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 set up properly 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 207', function(done) {
  52. var async = OC.SetupChecks.checkWellKnownUrl('/.well-known/caldav/', 'http://example.org/PLACEHOLDER', true);
  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 set up properly to resolve "/.well-known/caldav/". Further information can be found in our <a target="_blank" href="http://example.org/admin-setup-well-known-URL">documentation</a>.',
  57. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  58. }]);
  59. done();
  60. });
  61. });
  62. it('should return no error with a response status code of 207', function(done) {
  63. var async = OC.SetupChecks.checkWellKnownUrl('/.well-known/caldav/', 'http://example.org/PLACEHOLDER', true);
  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 when no check should be run', function(done) {
  71. var async = OC.SetupChecks.checkWellKnownUrl('/.well-known/caldav/', 'http://example.org/PLACEHOLDER', false);
  72. async.done(function( data, s, x ){
  73. expect(data).toEqual([]);
  74. done();
  75. });
  76. });
  77. });
  78. describe('checkDataProtected', function() {
  79. oc_dataURL = "data";
  80. it('should return an error if data directory is not protected', function(done) {
  81. var async = OC.SetupChecks.checkDataProtected();
  82. suite.server.requests[0].respond(200);
  83. async.done(function( data, s, x ){
  84. expect(data).toEqual([
  85. {
  86. msg: 'Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.',
  87. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  88. }]);
  89. done();
  90. });
  91. });
  92. it('should not return an error if data directory is protected', function(done) {
  93. var async = OC.SetupChecks.checkDataProtected();
  94. suite.server.requests[0].respond(403);
  95. async.done(function( data, s, x ){
  96. expect(data).toEqual([]);
  97. done();
  98. });
  99. });
  100. it('should return an error if data directory is a boolean', function(done) {
  101. oc_dataURL = false;
  102. var async = OC.SetupChecks.checkDataProtected();
  103. async.done(function( data, s, x ){
  104. expect(data).toEqual([]);
  105. done();
  106. });
  107. });
  108. });
  109. describe('checkSetup', function() {
  110. it('should return an error if server has no internet connection', function(done) {
  111. var async = OC.SetupChecks.checkSetup();
  112. suite.server.requests[0].respond(
  113. 200,
  114. {
  115. 'Content-Type': 'application/json'
  116. },
  117. JSON.stringify({
  118. isUrandomAvailable: true,
  119. serverHasInternetConnection: false,
  120. memcacheDocs: 'https://doc.owncloud.org/server/go.php?to=admin-performance',
  121. forwardedForHeadersWorking: true,
  122. isCorrectMemcachedPHPModuleInstalled: true,
  123. hasPassedCodeIntegrityCheck: true,
  124. })
  125. );
  126. async.done(function( data, s, x ){
  127. expect(data).toEqual([
  128. {
  129. msg: 'This server has no working Internet connection. 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. We suggest to enable Internet connection for this server if you want to have all features.',
  130. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  131. }, {
  132. msg: 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our <a target="_blank" href="https://doc.owncloud.org/server/go.php?to=admin-performance">documentation</a>.',
  133. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  134. }]);
  135. done();
  136. });
  137. });
  138. it('should return an error if server has no internet connection and data directory is not protected', function(done) {
  139. var async = OC.SetupChecks.checkSetup();
  140. suite.server.requests[0].respond(
  141. 200,
  142. {
  143. 'Content-Type': 'application/json'
  144. },
  145. JSON.stringify({
  146. isUrandomAvailable: true,
  147. serverHasInternetConnection: false,
  148. memcacheDocs: 'https://doc.owncloud.org/server/go.php?to=admin-performance',
  149. forwardedForHeadersWorking: true,
  150. isCorrectMemcachedPHPModuleInstalled: true,
  151. hasPassedCodeIntegrityCheck: true,
  152. })
  153. );
  154. async.done(function( data, s, x ){
  155. expect(data).toEqual([
  156. {
  157. msg: 'This server has no working Internet connection. 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. We suggest to enable Internet connection for this server if you want to have all features.',
  158. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  159. },
  160. {
  161. msg: 'No memory cache has been configured. To enhance your performance please configure a memcache if available. Further information can be found in our <a target="_blank" href="https://doc.owncloud.org/server/go.php?to=admin-performance">documentation</a>.',
  162. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  163. }]);
  164. done();
  165. });
  166. });
  167. it('should return an error if server has no internet connection and data directory is not protected and memcache is available', 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. isUrandomAvailable: true,
  176. serverHasInternetConnection: false,
  177. isMemcacheConfigured: true,
  178. forwardedForHeadersWorking: true,
  179. isCorrectMemcachedPHPModuleInstalled: true,
  180. hasPassedCodeIntegrityCheck: true,
  181. })
  182. );
  183. async.done(function( data, s, x ){
  184. expect(data).toEqual([
  185. {
  186. msg: 'This server has no working Internet connection. 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. We suggest to enable Internet connection for this server if you want to have all features.',
  187. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  188. }
  189. ]);
  190. done();
  191. });
  192. });
  193. it('should return an error if /dev/urandom is not accessible', function(done) {
  194. var async = OC.SetupChecks.checkSetup();
  195. suite.server.requests[0].respond(
  196. 200,
  197. {
  198. 'Content-Type': 'application/json',
  199. },
  200. JSON.stringify({
  201. isUrandomAvailable: false,
  202. securityDocs: 'https://docs.owncloud.org/myDocs.html',
  203. serverHasInternetConnection: true,
  204. isMemcacheConfigured: true,
  205. forwardedForHeadersWorking: true,
  206. isCorrectMemcachedPHPModuleInstalled: true,
  207. hasPassedCodeIntegrityCheck: true,
  208. })
  209. );
  210. async.done(function( data, s, x ){
  211. expect(data).toEqual([{
  212. msg: '/dev/urandom is not readable by PHP which is highly discouraged for security reasons. Further information can be found in our <a target="_blank" href="https://docs.owncloud.org/myDocs.html">documentation</a>.',
  213. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  214. }]);
  215. done();
  216. });
  217. });
  218. it('should return an error if the wrong memcache PHP module is installed', function(done) {
  219. var async = OC.SetupChecks.checkSetup();
  220. suite.server.requests[0].respond(
  221. 200,
  222. {
  223. 'Content-Type': 'application/json',
  224. },
  225. JSON.stringify({
  226. isUrandomAvailable: true,
  227. securityDocs: 'https://docs.owncloud.org/myDocs.html',
  228. serverHasInternetConnection: true,
  229. isMemcacheConfigured: true,
  230. forwardedForHeadersWorking: true,
  231. isCorrectMemcachedPHPModuleInstalled: false,
  232. hasPassedCodeIntegrityCheck: true,
  233. })
  234. );
  235. async.done(function( data, s, x ){
  236. expect(data).toEqual([{
  237. msg: 'Memcached is configured as distributed cache, but the wrong PHP module "memcache" is installed. \\OC\\Memcache\\Memcached only supports "memcached" and not "memcache". See the <a target="_blank" href="https://code.google.com/p/memcached/wiki/PHPClientComparison">memcached wiki about both modules</a>.',
  238. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  239. }]);
  240. done();
  241. });
  242. });
  243. it('should return an error if the forwarded for headers are not working', function(done) {
  244. var async = OC.SetupChecks.checkSetup();
  245. suite.server.requests[0].respond(
  246. 200,
  247. {
  248. 'Content-Type': 'application/json',
  249. },
  250. JSON.stringify({
  251. isUrandomAvailable: true,
  252. serverHasInternetConnection: true,
  253. isMemcacheConfigured: true,
  254. forwardedForHeadersWorking: false,
  255. reverseProxyDocs: 'https://docs.owncloud.org/foo/bar.html',
  256. isCorrectMemcachedPHPModuleInstalled: true,
  257. hasPassedCodeIntegrityCheck: true,
  258. })
  259. );
  260. async.done(function( data, s, x ){
  261. expect(data).toEqual([{
  262. msg: 'The reverse proxy headers configuration is incorrect, or you are accessing ownCloud from a trusted proxy. If you are not accessing ownCloud from a trusted proxy, this is a security issue and can allow an attacker to spoof their IP address as visible to ownCloud. Further information can be found in our <a target="_blank" href="https://docs.owncloud.org/foo/bar.html">documentation</a>.',
  263. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  264. }]);
  265. done();
  266. });
  267. });
  268. it('should return an error if the response has no statuscode 200', function(done) {
  269. var async = OC.SetupChecks.checkSetup();
  270. suite.server.requests[0].respond(
  271. 500,
  272. {
  273. 'Content-Type': 'application/json'
  274. },
  275. JSON.stringify({data: {serverHasInternetConnection: false}})
  276. );
  277. async.done(function( data, s, x ){
  278. expect(data).toEqual([{
  279. msg: 'Error occurred while checking server setup',
  280. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  281. }]);
  282. done();
  283. });
  284. });
  285. it('should return an error if the php version is no longer supported', function(done) {
  286. var async = OC.SetupChecks.checkSetup();
  287. suite.server.requests[0].respond(
  288. 200,
  289. {
  290. 'Content-Type': 'application/json',
  291. },
  292. JSON.stringify({
  293. isUrandomAvailable: true,
  294. securityDocs: 'https://docs.owncloud.org/myDocs.html',
  295. serverHasInternetConnection: true,
  296. isMemcacheConfigured: true,
  297. forwardedForHeadersWorking: true,
  298. phpSupported: {eol: true, version: '5.4.0'},
  299. isCorrectMemcachedPHPModuleInstalled: true,
  300. hasPassedCodeIntegrityCheck: true,
  301. })
  302. );
  303. async.done(function( data, s, x ){
  304. expect(data).toEqual([{
  305. msg: 'Your PHP version (5.4.0) is no longer <a target="_blank" href="https://secure.php.net/supported-versions.php">supported by PHP</a>. We encourage you to upgrade your PHP version to take advantage of performance and security updates provided by PHP.',
  306. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  307. }]);
  308. done();
  309. });
  310. });
  311. });
  312. describe('checkGeneric', function() {
  313. it('should return an error if the response has no statuscode 200', function(done) {
  314. var async = OC.SetupChecks.checkGeneric();
  315. suite.server.requests[0].respond(
  316. 500,
  317. {
  318. 'Content-Type': 'application/json'
  319. }
  320. );
  321. async.done(function( data, s, x ){
  322. expect(data).toEqual([{
  323. msg: 'Error occurred while checking server setup',
  324. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  325. },{
  326. msg: 'Error occurred while checking server setup',
  327. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  328. }]);
  329. done();
  330. });
  331. });
  332. it('should return all errors if all headers are missing', function(done) {
  333. protocolStub.returns('https');
  334. var async = OC.SetupChecks.checkGeneric();
  335. suite.server.requests[0].respond(
  336. 200,
  337. {
  338. 'Content-Type': 'application/json',
  339. 'Strict-Transport-Security': 'max-age=15768000'
  340. }
  341. );
  342. async.done(function( data, s, x ){
  343. expect(data).toEqual([
  344. {
  345. msg: 'The "X-XSS-Protection" HTTP header is not configured to equal to "1; mode=block". This is a potential security or privacy risk and we recommend adjusting this setting.',
  346. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  347. }, {
  348. msg: 'The "X-Content-Type-Options" HTTP header is not configured to equal to "nosniff". This is a potential security or privacy risk and we recommend adjusting this setting.',
  349. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  350. }, {
  351. msg: 'The "X-Robots-Tag" HTTP header is not configured to equal to "none". This is a potential security or privacy risk and we recommend adjusting this setting.',
  352. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  353. }, {
  354. msg: 'The "X-Frame-Options" HTTP header is not configured to equal to "SAMEORIGIN". This is a potential security or privacy risk and we recommend adjusting this setting.',
  355. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  356. }, {
  357. msg: 'The "X-Download-Options" HTTP header is not configured to equal to "noopen". This is a potential security or privacy risk and we recommend adjusting this setting.',
  358. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  359. }, {
  360. msg: 'The "X-Permitted-Cross-Domain-Policies" HTTP header is not configured to equal to "none". This is a potential security or privacy risk and we recommend adjusting this setting.',
  361. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  362. },
  363. ]);
  364. done();
  365. });
  366. });
  367. it('should return only some errors if just some headers are missing', function(done) {
  368. protocolStub.returns('https');
  369. var async = OC.SetupChecks.checkGeneric();
  370. suite.server.requests[0].respond(
  371. 200,
  372. {
  373. 'X-Robots-Tag': 'none',
  374. 'X-Frame-Options': 'SAMEORIGIN',
  375. 'Strict-Transport-Security': 'max-age=15768000;preload',
  376. 'X-Download-Options': 'noopen',
  377. 'X-Permitted-Cross-Domain-Policies': 'none',
  378. }
  379. );
  380. async.done(function( data, s, x ){
  381. expect(data).toEqual([{
  382. msg: 'The "X-XSS-Protection" HTTP header is not configured to equal to "1; mode=block". This is a potential security or privacy risk and we recommend adjusting this setting.',
  383. type: OC.SetupChecks.MESSAGE_TYPE_WARNING,
  384. }, {
  385. msg: 'The "X-Content-Type-Options" HTTP header is not configured to equal to "nosniff". This is a potential security or privacy risk and we recommend adjusting this setting.',
  386. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  387. }]);
  388. done();
  389. });
  390. });
  391. it('should return none errors if all headers are there', function(done) {
  392. protocolStub.returns('https');
  393. var async = OC.SetupChecks.checkGeneric();
  394. suite.server.requests[0].respond(
  395. 200,
  396. {
  397. 'X-XSS-Protection': '1; mode=block',
  398. 'X-Content-Type-Options': 'nosniff',
  399. 'X-Robots-Tag': 'none',
  400. 'X-Frame-Options': 'SAMEORIGIN',
  401. 'Strict-Transport-Security': 'max-age=15768000',
  402. 'X-Download-Options': 'noopen',
  403. 'X-Permitted-Cross-Domain-Policies': 'none',
  404. }
  405. );
  406. async.done(function( data, s, x ){
  407. expect(data).toEqual([]);
  408. done();
  409. });
  410. });
  411. });
  412. it('should return a SSL warning if HTTPS is not used', function(done) {
  413. protocolStub.returns('http');
  414. var async = OC.SetupChecks.checkGeneric();
  415. suite.server.requests[0].respond(200,
  416. {
  417. 'X-XSS-Protection': '1; mode=block',
  418. 'X-Content-Type-Options': 'nosniff',
  419. 'X-Robots-Tag': 'none',
  420. 'X-Frame-Options': 'SAMEORIGIN',
  421. 'X-Download-Options': 'noopen',
  422. 'X-Permitted-Cross-Domain-Policies': 'none',
  423. }
  424. );
  425. async.done(function( data, s, x ){
  426. expect(data).toEqual([{
  427. msg: 'You are accessing this site via HTTP. We strongly suggest you configure your server to require using HTTPS instead as described in our <a href="#admin-tips">security tips</a>.',
  428. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  429. }]);
  430. done();
  431. });
  432. });
  433. it('should return an error if the response has no statuscode 200', function(done) {
  434. var async = OC.SetupChecks.checkGeneric();
  435. suite.server.requests[0].respond(
  436. 500,
  437. {
  438. 'Content-Type': 'application/json'
  439. },
  440. JSON.stringify({data: {serverHasInternetConnection: false}})
  441. );
  442. async.done(function( data, s, x ){
  443. expect(data).toEqual([{
  444. msg: 'Error occurred while checking server setup',
  445. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  446. }, {
  447. msg: 'Error occurred while checking server setup',
  448. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  449. }]);
  450. done();
  451. });
  452. });
  453. it('should return a SSL warning if SSL used without Strict-Transport-Security-Header', function(done) {
  454. protocolStub.returns('https');
  455. var async = OC.SetupChecks.checkGeneric();
  456. suite.server.requests[0].respond(200,
  457. {
  458. 'X-XSS-Protection': '1; mode=block',
  459. 'X-Content-Type-Options': 'nosniff',
  460. 'X-Robots-Tag': 'none',
  461. 'X-Frame-Options': 'SAMEORIGIN',
  462. 'X-Download-Options': 'noopen',
  463. 'X-Permitted-Cross-Domain-Policies': 'none',
  464. }
  465. );
  466. async.done(function( data, s, x ){
  467. expect(data).toEqual([{
  468. msg: 'The "Strict-Transport-Security" HTTP header is not configured to at least "15768000" seconds. For enhanced security we recommend enabling HSTS as described in our <a href="#admin-tips">security tips</a>.',
  469. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  470. }]);
  471. done();
  472. });
  473. });
  474. it('should return a SSL warning if SSL used with to small Strict-Transport-Security-Header', function(done) {
  475. protocolStub.returns('https');
  476. var async = OC.SetupChecks.checkGeneric();
  477. suite.server.requests[0].respond(200,
  478. {
  479. 'Strict-Transport-Security': 'max-age=15767999',
  480. 'X-XSS-Protection': '1; mode=block',
  481. 'X-Content-Type-Options': 'nosniff',
  482. 'X-Robots-Tag': 'none',
  483. 'X-Frame-Options': 'SAMEORIGIN',
  484. 'X-Download-Options': 'noopen',
  485. 'X-Permitted-Cross-Domain-Policies': 'none',
  486. }
  487. );
  488. async.done(function( data, s, x ){
  489. expect(data).toEqual([{
  490. msg: 'The "Strict-Transport-Security" HTTP header is not configured to at least "15768000" seconds. For enhanced security we recommend enabling HSTS as described in our <a href="#admin-tips">security tips</a>.',
  491. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  492. }]);
  493. done();
  494. });
  495. });
  496. it('should return a SSL warning if SSL used with to a bogus Strict-Transport-Security-Header', function(done) {
  497. protocolStub.returns('https');
  498. var async = OC.SetupChecks.checkGeneric();
  499. suite.server.requests[0].respond(200,
  500. {
  501. 'Strict-Transport-Security': 'iAmABogusHeader342',
  502. 'X-XSS-Protection': '1; mode=block',
  503. 'X-Content-Type-Options': 'nosniff',
  504. 'X-Robots-Tag': 'none',
  505. 'X-Frame-Options': 'SAMEORIGIN',
  506. 'X-Download-Options': 'noopen',
  507. 'X-Permitted-Cross-Domain-Policies': 'none',
  508. }
  509. );
  510. async.done(function( data, s, x ){
  511. expect(data).toEqual([{
  512. msg: 'The "Strict-Transport-Security" HTTP header is not configured to at least "15768000" seconds. For enhanced security we recommend enabling HSTS as described in our <a href="#admin-tips">security tips</a>.',
  513. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  514. }]);
  515. done();
  516. });
  517. });
  518. it('should return no SSL warning if SSL used with to exact the minimum Strict-Transport-Security-Header', function(done) {
  519. protocolStub.returns('https');
  520. var async = OC.SetupChecks.checkGeneric();
  521. suite.server.requests[0].respond(200, {
  522. 'Strict-Transport-Security': 'max-age=15768000',
  523. 'X-XSS-Protection': '1; mode=block',
  524. 'X-Content-Type-Options': 'nosniff',
  525. 'X-Robots-Tag': 'none',
  526. 'X-Frame-Options': 'SAMEORIGIN',
  527. 'X-Download-Options': 'noopen',
  528. 'X-Permitted-Cross-Domain-Policies': 'none',
  529. });
  530. async.done(function( data, s, x ){
  531. expect(data).toEqual([]);
  532. done();
  533. });
  534. });
  535. it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header', function(done) {
  536. protocolStub.returns('https');
  537. var async = OC.SetupChecks.checkGeneric();
  538. suite.server.requests[0].respond(200, {
  539. 'Strict-Transport-Security': 'max-age=99999999',
  540. 'X-XSS-Protection': '1; mode=block',
  541. 'X-Content-Type-Options': 'nosniff',
  542. 'X-Robots-Tag': 'none',
  543. 'X-Frame-Options': 'SAMEORIGIN',
  544. 'X-Download-Options': 'noopen',
  545. 'X-Permitted-Cross-Domain-Policies': 'none',
  546. });
  547. async.done(function( data, s, x ){
  548. expect(data).toEqual([]);
  549. done();
  550. });
  551. });
  552. it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header and includeSubDomains parameter', function(done) {
  553. protocolStub.returns('https');
  554. var async = OC.SetupChecks.checkGeneric();
  555. suite.server.requests[0].respond(200, {
  556. 'Strict-Transport-Security': 'max-age=99999999; includeSubDomains',
  557. 'X-XSS-Protection': '1; mode=block',
  558. 'X-Content-Type-Options': 'nosniff',
  559. 'X-Robots-Tag': 'none',
  560. 'X-Frame-Options': 'SAMEORIGIN',
  561. 'X-Download-Options': 'noopen',
  562. 'X-Permitted-Cross-Domain-Policies': 'none',
  563. });
  564. async.done(function( data, s, x ){
  565. expect(data).toEqual([]);
  566. done();
  567. });
  568. });
  569. 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) {
  570. protocolStub.returns('https');
  571. var async = OC.SetupChecks.checkGeneric();
  572. suite.server.requests[0].respond(200, {
  573. 'Strict-Transport-Security': 'max-age=99999999; preload; includeSubDomains',
  574. 'X-XSS-Protection': '1; mode=block',
  575. 'X-Content-Type-Options': 'nosniff',
  576. 'X-Robots-Tag': 'none',
  577. 'X-Frame-Options': 'SAMEORIGIN',
  578. 'X-Download-Options': 'noopen',
  579. 'X-Permitted-Cross-Domain-Policies': 'none',
  580. });
  581. async.done(function( data, s, x ){
  582. expect(data).toEqual([]);
  583. done();
  584. });
  585. });
  586. });