def test_url_with_multiple_slashes(): assert (config_clean.remove_trailing_slashes("http://example.com/a/b/c") == "http://example.com/a/b/c") assert (config_clean.remove_trailing_slashes("http://example.com/a/b/c/") == "http://example.com/a/b/c") assert (config_clean.remove_trailing_slashes("http://example.com/a/b/c///") == "http://example.com/a/b/c")
def web_service_url_scheme_host_port(cls, val: str) -> str: # Tokenize the web url url = urlparse(val) if url.scheme not in ["http", "https"]: raise ConfigurationError( f"Scheme should be http or https, found {url.scheme}" ) if not _is_valid_hostname(url.hostname.__str__()): raise ConfigurationError( f"Not a valid hostname, hostname contains invalid characters, found {url.hostname}" ) return config_clean.remove_trailing_slashes(val)
def one_of_host_port_or_account_id_is_required(cls, values): host_port = values.get("host_port") if host_port is not None: logger.warning( "snowflake's `host_port` option has been deprecated; use account_id instead" ) host_port = remove_protocol(host_port) host_port = remove_trailing_slashes(host_port) host_port = remove_suffix(host_port, ".snowflakecomputing.com") values["host_port"] = host_port account_id = values.get("account_id") if account_id is None: if host_port is None: raise ConfigurationError( "One of account_id (recommended) or host_port (deprecated) is required" ) else: values["account_id"] = host_port return values
def remove_trailing_slash(cls, v): return config_clean.remove_trailing_slashes(v)
def test_url_with_suffix(): assert (config_clean.remove_trailing_slashes("http://example.com/") == "http://example.com")
def host_port_is_valid(cls, v, values, **kwargs): v = remove_protocol(v) v = remove_trailing_slashes(v) v = remove_suffix(v, ".snowflakecomputing.com") return v
def host_port_is_valid(cls, v, values, **kwargs): v = remove_protocol(v) v = remove_trailing_slashes(v) v = remove_suffix(v, ".snowflakecomputing.com") logger.info(f"Cleaned Host port is {v}") return v