Skip to content

Commit

Permalink
Add tests for several more gel envvars (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoor authored Jan 2, 2025
1 parent e395996 commit eb8b4d9
Show file tree
Hide file tree
Showing 5 changed files with 505 additions and 19 deletions.
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ arguments for the CLI. Possible values:
| `tlsSecurity` | enum string | one of `strict`, `no_host_verification` and `insecure` (test cases may contain invalid values) |
| `tlsCA` | string | PEM string of the CA certificate to trust |
| `tlsCAFile` | path string | path to a file containing `tlsCA` |
| `tlsServerName` | string | Server name to expect when performing host verification |
| `serverSettings` | object | additional [connection parameters](https://www.edgedb.com/docs/reference/protocol/messages#ref-protocol-msg-client-handshake) to send to the server |
| `credentials` | JSON string | decodes to an object with possible keys: `host`, `port`, `user`, `password`, `database`, `tls_ca`, `tls_security` |
| `credentialsFile` | string | path to a file containing `credentials` |
Expand All @@ -56,25 +57,26 @@ same time.

Environment variables present at the time of connecting. Possible values:

| name | value |
| ----------------------------- | --------------------------------------------------- |
| `EDGEDB_HOST` | same as `host` above |
| `EDGEDB_PORT` | same as `port` above |
| `EDGEDB_USER` | same as `user` above |
| `EDGEDB_PASSWORD` | same as `password` above |
| `EDGEDB_SECRET_KEY` | same as `secretKey` above |
| `EDGEDB_DATABASE` | same as `database` above |
| `EDGEDB_BRANCH` | same as `branch` above |
| `EDGEDB_WAIT_UNTIL_AVAILABLE` | same as `waitUntilAvailable` above |
| `EDGEDB_CLIENT_TLS_SECURITY` | same as `tlsSecurity` above |
| `EDGEDB_TLS_CA` | same as `tlsCA` above |
| `EDGEDB_TLS_CA_FILE` | same as `tlsCAFile` above |
| `EDGEDB_CREDENTIALS_FILE` | same as `credentialsFile` above |
| `EDGEDB_INSTANCE` | same as `instance` above |
| `EDGEDB_DSN` | same as `dsn` above |
| `EDGEDB_CLIENT_SECURITY` | one of `default`, `strict`, `insecure_dev_mode` |
| `EDGEDB_CLOUD_PROFILE` | the cloud profile name to use |
| any other name | DSN query may reference these environment variables |
| name | value |
| -------------------------- | --------------------------------------------------- |
| `GEL_HOST` | same as `host` above |
| `GEL_PORT` | same as `port` above |
| `EDGEDB_USER` | same as `user` above |
| `EDGEDB_PASSWORD` | same as `password` above |
| `EDGEDB_SECRET_KEY` | same as `secretKey` above |
| `EDGEDB_DATABASE` | same as `database` above |
| `GEL_BRANCH` | same as `branch` above |
| `GEL_WAIT_UNTIL_AVAILABLE` | same as `waitUntilAvailable` above |
| `GEL_CLIENT_TLS_SECURITY` | same as `tlsSecurity` above |
| `GEL_TLS_CA` | same as `tlsCA` above |
| `GEL_TLS_CA_FILE` | same as `tlsCAFile` above |
| `GEL_TLS_SERVER_NAME` | same as `tlsServerName` above |
| `EDGEDB_CREDENTIALS_FILE` | same as `credentialsFile` above |
| `GEL_INSTANCE` | same as `instance` above |
| `GEL_DSN` | same as `dsn` above |
| `GEL_CLIENT_SECURITY` | one of `default`, `strict`, `insecure_dev_mode` |
| `GEL_CLOUD_PROFILE` | the cloud profile name to use |
| any other name | DSN query may reference these environment variables |

### Input - `fs`

Expand Down Expand Up @@ -121,6 +123,7 @@ Expected result of parsed connection parameters as an object, containing:
| `waitUntilAvailable` | string | ISO 8601 max time to wait before server becomes available |
| `tlsSecurity` | enum string | one of `strict`, `no_host_verification` and `insecure` |
| `tlsCAData` | string or `null` | optional PEM string of the CA certificate to trust |
| `tlsServerName` | string or `null` | optional server name to expect when performing host verification |
| `serverSettings` | object | additional [connection parameters](https://www.edgedb.com/docs/reference/protocol/messages#ref-protocol-msg-client-handshake) to send to the server |

### Output - `error`
Expand Down
297 changes: 297 additions & 0 deletions connection_testcases.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,33 @@
"waitUntilAvailable": "PT30S"
}
},
{
"env": {
"EDGEDB_CLIENT_SECURITY": "strict",
"EDGEDB_DSN": "edgedb://",
"GEL_CLIENT_SECURITY": "insecure_dev_mode"
},
"name": "basic_env_test_12",
"result": {
"address": [
"localhost",
5656
],
"branch": "__default__",
"database": "edgedb",
"password": null,
"secretKey": null,
"serverSettings": {},
"tlsCAData": null,
"tlsSecurity": "insecure",
"tlsServerName": null,
"user": "edgedb",
"waitUntilAvailable": "PT30S"
},
"warnings": [
"gel_and_edgedb"
]
},
{
"env": {
"EDGEDB_DATABASE": "experimental2",
Expand Down Expand Up @@ -802,6 +829,169 @@
"docker_tcp_port"
]
},
{
"env": {
"EDGEDB_BRANCH": "test_db2",
"GEL_BRANCH": "test_db",
"GEL_DSN": "gel://"
},
"name": "basic_env_Use GEL_BRANCH instead of EDGEDB_BRANCH",
"result": {
"address": [
"localhost",
5656
],
"branch": "test_db",
"database": "test_db",
"password": null,
"secretKey": null,
"serverSettings": {},
"tlsCAData": null,
"tlsSecurity": "strict",
"tlsServerName": null,
"user": "edgedb",
"waitUntilAvailable": "PT30S"
},
"warnings": [
"gel_and_edgedb"
]
},
{
"env": {
"EDGEDB_CLIENT_TLS_SECURITY": "no_host_verification",
"GEL_CLIENT_TLS_SECURITY": "insecure",
"GEL_DSN": "gel://"
},
"name": "basic_env_Use GEL_CLIENT_TLS_SECURITY instead of EDGEDB_CLIENT_TLS_SECURITY",
"result": {
"address": [
"localhost",
5656
],
"branch": "__default__",
"database": "edgedb",
"password": null,
"secretKey": null,
"serverSettings": {},
"tlsCAData": null,
"tlsSecurity": "insecure",
"tlsServerName": null,
"user": "edgedb",
"waitUntilAvailable": "PT30S"
},
"warnings": [
"gel_and_edgedb"
]
},
{
"env": {
"EDGEDB_DSN": "edgedb://user2:123@localhost:4444/xyz",
"GEL_DSN": "gel://user3:123123@localhost:5555/abcdef"
},
"name": "basic_env_Use GEL_DSN instead of EDGEDB_DSN",
"result": {
"address": [
"localhost",
5555
],
"branch": "abcdef",
"database": "abcdef",
"password": "123123",
"secretKey": null,
"serverSettings": {},
"tlsCAData": null,
"tlsSecurity": "strict",
"tlsServerName": null,
"user": "user3",
"waitUntilAvailable": "PT30S"
},
"warnings": [
"docker_tcp_port",
"gel_and_edgedb"
]
},
{
"env": {
"EDGEDB_TLS_CA": "-----BEGIN CERTIFICATE-----\nMIICEjCCAXsCAg36MA0GCSqGSIb3DQEBBQUAMIGbMQswCQYDVQQGEwJKUDEOMAwG\nA1UECBMFVG9reW8xEDAOBgNVBAcTB0NodW8ta3UxETAPBgNVBAoTCEZyYW5rNERE\nMRgwFgYDVQQLEw9XZWJDZXJ0IFN1cHBvcnQxGDAWBgNVBAMTD0ZyYW5rNEREIFdl\nYiBDQTEjMCEGCSqGSIb3DQEJARYUc3VwcG9ydEBmcmFuazRkZC5jb20wHhcNMTIw\nODIyMDUyNjU0WhcNMTcwODIxMDUyNjU0WjBKMQswCQYDVQQGEwJKUDEOMAwGA1UE\nCAwFVG9reW8xETAPBgNVBAoMCEZyYW5rNEREMRgwFgYDVQQDDA93d3cuZXhhbXBs\nZS5jb20wXDANBgkqhkiG9w0BAQEFAANLADBIAkEAm/xmkHmEQrurE/0re/jeFRLl\n8ZPjBop7uLHhnia7lQG/5zDtZIUC3RVpqDSwBuw/NTweGyuP+o8AG98HxqxTBwID\nAQABMA0GCSqGSIb3DQEBBQUAA4GBABS2TLuBeTPmcaTaUW/LCB2NYOy8GMdzR1mx\n8iBIu2H6/E2tiY3RIevV2OW61qY2/XRQg7YPxx3ffeUugX9F4J/iPnnu1zAxxyBy\n2VguKv4SWjRFoRkIfIlHX0qVviMhSlNy2ioFLy7JcPZb+v3ftDGywUqcBiVDoea0\nHn+GmxZA\n-----END CERTIFICATE-----\n",
"GEL_CLIENT_TLS_SECURITY": "strict",
"GEL_DSN": "gel://",
"GEL_TLS_CA": "-----BEGIN CERTIFICATE-----\nx\n-----END CERTIFICATE-----\n"
},
"name": "basic_env_Use GEL_TLS_CA instead of EDGEDB_TLS_CA",
"result": {
"address": [
"localhost",
5656
],
"branch": "__default__",
"database": "edgedb",
"password": null,
"secretKey": null,
"serverSettings": {},
"tlsCAData": "-----BEGIN CERTIFICATE-----\nx\n-----END CERTIFICATE-----\n",
"tlsSecurity": "strict",
"tlsServerName": null,
"user": "edgedb",
"waitUntilAvailable": "PT30S"
},
"warnings": [
"gel_and_edgedb"
]
},
{
"env": {
"EDGEDB_TLS_SERVER_NAME": "edgedb.example.com",
"GEL_DSN": "gel://",
"GEL_TLS_SERVER_NAME": "gel.example.com"
},
"name": "basic_env_Use GEL_TLS_SERVER_NAME instead of EDGEDB_TLS_SERVER_NAME",
"result": {
"address": [
"localhost",
5656
],
"branch": "__default__",
"database": "edgedb",
"password": null,
"secretKey": null,
"serverSettings": {},
"tlsCAData": null,
"tlsSecurity": "strict",
"tlsServerName": "gel.example.com",
"user": "edgedb",
"waitUntilAvailable": "PT30S"
},
"warnings": [
"gel_and_edgedb"
]
},
{
"env": {
"EDGEDB_WAIT_UNTIL_AVAILABLE": "PT7S",
"GEL_DSN": "gel://",
"GEL_WAIT_UNTIL_AVAILABLE": "PT10S"
},
"name": "basic_env_Use GEL_WAIT_UNTIL_AVAILABLE instead of EDGEDB_WAIT_UNTIL_AVAILABLE",
"result": {
"address": [
"localhost",
5656
],
"branch": "__default__",
"database": "edgedb",
"password": null,
"secretKey": null,
"serverSettings": {},
"tlsCAData": null,
"tlsSecurity": "strict",
"tlsServerName": null,
"user": "edgedb",
"waitUntilAvailable": "PT10S"
},
"warnings": [
"gel_and_edgedb"
]
},
{
"fs": {
"cwd": "/home/edgedb/test",
Expand Down Expand Up @@ -3418,6 +3608,40 @@
"waitUntilAvailable": "PT30S"
}
},
{
"env": {
"EDGEDB_TLS_CA_FILE": "/home/edgedb/test/edgedb.pem",
"GEL_CLIENT_TLS_SECURITY": "strict",
"GEL_DSN": "gel://",
"GEL_TLS_CA_FILE": "/home/edgedb/test/gel.pem"
},
"fs": {
"files": {
"/home/edgedb/test/edgedb.pem": "-----BEGIN CERTIFICATE-----\nedgedb\n-----END CERTIFICATE-----\n",
"/home/edgedb/test/gel.pem": "-----BEGIN CERTIFICATE-----\ngel\n-----END CERTIFICATE-----\n"
}
},
"name": "override_certificate_Use GEL_TLS_CA_FILE instead of EDGEDB_TLS_CA_FILE",
"result": {
"address": [
"localhost",
5656
],
"branch": "__default__",
"database": "edgedb",
"password": null,
"secretKey": null,
"serverSettings": {},
"tlsCAData": "-----BEGIN CERTIFICATE-----\ngel\n-----END CERTIFICATE-----\n",
"tlsSecurity": "strict",
"tlsServerName": null,
"user": "edgedb",
"waitUntilAvailable": "PT30S"
},
"warnings": [
"gel_and_edgedb"
]
},
{
"fs": {
"files": {
Expand Down Expand Up @@ -5711,7 +5935,80 @@
"tlsServerName": null,
"user": "testuser",
"waitUntilAvailable": "PT30S"
}
},
{
"env": {
"EDGEDB_CLOUD_PROFILE": "edgedb",
"GEL_CLOUD_PROFILE": "gel"
},
"fs": {
"files": {
"/home/edgedb/.config/edgedb/cloud-credentials/default.json": "{\"secret_key\": \"nbwt_eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9\"}",
"/home/edgedb/.config/edgedb/cloud-credentials/edgedb.json": "{\"secret_key\": \"nbwt_eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9\"}",
"/home/edgedb/.config/edgedb/cloud-credentials/gel.json": "{\"secret_key\": \"nbwt_eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJlZGdlZGIuc2VydmVyLmFueV9yb2xlIjp0cnVlLCJpYXQiOjE2NjkzMTE3NjMsImlzcyI6ImxvY2FsLTEuaW50ZXJuYWwiLCJuZWJ1bGEuc2NvcGVzIjpbImFkbWluIl0sIm5lYnVsYS51c2VyX2lkIjoiM2U3ODU4YTgtNmJjNy0xMWVkLWFmNTAtMTdiMzkzMjlmZmEyIn0.9cS6-rR00fgmEmGu423IP3snJvmXe7ZGol7ZlYuHBNqmKGrWtTsMZPj-3C7dmureUmk3ZUttxioouPeAreKueg\"}"
},
"homedir": "/home/edgedb"
},
"name": "override_other_Use GEL_CLOUD_PROFILE instead of EDGEDB_CLOUD_PROFILE",
"opts": {
"instance": "test-org/test-123"
},
"result": {
"address": [
"test-123--test-org.c-96.i.local-1.internal",
5656
],
"branch": "__default__",
"database": "edgedb",
"password": null,
"secretKey": "nbwt_eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJlZGdlZGIuc2VydmVyLmFueV9yb2xlIjp0cnVlLCJpYXQiOjE2NjkzMTE3NjMsImlzcyI6ImxvY2FsLTEuaW50ZXJuYWwiLCJuZWJ1bGEuc2NvcGVzIjpbImFkbWluIl0sIm5lYnVsYS51c2VyX2lkIjoiM2U3ODU4YTgtNmJjNy0xMWVkLWFmNTAtMTdiMzkzMjlmZmEyIn0.9cS6-rR00fgmEmGu423IP3snJvmXe7ZGol7ZlYuHBNqmKGrWtTsMZPj-3C7dmureUmk3ZUttxioouPeAreKueg",
"serverSettings": {},
"tlsCAData": null,
"tlsSecurity": "strict",
"tlsServerName": null,
"user": "edgedb",
"waitUntilAvailable": "PT30S"
},
"warnings": [
"gel_and_edgedb"
]
},
{
"env": {
"EDGEDB_INSTANCE": "edgedb",
"GEL_INSTANCE": "gel"
},
"fs": {
"files": {
"/home/edgedb/.config/edgedb/credentials/edgedb.json": "{\"port\": 5555, \"user\": \"test1n\", \"password\": \"wrong\", \"database\": \"test2n\"}",
"/home/edgedb/.config/edgedb/credentials/gel.json": "{\"port\": 10702, \"user\": \"test3n\", \"password\": \"lZTBy1RVCfOpBAOwSCwIyBIR\", \"database\": \"test3n\"}"
},
"homedir": "/home/edgedb"
},
"name": "override_other_Use GEL_INSTANCE instead of EDGEDB_INSTANCE",
"opts": {
"user": "super_user"
},
"result": {
"address": [
"localhost",
10702
],
"branch": "test3n",
"database": "test3n",
"password": "lZTBy1RVCfOpBAOwSCwIyBIR",
"secretKey": null,
"serverSettings": {},
"tlsCAData": null,
"tlsSecurity": "strict",
"tlsServerName": null,
"user": "super_user",
"waitUntilAvailable": "PT30S"
},
"warnings": [
"gel_and_edgedb"
],
"~": "/*** WARNING: do not edit this file. This is automatically rebuilt using tools/rebuild.ts ***/"
}
]
Loading

0 comments on commit eb8b4d9

Please sign in to comment.