summaryrefslogtreecommitdiff
path: root/internal/command/authorizedprincipals/authorized_principals_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/command/authorizedprincipals/authorized_principals_test.go')
-rw-r--r--internal/command/authorizedprincipals/authorized_principals_test.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/internal/command/authorizedprincipals/authorized_principals_test.go b/internal/command/authorizedprincipals/authorized_principals_test.go
index f0334e5..f11dd0f 100644
--- a/internal/command/authorizedprincipals/authorized_principals_test.go
+++ b/internal/command/authorizedprincipals/authorized_principals_test.go
@@ -12,8 +12,12 @@ import (
)
func TestExecute(t *testing.T) {
+ defaultConfig := &config.Config{RootDir: "/tmp"}
+ configWithSslCertDir := &config.Config{RootDir: "/tmp", SslCertDir: "/tmp/certs"}
+
testCases := []struct {
desc string
+ config *config.Config
arguments *commandargs.AuthorizedPrincipals
expectedOutput string
}{
@@ -23,6 +27,12 @@ func TestExecute(t *testing.T) {
expectedOutput: "command=\"/tmp/bin/gitlab-shell username-key\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty principal\n",
},
{
+ desc: "With SSL cert dir",
+ config: configWithSslCertDir,
+ arguments: &commandargs.AuthorizedPrincipals{KeyId: "key", Principals: []string{"principal"}},
+ expectedOutput: "command=\"SSL_CERT_DIR=/tmp/certs /tmp/bin/gitlab-shell username-key\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty principal\n",
+ },
+ {
desc: "With multiple principals",
arguments: &commandargs.AuthorizedPrincipals{KeyId: "key", Principals: []string{"principal-1", "principal-2"}},
expectedOutput: "command=\"/tmp/bin/gitlab-shell username-key\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty principal-1\ncommand=\"/tmp/bin/gitlab-shell username-key\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty principal-2\n",
@@ -32,8 +42,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"},
+ Config: config,
Args: tc.arguments,
ReadWriter: &readwriter.ReadWriter{Out: buffer},
}