summaryrefslogtreecommitdiff
path: root/internal/command/authorizedkeys/authorized_keys_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/command/authorizedkeys/authorized_keys_test.go')
-rw-r--r--internal/command/authorizedkeys/authorized_keys_test.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/internal/command/authorizedkeys/authorized_keys_test.go b/internal/command/authorizedkeys/authorized_keys_test.go
index 4aa7586..e12f4fa 100644
--- a/internal/command/authorizedkeys/authorized_keys_test.go
+++ b/internal/command/authorizedkeys/authorized_keys_test.go
@@ -45,8 +45,12 @@ func TestExecute(t *testing.T) {
url, cleanup := testserver.StartSocketHttpServer(t, requests)
defer cleanup()
+ defaultConfig := &config.Config{RootDir: "/tmp", GitlabUrl: url}
+ configWithSslCertDir := &config.Config{RootDir: "/tmp", GitlabUrl: url, SslCertDir: "/tmp/certs"}
+
testCases := []struct {
desc string
+ config *config.Config
arguments *commandargs.AuthorizedKeys
expectedOutput string
}{
@@ -56,6 +60,12 @@ func TestExecute(t *testing.T) {
expectedOutput: "command=\"/tmp/bin/gitlab-shell key-1\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty public-key\n",
},
{
+ desc: "With SSL cert dir",
+ config: configWithSslCertDir,
+ arguments: &commandargs.AuthorizedKeys{ExpectedUser: "user", ActualUser: "user", Key: "key"},
+ expectedOutput: "command=\"SSL_CERT_DIR=/tmp/certs /tmp/bin/gitlab-shell key-1\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty public-key\n",
+ },
+ {
desc: "When key doesn't match any existing key",
arguments: &commandargs.AuthorizedKeys{ExpectedUser: "user", ActualUser: "user", Key: "not-found"},
expectedOutput: "# No key was found for not-found\n",
@@ -75,8 +85,14 @@ func TestExecute(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
buffer := &bytes.Buffer{}
+
+ config := defaultConfig
+ if tc.config != nil {
+ config = tc.config
+ }
+
cmd := &Command{
- Config: &config.Config{RootDir: "/tmp", GitlabUrl: url},
+ Config: config,
Args: tc.arguments,
ReadWriter: &readwriter.ReadWriter{Out: buffer},
}