예제 #1
0
        public void TestGetACL()
        {
            using (var requestHandler = new TestRequestHandler())
                using (var client = new RingMasterClient(requestHandler))
                {
                    string path = this.GetRandomString();
                    var    stat = new Stat()
                    {
                        Version = this.GetRandomInt()
                    };
                    var expectedAcl = new List <Acl>()
                    {
                        new Acl((int)Acl.Perm.ALL, new Id(AuthSchemes.Digest, this.GetRandomString()))
                    };

                    requestHandler.Implementation = request =>
                    {
                        Assert.IsTrue(request is RequestGetAcl);
                        var getAclRequest = (RequestGetAcl)request;
                        Assert.AreEqual(path, getAclRequest.Path);
                        Assert.AreEqual(stat.Version, getAclRequest.Stat.Version);

                        return(new RequestResponse()
                        {
                            ResultCode = (int)RingMasterException.Code.Ok,
                            Content = expectedAcl
                        });
                    };

                    var resultAcl = client.GetACL(path, stat).Result;
                    Assert.AreEqual(expectedAcl.Count, resultAcl.Count);
                    Assert.IsTrue(Acl.AreEqual(expectedAcl[0], resultAcl[0]));
                }
        }