Skip to content

Commit

Permalink
chore: jit secrets (#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
fracasula authored Aug 13, 2024
1 parent 6dc8c45 commit b53a005
Show file tree
Hide file tree
Showing 17 changed files with 133 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Linear Ticket

< Replace_with_Linear_Link >
< Linear_Link >

## Security

Expand Down
6 changes: 4 additions & 2 deletions kafkaclient/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/rudderlabs/rudder-go-kit/kafkaclient/testutil"
dockerKafka "github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource/kafka"
"github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource/sshserver"
"github.com/rudderlabs/rudder-go-kit/testhelper/keygen"
)

const (
Expand Down Expand Up @@ -838,8 +839,9 @@ func TestSSH(t *testing.T) {
require.NoError(t, err)

// Let's setup the SSH server
publicKeyPath, err := filepath.Abs("./testdata/ssh/test_key.pub")
privateKeyPath, publicKeyPath, err := keygen.NewRSAKeyPair(2048, keygen.SaveTo(t.TempDir()))
require.NoError(t, err)

sshServer, err := sshserver.Setup(pool, t,
sshserver.WithPublicKeyPath(publicKeyPath),
sshserver.WithCredentials("linuxserver.io", ""),
Expand All @@ -850,7 +852,7 @@ func TestSSH(t *testing.T) {
t.Logf("SSH server is listening on %s", sshServerHost)

// Read private key
privateKey, err := os.ReadFile("./testdata/ssh/test_key")
privateKey, err := os.ReadFile(privateKeyPath)
require.NoError(t, err)

// Setup client and ping
Expand Down
28 changes: 0 additions & 28 deletions kafkaclient/testdata/client.key.pem

This file was deleted.

39 changes: 0 additions & 39 deletions kafkaclient/testdata/ssh/test_key

This file was deleted.

1 change: 0 additions & 1 deletion kafkaclient/testdata/ssh/test_key.pub

This file was deleted.

11 changes: 8 additions & 3 deletions sftp/sftp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"github.com/rudderlabs/rudder-go-kit/sftp/mock_sftp"
"github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource/sshserver"
"github.com/rudderlabs/rudder-go-kit/testhelper/keygen"
)

type nopReadWriteCloser struct {
Expand All @@ -30,7 +31,10 @@ func (nwc *nopReadWriteCloser) Close() error {

func TestSSHClientConfig(t *testing.T) {
// Read private key
privateKey, err := os.ReadFile("testdata/ssh/test_key")
privateKeyPath, _, err := keygen.NewRSAKeyPair(2048, keygen.SaveTo(t.TempDir()))
require.NoError(t, err)

privateKey, err := os.ReadFile(privateKeyPath)
require.NoError(t, err)

type testCase struct {
Expand Down Expand Up @@ -218,8 +222,9 @@ func TestSFTP(t *testing.T) {
require.NoError(t, err)

// Let's setup the SSH server
publicKeyPath, err := filepath.Abs("testdata/ssh/test_key.pub")
privateKeyPath, publicKeyPath, err := keygen.NewRSAKeyPair(2048, keygen.SaveTo(t.TempDir()))
require.NoError(t, err)

sshServer, err := sshserver.Setup(pool, t,
sshserver.WithPublicKeyPath(publicKeyPath),
sshserver.WithCredentials("linuxserver.io", ""),
Expand All @@ -229,7 +234,7 @@ func TestSFTP(t *testing.T) {
t.Logf("SSH server is listening on %s", sshServerHost)

// Read private key
privateKey, err := os.ReadFile("testdata/ssh/test_key")
privateKey, err := os.ReadFile(privateKeyPath)
require.NoError(t, err)

// Setup ssh client
Expand Down
39 changes: 0 additions & 39 deletions sftp/testdata/ssh/test_key

This file was deleted.

1 change: 0 additions & 1 deletion sftp/testdata/ssh/test_key.pub

This file was deleted.

6 changes: 4 additions & 2 deletions testhelper/docker/resource/kafka/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"golang.org/x/crypto/ssh"

"github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource/sshserver"
"github.com/rudderlabs/rudder-go-kit/testhelper/keygen"
)

const (
Expand Down Expand Up @@ -266,8 +267,9 @@ func TestSSH(t *testing.T) {
require.NoError(t, err)

// Let's setup the SSH server
publicKeyPath, err := filepath.Abs("./testdata/ssh/test_key.pub")
privateKeyPath, publicKeyPath, err := keygen.NewRSAKeyPair(2048, keygen.SaveTo(t.TempDir()))
require.NoError(t, err)

sshServer, err := sshserver.Setup(pool, t,
sshserver.WithPublicKeyPath(publicKeyPath),
sshserver.WithCredentials("linuxserver.io", ""),
Expand All @@ -278,7 +280,7 @@ func TestSSH(t *testing.T) {
t.Logf("SSH server is listening on %s", sshServerHost)

// Prepare SSH configuration
privateKey, err := os.ReadFile("./testdata/ssh/test_key")
privateKey, err := os.ReadFile(privateKeyPath)
require.NoError(t, err)

signer, err := ssh.ParsePrivateKey(privateKey)
Expand Down
39 changes: 0 additions & 39 deletions testhelper/docker/resource/kafka/testdata/ssh/test_key

This file was deleted.

1 change: 0 additions & 1 deletion testhelper/docker/resource/kafka/testdata/ssh/test_key.pub

This file was deleted.

9 changes: 9 additions & 0 deletions testhelper/docker/resource/postgres/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package postgres

import "github.com/ory/dockertest/v3/docker"

type Opt func(*Config)

func WithTag(tag string) Opt {
Expand Down Expand Up @@ -38,11 +40,18 @@ func WithPrintLogsOnError(printLogsOnError bool) Opt {
}
}

func WithNetwork(network *docker.Network) Opt {
return func(c *Config) {
c.NetworkID = network.ID
}
}

type Config struct {
Tag string
Options []string
ShmSize int64
Memory int64
OOMKillDisable bool
PrintLogsOnError bool
NetworkID string
}
1 change: 1 addition & 0 deletions testhelper/docker/resource/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func Setup(pool *dockertest.Pool, d resource.Cleaner, opts ...func(*Config)) (*R
postgresContainer, err := pool.RunWithOptions(&dockertest.RunOptions{
Repository: "postgres",
Tag: c.Tag,
NetworkID: c.NetworkID,
Env: []string{
"POSTGRES_PASSWORD=" + postgresDefaultPassword,
"POSTGRES_DB=" + postgresDefaultDB,
Expand Down
8 changes: 4 additions & 4 deletions testhelper/docker/resource/sshserver/sshserver_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package sshserver

import (
"path/filepath"
"testing"

"github.com/rudderlabs/rudder-go-kit/testhelper/keygen"

"github.com/melbahja/goph"
"github.com/ory/dockertest/v3"
dc "github.com/ory/dockertest/v3/docker"
Expand Down Expand Up @@ -50,17 +51,16 @@ func TestKeys(t *testing.T) {
}
})

publicKeyPath, err := filepath.Abs("./testdata/test_key.pub")
privateKeyPath, publicKeyPath, err := keygen.NewRSAKeyPair(2048, keygen.SaveTo(t.TempDir()))
require.NoError(t, err)

res, err := Setup(pool, t,
WithPublicKeyPath(publicKeyPath),
WithCredentials("linuxserver.io", ""),
WithDockerNetwork(network),
)
require.NoError(t, err)

privateKeyPath, err := filepath.Abs("./testdata/test_key")
require.NoError(t, err)
auth, err := goph.Key(privateKeyPath, "")
require.NoError(t, err)

Expand Down
39 changes: 0 additions & 39 deletions testhelper/docker/resource/sshserver/testdata/test_key

This file was deleted.

1 change: 0 additions & 1 deletion testhelper/docker/resource/sshserver/testdata/test_key.pub

This file was deleted.

Loading

0 comments on commit b53a005

Please sign in to comment.