Skip to content

Commit

Permalink
IG-20463 GetContainerContents: escape url path (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf758 authored May 31, 2022
1 parent 7d60ae8 commit 54dfe2a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/dataplane/http/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (c *context) GetContainerContentsSync(getContainerContentsInput *v3io.GetCo
var queryBuilder strings.Builder
if getContainerContentsInput.Path != "" {
queryBuilder.WriteString("prefix=")
queryBuilder.WriteString(getContainerContentsInput.Path)
queryBuilder.WriteString(url.PathEscape(getContainerContentsInput.Path))
}

if getContainerContentsInput.DirectoriesOnly {
Expand Down
26 changes: 15 additions & 11 deletions pkg/dataplane/test/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type syncTestSuite struct {
testSuite
}

const (
TestPath = "/dir1/#dir2/"
)

//
// Container tests
//
Expand Down Expand Up @@ -368,7 +372,7 @@ type syncObjectTestSuite struct {
}

func (suite *syncObjectTestSuite) TestObject() {
path := "/object.txt"
path := TestPath + "#object.txt"
contents := "vegans are better than everyone"

getObjectInput := &v3io.GetObjectInput{
Expand Down Expand Up @@ -795,7 +799,7 @@ func (suite *syncKVTestSuite) TestEMD() {
// create the items
for itemToCreateKey, itemToCreateAttributes := range itemsToCreate {
input := v3io.PutItemInput{
Path: "/emd0/" + itemToCreateKey,
Path: TestPath + "emd0/" + itemToCreateKey,
Attributes: itemToCreateAttributes,
}

Expand All @@ -815,7 +819,7 @@ func (suite *syncKVTestSuite) TestEMD() {

// update louise item
updateItemInput := v3io.UpdateItemInput{
Path: "/emd0/louise",
Path: TestPath + "/emd0/louise",
Attributes: map[string]interface{}{
"height": 130,
"quip": "i can smell fear on you",
Expand All @@ -830,7 +834,7 @@ func (suite *syncKVTestSuite) TestEMD() {

// get louise
getItemInput := v3io.GetItemInput{
Path: "/emd0/louise",
Path: TestPath + "/emd0/louise",
AttributeNames: []string{"__size", "age", "quip", "height"},
}

Expand All @@ -853,7 +857,7 @@ func (suite *syncKVTestSuite) TestEMD() {

// get all items whose age is over 15
getItemsInput := v3io.GetItemsInput{
Path: "/emd0/",
Path: TestPath + "/emd0/",
AttributeNames: []string{"age", "feature"},
Filter: "age > 15",
}
Expand Down Expand Up @@ -886,7 +890,7 @@ func (suite *syncKVTestSuite) TestEMD() {

// update louise's age
updateItemInput = v3io.UpdateItemInput{
Path: "/emd0/louise",
Path: TestPath + "/emd0/louise",
Expression: &incrementAgeExpression,
}

Expand All @@ -898,7 +902,7 @@ func (suite *syncKVTestSuite) TestEMD() {

// get tina
getItemInput = v3io.GetItemInput{
Path: "/emd0/louise",
Path: TestPath + "/emd0/louise",
AttributeNames: []string{"age"},
}

Expand All @@ -920,7 +924,7 @@ func (suite *syncKVTestSuite) TestEMD() {
// Delete everything
//

suite.deleteItems("/emd0", itemsToCreate)
suite.deleteItems(TestPath+"/emd0", itemsToCreate)
}

func (suite *syncKVTestSuite) TestPutItems() {
Expand All @@ -930,7 +934,7 @@ func (suite *syncKVTestSuite) TestPutItems() {
}

putItemsInput := &v3io.PutItemsInput{
Path: "/emd0",
Path: TestPath + "emd0",
Items: items,
}

Expand Down Expand Up @@ -1073,7 +1077,7 @@ func (suite *syncKVTestSuite) TestPutItemsWithError() {
}

putItemsInput := &v3io.PutItemsInput{
Path: "/emd0",
Path: TestPath + "/emd0",
Items: items,
}

Expand Down Expand Up @@ -1155,7 +1159,7 @@ func (suite *syncKVTestSuite) verifyItems(items map[string]map[string]interface{

// get all items
getItemsInput := v3io.GetItemsInput{
Path: "/emd0/",
Path: TestPath + "/emd0/",
AttributeNames: []string{"*"},
}

Expand Down

0 comments on commit 54dfe2a

Please sign in to comment.