mirror of
https://github.com/enso-org/enso.git
synced 2024-12-22 20:31:45 +03:00
Stop publishing Postgres
constructor, update Postgres_Details.Postgres
to Postgres.Server
. (#10466)
![image](https://github.com/enso-org/enso/assets/4699705/6d0d4167-e97b-4765-8079-650ad091ce60) - Rename `Postgres_Details` to `Postgres`. - Rename `Postgres` constructor to `Server`. - Update SPI. - Linting issues (indent, missing doc comment)
This commit is contained in:
parent
2952603931
commit
018d4c312f
@ -12,9 +12,11 @@
|
|||||||
methods.][10434]
|
methods.][10434]
|
||||||
- [Renamed `Location.Start` to `Location.Left` and `Location.End` to
|
- [Renamed `Location.Start` to `Location.Left` and `Location.End` to
|
||||||
`Location.Right`.][10445]
|
`Location.Right`.][10445]
|
||||||
|
- [Renamed `Postgres_Details.Postgres` to `Postgres.Server`.][10466]
|
||||||
|
|
||||||
[10434]: https://github.com/enso-org/enso/pull/10434
|
[10434]: https://github.com/enso-org/enso/pull/10434
|
||||||
[10445]: https://github.com/enso-org/enso/pull/10445
|
[10445]: https://github.com/enso-org/enso/pull/10445
|
||||||
|
[10466]: https://github.com/enso-org/enso/pull/10466
|
||||||
|
|
||||||
# Enso 2024.2
|
# Enso 2024.2
|
||||||
|
|
||||||
|
@ -74,12 +74,11 @@ type Redshift_Dialect
|
|||||||
wrap_identifier self identifier =
|
wrap_identifier self identifier =
|
||||||
Base_Generator.wrap_in_quotes identifier
|
Base_Generator.wrap_in_quotes identifier
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Generates a SQL expression for a table literal.
|
Generates a SQL expression for a table literal.
|
||||||
make_table_literal : Vector (Vector Text) -> Vector Text -> Text -> SQL_Builder
|
make_table_literal : Vector (Vector Text) -> Vector Text -> Text -> SQL_Builder
|
||||||
make_table_literal self vecs column_names as_name =
|
make_table_literal self vecs column_names as_name =
|
||||||
Base_Generator.default_make_table_literal self.wrap_identifier vecs column_names as_name
|
Base_Generator.default_make_table_literal self.wrap_identifier vecs column_names as_name
|
||||||
|
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Prepares an ordering descriptor.
|
Prepares an ordering descriptor.
|
||||||
|
@ -2,7 +2,6 @@ import project.Any.Any
|
|||||||
import project.Data.Array.Array
|
import project.Data.Array.Array
|
||||||
import project.Data.Array_Proxy.Array_Proxy
|
import project.Data.Array_Proxy.Array_Proxy
|
||||||
import project.Data.Decimal.Decimal
|
import project.Data.Decimal.Decimal
|
||||||
import project.Data.Numeric.Math_Context.Math_Context
|
|
||||||
import project.Data.Json.JS_Object
|
import project.Data.Json.JS_Object
|
||||||
import project.Data.Json.Json
|
import project.Data.Json.Json
|
||||||
import project.Data.Locale.Locale
|
import project.Data.Locale.Locale
|
||||||
@ -10,12 +9,13 @@ import project.Data.Map.Map
|
|||||||
import project.Data.Numbers.Float
|
import project.Data.Numbers.Float
|
||||||
import project.Data.Numbers.Integer
|
import project.Data.Numbers.Integer
|
||||||
import project.Data.Numbers.Number
|
import project.Data.Numbers.Number
|
||||||
|
import project.Data.Numeric.Math_Context.Math_Context
|
||||||
import project.Data.Text.Text
|
import project.Data.Text.Text
|
||||||
import project.Data.Text.Text_Sub_Range.Text_Sub_Range
|
import project.Data.Text.Text_Sub_Range.Text_Sub_Range
|
||||||
import project.Data.Vector.Vector
|
import project.Data.Vector.Vector
|
||||||
import project.Error.Error
|
import project.Error.Error
|
||||||
import project.Errors.Illegal_Argument.Illegal_Argument
|
|
||||||
import project.Errors.Deprecated.Deprecated
|
import project.Errors.Deprecated.Deprecated
|
||||||
|
import project.Errors.Illegal_Argument.Illegal_Argument
|
||||||
import project.Meta
|
import project.Meta
|
||||||
import project.Nothing.Nothing
|
import project.Nothing.Nothing
|
||||||
import project.Warning.Warning
|
import project.Warning.Warning
|
||||||
|
@ -9,7 +9,7 @@ from project.Errors import SQL_Error
|
|||||||
## Specifies the connection details for the database.
|
## Specifies the connection details for the database.
|
||||||
|
|
||||||
This is an interface that is implemented by particular database types, like
|
This is an interface that is implemented by particular database types, like
|
||||||
`Postgres_Details`, `SQLite` etc.
|
`Postgres`, `SQLite` etc.
|
||||||
type Connection_Details
|
type Connection_Details
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
|
@ -8,17 +8,17 @@ from Standard.Base.Enso_Cloud.Public_Utils import get_optional_field, get_requir
|
|||||||
|
|
||||||
import project.Connection.Connection_Options.Connection_Options
|
import project.Connection.Connection_Options.Connection_Options
|
||||||
import project.Connection.Credentials.Credentials
|
import project.Connection.Credentials.Credentials
|
||||||
import project.Connection.Postgres_Details.Postgres_Details
|
import project.Connection.Postgres.Postgres
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
type Postgres_Data_Link
|
type Postgres_Data_Link
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
A data-link returning a connection to the specified database.
|
A data-link returning a connection to the specified database.
|
||||||
Connection details:Postgres_Details
|
Connection details:Postgres
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
A data-link returning a query to a specific table within a database.
|
A data-link returning a query to a specific table within a database.
|
||||||
Table name:Text details:Postgres_Details
|
Table name:Text details:Postgres
|
||||||
|
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
@ -34,7 +34,7 @@ type Postgres_Data_Link
|
|||||||
password = get_required_field "password" credentials_json |> parse_secure_value
|
password = get_required_field "password" credentials_json |> parse_secure_value
|
||||||
Credentials.Username_And_Password username password
|
Credentials.Username_And_Password username password
|
||||||
|
|
||||||
details = Postgres_Details.Postgres host=host port=port database=db_name schema=schema credentials=credentials
|
details = Postgres.Server host=host port=port database=db_name schema=schema credentials=credentials
|
||||||
case get_optional_field "table" json expected_type=Text of
|
case get_optional_field "table" json expected_type=Text of
|
||||||
Nothing ->
|
Nothing ->
|
||||||
Postgres_Data_Link.Connection details
|
Postgres_Data_Link.Connection details
|
||||||
|
@ -12,7 +12,7 @@ import project.Internal.Postgres.Postgres_Data_Link_Setup.Postgres_Data_Link_Set
|
|||||||
|
|
||||||
polyglot java import org.postgresql.Driver
|
polyglot java import org.postgresql.Driver
|
||||||
|
|
||||||
type Postgres_Details
|
type Postgres
|
||||||
## Connect to a PostgreSQL database.
|
## Connect to a PostgreSQL database.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
@ -28,7 +28,7 @@ type Postgres_Details
|
|||||||
- use_ssl: Whether to use SSL (defaults to `SSL_Mode.Prefer`).
|
- use_ssl: Whether to use SSL (defaults to `SSL_Mode.Prefer`).
|
||||||
- client_cert: The client certificate to use or `Nothing` if not needed.
|
- client_cert: The client certificate to use or `Nothing` if not needed.
|
||||||
@credentials Credentials.default_widget
|
@credentials Credentials.default_widget
|
||||||
Postgres (host:Text=default_postgres_host) (port:Integer=default_postgres_port) (database:Text=default_postgres_database) (schema:Text="") (credentials:(Credentials|Nothing)=Nothing) (use_ssl:SSL_Mode=SSL_Mode.Prefer) (client_cert:(Client_Certificate|Nothing)=Nothing)
|
Server (host:Text=default_postgres_host) (port:Integer=default_postgres_port) (database:Text=default_postgres_database) (schema:Text="") (credentials:(Credentials|Nothing)=Nothing) (use_ssl:SSL_Mode=SSL_Mode.Prefer) (client_cert:(Client_Certificate|Nothing)=Nothing)
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Build the Connection resource.
|
Build the Connection resource.
|
||||||
@ -46,7 +46,7 @@ type Postgres_Details
|
|||||||
|
|
||||||
## Cannot use default argument values as gets in an infinite loop if you do.
|
## Cannot use default argument values as gets in an infinite loop if you do.
|
||||||
make_new database schema =
|
make_new database schema =
|
||||||
Postgres_Details.Postgres self.host self.port (database.if_nothing self.database) (schema.if_nothing self.schema) self.credentials self.use_ssl self.client_cert . connect options allow_data_links
|
Postgres.Server self.host self.port (database.if_nothing self.database) (schema.if_nothing self.schema) self.credentials self.use_ssl self.client_cert . connect options allow_data_links
|
||||||
|
|
||||||
Postgres_Connection.create self.jdbc_url properties make_new data_link_setup
|
Postgres_Connection.create self.jdbc_url properties make_new data_link_setup
|
||||||
|
|
@ -8,13 +8,13 @@ import Standard.Base.Runtime.Context
|
|||||||
from Standard.Base.Enso_Cloud.Data_Link_Helpers import data_link_extension, secure_value_to_json
|
from Standard.Base.Enso_Cloud.Data_Link_Helpers import data_link_extension, secure_value_to_json
|
||||||
|
|
||||||
import project.Connection.Credentials.Credentials
|
import project.Connection.Credentials.Credentials
|
||||||
import project.Connection.Postgres_Details.Postgres_Details
|
import project.Connection.Postgres.Postgres
|
||||||
import project.Connection.SSL_Mode.SSL_Mode
|
import project.Connection.SSL_Mode.SSL_Mode
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
type Postgres_Data_Link_Setup
|
type Postgres_Data_Link_Setup
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Available details:Postgres_Details
|
Available details:Postgres
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Unavailable cause:Text
|
Unavailable cause:Text
|
||||||
@ -45,7 +45,7 @@ type Postgres_Data_Link_Setup
|
|||||||
Error.throw (Illegal_Argument.Error "Cannot save connection as Data Link: "+cause)
|
Error.throw (Illegal_Argument.Error "Cannot save connection as Data Link: "+cause)
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
prepare_credentials data_link_location:Enso_File details:Postgres_Details -> JS_Object | Nothing =
|
prepare_credentials data_link_location:Enso_File details:Postgres -> JS_Object | Nothing =
|
||||||
case details.credentials of
|
case details.credentials of
|
||||||
Nothing -> Nothing
|
Nothing -> Nothing
|
||||||
credentials:Credentials ->
|
credentials:Credentials ->
|
||||||
|
@ -85,11 +85,11 @@ type Postgres_Dialect
|
|||||||
wrap_identifier self identifier =
|
wrap_identifier self identifier =
|
||||||
Base_Generator.wrap_in_quotes identifier
|
Base_Generator.wrap_in_quotes identifier
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Generates a SQL expression for a table literal.
|
Generates a SQL expression for a table literal.
|
||||||
make_table_literal : Vector (Vector Text) -> Vector Text -> Text -> SQL_Builder
|
make_table_literal : Vector (Vector Text) -> Vector Text -> Text -> SQL_Builder
|
||||||
make_table_literal self vecs column_names as_name =
|
make_table_literal self vecs column_names as_name =
|
||||||
Base_Generator.default_make_table_literal self.wrap_identifier vecs column_names as_name
|
Base_Generator.default_make_table_literal self.wrap_identifier vecs column_names as_name
|
||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
Prepares an ordering descriptor.
|
Prepares an ordering descriptor.
|
||||||
|
@ -64,6 +64,8 @@ type SQLite_Dialect
|
|||||||
generate_sql self query =
|
generate_sql self query =
|
||||||
Base_Generator.generate_query self query . build
|
Base_Generator.generate_query self query . build
|
||||||
|
|
||||||
|
## PRIVATE
|
||||||
|
Generates SQL to truncate a table.
|
||||||
generate_truncate_table_sql : Text -> SQL_Builder
|
generate_truncate_table_sql : Text -> SQL_Builder
|
||||||
generate_truncate_table_sql self table_name =
|
generate_truncate_table_sql self table_name =
|
||||||
Base_Generator.truncate_table_delete_from_style self table_name
|
Base_Generator.truncate_table_delete_from_style self table_name
|
||||||
|
@ -3,12 +3,11 @@ export project.Connection.Client_Certificate.Client_Certificate
|
|||||||
export project.Connection.Connection_Options.Connection_Options
|
export project.Connection.Connection_Options.Connection_Options
|
||||||
export project.Connection.Credentials.Credentials
|
export project.Connection.Credentials.Credentials
|
||||||
export project.Connection.Database
|
export project.Connection.Database
|
||||||
export project.Connection.Postgres_Details.Postgres_Details
|
export project.Connection.Postgres.Postgres
|
||||||
export project.Connection.SQLite.SQLite
|
export project.Connection.SQLite.SQLite
|
||||||
export project.Connection.SQLite_Format.SQLite_Format
|
export project.Connection.SQLite_Format.SQLite_Format
|
||||||
export project.Connection.SSL_Mode.SSL_Mode
|
export project.Connection.SSL_Mode.SSL_Mode
|
||||||
export project.SQL_Query.SQL_Query
|
export project.SQL_Query.SQL_Query
|
||||||
export project.Update_Action.Update_Action
|
export project.Update_Action.Update_Action
|
||||||
from project.Connection.Postgres_Details.Postgres_Details export Postgres
|
|
||||||
from project.Extensions.Upload_Database_Table export all
|
from project.Extensions.Upload_Database_Table export all
|
||||||
from project.Extensions.Upload_In_Memory_Table export all
|
from project.Extensions.Upload_In_Memory_Table export all
|
||||||
|
@ -41,7 +41,7 @@ type Snowflake_Connection
|
|||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
|
|
||||||
A Postgres database connection.
|
A Snowflake database connection.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
- connection: the underlying connection.
|
- connection: the underlying connection.
|
||||||
|
@ -6,17 +6,17 @@ import org.enso.database.DatabaseConnectionDetailsSPI;
|
|||||||
public class PostgresConnectionDetailsSPI extends DatabaseConnectionDetailsSPI {
|
public class PostgresConnectionDetailsSPI extends DatabaseConnectionDetailsSPI {
|
||||||
@Override
|
@Override
|
||||||
protected String getModuleName() {
|
protected String getModuleName() {
|
||||||
return "Standard.Database.Connection.Postgres_Details";
|
return "Standard.Database.Connection.Postgres";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTypeName() {
|
protected String getTypeName() {
|
||||||
return "Postgres_Details";
|
return "Postgres";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getCodeForDefaultConstructor() {
|
protected String getCodeForDefaultConstructor() {
|
||||||
return "(Postgres 'localhost' 5432)";
|
return "(Postgres.Server 'localhost' 5432)";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -728,27 +728,27 @@ add_table_specs suite_builder =
|
|||||||
|
|
||||||
suite_builder.group "[PostgreSQL] SSL connectivity tests" pending=ssl_pending group_builder->
|
suite_builder.group "[PostgreSQL] SSL connectivity tests" pending=ssl_pending group_builder->
|
||||||
group_builder.specify "should connect without ssl parameter" <|
|
group_builder.specify "should connect without ssl parameter" <|
|
||||||
Database.connect (Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password)) . should_succeed
|
Database.connect (Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password)) . should_succeed
|
||||||
|
|
||||||
group_builder.specify "should connect, requiring SSL" <|
|
group_builder.specify "should connect, requiring SSL" <|
|
||||||
Database.connect (Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=SSL_Mode.Require) . should_succeed
|
Database.connect (Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=SSL_Mode.Require) . should_succeed
|
||||||
|
|
||||||
group_builder.specify "should connect be able to verify the certificate" <|
|
group_builder.specify "should connect be able to verify the certificate" <|
|
||||||
Database.connect (Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Verify_CA ca_cert_file)) . should_succeed
|
Database.connect (Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Verify_CA ca_cert_file)) . should_succeed
|
||||||
|
|
||||||
## Default certificate should not accept the self signed certificate.
|
## Default certificate should not accept the self signed certificate.
|
||||||
ca_fail = Database.connect (Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=SSL_Mode.Verify_CA)
|
ca_fail = Database.connect (Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=SSL_Mode.Verify_CA)
|
||||||
ca_fail.is_error . should_equal True
|
ca_fail.is_error . should_equal True
|
||||||
ca_fail.catch SQL_Error . is_a SQL_Error . should_equal True
|
ca_fail.catch SQL_Error . is_a SQL_Error . should_equal True
|
||||||
|
|
||||||
group_builder.specify "should connect be able to verify the host name against the certificate" <|
|
group_builder.specify "should connect be able to verify the host name against the certificate" <|
|
||||||
Database.connect (Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Full_Verification ca_cert_file)) . should_succeed
|
Database.connect (Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Full_Verification ca_cert_file)) . should_succeed
|
||||||
|
|
||||||
alternate_host = Environment.get "ENSO_POSTGRES_ALTERNATE_HOST" . if_nothing <|
|
alternate_host = Environment.get "ENSO_POSTGRES_ALTERNATE_HOST" . if_nothing <|
|
||||||
if db_host == "127.0.0.1" then "localhost" else Nothing
|
if db_host == "127.0.0.1" then "localhost" else Nothing
|
||||||
pending_alternate = if alternate_host.is_nothing then "Alternative host name not configured." else Nothing
|
pending_alternate = if alternate_host.is_nothing then "Alternative host name not configured." else Nothing
|
||||||
group_builder.specify "should fail to connect with alternate host name not valid in certificate" pending=pending_alternate <|
|
group_builder.specify "should fail to connect with alternate host name not valid in certificate" pending=pending_alternate <|
|
||||||
ca_fail = Database.connect (Postgres alternate_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Full_Verification ca_cert_file))
|
ca_fail = Database.connect (Postgres.Server alternate_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Full_Verification ca_cert_file))
|
||||||
ca_fail.is_error . should_equal True
|
ca_fail.is_error . should_equal True
|
||||||
ca_fail.catch SQL_Error . is_a SQL_Error . should_equal True
|
ca_fail.catch SQL_Error . is_a SQL_Error . should_equal True
|
||||||
|
|
||||||
@ -770,7 +770,7 @@ add_table_specs suite_builder =
|
|||||||
with_secret "my_postgres_username" db_user username_secret-> with_secret "my_postgres_password" db_password password_secret->
|
with_secret "my_postgres_username" db_user username_secret-> with_secret "my_postgres_password" db_password password_secret->
|
||||||
my_secret_name = "Enso Test: My Secret App NAME " + (Random.uuid.take 5)
|
my_secret_name = "Enso Test: My Secret App NAME " + (Random.uuid.take 5)
|
||||||
with_secret "my_postgres_app_name" my_secret_name app_name_secret-> Test.with_retries <|
|
with_secret "my_postgres_app_name" my_secret_name app_name_secret-> Test.with_retries <|
|
||||||
details = Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password username_secret password_secret)
|
details = Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password username_secret password_secret)
|
||||||
# We set the ApplicationName option, so that we can see that secrets can be used in custom properties.
|
# We set the ApplicationName option, so that we can see that secrets can be used in custom properties.
|
||||||
options = Connection_Options.Value [["ApplicationName", app_name_secret]]
|
options = Connection_Options.Value [["ApplicationName", app_name_secret]]
|
||||||
connection = Database.connect details options
|
connection = Database.connect details options
|
||||||
@ -794,7 +794,7 @@ get_configured_connection_details =
|
|||||||
db_user = Environment.get "ENSO_POSTGRES_USER"
|
db_user = Environment.get "ENSO_POSTGRES_USER"
|
||||||
db_password = Environment.get "ENSO_POSTGRES_PASSWORD"
|
db_password = Environment.get "ENSO_POSTGRES_PASSWORD"
|
||||||
if db_name.is_nothing then Nothing else
|
if db_name.is_nothing then Nothing else
|
||||||
Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password)
|
Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password)
|
||||||
|
|
||||||
## Returns a function that takes anything and returns a new connection.
|
## Returns a function that takes anything and returns a new connection.
|
||||||
The function creates a _new_ connection on each invocation
|
The function creates a _new_ connection on each invocation
|
||||||
@ -852,12 +852,12 @@ add_pgpass_specs suite_builder = suite_builder.group "[PostgreSQL] .pgpass" grou
|
|||||||
|
|
||||||
add_connection_setup_specs suite_builder = suite_builder.group "[PostgreSQL] Connection setup" group_builder->
|
add_connection_setup_specs suite_builder = suite_builder.group "[PostgreSQL] Connection setup" group_builder->
|
||||||
group_builder.specify "should use environment variables as host, port and database defaults and fall back to hardcoded defaults" <|
|
group_builder.specify "should use environment variables as host, port and database defaults and fall back to hardcoded defaults" <|
|
||||||
c1 = Postgres "example.com" 12345 "my_db"
|
c1 = Postgres.Server "example.com" 12345 "my_db"
|
||||||
c2 = Postgres
|
c2 = Postgres.Server
|
||||||
c3 = Test_Environment.unsafe_with_environment_override "PGHOST" "192.168.0.1" <|
|
c3 = Test_Environment.unsafe_with_environment_override "PGHOST" "192.168.0.1" <|
|
||||||
Test_Environment.unsafe_with_environment_override "PGPORT" "1000" <|
|
Test_Environment.unsafe_with_environment_override "PGPORT" "1000" <|
|
||||||
Test_Environment.unsafe_with_environment_override "PGDATABASE" "ensoDB" <|
|
Test_Environment.unsafe_with_environment_override "PGDATABASE" "ensoDB" <|
|
||||||
Postgres
|
Postgres.Server
|
||||||
|
|
||||||
c1.host . should_equal "example.com"
|
c1.host . should_equal "example.com"
|
||||||
c1.port . should_equal 12345
|
c1.port . should_equal 12345
|
||||||
@ -877,7 +877,7 @@ add_connection_setup_specs suite_builder = suite_builder.group "[PostgreSQL] Con
|
|||||||
## Currently we require the port to be numeric. When we support
|
## Currently we require the port to be numeric. When we support
|
||||||
Unix-sockets, we may lift that restriction.
|
Unix-sockets, we may lift that restriction.
|
||||||
c4 = Test_Environment.unsafe_with_environment_override "PGPORT" "foobar" <|
|
c4 = Test_Environment.unsafe_with_environment_override "PGPORT" "foobar" <|
|
||||||
Postgres
|
Postgres.Server
|
||||||
c4.host . should_equal "localhost"
|
c4.host . should_equal "localhost"
|
||||||
c4.port . should_equal 5432
|
c4.port . should_equal 5432
|
||||||
c4.database . should_equal "postgres"
|
c4.database . should_equal "postgres"
|
||||||
@ -885,12 +885,12 @@ add_connection_setup_specs suite_builder = suite_builder.group "[PostgreSQL] Con
|
|||||||
|
|
||||||
add_ssl props = props+[Pair.new 'sslmode' 'prefer']
|
add_ssl props = props+[Pair.new 'sslmode' 'prefer']
|
||||||
group_builder.specify "should use the given credentials" <|
|
group_builder.specify "should use the given credentials" <|
|
||||||
c = Postgres credentials=(Credentials.Username_And_Password "myuser" "mypass")
|
c = Postgres.Server credentials=(Credentials.Username_And_Password "myuser" "mypass")
|
||||||
c.jdbc_url . should_equal "jdbc:postgresql://localhost:5432/postgres"
|
c.jdbc_url . should_equal "jdbc:postgresql://localhost:5432/postgres"
|
||||||
c.jdbc_properties . should_equal <| add_ssl [Pair.new "user" "myuser", Pair.new "password" "mypass"]
|
c.jdbc_properties . should_equal <| add_ssl [Pair.new "user" "myuser", Pair.new "password" "mypass"]
|
||||||
|
|
||||||
group_builder.specify "should fallback to environment variables and fill-out missing information based on the PGPASS file (if available)" <|
|
group_builder.specify "should fallback to environment variables and fill-out missing information based on the PGPASS file (if available)" <|
|
||||||
c1 = Postgres
|
c1 = Postgres.Server
|
||||||
c1.jdbc_url . should_equal "jdbc:postgresql://localhost:5432/postgres"
|
c1.jdbc_url . should_equal "jdbc:postgresql://localhost:5432/postgres"
|
||||||
|
|
||||||
c1.jdbc_properties . should_equal <| add_ssl []
|
c1.jdbc_properties . should_equal <| add_ssl []
|
||||||
@ -901,9 +901,9 @@ add_connection_setup_specs suite_builder = suite_builder.group "[PostgreSQL] Con
|
|||||||
Test_Environment.unsafe_with_environment_override "PGUSER" "someuser" <|
|
Test_Environment.unsafe_with_environment_override "PGUSER" "someuser" <|
|
||||||
c1.jdbc_properties . should_equal <| add_ssl [Pair.new "user" "someuser", Pair.new "password" "somepassword"]
|
c1.jdbc_properties . should_equal <| add_ssl [Pair.new "user" "someuser", Pair.new "password" "somepassword"]
|
||||||
|
|
||||||
c2 = Postgres "192.168.4.0" 1234 "foo"
|
c2 = Postgres.Server "192.168.4.0" 1234 "foo"
|
||||||
c3 = Postgres "::1" 55999 "database_name"
|
c3 = Postgres.Server "::1" 55999 "database_name"
|
||||||
c4 = Postgres "::1" 55999 "otherDB"
|
c4 = Postgres.Server "::1" 55999 "otherDB"
|
||||||
c2.jdbc_properties . should_equal <| add_ssl []
|
c2.jdbc_properties . should_equal <| add_ssl []
|
||||||
c3.jdbc_properties . should_equal <| add_ssl []
|
c3.jdbc_properties . should_equal <| add_ssl []
|
||||||
c4.jdbc_properties . should_equal <| add_ssl []
|
c4.jdbc_properties . should_equal <| add_ssl []
|
||||||
|
Loading…
Reference in New Issue
Block a user