@Test public void testGatewayWhitelistConfig() { TemplatePreparationObject noKerberosTPO = Builder.builder() .withGeneralClusterConfigs(new GeneralClusterConfigs()) .build(); assertEquals(config("gateway_dispatch_whitelist", "^*.*$"), underTest.getGatewayWhitelistConfig(noKerberosTPO)); KerberosConfig kerberosConfig = KerberosConfig.KerberosConfigBuilder.aKerberosConfig() .withDomain("example.com").build(); TemplatePreparationObject kerberosNoAutoTlsTPO = Builder.builder() .withGeneralClusterConfigs(new GeneralClusterConfigs()) .withKerberosConfig(kerberosConfig) .build(); assertEquals(config("gateway_dispatch_whitelist", "^/.*$;^https?: underTest.getGatewayWhitelistConfig(kerberosNoAutoTlsTPO)); GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs(); generalClusterConfigs.setAutoTlsEnabled(true); TemplatePreparationObject kerberosAutoTlsTPO = Builder.builder() .withGeneralClusterConfigs(generalClusterConfigs) .withKerberosConfig(kerberosConfig) .build(); assertEquals(config("gateway_dispatch_whitelist", "^/.*$;^https: underTest.getGatewayWhitelistConfig(kerberosAutoTlsTPO)); }
@VisibleForTesting ApiClusterTemplateConfig getGatewayWhitelistConfig(TemplatePreparationObject source) { String whitelist; Optional<KerberosConfig> kerberosConfig = source.getKerberosConfig(); if (kerberosConfig.isPresent()) { String domain = kerberosConfig.get().getDomain(); if (source.getGeneralClusterConfigs().getAutoTlsEnabled()) { whitelist = "^/.*$;^https: } else { whitelist = "^/.*$;^https?: } } else { whitelist = "^*.*$"; } return config(GATEWAY_WHITELIST, whitelist); }
KnoxGatewayConfigProvider extends AbstractRoleConfigProvider { @VisibleForTesting ApiClusterTemplateConfig getGatewayWhitelistConfig(TemplatePreparationObject source) { String whitelist; Optional<KerberosConfig> kerberosConfig = source.getKerberosConfig(); if (kerberosConfig.isPresent()) { String domain = kerberosConfig.get().getDomain(); if (source.getGeneralClusterConfigs().getAutoTlsEnabled()) { whitelist = "^/.*$;^https: } else { whitelist = "^/.*$;^https?: } } else { whitelist = "^*.*$"; } return config(GATEWAY_WHITELIST, whitelist); } }
KnoxGatewayConfigProvider extends AbstractRoleConfigProvider { @VisibleForTesting ApiClusterTemplateConfig getGatewayWhitelistConfig(TemplatePreparationObject source) { String whitelist; Optional<KerberosConfig> kerberosConfig = source.getKerberosConfig(); if (kerberosConfig.isPresent()) { String domain = kerberosConfig.get().getDomain(); if (source.getGeneralClusterConfigs().getAutoTlsEnabled()) { whitelist = "^/.*$;^https: } else { whitelist = "^/.*$;^https?: } } else { whitelist = "^*.*$"; } return config(GATEWAY_WHITELIST, whitelist); }  }
KnoxGatewayConfigProvider extends AbstractRoleConfigProvider { @VisibleForTesting ApiClusterTemplateConfig getGatewayWhitelistConfig(TemplatePreparationObject source) { String whitelist; Optional<KerberosConfig> kerberosConfig = source.getKerberosConfig(); if (kerberosConfig.isPresent()) { String domain = kerberosConfig.get().getDomain(); if (source.getGeneralClusterConfigs().getAutoTlsEnabled()) { whitelist = "^/.*$;^https: } else { whitelist = "^/.*$;^https?: } } else { whitelist = "^*.*$"; } return config(GATEWAY_WHITELIST, whitelist); }  @Override Map<String, ApiClusterTemplateService> getAdditionalServices(CmTemplateProcessor cmTemplateProcessor, TemplatePreparationObject source); @Override String getServiceType(); @Override List<String> getRoleTypes(); }
KnoxGatewayConfigProvider extends AbstractRoleConfigProvider { @VisibleForTesting ApiClusterTemplateConfig getGatewayWhitelistConfig(TemplatePreparationObject source) { String whitelist; Optional<KerberosConfig> kerberosConfig = source.getKerberosConfig(); if (kerberosConfig.isPresent()) { String domain = kerberosConfig.get().getDomain(); if (source.getGeneralClusterConfigs().getAutoTlsEnabled()) { whitelist = "^/.*$;^https: } else { whitelist = "^/.*$;^https?: } } else { whitelist = "^*.*$"; } return config(GATEWAY_WHITELIST, whitelist); }  @Override Map<String, ApiClusterTemplateService> getAdditionalServices(CmTemplateProcessor cmTemplateProcessor, TemplatePreparationObject source); @Override String getServiceType(); @Override List<String> getRoleTypes();  }