this repo has no description
1package main
2
3import "testing"
4
5func TestFormatKeyData(t *testing.T) {
6 tests := []struct {
7 name string
8 repoguardPath string
9 data map[string]string
10 want string
11 }{
12 {
13 name: "single user",
14 repoguardPath: "/usr/bin/repoguard",
15 data: map[string]string{
16 "user1": "ssh-rsa AAAA...",
17 },
18 want: `command="/usr/bin/repoguard -base-dir /home/git -user user1 -log-path /home/git/log ",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAA...` + "\n",
19 },
20 {
21 name: "multiple users",
22 repoguardPath: "/usr/bin/repoguard",
23 data: map[string]string{
24 "user1": "ssh-rsa AAAA...",
25 "user2": "ssh-rsa BBBB...",
26 },
27 want: `command="/usr/bin/repoguard -base-dir /home/git -user user1 -log-path /home/git/log ",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAA...` + "\n" +
28 `command="/usr/bin/repoguard -base-dir /home/git -user user2 -log-path /home/git/log ",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa BBBB...` + "\n",
29 },
30 {
31 name: "empty data",
32 repoguardPath: "/usr/bin/repoguard",
33 data: map[string]string{},
34 want: "",
35 },
36 }
37
38 for _, tt := range tests {
39 t.Run(tt.name, func(t *testing.T) {
40 if got := formatKeyData(tt.repoguardPath, tt.data); got != tt.want {
41 t.Errorf("formatKeyData() = %v, want %v", got, tt.want)
42 }
43 })
44 }
45}