diff --git a/Makefile b/Makefile index 8c18c647..c0653c2a 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,10 @@ gomake-all: getdeps verifiers @go run make.go -install @mkdir -p $(HOME)/.mc +coverage: + @go test -race -coverprofile=cover.out + @go tool cover -html=cover.out && echo "Visit your browser" + release: getdeps verifiers @echo "Installing mc:" @go run make.go -release diff --git a/acl.go b/acl.go index ea514167..09b18a1f 100644 --- a/acl.go +++ b/acl.go @@ -47,9 +47,6 @@ func (b bucketACL) String() string { if !b.isValidBucketACL() { return string(b) } - if b.isPrivate() { - return "private" - } if b.isReadOnly() { return "public-read" } diff --git a/aliases.go b/aliases.go index 65bef755..b808da7f 100644 --- a/aliases.go +++ b/aliases.go @@ -35,11 +35,11 @@ func isValidAliasName(aliasName string) bool { fallthrough case "private": fallthrough - case "read-only": + case "readonly": fallthrough - case "public-read": + case "public": fallthrough - case "public-read-write": + case "authenticated": return false } return validAliasName.MatchString(aliasName) diff --git a/cat_test.go b/cat_test.go index 1f7433e9..2b61125d 100644 --- a/cat_test.go +++ b/cat_test.go @@ -47,4 +47,8 @@ func (s *CmdTestSuite) TestCatCmd(c *C) { _, err = doCatCmd(sourceURL) c.Assert(err, IsNil) } + + objectPath = filepath.Join(root, "object2") + _, err = doCatCmd(objectPath) + c.Assert(err, Not(IsNil)) } diff --git a/cmd_test.go b/cmd_test.go index 9f9472e7..3b1bf158 100644 --- a/cmd_test.go +++ b/cmd_test.go @@ -60,13 +60,33 @@ func (s *CmdTestSuite) SetUpSuite(c *C) { _, err = doConfig("generate", nil) c.Assert(err, IsNil) + _, err = doConfig("generate", nil) + c.Assert(err, Not(IsNil)) + + _, err = doConfig("cover", nil) + c.Assert(err, Not(IsNil)) + + _, err = doConfig("alias", []string{"test", "https://test.io"}) + c.Assert(err, IsNil) + + _, err = doConfig("alias", []string{"test", "https://test.io"}) + c.Assert(err, Not(IsNil)) + + _, err = doConfig("alias", []string{"test", "htt://test.io"}) + c.Assert(err, Not(IsNil)) + + _, err = doConfig("alias", []string{"readonly", "https://new.test.io"}) + c.Assert(err, Not(IsNil)) + objectAPI := objectAPIHandler(objectAPIHandler{lock: &sync.Mutex{}, bucket: "bucket", object: make(map[string][]byte)}) server = httptest.NewServer(objectAPI) } func (s *CmdTestSuite) TearDownSuite(c *C) { os.RemoveAll(customConfigDir) - server.Close() + if server != nil { + server.Close() + } } func (s *CmdTestSuite) TestGetNewClient(c *C) { @@ -93,7 +113,7 @@ func (s *CmdTestSuite) TestNewConfigV1(c *C) { err = conf.Save(configFile) c.Assert(err, IsNil) - confNew := newConfigV1() + confNew := newConfigV101() config, err := quick.New(confNew) c.Assert(err, IsNil) err = config.Load(configFile) @@ -126,6 +146,8 @@ func (s *CmdTestSuite) TestNewConfigV1(c *C) { } wantHosts := []string{ + "localhost:*", + "127.0.0.1:*", "play.minio.io:9000", "dl.minio.io:9000", "s3*.amazonaws.com", @@ -145,9 +167,39 @@ func (s *CmdTestSuite) TestRecursiveURL(c *C) { c.Assert(stripRecursiveURL("...url"), Equals, "...url") } +func (s *CmdTestSuite) TestHostConfig(c *C) { + hostcfg, err := getHostConfig("https://s3.amazonaws.com") + c.Assert(err, IsNil) + c.Assert(hostcfg.AccessKeyID, Equals, globalAccessKeyID) + c.Assert(hostcfg.SecretAccessKey, Equals, globalSecretAccessKey) + + _, err = getHostConfig("http://test.minio.io") + c.Assert(err, Not(IsNil)) +} + +func (s *CmdTestSuite) TestArgs2URL(c *C) { + URLs := []string{"localhost:", "s3:", "play:", "https://s3-us-west-2.amazonaws.com"} + expandedURLs, err := args2URLs(URLs) + c.Assert(err, IsNil) + c.Assert(expandedURLs[0], Equals, "http://localhost:9000/") + c.Assert(expandedURLs[1], Equals, "https://s3.amazonaws.com/") + c.Assert(expandedURLs[2], Equals, "https://play.minio.io:9000/") + c.Assert(expandedURLs[3], Equals, "https://s3-us-west-2.amazonaws.com") +} + func (s *CmdTestSuite) TestValidACL(c *C) { acl := bucketACL("private") c.Assert(acl.isValidBucketACL(), Equals, true) + c.Assert(acl.String(), Equals, "private") + acl = bucketACL("public") + c.Assert(acl.isValidBucketACL(), Equals, true) + c.Assert(acl.String(), Equals, "public-read-write") + acl = bucketACL("readonly") + c.Assert(acl.isValidBucketACL(), Equals, true) + c.Assert(acl.String(), Equals, "public-read") + acl = bucketACL("authenticated") + c.Assert(acl.isValidBucketACL(), Equals, true) + c.Assert(acl.String(), Equals, "authenticated-read") } func (s *CmdTestSuite) TestInvalidACL(c *C) {