def test_prompt_postgres_install(monkeypatch, settings): from pygluu.kubernetes.terminal.postgres import PromptPostgres monkeypatch.setattr("click.confirm", lambda x, default: True) settings.set("installer-settings.postgres.namespace", "postgres") settings.set("installer-settings.postgres.install", "") prompt = PromptPostgres(settings) prompt.prompt_postgres() assert settings.get("installer-settings.postgres.install") == True
class PromptJackrabbit: """Prompt is used for prompting users for input used in deploying Gluu. """ def __init__(self, settings): self.settings = settings self.postgres = PromptPostgres(self.settings) def prompt_jackrabbit(self): """Prompts for Jackrabbit content repository """ if self.settings.get("global.jackrabbit.enabled") in (None, ''): logger.info("Jackrabbit must be installed. If the following prompt is answered with N it is assumed " "the jackrabbit content repository is either installed locally or remotely") self.settings.set("global.jackrabbit.enabled", click.confirm("Install Jackrabbit content repository", default=True)) jackrabbit_cluster_prompt = "Is" if self.settings.get("global.jackrabbit.enabled"): if self.settings.get("jackrabbit.storage.size") in (None, ''): self.settings.set("jackrabbit.storage.size", click.prompt( "Size of Jackrabbit content repository volume storage", default="4Gi")) self.settings.set("config.configmap.cnJackrabbitUrl", "http://jackrabbit:8080") jackrabbit_cluster_prompt = "Enable" if self.settings.get("config.configmap.cnJackrabbitUrl") in (None, ''): self.settings.set("config.configmap.cnJackrabbitUrl", click.prompt("Please enter jackrabbit url.", default="http://jackrabbit:8080")) if self.settings.get("config.configmap.cnJackrabbitAdminId") in (None, ''): self.settings.set("config.configmap.cnJackrabbitAdminId", click.prompt("Please enter Jackrabbit admin user", default="admin")) if self.settings.get("jackrabbit.secrets.cnJackrabbitAdminPassword") in (None, ''): self.settings.set("jackrabbit.secrets.cnJackrabbitAdminPassword", prompt_password("jackrabbit-admin", 24)) if self.settings.get("installer-settings.jackrabbit.clusterMode") in (None, ''): self.settings.set("installer-settings.jackrabbit.clusterMode", click.confirm("{} Jackrabbit in cluster mode[beta] " "Recommended in production" .format(jackrabbit_cluster_prompt), default=True)) if self.settings.get("installer-settings.jackrabbit.clusterMode"): self.postgres.prompt_postgres() if self.settings.get("config.configmap.cnJackrabbitPostgresUser") in (None, ''): self.settings.set("config.configmap.cnJackrabbitPostgresUser", click.prompt("Please enter a user for jackrabbit postgres database", default="jackrabbit")) if self.settings.get("jackrabbit.secrets.cnJackrabbitPostgresPassword") in (None, ''): self.settings.set("jackrabbit.secrets.cnJackrabbitPostgresPassword", prompt_password("jackrabbit-postgres")) if self.settings.get("config.configmap.cnJackrabbitPostgresDatabaseName") in (None, ''): self.settings.set("config.configmap.cnJackrabbitPostgresDatabaseName", click.prompt("Please enter jackrabbit postgres database name", default="jackrabbit"))
def test_postgres_namespace(monkeypatch, settings, given, expected): from pygluu.kubernetes.terminal.postgres import PromptPostgres monkeypatch.setattr("click.prompt", lambda x, default: given or expected) settings.set("CN_POSTGRES_REPLICAS", 3) settings.set("CN_POSTGRES_URL", "postgres.postgres.svc.cluster.local") prompt = PromptPostgres(settings) prompt.prompt_postgres() assert settings.get("installer-settings.postgres.install") == expected
def test_postgres_url(monkeypatch, settings, given, expected): from pygluu.kubernetes.terminal.postgres import PromptPostgres monkeypatch.setattr("click.prompt", lambda x, default: given or expected) settings.set("POSTGRES_NAMESPACE", "postgres") settings.set("POSTGRES_REPLICAS", 3) prompt = PromptPostgres(settings) prompt.prompt_postgres() assert settings.get("POSTGRES_URL") == expected
def test_postgres_namespace(monkeypatch, settings, given, expected): from pygluu.kubernetes.terminal.postgres import PromptPostgres monkeypatch.setattr("click.prompt", lambda x, default: given or expected) settings.set("installer-settings.postgres.install", True) settings.set("config.configmap.cnJackrabbitPostgresHost", "postgres.postgres.svc.cluster.local") settings.set("installer-settings.postgres.namespace", "") prompt = PromptPostgres(settings) prompt.prompt_postgres() assert settings.get("installer-settings.postgres.namespace") == expected
def __init__(self, settings): self.settings = settings self.postgres = PromptPostgres(self.settings)
def __init__(self, settings): self.settings = settings self.enabled_services = self.settings.get("ENABLED_SERVICES_LIST") self.postgres = PromptPostgres(self.settings)
class PromptGluuGateway: """Prompt is used for prompting users for input used in deploying Gluu. """ def __init__(self, settings): self.settings = settings self.enabled_services = self.settings.get("ENABLED_SERVICES_LIST") self.postgres = PromptPostgres(self.settings) def prompt_gluu_gateway(self): """Prompts for Gluu Gateway """ if not self.settings.get("INSTALL_GLUU_GATEWAY"): self.settings.set( "INSTALL_GLUU_GATEWAY", confirm_yesno("Install Gluu Gateway Database mode")) if self.settings.get("INSTALL_GLUU_GATEWAY") == "Y": self.enabled_services.append("gluu-gateway-ui") self.settings.set("ENABLED_SERVICES_LIST", self.enabled_services) self.settings.set("ENABLE_CLIENT_API", "Y") self.postgres.prompt_postgres() if not self.settings.get("KONG_NAMESPACE"): self.settings.set( "KONG_NAMESPACE", click.prompt("Please enter a namespace for Gluu Gateway", default="gluu-gateway")) if not self.settings.get("GLUU_GATEWAY_UI_NAMESPACE"): self.settings.set( "GLUU_GATEWAY_UI_NAMESPACE", click.prompt( "Please enter a namespace for gluu gateway ui", default="gg-ui")) if not self.settings.get("KONG_PG_USER"): self.settings.set( "KONG_PG_USER", click.prompt( "Please enter a user for gluu-gateway postgres database", default="kong")) if not self.settings.get("KONG_PG_PASSWORD"): self.settings.set("KONG_PG_PASSWORD", prompt_password("gluu-gateway-postgres")) if not self.settings.get("GLUU_GATEWAY_UI_PG_USER"): self.settings.set( "GLUU_GATEWAY_UI_PG_USER", click.prompt( "Please enter a user for gluu-gateway-ui postgres database", default="konga")) if not self.settings.get("GLUU_GATEWAY_UI_PG_PASSWORD"): self.settings.set("GLUU_GATEWAY_UI_PG_PASSWORD", prompt_password("gluu-gateway-ui-postgres")) if not self.settings.get("KONG_DATABASE"): self.settings.set( "KONG_DATABASE", click.prompt( "Please enter gluu-gateway postgres database name", default="kong")) if not self.settings.get("GLUU_GATEWAY_UI_DATABASE"): self.settings.set( "GLUU_GATEWAY_UI_DATABASE", click.prompt( "Please enter gluu-gateway-ui postgres database name", default="konga"))
class PromptJackrabbit: """Prompt is used for prompting users for input used in deploying Gluu. """ def __init__(self, settings): self.settings = settings self.postgres = PromptPostgres(self.settings) def prompt_jackrabbit(self): """Prompts for Jackrabbit content repository """ if not self.settings.get("INSTALL_JACKRABBIT"): logger.info( "Jackrabbit must be installed. If the following prompt is answered with N it is assumed " "the jackrabbit content repository is either installed locally or remotely" ) self.settings.set( "INSTALL_JACKRABBIT", confirm_yesno("Install Jackrabbit content repository", default=True)) jackrabbit_cluster_prompt = "Is" if self.settings.get("INSTALL_JACKRABBIT") == "Y": if not self.settings.get("JACKRABBIT_STORAGE_SIZE"): self.settings.set( "JACKRABBIT_STORAGE_SIZE", click.prompt( "Size of Jackrabbit content repository volume storage", default="4Gi")) self.settings.set("JACKRABBIT_URL", "http://jackrabbit:8080") jackrabbit_cluster_prompt = "Enable" if not self.settings.get("JACKRABBIT_URL"): self.settings.set( "JACKRABBIT_URL", click.prompt("Please enter jackrabbit url.", default="http://jackrabbit:8080")) if not self.settings.get("JACKRABBIT_ADMIN_ID"): self.settings.set( "JACKRABBIT_ADMIN_ID", click.prompt("Please enter Jackrabit admin user", default="admin")) if not self.settings.get("JACKRABBIT_ADMIN_PASSWORD"): self.settings.set("JACKRABBIT_ADMIN_PASSWORD", prompt_password("jackrabbit-admin", 24)) if not self.settings.get("JACKRABBIT_CLUSTER"): self.settings.set( "JACKRABBIT_CLUSTER", confirm_yesno("{} Jackrabbit in cluster mode[beta] " "Recommended in production".format( jackrabbit_cluster_prompt), default=True)) if self.settings.get("JACKRABBIT_CLUSTER") == "Y": self.postgres.prompt_postgres() if not self.settings.get("JACKRABBIT_PG_USER"): self.settings.set( "JACKRABBIT_PG_USER", click.prompt( "Please enter a user for jackrabbit postgres " "database", default="jackrabbit")) if not self.settings.get("JACKRABBIT_PG_PASSWORD"): self.settings.set("JACKRABBIT_PG_PASSWORD", prompt_password("jackrabbit-postgres")) if not self.settings.get("JACKRABBIT_DATABASE"): self.settings.set( "JACKRABBIT_DATABASE", click.prompt( "Please enter jackrabbit postgres database name", default="jackrabbit"))