return resp, nil
}
+// CollectionCreate defers to railsProxy for everything except blob
+// signatures.
+func (conn *Conn) CollectionCreate(ctx context.Context, opts arvados.CreateOptions) (arvados.Collection, error) {
+ if len(opts.Select) > 0 {
+ // We need to know IsTrashed and TrashAt to implement
+ // signing properly, even if the caller doesn't want
+ // them.
+ opts.Select = append([]string{"is_trashed", "trash_at"}, opts.Select...)
+ }
+ resp, err := conn.railsProxy.CollectionCreate(ctx, opts)
+ if err != nil {
+ return resp, err
+ }
+ conn.signCollection(ctx, &resp)
+ return resp, nil
+}
+
+// CollectionUpdate defers to railsProxy for everything except blob
+// signatures.
+func (conn *Conn) CollectionUpdate(ctx context.Context, opts arvados.UpdateOptions) (arvados.Collection, error) {
+ if len(opts.Select) > 0 {
+ // We need to know IsTrashed and TrashAt to implement
+ // signing properly, even if the caller doesn't want
+ // them.
+ opts.Select = append([]string{"is_trashed", "trash_at"}, opts.Select...)
+ }
+ resp, err := conn.railsProxy.CollectionUpdate(ctx, opts)
+ if err != nil {
+ return resp, err
+ }
+ conn.signCollection(ctx, &resp)
+ return resp, nil
+}
+
func (conn *Conn) signCollection(ctx context.Context, coll *arvados.Collection) {
if coll.IsTrashed || coll.ManifestText == "" || !conn.cluster.Collections.BlobSigning {
return
c.Check(lresp.Items[0].UnsignedManifestText, check.Matches, `(?ms).* acbd[^ ]*\+3 0:.*`)
}
- // early trash date causes lower signature TTL
+ // early trash date causes lower signature TTL (even if
+ // trash_at and is_trashed fields are unselected)
trashed, err := s.localdb.CollectionCreate(ctx, arvados.CreateOptions{
+ Select: []string{"uuid", "manifest_text"},
Attrs: map[string]interface{}{
"manifest_text": ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:foo\n",
"trash_at": time.Now().UTC().Add(time.Hour),
}})
c.Assert(err, check.IsNil)
+ s.checkSignatureExpiry(c, trashed.ManifestText, time.Hour)
resp, err = s.localdb.CollectionGet(ctx, arvados.GetOptions{UUID: trashed.UUID})
c.Assert(err, check.IsNil)
s.checkSignatureExpiry(c, resp.ManifestText, time.Hour)
// distant future trash date does not cause higher signature TTL
- trashed, err = s.localdb.CollectionCreate(ctx, arvados.CreateOptions{
+ trashed, err = s.localdb.CollectionUpdate(ctx, arvados.UpdateOptions{
+ UUID: trashed.UUID,
Attrs: map[string]interface{}{
- "manifest_text": ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:foo\n",
- "trash_at": time.Now().UTC().Add(time.Hour * 24 * 365),
+ "trash_at": time.Now().UTC().Add(time.Hour * 24 * 365),
}})
c.Assert(err, check.IsNil)
+ s.checkSignatureExpiry(c, trashed.ManifestText, time.Hour*24*7*2)
resp, err = s.localdb.CollectionGet(ctx, arvados.GetOptions{UUID: trashed.UUID})
c.Assert(err, check.IsNil)
s.checkSignatureExpiry(c, resp.ManifestText, time.Hour*24*7*2)