@@ -270,7 +270,7 @@ func TestLsWithPrefixAzure(t *testing.T) {
270270 }
271271
272272 defer func () {
273- err := azurePrv .RemoveAllWithPrefix (context .Background (), "testDir" )
273+ err := azurePrv .RemoveAllWithPrefix (context .Background (), "testDir/ " )
274274 if err != nil {
275275 t .Errorf ("unexpected error when deleting file %s: %v" , "testDir" , err )
276276 }
@@ -295,7 +295,7 @@ func TestLsWithPrefixAzure(t *testing.T) {
295295 }(fileName )
296296 }
297297
298- contents , err := azurePrv .Ls (context .Background (), "testDir" )
298+ contents , err := azurePrv .Ls (context .Background (), "testDir/ " )
299299 if err != nil {
300300 t .Fatalf ("unexpected error when listing files: %v" , err )
301301 }
@@ -342,7 +342,7 @@ func TestRemoveAllWithPrefixAzure(t *testing.T) {
342342 }(fileName )
343343 }
344344
345- err := azurePrv .RemoveAllWithPrefix (context .Background (), "testDir" )
345+ err := azurePrv .RemoveAllWithPrefix (context .Background (), "testDir/ " )
346346 if err != nil {
347347 t .Errorf ("unexpected error when deleting all with prefix testDir: %v" , err )
348348 }
@@ -695,12 +695,7 @@ func TestPathValidationAzure(t *testing.T) {
695695 {"traversal nested" , "foo/../../test.txt" , true , "must not contain '..'" , nil },
696696 {"traversal with slash" , "../test.txt/" , true , "must not contain '..'" , nil },
697697
698- // Absolute path tests
699- {"absolute path" , "/test.txt" , true , "must be relative" , nil },
700- {"absolute nested" , "/foo/test.txt" , true , "must be relative" , nil },
701-
702698 // Azure naming rule tests
703- {"trailing slash" , "test/" , true , "cannot end with '/'" , nil },
704699 {"double slash" , "foo//bar.txt" , true , "cannot contain consecutive '/'" , nil },
705700 {"invalid chars" , "test*.txt" , true , "contains invalid characters" , nil },
706701 {"invalid chars nested" , "foo/test*.txt" , true , "contains invalid characters" , nil },
@@ -725,6 +720,7 @@ func TestPathValidationAzure(t *testing.T) {
725720 }()
726721
727722 for _ , tt := range tests {
723+ // Test operations that should not allow trailing slashes
728724 t .Run (fmt .Sprintf ("WriteFile/%s" , tt .name ), func (t * testing.T ) {
729725 err := azurePrv .WriteFile (context .Background (), tt .path , strings .NewReader ("test" ), WriteOptions {})
730726 assertPathError (t , err , tt .wantErr , tt .errMsg )
@@ -745,6 +741,7 @@ func TestPathValidationAzure(t *testing.T) {
745741 assertPathError (t , err , tt .wantErr , tt .errMsg )
746742 })
747743
744+ // Test operations that should allow trailing slashes
748745 t .Run (fmt .Sprintf ("Ls/%s" , tt .name ), func (t * testing.T ) {
749746 _ , err := azurePrv .Ls (context .Background (), tt .path )
750747 assertPathError (t , err , tt .wantErr , tt .errMsg )
@@ -755,6 +752,7 @@ func TestPathValidationAzure(t *testing.T) {
755752 assertPathError (t , err , tt .wantErr , tt .errMsg )
756753 })
757754
755+ // Test revision operations that should not allow trailing slashes
758756 t .Run (fmt .Sprintf ("ListRevisions/%s" , tt .name ), func (t * testing.T ) {
759757 _ , err := azurePrv .ListRevisions (context .Background (), tt .path )
760758 assertPathError (t , err , tt .wantErr , tt .errMsg )
@@ -772,6 +770,51 @@ func TestPathValidationAzure(t *testing.T) {
772770 assertPathError (t , err , tt .wantErr , tt .errMsg )
773771 })
774772 }
773+
774+ // Additional tests specifically for trailing slashes
775+ trailingSlashTests := []struct {
776+ name string
777+ path string
778+ wantErr bool
779+ errMsg string
780+ }{
781+ {"trailing slash in Ls" , "test/" , false , "" },
782+ {"trailing slash in RemoveAllWithPrefix" , "test/" , false , "" },
783+ {"trailing slash in WriteFile" , "test/" , true , "cannot end with '/'" },
784+ {"trailing slash in OpenFile" , "test/" , true , "cannot end with '/'" },
785+ {"trailing slash in StatFile" , "test/" , true , "cannot end with '/'" },
786+ {"trailing slash in DeleteFile" , "test/" , true , "cannot end with '/'" },
787+ {"trailing slash in ListRevisions" , "test/" , true , "cannot end with '/'" },
788+ {"trailing slash in GetRevision" , "test/" , true , "cannot end with '/'" },
789+ {"trailing slash in DeleteRevision" , "test/" , true , "cannot end with '/'" },
790+ }
791+
792+ for _ , tt := range trailingSlashTests {
793+ t .Run (tt .name , func (t * testing.T ) {
794+ var err error
795+ switch {
796+ case strings .Contains (tt .name , "Ls" ):
797+ _ , err = azurePrv .Ls (context .Background (), tt .path )
798+ case strings .Contains (tt .name , "RemoveAllWithPrefix" ):
799+ err = azurePrv .RemoveAllWithPrefix (context .Background (), tt .path )
800+ case strings .Contains (tt .name , "WriteFile" ):
801+ err = azurePrv .WriteFile (context .Background (), tt .path , strings .NewReader ("test" ), WriteOptions {})
802+ case strings .Contains (tt .name , "OpenFile" ):
803+ _ , err = azurePrv .OpenFile (context .Background (), tt .path , OpenOptions {})
804+ case strings .Contains (tt .name , "StatFile" ):
805+ _ , err = azurePrv .StatFile (context .Background (), tt .path , StatOptions {})
806+ case strings .Contains (tt .name , "DeleteFile" ):
807+ err = azurePrv .DeleteFile (context .Background (), tt .path )
808+ case strings .Contains (tt .name , "ListRevisions" ):
809+ _ , err = azurePrv .ListRevisions (context .Background (), tt .path )
810+ case strings .Contains (tt .name , "GetRevision" ):
811+ _ , err = azurePrv .GetRevision (context .Background (), tt .path , "1" )
812+ case strings .Contains (tt .name , "DeleteRevision" ):
813+ err = azurePrv .DeleteRevision (context .Background (), tt .path , "1" )
814+ }
815+ assertPathError (t , err , tt .wantErr , tt .errMsg )
816+ })
817+ }
775818}
776819
777820// Helper function to assert path validation errors
0 commit comments