ConfigFacadeEjb implements ConfigFacade { @Override public void validateAppUrls() { String appUrl = getAppUrl(); String appLegacyUrl = getAppLegacyUrl(); int[] appVersion = VersionHelper.extractVersion(appUrl); if (!DataHelper.isNullOrEmpty(appUrl) && !VersionHelper.isVersion(appVersion)) { throw new IllegalArgumentException("Property '" + ConfigFacadeEjb.APP_URL + "' must contain a valid version: '" + appUrl + "'"); } int[] appLegacyVersion = VersionHelper.extractVersion(appLegacyUrl); if (!DataHelper.isNullOrEmpty(appLegacyUrl) && !VersionHelper.isVersion(appLegacyVersion)) { throw new IllegalArgumentException( "Property '" + ConfigFacadeEjb.APP_LEGACY_URL + "' must contain a valid version: '" + appLegacyUrl + "'"); } if (appLegacyVersion != null && appVersion != null) { if (!VersionHelper.isBefore(appLegacyVersion, appVersion)) { throw new IllegalArgumentException( "Property '" + ConfigFacadeEjb.APP_LEGACY_URL + "' must have a version smaller " + "than property '" + ConfigFacadeEjb.APP_URL + "': '" + appLegacyUrl + "' - '" + appUrl + "'"); } } if (appVersion != null && InfoProvider.get().isCompatibleToApi(appVersion) != CompatibilityCheckResponse.COMPATIBLE) { throw new IllegalArgumentException( "Property '" + ConfigFacadeEjb.APP_URL + "' does not point to a compatible app version: '" + appUrl + "'. Minimum is '" + InfoProvider.get().getMinimumRequiredVersion() + "'"); } if (appLegacyVersion != null && InfoProvider.get().isCompatibleToApi(appLegacyVersion) != CompatibilityCheckResponse.COMPATIBLE) { throw new IllegalArgumentException( "Property '" + ConfigFacadeEjb.APP_LEGACY_URL + "' does not point to a compatible app version: '" + appLegacyUrl + "'. Minimum is '" + InfoProvider.get().getMinimumRequiredVersion() + "'"); } }  @Override String getCountryName(); @Override String getCountryLocale(); @Override String getCountryCode(); @Override boolean isConfiguredCountry(String countryCode); @Override String getEpidPrefix(); @Override GeoLatLon getCountryCenter(); @Override int getMapZoom(); @Override boolean isDevMode(); @Override boolean isCustomBranding(); @Override String getCustomBrandingName(); @Override String getCustomBrandingLogoPath(); @Override boolean isUseLoginSidebar(); @Override String getLoginBackgroundPath(); @Override String getSormasInstanceName(); @Override String getAppUrl(); @Override String getAppLegacyUrl(); @Override String getTempFilesPath(); @Override String getGeneratedFilesPath(); @Override String getCustomFilesPath(); @Override String getRScriptExecutable(); @Override boolean isFeatureAutomaticCaseClassification(); @Override String getEmailSenderAddress(); @Override String getEmailSenderName(); @Override String getSmsSenderName(); @Override String getSmsAuthKey(); @Override String getSmsAuthSecret(); @Override double getNameSimilarityThreshold(); @Override int getInfrastructureSyncThreshold(); @Override char getCsvSeparator(); @Override int getDaysAfterCaseGetsArchived(); @Override int getDaysAfterEventGetsArchived(); @Override String getGeocodingOsgtsEndpoint(); @Override String getSymptomJournalUrl(); @Override String getSymptomJournalAuthUrl(); @Override String getSymptomJournalClientId(); @Override String getSymptomJournalSecret(); @Override SormasToSormasConfig getSormasToSormasConfig(); @Override String getPatientDiaryUrl(); @Override String getSormasToSormasUserPassword(); @Override void validateExternalUrls(); @Override String getAuthenticationProvider(); @Override void validateAppUrls(); static final String COUNTRY_NAME; static final String COUNTRY_LOCALE; static final String COUNTRY_EPID_PREFIX; static final String VERSION_PLACEHOLER; static final String DEV_MODE; static final String CUSTOM_BRANDING; static final String CUSTOM_BRANDING_NAME; static final String CUSTOM_BRANDING_LOGO_PATH; static final String CUSTOM_BRANDING_USE_LOGIN_SIDEBAR; static final String CUSTOM_BRANDING_LOGIN_BACKGROUND_PATH; static final String APP_URL; static final String APP_LEGACY_URL; static final String FEATURE_AUTOMATIC_CASE_CLASSIFICATION; static final String TEMP_FILES_PATH; static final String GENERATED_FILES_PATH; static final String CUSTOM_FILES_PATH; static final String CSV_SEPARATOR; static final String RSCRIPT_EXECUTABLE; static final String EMAIL_SENDER_ADDRESS; static final String EMAIL_SENDER_NAME; static final String SMS_SENDER_NAME; static final String SMS_AUTH_KEY; static final String SMS_AUTH_SECRET; static final String NAME_SIMILARITY_THRESHOLD; static final String INFRASTRUCTURE_SYNC_THRESHOLD; static final String INTERFACE_SYMPTOM_JOURNAL_URL; static final String INTERFACE_SYMPTOM_JOURNAL_AUTH_URL; static final String INTERFACE_SYMPTOM_JOURNAL_CLIENT_ID; static final String INTERFACE_SYMPTOM_JOURNAL_SECRET; static final String INTERFACE_PATIENT_DIARY_URL; static final String DAYS_AFTER_CASE_GETS_ARCHIVED; }
@Test public void testValidateAppUrls() { Mockito.when(InfoProvider.get().getVersion()).thenReturn("0.7.0"); Mockito.when(InfoProvider.get().getMinimumRequiredVersion()).thenReturn("0.5.0"); MockProducer.getProperties().setProperty(ConfigFacadeEjb.APP_URL, "https: getConfigFacade().validateAppUrls(); MockProducer.getProperties().setProperty(ConfigFacadeEjb.APP_URL, "https: getConfigFacade().validateAppUrls(); MockProducer.getProperties().setProperty(ConfigFacadeEjb.APP_URL, "https: try { getConfigFacade().validateAppUrls(); fail(); } catch (IllegalArgumentException e) { } MockProducer.getProperties().setProperty(ConfigFacadeEjb.APP_URL, "https: try { getConfigFacade().validateAppUrls(); fail(); } catch (IllegalArgumentException e) { } MockProducer.getProperties().setProperty(ConfigFacadeEjb.APP_URL, "https: try { getConfigFacade().validateAppUrls(); fail(); } catch (IllegalArgumentException e) { } Mockito.when(InfoProvider.get().getVersion()).thenReturn("1.0.0"); getConfigFacade().validateAppUrls(); MockProducer.getProperties().setProperty(ConfigFacadeEjb.APP_LEGACY_URL, "https: try { getConfigFacade().validateAppUrls(); fail(); } catch (IllegalArgumentException e) { } MockProducer.getProperties().setProperty(ConfigFacadeEjb.APP_LEGACY_URL, "https: getConfigFacade().validateAppUrls(); MockProducer.getProperties().setProperty(ConfigFacadeEjb.APP_URL, "https: getConfigFacade().validateAppUrls(); MockProducer.getProperties().setProperty(ConfigFacadeEjb.APP_LEGACY_URL, "https: try { getConfigFacade().validateAppUrls(); fail(); } catch (IllegalArgumentException e) { } }