Exemplo n.º 1
0
        public void TestCheck()
        {
            var expectedCheck = new CheckBuilder(Arrays.AsList(
                                                     Utils.Rule("query",
                                                                new List <Term>(),
                                                                Arrays.AsList(
                                                                    Utils.Pred("resource", Arrays.AsList(Utils.Symbol("ambient"), Utils.Var("0"))),
                                                                    Utils.Pred("operation", Arrays.AsList(Utils.Symbol("ambient"), Utils.Symbol("read")))
                                                                    )
                                                                ),
                                                     Utils.Rule("query",
                                                                new List <Term>(),
                                                                Arrays.AsList(
                                                                    Utils.Pred("admin", Arrays.AsList(Utils.Symbol("authority")))
                                                                    )
                                                                )
                                                     ));
            //var expected = new Right(new Tuple<string, Check>("", check));

            Either <Error, Tuple <string, CheckBuilder> > res =
                Parser.Check("check if resource(#ambient, $0), operation(#ambient, #read) or admin(#authority)");


            Assert.IsTrue(res.IsRight);

            Assert.AreEqual(expectedCheck, res.Right.Item2);
        }
Exemplo n.º 2
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || GetType() != o.GetType())
            {
                return(false);
            }

            CheckBuilder check = (CheckBuilder)o;

            return(queries != null?queries.SequenceEqual(check.queries) : check.queries == null);
        }
Exemplo n.º 3
0
 public void AddAuthorityCheck(CheckBuilder c)
 {
     this.Checks.Add(c.Convert(this.Symbols));
 }
Exemplo n.º 4
0
 public void AddCheck(CheckBuilder check)
 {
     this.checks.Add(check.Convert(this.symbols));
 }