Skip to content

Commit

Permalink
Changes errors/msgs from checkValidQuery
Browse files Browse the repository at this point in the history
joereuss12 committed May 3, 2024
1 parent 31338f2 commit 2763403
Showing 2 changed files with 8 additions and 8 deletions.
9 changes: 5 additions & 4 deletions utils/utils.go
Original file line number Diff line number Diff line change
@@ -78,19 +78,20 @@ func CheckValidQuery(transferUrl *url.URL, isPlugin bool) (err error) {
_, hasPack := query["pack"]
directRead, hasDirectRead := query["directread"]

// // If we are not the plugin, we should not use ?recursive (we should pass a -r flag)
// If we are not the plugin, we should not use ?recursive (we should pass a -r flag)
if !isPlugin && hasRecursive {
return errors.New("cannot use the recursive query parameter when not utilizing the pelican plugin")
return errors.New("recursive query parameter is not yet supported in URLs outside of the plugin")
}

// If we have both recursive and pack, we should return a failure
if hasRecursive && hasPack {
return errors.New("cannot have both recursive and pack query parameters")
}

// If we have both recursive and pack, we should return a failure
// If there is an argument in the directread query param, inform the user this is deprecated and their argument will be ignored
if hasDirectRead && directRead[0] != "" {
return errors.New("directread query parameter should not have any values assigned to it")
log.Warnln("Arguments (true/false) for the directread query have been deprecated and will be disallowed in a future release. The argument provided will be ignored")
return nil
}

// If we have no query, or we have recursive or pack, we are good
7 changes: 3 additions & 4 deletions utils/utils_test.go
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ func TestValidQuery(t *testing.T) {

err = CheckValidQuery(transferUrl, false)
assert.Error(t, err)
assert.Contains(t, err.Error(), "cannot use the recursive query parameter when not utilizing the pelican plugin")
assert.Contains(t, err.Error(), "recursive query parameter is not yet supported in URLs outside of the plugin")
})

// Test we pass with both pack and directread
@@ -111,13 +111,12 @@ func TestValidQuery(t *testing.T) {
})

// Test if we have a value assigned to directread, we fail
t.Run("testValueOnDirectReadFailure", func(t *testing.T) {
t.Run("testValueOnDirectReadNoFailure", func(t *testing.T) {
transferStr := "pelican://something/here?directread=false"
transferUrl, err := url.Parse(transferStr)
assert.NoError(t, err)

err = CheckValidQuery(transferUrl, false)
assert.Error(t, err)
assert.Equal(t, err.Error(), "directread query parameter should not have any values assigned to it")
assert.NoError(t, err)
})
}

0 comments on commit 2763403

Please sign in to comment.