示例#1
0
        public void testKeysOther()
        {
            ObjectKey key = new ObjectKey("Test_key-pool#@!$%^..", "KEY_TEST2");
            string content = "Key tests!";
            byte[] data = Encoding.UTF8.GetBytes(content);

            ObjectId oid = this.esu.CreateObjectWithKey(key, null, null, data, "text/plain");
            cleanup.Add(oid);

            // test getting stuff
            Acl acl = this.esu.GetAcl(key);
            Assert.IsNotNull(acl, "ACL is null");
            ObjectMetadata objectMeta = this.esu.GetAllMetadata(key);
            Assert.IsTrue(objectMeta.Metadata.Count() > 0, "Object metadata is null");
            ObjectInfo info = this.esu.GetObjectInfo(key);
            Assert.IsNotNull(info.ObjectID, "GetObjectInfo object ID is null");
            Assert.IsTrue(this.esu.GetSystemMetadata(key, null).Count() > 0, "System Metadata is empty");
            Assert.IsTrue(this.esu.GetUserMetadata(key, null).Count() == 0, "User Metadata is not empty");

            // test setting stuff
            foreach (Grant grant in acl) {
                if (grant.Grantee.Name == "other")
                {
                    grant.Permission = Permission.READ;
                    break;
                }
            }
            this.esu.SetAcl(key, acl);
            Assert.AreEqual(acl, this.esu.GetAcl(key), "ACL is different");
            MetadataList mList = new MetadataList();
            mList.AddMetadata(new Metadata("foo", "bar", false));
            mList.AddMetadata(new Metadata("listable", "", true));
            this.esu.SetUserMetadata(key, mList);
            MetadataList readList = this.esu.GetUserMetadata(key, null);
            Assert.AreEqual(mList.ToString(), readList.ToString(), "User meta is different");
        }