Skip to content

Commit

Permalink
Use a real Trino server for TLS integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
nineinchnick committed Apr 30, 2024
1 parent 3669f0d commit 76f09a6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 147 deletions.
2 changes: 1 addition & 1 deletion trino/etc/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ discovery-server.enabled=true
discovery.uri=http://localhost:8080


http-server.authentication.type=JWT
http-server.authentication.type=PASSWORD,JWT
http-server.authentication.jwt.key-file=/etc/trino/secrets/public_key.pem

http-server.https.enabled=true
Expand Down
2 changes: 2 additions & 0 deletions trino/etc/password-authenticator.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
password-authenticator.name=file
file.password-file=/etc/trino/secrets/password.db
1 change: 1 addition & 0 deletions trino/etc/secrets/password.db
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
admin:$2y$10$xLVM/FUuZaNEmGOU3y7fjOLzRJOGItnTWTiFVKwIFX.ZMBctxl8gq
21 changes: 20 additions & 1 deletion trino/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestMain(m *testing.M) {
log.Fatalf("Timed out waiting for container to get ready: %s\nContainer logs:\n%s", err, logs)
}
*integrationServerFlag = "http://test@localhost:" + resource.GetPort("8080/tcp")
tlsServer = "https://test@localhost:" + resource.GetPort("8443/tcp")
tlsServer = "https://admin:admin@localhost:" + resource.GetPort("8443/tcp")

http.DefaultTransport.(*http.Transport).TLSClientConfig, err = getTLSConfig(wd + "/etc/secrets")
if err != nil {
Expand Down Expand Up @@ -972,6 +972,25 @@ func generateToken() (string, error) {
return signedToken, nil
}

func TestIntegrationTLS(t *testing.T) {
if tlsServer == "" {
t.Skip("Skipping TLS test when using a custom integration server.")
}

dsn := tlsServer
db := integrationOpen(t, dsn)

defer db.Close()
row := db.QueryRow("SELECT 1")
var count int
if err := row.Scan(&count); err != nil {
t.Fatal(err)
}
if count != 1 {
t.Fatal("unexpected count=", count)
}
}

func contextSleep(ctx context.Context, d time.Duration) error {
timer := time.NewTimer(100 * time.Millisecond)
select {
Expand Down
145 changes: 0 additions & 145 deletions trino/integration_tls_test.go

This file was deleted.

0 comments on commit 76f09a6

Please sign in to comment.