@@ -23,7 +23,6 @@ package client_test
2323import (
2424 _ "embed"
2525 "fmt"
26- "io/fs"
2726 "net/url"
2827 "os"
2928 "path/filepath"
@@ -442,21 +441,22 @@ func TestRecursiveUploadsAndDownloadsWithQuery(t *testing.T) {
442441func TestFailureOnOriginDisablingListings (t * testing.T ) {
443442 server_utils .ResetTestState ()
444443
445- viper . Set ( "Logging.Level" , "debug" )
446- viper . Set ( "Origin.StorageType" , "posix" )
447- viper . Set ( "Origin.ExportVolumes" , "/ test" )
448- viper . Set ( "Origin.EnablePublicReads" , true )
449- viper . Set ( "Origin.EnableListings" , false )
450- fed := fed_test_utils . NewFedTest (t , " " )
451-
452- destDir := filepath . Join ( fed . Exports [ 0 ]. StoragePrefix , "test" )
453- require .NoError (t , os . MkdirAll ( destDir , os . FileMode ( 0755 )) )
454- log . Debugln ( "Will create origin file at" , destDir )
455- err := os . WriteFile ( filepath . Join ( destDir , "test.txt" ), [] byte ( "test file content" ), fs . FileMode ( 0644 ))
456- require . NoError ( t , err )
457- downloadURL := fmt .Sprintf ("pelican://%s:%s%s/%s " , param .Server_Hostname .GetString (), strconv .Itoa (param .Server_WebPort .GetInt ()),
458- fed .Exports [0 ].FederationPrefix , "test" )
444+ fed := fed_test_utils . NewFedTest ( t , pubExportNoDirectRead )
445+
446+ testFileContent := " test file content"
447+ // Drop the testFileContent into the origin directory
448+ tempFile , err := os . Create ( filepath . Join ( fed . Exports [ 0 ]. StoragePrefix , "test.txt" ) )
449+ require . NoError (t , err , "Error creating temp file " )
450+ defer os . Remove ( tempFile . Name ())
451+ _ , err = tempFile . WriteString ( testFileContent )
452+ require .NoError (t , err , "Error writing to temp file" )
453+ tempFile . Close ( )
454+
455+ // Set path for object to upload/download
456+ downloadURL := fmt .Sprintf ("pelican://%s:%s%s/" , param .Server_Hostname .GetString (), strconv .Itoa (param .Server_WebPort .GetInt ()),
457+ fed .Exports [0 ].FederationPrefix )
459458
459+ // Download the directory with get, should fail due to no collections URL
460460 _ , err = client .DoGet (fed .Ctx , downloadURL , t .TempDir (), true )
461461 require .Error (t , err )
462462 require .Contains (t , err .Error (), "no collections URL found in director response" )
0 commit comments