Skip to content

Commit

Permalink
Fixes to unit test to be functional with xrootd
Browse files Browse the repository at this point in the history
  • Loading branch information
joereuss12 committed Jan 10, 2024
1 parent c35380b commit c719bab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions client/handle_http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func TestFailedUpload(t *testing.T) {
func generateFileTestScitoken() (string, error) {
// Issuer is whichever server that initiates the test, so it's the server itself
issuerUrl := param.Origin_Url.GetString()
if issuerUrl == "" { // if both are empty, then error
if issuerUrl == "" { // if empty, then error
return "", errors.New("Failed to create token: Invalid iss, Server_ExternalWebUrl is empty")
}
jti_bytes := make([]byte, 16)
Expand All @@ -400,7 +400,7 @@ func generateFileTestScitoken() (string, error) {
Claim("wlcg.ver", "1.0").
JwtID(jti).
Issuer(issuerUrl).
Audience([]string{"https://wlcg.cern.ch/jwt/v1/any"}).
Audience([]string{param.Origin_Url.GetString()}).
Subject("origin").
Expiration(time.Now().Add(time.Minute)).
IssuedAt(time.Now()).
Expand Down Expand Up @@ -452,7 +452,7 @@ func TestFullUpload(t *testing.T) {
viper.Set("ConfigDir", tmpPath)

// Increase the log level; otherwise, its difficult to debug failures
// viper.Set("Logging.Level", "Debug")
viper.Set("Logging.Level", "Debug")
config.InitConfig()

originDir, err := os.MkdirTemp("", "Origin")
Expand All @@ -473,6 +473,7 @@ func TestFullUpload(t *testing.T) {
viper.Set("TLSSkipVerify", true)
viper.Set("Server.EnableUI", false)
viper.Set("Registry.DbLocation", filepath.Join(t.TempDir(), "ns-registry.sqlite"))
viper.Set("Xrootd.RunLocation", tmpPath)

err = config.InitServer(ctx, modules)
require.NoError(t, err)
Expand Down Expand Up @@ -525,7 +526,7 @@ func TestFullUpload(t *testing.T) {
defer os.Remove(tempToken.Name())
_, err = tempToken.WriteString(token)
assert.NoError(t, err, "Error writing to temp token file")
tempFile.Close()
tempToken.Close()
ObjectClientOptions.Token = tempToken.Name()

// Upload the file
Expand Down

0 comments on commit c719bab

Please sign in to comment.