18600: Add more invalid splice request tests.
authorTom Clegg <tom@curii.com>
Mon, 7 Mar 2022 19:59:32 +0000 (14:59 -0500)
committerTom Clegg <tom@curii.com>
Mon, 7 Mar 2022 19:59:32 +0000 (14:59 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/controller/localdb/collection.go
lib/controller/localdb/collection_test.go

index 965b009f45c0996edc954ae708261e45984c2b5a..2283b2fcb540383a330a964a09dec3b13c4e9f89 100644 (file)
@@ -238,7 +238,7 @@ func (conn *Conn) applySplices(ctx context.Context, fromUUID string, attrs map[s
                srcspec := strings.SplitN(src, "/", 2)
                srcid, srcpath := srcspec[0], "/"
                if !arvadosclient.PDHMatch(srcid) {
-                       return httpserver.Errorf(http.StatusBadRequest, "invalid source %q for splices[%q]: must be \"\" or \"PDH[/path]\"", src, dst)
+                       return httpserver.Errorf(http.StatusBadRequest, "invalid source %q for splices[%q]: must be \"\" or \"PDH\" or \"PDH/path\"", src, dst)
                }
                if len(srcspec) == 2 && srcspec[1] != "" {
                        srcpath = srcspec[1]
index 27cdf3899e42fb230168c6b8444502cced5e87f9..e71ae35c21e0ce1398b799988e7a8049b47134f8 100644 (file)
@@ -219,6 +219,7 @@ func (s *CollectionSuite) TestCollectionUpdateFiles(c *check.C) {
        c.Check(dstcopy.PortableDataHash, check.Equals, dst.PortableDataHash)
        s.expectFiles(c, dstcopy, "b/corge.txt")
 
+       // Check invalid targets, sources, and combinations
        for _, splices := range []map[string]string{
                {
                        "/foo/nope": dst.PortableDataHash + "/b",
@@ -256,9 +257,14 @@ func (s *CollectionSuite) TestCollectionUpdateFiles(c *check.C) {
                c.Logf("splices %#v\n... got err: %s", splices, err)
                c.Check(err, check.NotNil)
        }
+
+       // Check "splices" value that isn't even the right type
        for _, splices := range []interface{}{
                map[string]int{"foo": 1},
                map[int]string{1: "foo"},
+               12345,
+               "foo",
+               []string{"foo"},
        } {
                _, err = s.localdb.CollectionUpdate(ctx, arvados.UpdateOptions{
                        UUID: dst.UUID,
@@ -266,8 +272,18 @@ func (s *CollectionSuite) TestCollectionUpdateFiles(c *check.C) {
                                "splices": splices,
                        }})
                c.Logf("splices %#v\n... got err: %s", splices, err)
-               c.Check(err, check.NotNil)
+               c.Check(err, check.ErrorMatches, "invalid type .* for splices parameter")
        }
+
+       // Check conflicting splices and manifest_text
+       _, err = s.localdb.CollectionUpdate(ctx, arvados.UpdateOptions{
+               UUID: dst.UUID,
+               Attrs: map[string]interface{}{
+                       "splices":       map[string]string{"/": ""},
+                       "manifest_text": ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:z\n",
+               }})
+       c.Logf("splices+manifest_text\n... got err: %s", err)
+       c.Check(err, check.ErrorMatches, "ambiguous request: both.*splices.*manifest_text.*")
 }
 
 // expectFiles checks coll's directory structure against the given