public void HasPrivilege3()
        {
            string privilege = "TestPriv";
            string productionUnit = "6029537682";
            AuthorisationsParser ap = new AuthorisationsParser();
            AuthorisationsType at = new AuthorisationsType();

            PrivilegeType priv = new PrivilegeType();
            priv.Value = privilege;

            AuthorisationType auth = new AuthorisationType();
            auth.resource = "urn:dk:cvr:productionUnitIdentifier:" + productionUnit;
            auth.Privilege.Add(priv);
            at.Authorisations.Add(auth);

            ap.Load(at);

            Assert.That(ap.HasPrivilege(AuthorisationsParser.PrivilegeFor.ProductionUnit, productionUnit, privilege), "User unexpectedly does not have privilege for production unit");
        }
        public void HasPrivilege2()
        {
            string privilege = "TestPriv";
            string cvrNumber = "29537682";
            AuthorisationsParser ap = new AuthorisationsParser();
            AuthorisationsType at = new AuthorisationsType();

            PrivilegeType priv = new PrivilegeType();
            priv.Value = privilege;

            AuthorisationType auth = new AuthorisationType();
            auth.resource = "urn:dk:cvr:cVRnumberIdentifier:" + cvrNumber;
            auth.Privilege.Add(priv);
            at.Authorisations.Add(auth);

            ap.Load(at);

            Assert.IsFalse(ap.HasPrivilege(AuthorisationsParser.PrivilegeFor.ProductionUnit, cvrNumber, privilege), "User unexpectedly has privilege");
        }
Exemplo n.º 3
0
        public void LoadFromStronglyTypedObject()
        {
            string privilege = "TestPriv";
            string cvrNumber = "29537682";
            AuthorisationsParser ap = new AuthorisationsParser();
            AuthorisationsType at = new AuthorisationsType();

            PrivilegeType priv = new PrivilegeType();
            priv.Value = privilege;

            AuthorisationType auth = new AuthorisationType();
            auth.resource = "urn:dk:cvr:cVRnumberIdentifier:" + cvrNumber;
            auth.Privilege.Add(priv);
            at.Authorisations.Add(auth);

            ap.Load(at);

            Assert.That(ap.HasPrivilege(AuthorisationsParser.PrivilegeFor.CvrNumber, cvrNumber, privilege), "User does not have expected privilege");

        }
        public void HasPrivilege5()
        {
            string privilege = "SomePrivilege";
            string productionUnit = "6029537682";
            AuthorisationsParser ap = new AuthorisationsParser();
            AuthorisationsType at = new AuthorisationsType();

            PrivilegeType priv = new PrivilegeType();
            priv.Value = privilege;

            AuthorisationType auth = new AuthorisationType();
            auth.resource = "urn:dk:cvr:productionUnitIdentifier:" + productionUnit;
            auth.Privilege.Add(priv);
            at.Authorisations.Add(auth);

            string xml = Serialization.SerializeToXmlString(at);

            ap.Load(Convert.ToBase64String(Encoding.UTF8.GetBytes(xml)));

            Assert.That(ap.HasPrivilege(AuthorisationsParser.PrivilegeFor.ProductionUnit, productionUnit, privilege), "User unexpectedly does not have privilege for production unit");
        }