diff --git a/internal/incoming/web/api_files.go b/internal/incoming/web/api_files.go index a93620e..13a4fdd 100644 --- a/internal/incoming/web/api_files.go +++ b/internal/incoming/web/api_files.go @@ -23,6 +23,7 @@ import ( "fmt" "io" "net/http" + "strings" "github.com/moov-io/ach" "github.com/moov-io/achgateway/internal/incoming" @@ -164,6 +165,9 @@ func (c *FilesController) CancelFileHandler(w http.ResponseWriter, r *http.Reque } func (c *FilesController) cancelFile(shardKey, fileID string) error { + // Remove .ach suffix if the request added it + fileID = strings.TrimSuffix(fileID, ".ach") + bs, err := compliance.Protect(c.cfg.Transform, models.Event{ Event: incoming.CancelACHFile{ FileID: fileID, diff --git a/internal/incoming/web/api_files_test.go b/internal/incoming/web/api_files_test.go index 9b7c4a9..606c75a 100644 --- a/internal/incoming/web/api_files_test.go +++ b/internal/incoming/web/api_files_test.go @@ -89,7 +89,7 @@ func TestCancelFileHandler(t *testing.T) { controller.AppendRoutes(r) // Cancel our file - req := httptest.NewRequest("DELETE", "/shards/s2/files/f2", nil) + req := httptest.NewRequest("DELETE", "/shards/s2/files/f2.ach", nil) w := httptest.NewRecorder() r.ServeHTTP(w, req) @@ -102,6 +102,6 @@ func TestCancelFileHandler(t *testing.T) { var file incoming.CancelACHFile require.NoError(t, models.ReadEvent(msg.Body, &file)) - require.Equal(t, "f2", file.FileID) + require.Equal(t, "f2", file.FileID) // make sure .ach suffix is trimmed require.Equal(t, "s2", file.ShardKey) }