posix: Support UNC paths on windows. (#1887)

This allows us to now use 32K paths names on windows.

Fixes #1620
This commit is contained in:
Harshavardhana
2016-06-13 15:23:09 +05:30
committed by Anand Babu (AB) Periasamy
parent 4ab57f7d60
commit ed4fe689b4
13 changed files with 379 additions and 83 deletions

View File

@@ -19,6 +19,7 @@ package main
import (
"bytes"
"crypto/md5"
"fmt"
"io"
"io/ioutil"
"os"
@@ -86,7 +87,7 @@ func (s *MyAPISuite) SetUpSuite(c *C) {
}
func (s *MyAPISuite) TearDownSuite(c *C) {
os.RemoveAll(s.root)
removeAll(s.root)
testAPIFSCacheServer.Close()
}
@@ -686,6 +687,34 @@ func (s *MyAPISuite) TestListBuckets(c *C) {
c.Assert(err, IsNil)
}
// Tests put object with long names.
func (s *MyAPISuite) TestPutObjectLongName(c *C) {
request, err := s.newRequest("PUT", testAPIFSCacheServer.URL+"/put-object-long-name", 0, nil)
c.Assert(err, IsNil)
client := http.Client{}
response, err := client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
buffer := bytes.NewReader([]byte("hello world"))
longObjName := fmt.Sprintf("%0255d/%0255d/%0255d", 1, 1, 1)
request, err = s.newRequest("PUT", testAPIFSCacheServer.URL+"/put-object-long-name/"+longObjName, int64(buffer.Len()), buffer)
c.Assert(err, IsNil)
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
longObjName = fmt.Sprintf("%0256d", 1)
request, err = s.newRequest("PUT", testAPIFSCacheServer.URL+"/put-object-long-name/"+longObjName, int64(buffer.Len()), buffer)
c.Assert(err, IsNil)
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusNotFound)
}
func (s *MyAPISuite) TestNotBeAbleToCreateObjectInNonexistentBucket(c *C) {
buffer1 := bytes.NewReader([]byte("hello world"))
request, err := s.newRequest("PUT", testAPIFSCacheServer.URL+"/innonexistentbucket/object", int64(buffer1.Len()), buffer1)