(t *testing.T)
| 240 | } |
| 241 | |
| 242 | func TestSafeUploadPath_AcceptsRelativePath(t *testing.T) { |
| 243 | // GIVEN: a clean temp CWD with a real file |
| 244 | dir := t.TempDir() |
| 245 | dir, _ = filepath.EvalSymlinks(dir) |
| 246 | orig, _ := os.Getwd() |
| 247 | defer os.Chdir(orig) |
| 248 | os.Chdir(dir) |
| 249 | |
| 250 | os.WriteFile(filepath.Join(dir, "upload.bin"), []byte("data"), 0600) |
| 251 | |
| 252 | // WHEN: SafeUploadPath validates a relative path to an existing file |
| 253 | got, err := SafeInputPath("upload.bin") |
| 254 | |
| 255 | // THEN: accepted and returned as absolute canonical path |
| 256 | if err != nil { |
| 257 | t.Fatalf("SafeUploadPath(relative) error = %v", err) |
| 258 | } |
| 259 | want := filepath.Join(dir, "upload.bin") |
| 260 | if got != want { |
| 261 | t.Errorf("SafeUploadPath(relative) = %q, want %q", got, want) |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | func TestSafeInputPath_ErrorMessageContainsCorrectFlagName(t *testing.T) { |
| 266 | // GIVEN: an absolute path |
nothing calls this directly
no test coverage detected