@@ -181,66 +181,12 @@ def test_nextcloud(IP: str, nc_port: str, driver: WebDriver, skip_release_check:
181181
182182 test .new ("settings config" )
183183 wait = WebDriverWait (driver , 60 * wait_multiplier * 3 )
184- try :
185- wait .until (VisibilityOfElementLocatedByAnyLocator ([(By .CSS_SELECTOR , "#security-warning-state-ok" ),
186- (By .CSS_SELECTOR , "#security-warning-state-warning" ),
187- (By .CSS_SELECTOR , "#security-warning-state-error" ),
188- (By .CSS_SELECTOR , "#security-warning-state-failure" )]))
189-
190- element_ok = driver .find_element (By .ID , "security-warning-state-ok" )
191- element_warn = driver .find_element (By .ID , "security-warning-state-warning" )
192-
193- if element_warn .is_displayed ():
194-
195- warnings = driver .find_elements (By .CSS_SELECTOR , "#postsetupchecks > .warnings > li" )
196- for warning in warnings :
197- if re .match (r'.*Server has no maintenance window start time configured.*' , warning .text ) \
198- or re .match (r'.*Server has no maintenance window start time configured.*' , warning .text ):
199- continue
200- elif re .match (r'.*Could not check for JavaScript support.*' , warning .text ):
201- continue
202- # TODO: Solve redis error logs at the source
203- elif re .match (r'.*\d+ errors? in the logs since.*' , warning .text ):
204- continue
205- else :
206- raise ConfigTestFailure (f"WARN: { warning .text } " )
207-
208- if driver .find_element (By .CSS_SELECTOR , "#postsetupchecks > .errors" ).is_displayed ():
209- try :
210- first_error = driver .find_element (By .CSS_SELECTOR , "#postsetupchecks > .errors > li" )
211- except NoSuchElementException :
212- first_error = None
213- raise ConfigTestFailure (f"ERROR: { first_error .text if first_error is not None else 'unexpected error' } " )
214-
215- infos = driver .find_elements (By .CSS_SELECTOR , "#postsetupchecks > .info > li" )
216- for info in infos :
217- if re .match (r'.*Your installation has no default phone region set.*' , info .text ) \
218- or re .match (r'The PHP module "imagick" is not enabled' , info .text ) \
219- or re .match (r'The PHP module "imagick" in this instance has no SVG support.*' , info .text ) \
220- or re .match (r'\d+ warning in the logs since.*' , info .text ):
221- continue
222- else :
223- print (f'INFO: { info .text } ' )
224- php_modules = info .find_elements (By .CSS_SELECTOR , "li" )
225- if len (php_modules ) != 1 :
226- raise ConfigTestFailure (f"Could not find the list of php modules within the info message "
227- f"'{ infos [0 ].text } '" )
228- if php_modules [0 ].text != "imagick" :
229- raise ConfigTestFailure ("The list of php_modules does not equal [imagick]" )
230-
231- elif not element_ok .is_displayed ():
232- errors = driver .find_elements (By .CSS_SELECTOR , "#postsetupchecks > .errors > li" )
233- for error in errors :
234- print (f'ERROR: { error .text } ' )
235- raise ConfigTestFailure ("Neither the warnings nor the ok status is displayed "
236- "(so there are probably errors or the page is broken)" )
237-
238- test .check (True )
184+ secwarn = driver .find_element (By .CSS_SELECTOR , "#security-warning.settings-section" )
185+ if secwarn is None :
186+ settings_config_check_pre32 (wait , test )
187+ else :
188+ settings_config_check (wait , test )
239189
240- except Exception as e :
241-
242- print (driver .find_element (By .CSS_SELECTOR , "#security-warning" ).get_attribute ("innerHTML" ))
243- test .check (e )
244190
245191 close_first_run_wizard (driver , wait_multiplier )
246192
@@ -321,6 +267,98 @@ def test_nextcloud(IP: str, nc_port: str, driver: WebDriver, skip_release_check:
321267 except Exception as e :
322268 test .check (e )
323269
270+ def settings_config_check_warnings (warnings ):
271+ for warning in warnings :
272+ if re .match (r'.*Server has no maintenance window start time configured.*' , warning .text ) \
273+ or re .match (r'.*Server has no maintenance window start time configured.*' , warning .text ):
274+ continue
275+ elif re .match (r'.*Could not check for JavaScript support.*' , warning .text ):
276+ continue
277+ # TODO: Solve redis error logs at the source
278+ elif re .match (r'.*\d+ errors? in the logs since.*' , warning .text ):
279+ continue
280+ else :
281+ raise ConfigTestFailure (f"WARN: { warning .text } " )
282+
283+ def settings_config_check_infos (infos ):
284+ for info in infos :
285+ if re .match (r'.*Your installation has no default phone region set.*' , info .text ) \
286+ or re .match (r'The PHP module "imagick" is not enabled' , info .text ) \
287+ or re .match (r'The PHP module "imagick" in this instance has no SVG support.*' , info .text ) \
288+ or re .match (r'\d+ warnings? in the logs since.*' , info .text ):
289+ continue
290+ else :
291+ print (f'INFO: { info .text } ' )
292+ php_modules = info .find_elements (By .CSS_SELECTOR , "li" )
293+ if len (php_modules ) != 1 :
294+ raise ConfigTestFailure (f"Could not find the list of php modules within the info message "
295+ f"'{ infos [0 ].text } '" )
296+ if php_modules [0 ].text != "imagick" :
297+ raise ConfigTestFailure ("The list of php_modules does not equal [imagick]" )
298+
299+
300+ def settings_config_check_errors (errors ):
301+ if len (errors ) == 0 :
302+ return
303+ for error in errors :
304+ print (f'ERROR: { error .text } ' )
305+ raise ConfigTestFailure ("Neither the warnings nor the ok status is displayed "
306+ "(so there are probably errors or the page is broken)" )
307+
308+
309+ def settings_config_check (wait , test ):
310+ try :
311+ wait .until_not (VisibilityOfElementLocatedByAnyLocator ([(By .CSS_SELECTOR , "#security-warning .loading-icon" )]))
312+ warnings = driver .find_elements (By .CSS_SELECTOR , "#security-warning li.settings-setup-checks-item--warning .settings-setup-checks-item__description" )
313+ settings_config_check_warnings (warnings )
314+ infos = driver .find_elements (By .CSS_SELECTOR , "#security-warning li.settings-setup-checks-item--info .settings-setup-checks-item__description" )
315+ settings_config_check_infos (infos )
316+ errors = driver .find_elements (By .CSS_SELECTOR , "#security-warning li.settings-setup-checks-item--error .settings-setup-checks-item__description" )
317+ settings_config_check_errors (errors )
318+
319+ test .check (True )
320+ except Exception as e :
321+ print (driver .find_element (By .CSS_SELECTOR , "#security-warning" ).get_attribute ("innerHTML" ))
322+ test .check (e )
323+
324+
325+ def settings_config_check_pre32 (wait , test ):
326+ try :
327+ wait .until (VisibilityOfElementLocatedByAnyLocator ([(By .CSS_SELECTOR , "#security-warning-state-ok" ),
328+ (By .CSS_SELECTOR , "#security-warning-state-warning" ),
329+ (By .CSS_SELECTOR , "#security-warning-state-error" ),
330+ (By .CSS_SELECTOR , "#security-warning-state-failure" )]))
331+
332+ element_ok = driver .find_element (By .ID , "security-warning-state-ok" )
333+ element_warn = driver .find_element (By .ID , "security-warning-state-warning" )
334+
335+ if element_warn .is_displayed ():
336+
337+ warnings = driver .find_elements (By .CSS_SELECTOR , "#postsetupchecks > .warnings > li" )
338+ settings_config_check_warnings (warnings )
339+
340+ if driver .find_element (By .CSS_SELECTOR , "#postsetupchecks > .errors" ).is_displayed ():
341+ try :
342+ first_error = driver .find_element (By .CSS_SELECTOR , "#postsetupchecks > .errors > li" )
343+ except NoSuchElementException :
344+ first_error = None
345+ raise ConfigTestFailure (f"ERROR: { first_error .text if first_error is not None else 'unexpected error' } " )
346+
347+ infos = driver .find_elements (By .CSS_SELECTOR , "#postsetupchecks > .info > li" )
348+ settings_config_check_infos (infos )
349+
350+
351+ elif not element_ok .is_displayed ():
352+ errors = driver .find_elements (By .CSS_SELECTOR , "#postsetupchecks > .errors > li" )
353+ settings_config_check_errors (errors )
354+
355+ test .check (True )
356+
357+ except Exception as e :
358+
359+ print (driver .find_element (By .CSS_SELECTOR , "#security-warning" ).get_attribute ("innerHTML" ))
360+ test .check (e )
361+
324362
325363if __name__ == "__main__" :
326364 signal .signal (signal .SIGINT , signal_handler )
0 commit comments