summaryrefslogtreecommitdiff
path: root/go/internal/command/commandargs/command_args_test.go
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-08-14 03:43:08 +0000
committerAsh McKenzie <amckenzie@gitlab.com>2019-08-14 03:43:08 +0000
commitf34e2cd5c4194aa8bb049e1ac8aa1b2f002395b5 (patch)
tree6a12b351838af281ae2ad34a4340231f2a030d49 /go/internal/command/commandargs/command_args_test.go
parent4812f6478771a6d261eb4a5c3aa4b450333fbf00 (diff)
parent1962b49971cf1602ed5ee20b33193e10022cf8cb (diff)
downloadgitlab-shell-f34e2cd5c4194aa8bb049e1ac8aa1b2f002395b5.tar.gz
Merge branch '181-authorized-principals-check-go' into 'master'
Implement AuthorizedPrincipals command Closes #181 See merge request gitlab-org/gitlab-shell!322
Diffstat (limited to 'go/internal/command/commandargs/command_args_test.go')
-rw-r--r--go/internal/command/commandargs/command_args_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/go/internal/command/commandargs/command_args_test.go b/go/internal/command/commandargs/command_args_test.go
index e981c22..9f1575d 100644
--- a/go/internal/command/commandargs/command_args_test.go
+++ b/go/internal/command/commandargs/command_args_test.go
@@ -125,6 +125,11 @@ func TestParseSuccess(t *testing.T) {
arguments: []string{"git", "git", "key"},
expectedArgs: &AuthorizedKeys{Arguments: []string{"git", "git", "key"}, ExpectedUser: "git", ActualUser: "git", Key: "key"},
}, {
+ desc: "It parses authorized-principals command",
+ executable: &executable.Executable{Name: executable.AuthorizedPrincipalsCheck},
+ arguments: []string{"key", "principal-1", "principal-2"},
+ expectedArgs: &AuthorizedPrincipals{Arguments: []string{"key", "principal-1", "principal-2"}, KeyId: "key", Principals: []string{"principal-1", "principal-2"}},
+ }, {
desc: "Unknown executable",
executable: &executable.Executable{Name: "unknown"},
arguments: []string{},
@@ -193,6 +198,24 @@ func TestParseFailure(t *testing.T) {
arguments: []string{"user", "user", ""},
expectedError: "# No key provided",
},
+ {
+ desc: "With not enough arguments for the AuthorizedPrincipalsCheck",
+ executable: &executable.Executable{Name: executable.AuthorizedPrincipalsCheck},
+ arguments: []string{"key"},
+ expectedError: "# Insufficient arguments. 1. Usage\n#\tgitlab-shell-authorized-principals-check <key-id> <principal1> [<principal2>...]",
+ },
+ {
+ desc: "With missing key_id for the AuthorizedPrincipalsCheck",
+ executable: &executable.Executable{Name: executable.AuthorizedPrincipalsCheck},
+ arguments: []string{"", "principal"},
+ expectedError: "# No key_id provided",
+ },
+ {
+ desc: "With blank principal for the AuthorizedPrincipalsCheck",
+ executable: &executable.Executable{Name: executable.AuthorizedPrincipalsCheck},
+ arguments: []string{"key", "principal", ""},
+ expectedError: "# An invalid principal was provided",
+ },
}
for _, tc := range testCases {