setupchecksSpec.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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('checkSetup', function() {
  22. it('should return an error if server has no internet connection', function(done) {
  23. var async = OC.SetupChecks.checkSetup();
  24. suite.server.requests[0].respond(
  25. 200,
  26. {
  27. 'Content-Type': 'application/json'
  28. },
  29. JSON.stringify({
  30. generic: {
  31. network: {
  32. "Internet connectivity": {
  33. severity: "warning",
  34. description: '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.',
  35. linkToDoc: null
  36. }
  37. },
  38. },
  39. })
  40. );
  41. async.done(function( data, s, x ){
  42. expect(data).toEqual([
  43. {
  44. 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.',
  45. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  46. },
  47. ]);
  48. done();
  49. });
  50. });
  51. it('should return an error if server has no internet connection and data directory is not protected', function(done) {
  52. var async = OC.SetupChecks.checkSetup();
  53. suite.server.requests[0].respond(
  54. 200,
  55. {
  56. 'Content-Type': 'application/json'
  57. },
  58. JSON.stringify({
  59. generic: {
  60. network: {
  61. "Internet connectivity": {
  62. severity: "warning",
  63. description: '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.',
  64. linkToDoc: null
  65. }
  66. },
  67. },
  68. })
  69. );
  70. async.done(function( data, s, x ){
  71. expect(data).toEqual([
  72. {
  73. 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.',
  74. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  75. },
  76. ]);
  77. done();
  78. });
  79. });
  80. it('should return an error if server has no internet connection and data directory is not protected and memcache is available', function(done) {
  81. var async = OC.SetupChecks.checkSetup();
  82. suite.server.requests[0].respond(
  83. 200,
  84. {
  85. 'Content-Type': 'application/json',
  86. },
  87. JSON.stringify({
  88. generic: {
  89. network: {
  90. "Internet connectivity": {
  91. severity: "warning",
  92. description: '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.',
  93. linkToDoc: null
  94. }
  95. },
  96. },
  97. })
  98. );
  99. async.done(function( data, s, x ){
  100. expect(data).toEqual([
  101. {
  102. 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.',
  103. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  104. }
  105. ]);
  106. done();
  107. });
  108. });
  109. it('should return a warning if the memory limit is below the recommended value', function(done) {
  110. var async = OC.SetupChecks.checkSetup();
  111. suite.server.requests[0].respond(
  112. 200,
  113. {
  114. 'Content-Type': 'application/json',
  115. },
  116. JSON.stringify({
  117. generic: {
  118. network: {
  119. "Internet connectivity": {
  120. severity: "success",
  121. description: null,
  122. linkToDoc: null
  123. }
  124. },
  125. php: {
  126. "Internet connectivity": {
  127. severity: "success",
  128. description: null,
  129. linkToDoc: null
  130. },
  131. "PHP memory limit": {
  132. severity: "error",
  133. description: "The PHP memory limit is below the recommended value of 512MB.",
  134. linkToDoc: null
  135. },
  136. },
  137. },
  138. })
  139. );
  140. async.done(function( data, s, x ){
  141. expect(data).toEqual([{
  142. msg: 'The PHP memory limit is below the recommended value of 512MB.',
  143. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  144. }]);
  145. done();
  146. });
  147. });
  148. it('should return an error if the response has no statuscode 200', function(done) {
  149. var async = OC.SetupChecks.checkSetup();
  150. suite.server.requests[0].respond(
  151. 500,
  152. {
  153. 'Content-Type': 'application/json'
  154. },
  155. JSON.stringify({data: {serverHasInternetConnectionProblems: true}})
  156. );
  157. async.done(function( data, s, x ){
  158. expect(data).toEqual([{
  159. msg: 'Error occurred while checking server setup',
  160. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  161. }]);
  162. done();
  163. });
  164. });
  165. it('should return an error if the php version is no longer supported', function(done) {
  166. var async = OC.SetupChecks.checkSetup();
  167. suite.server.requests[0].respond(
  168. 200,
  169. {
  170. 'Content-Type': 'application/json',
  171. },
  172. JSON.stringify({
  173. generic: {
  174. network: {
  175. "Internet connectivity": {
  176. severity: "success",
  177. description: null,
  178. linkToDoc: null
  179. }
  180. },
  181. security: {
  182. "Checking for PHP version": {
  183. severity: "warning",
  184. description: "You are currently running PHP 8.0.30. PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to one of the officially supported PHP versions provided by the PHP Group as soon as possible.",
  185. linkToDoc: "https://secure.php.net/supported-versions.php"
  186. }
  187. },
  188. },
  189. })
  190. );
  191. async.done(function( data, s, x ){
  192. expect(data).toEqual([{
  193. msg: 'You are currently running PHP 8.0.30. PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to one of the officially supported PHP versions provided by the PHP Group as soon as possible. For more details see the <a target="_blank" rel="noreferrer noopener" class="external" href="https://secure.php.net/supported-versions.php">documentation ↗</a>.',
  194. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  195. }]);
  196. done();
  197. });
  198. });
  199. it('should not return an error if the protocol is http and the server generates http links', function(done) {
  200. var async = OC.SetupChecks.checkSetup();
  201. suite.server.requests[0].respond(
  202. 200,
  203. {
  204. 'Content-Type': 'application/json',
  205. },
  206. JSON.stringify({
  207. generic: {
  208. network: {
  209. "Internet connectivity": {
  210. severity: "success",
  211. description: null,
  212. linkToDoc: null
  213. }
  214. },
  215. },
  216. })
  217. );
  218. async.done(function( data, s, x ){
  219. expect(data).toEqual([]);
  220. done();
  221. });
  222. });
  223. it('should return an info if there is no default phone region', function(done) {
  224. var async = OC.SetupChecks.checkSetup();
  225. suite.server.requests[0].respond(
  226. 200,
  227. {
  228. 'Content-Type': 'application/json',
  229. },
  230. JSON.stringify({
  231. generic: {
  232. network: {
  233. "Internet connectivity": {
  234. severity: "success",
  235. description: null,
  236. linkToDoc: null
  237. }
  238. },
  239. config: {
  240. "Checking for default phone region": {
  241. severity: "info",
  242. description: "Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add \"default_phone_region\" with the respective ISO 3166-1 code of the region to your config file.",
  243. linkToDoc: "https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements"
  244. },
  245. },
  246. },
  247. })
  248. );
  249. async.done(function( data, s, x ){
  250. expect(data).toEqual([{
  251. msg: 'Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add &quot;default_phone_region&quot; with the respective ISO 3166-1 code of the region to your config file. For more details see the <a target="_blank" rel="noreferrer noopener" class="external" href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements">documentation ↗</a>.',
  252. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  253. }]);
  254. done();
  255. });
  256. });
  257. });
  258. });