Skip to content

Commit d5c4bfa

Browse files
committed
rename tests
1 parent b8b714b commit d5c4bfa

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

internal/config/config_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,47 +170,47 @@ func TestResolveAllowedDirectories(t *testing.T) {
170170
expected: []string{"/etc/nginx-agent"},
171171
},
172172
{
173-
name: "Absolute path",
173+
name: "Test 1: Absolute path",
174174
configuredDirs: []string{"/etc/agent/"},
175175
expected: []string{"/etc/nginx-agent", "/etc/agent"},
176176
},
177177
{
178-
name: "Absolute paths",
178+
name: "Test 2: Absolute paths",
179179
configuredDirs: []string{"/etc/nginx/"},
180180
expected: []string{"/etc/nginx-agent", "/etc/nginx"},
181181
},
182182
{
183-
name: "Absolute path with multiple slashes",
183+
name: "Test 3: Absolute path with multiple slashes",
184184
configuredDirs: []string{"/etc///////////nginx-agent/"},
185185
expected: []string{"/etc/nginx-agent"},
186186
},
187187
{
188-
name: "Absolute path with directory traversal",
188+
name: "Test 4: Absolute path with directory traversal",
189189
configuredDirs: []string{"/etc/nginx/../nginx-agent"},
190190
expected: []string{"/etc/nginx-agent"},
191191
},
192192
{
193-
name: "Absolute path with repeat directory traversal",
193+
name: "Test 5: Absolute path with repeat directory traversal",
194194
configuredDirs: []string{"/etc/nginx-agent/../../../../../nginx-agent"},
195195
expected: []string{"/etc/nginx-agent"},
196196
},
197197
{
198-
name: "Absolute path with control characters",
198+
name: "Test 6: Absolute path with control characters",
199199
configuredDirs: []string{"/etc/nginx-agent/\\x08../tmp/"},
200200
expected: []string{"/etc/nginx-agent"},
201201
},
202202
{
203-
name: "Absolute path with invisible characters",
203+
name: "Test 7: Absolute path with invisible characters",
204204
configuredDirs: []string{"/etc/nginx-agent/ㅤㅤㅤ/tmp/"},
205205
expected: []string{"/etc/nginx-agent"},
206206
},
207207
{
208-
name: "Absolute path with escaped invisible characters",
208+
name: "Test 8: Absolute path with escaped invisible characters",
209209
configuredDirs: []string{"/etc/nginx-agent/\\\\ㅤ/tmp/"},
210210
expected: []string{"/etc/nginx-agent"},
211211
},
212212
{
213-
name: "Mixed paths",
213+
name: "Test 9: Mixed paths",
214214
configuredDirs: []string{
215215
"nginx-agent",
216216
"",
@@ -223,7 +223,7 @@ func TestResolveAllowedDirectories(t *testing.T) {
223223
expected: []string{"/etc/nginx-agent", "/etc/nginx"},
224224
},
225225
{
226-
name: "Relative path",
226+
name: "Test 10: Relative path",
227227
configuredDirs: []string{"nginx-agent"},
228228
expected: []string{"/etc/nginx-agent"},
229229
},

internal/config/types_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,47 @@ func TestTypes_isAllowedDir(t *testing.T) {
2222
allowed bool
2323
}{
2424
{
25-
name: "File is in allowed directory",
25+
name: "Test 1:File is in allowed directory",
2626
allowed: true,
2727
allowedDirs: []string{
2828
"/etc/nginx",
2929
},
3030
filePath: "/etc/nginx/nginx.conf",
3131
},
3232
{
33-
name: "File is in allowed directory with hyphen",
33+
name: "Test 2: File is in allowed directory with hyphen",
3434
allowed: true,
3535
allowedDirs: []string{
3636
"/etc/nginx-agent",
3737
},
3838
filePath: "/etc/nginx-agent/nginx.conf",
3939
},
4040
{
41-
name: "File exists and is in a subdirectory of allowed directory",
41+
name: "Test 3: File exists and is in a subdirectory of allowed directory",
4242
allowed: true,
4343
allowedDirs: []string{
4444
"/etc/nginx",
4545
},
4646
filePath: "/etc/nginx/conf.d/nginx.conf",
4747
},
4848
{
49-
name: "File exists and is outside allowed directory",
49+
name: "Test 4: File exists and is outside allowed directory",
5050
allowed: false,
5151
allowedDirs: []string{
5252
"/etc/nginx",
5353
},
5454
filePath: "/etc/test/nginx.conf",
5555
},
5656
{
57-
name: "File does not exist but is in allowed directory",
57+
name: "Test 5: File does not exist but is in allowed directory",
5858
allowed: true,
5959
allowedDirs: []string{
6060
"/etc/nginx",
6161
},
6262
filePath: "/etc/nginx/idontexist.conf",
6363
},
6464
{
65-
name: "File does not exist and is outside allowed directory",
65+
name: "Test 6: Test File does not exist and is outside allowed directory",
6666
allowed: false,
6767
allowedDirs: []string{
6868
"/etc/nginx",
@@ -79,7 +79,7 @@ func TestTypes_isAllowedDir(t *testing.T) {
7979
})
8080
}
8181

82-
t.Run("Symlink in allowed directory", func(t *testing.T) {
82+
t.Run("Test 7: Symlink in allowed directory", func(t *testing.T) {
8383
allowedDirs := []string{"/etc/nginx"}
8484
filePath := "file.conf"
8585
symlinkPath := "file_link"

0 commit comments

Comments
 (0)