summaryrefslogtreecommitdiff
path: root/go/internal/command/commandargs/command_args_test.go
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-08-09 01:14:28 +0000
committerAsh McKenzie <amckenzie@gitlab.com>2019-08-09 01:14:28 +0000
commit4812f6478771a6d261eb4a5c3aa4b450333fbf00 (patch)
treedc01da9252c0acd37966fb53f10a1adbf5e0adf6 /go/internal/command/commandargs/command_args_test.go
parentc577eb9ed8bd0336870f7a83302f70821d510169 (diff)
parent570ad65f9f4567428ee5214a470a1f97146d58c8 (diff)
downloadgitlab-shell-4812f6478771a6d261eb4a5c3aa4b450333fbf00.tar.gz
Merge branch '181-authorized-keys-check-go' into 'master'
Implement AuthorizedKeys command See merge request gitlab-org/gitlab-shell!321
Diffstat (limited to 'go/internal/command/commandargs/command_args_test.go')
-rw-r--r--go/internal/command/commandargs/command_args_test.go33
1 files changed, 31 insertions, 2 deletions
diff --git a/go/internal/command/commandargs/command_args_test.go b/go/internal/command/commandargs/command_args_test.go
index 148c987..e981c22 100644
--- a/go/internal/command/commandargs/command_args_test.go
+++ b/go/internal/command/commandargs/command_args_test.go
@@ -120,6 +120,11 @@ func TestParseSuccess(t *testing.T) {
arguments: []string{},
expectedArgs: &Shell{Arguments: []string{}, SshArgs: []string{"git-lfs-authenticate", "group/repo", "download"}, CommandType: LfsAuthenticate},
}, {
+ desc: "It parses authorized-keys command",
+ executable: &executable.Executable{Name: executable.AuthorizedKeysCheck},
+ arguments: []string{"git", "git", "key"},
+ expectedArgs: &AuthorizedKeys{Arguments: []string{"git", "git", "key"}, ExpectedUser: "git", ActualUser: "git", Key: "key"},
+ }, {
desc: "Unknown executable",
executable: &executable.Executable{Name: "unknown"},
arguments: []string{},
@@ -162,7 +167,31 @@ func TestParseFailure(t *testing.T) {
"SSH_ORIGINAL_COMMAND": `git receive-pack "`,
},
arguments: []string{},
- expectedError: "Invalid SSH allowed",
+ expectedError: "Invalid SSH command",
+ },
+ {
+ desc: "With not enough arguments for the AuthorizedKeysCheck",
+ executable: &executable.Executable{Name: executable.AuthorizedKeysCheck},
+ arguments: []string{"user"},
+ expectedError: "# Insufficient arguments. 1. Usage\n#\tgitlab-shell-authorized-keys-check <expected-username> <actual-username> <key>",
+ },
+ {
+ desc: "With too many arguments for the AuthorizedKeysCheck",
+ executable: &executable.Executable{Name: executable.AuthorizedKeysCheck},
+ arguments: []string{"user", "user", "key", "something-else"},
+ expectedError: "# Insufficient arguments. 4. Usage\n#\tgitlab-shell-authorized-keys-check <expected-username> <actual-username> <key>",
+ },
+ {
+ desc: "With missing username for the AuthorizedKeysCheck",
+ executable: &executable.Executable{Name: executable.AuthorizedKeysCheck},
+ arguments: []string{"user", "", "key"},
+ expectedError: "# No username provided",
+ },
+ {
+ desc: "With missing key for the AuthorizedKeysCheck",
+ executable: &executable.Executable{Name: executable.AuthorizedKeysCheck},
+ arguments: []string{"user", "user", ""},
+ expectedError: "# No key provided",
},
}
@@ -173,7 +202,7 @@ func TestParseFailure(t *testing.T) {
_, err := Parse(tc.executable, tc.arguments)
- require.Error(t, err, tc.expectedError)
+ require.EqualError(t, err, tc.expectedError)
})
}
}