| 1 | package sshd |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | func TestParseGitCommand(t *testing.T) { |
| 6 | svc, repo, err := parseCommand("git-upload-pack 'tim/bluegit.git'") |
| 7 | if err != nil || svc != "upload-pack" || repo != "tim/bluegit.git" { |
| 8 | t.Fatalf("%s %s %v", svc, repo, err) |
| 9 | } |
| 10 | svc, repo, err = parseCommand(`git-receive-pack "/groep/site.git"`) |
| 11 | if err != nil || svc != "receive-pack" || repo != "groep/site.git" { |
| 12 | t.Fatalf("%s %s %v", svc, repo, err) |
| 13 | } |
| 14 | owner, name, ok := splitRepo("/tim/bluegit.git") |
| 15 | if !ok || owner != "tim" || name != "bluegit" { |
| 16 | t.Fatalf("%s %s %v", owner, name, ok) |
| 17 | } |
| 18 | if _, _, err := parseCommand("ls"); err == nil { |
| 19 | t.Fatal("shell hoort geweigerd") |
| 20 | } |
| 21 | } |