Beispiel #1
0
        public void TestPermissionsSystemManager()
        {
            TLogging.Log("Running test 'TestPermissionsSystemManager'..." + Environment.NewLine);

            Assert.AreEqual("demo", UserInfo.GUserInfo.UserID.ToLower(), "Test should be run with DEMO user");

            //change demo's permissions in the xml back to normal
            TLstTasks.Init(UserInfo.GUserInfo.UserID, FalsePermission);

            // get the node that opens the screen TFrmMaintainUsers
            XPathExpression   expr     = FNavigator.Compile("//*[@ActionOpenScreen='TFrmMaintainUsers']");
            XPathNodeIterator iterator = FNavigator.Select(expr);

            iterator.MoveNext();

            if (iterator.Current is IHasXmlNode)
            {
                XmlNode ActionNode = ((IHasXmlNode)iterator.Current).GetNode();

                TLogging.Log(ActionNode.Name + " " + ActionNode.Attributes["ActionOpenScreen"].Value);

                Assert.AreEqual(false, TFrmMainWindowNew.HasAccessPermission(ActionNode, UserInfo.GUserInfo.UserID, false),
                                "user DEMO should not have permissions for TFrmMaintainUsers");

                // open the screen. should return an error message
                Assert.AreEqual(Catalog.GetString("Sorry, you don't have enough permissions to do this"),
                                TLstTasks.ExecuteAction(ActionNode, null));
            }
        }
Beispiel #2
0
        public void TestBrokenClientPermissions()
        {
            TLogging.Log("Running test 'TestBrokenClientPermissions'..." + Environment.NewLine);

            // Give the user access at the client end to open the screen
            TLstTasks.Init(UserInfo.GUserInfo.UserID, TruePermission);

            // Check that the user is 'demo'
            Assert.AreEqual("demo", UserInfo.GUserInfo.UserID.ToLower(), "Test should be run with DEMO user");

            // get the node that opens the screen TFrmMaintainUsers
            XPathExpression   expr     = FNavigator.Compile("//*[@ActionOpenScreen='TFrmMaintainUsers']");
            XPathNodeIterator iterator = FNavigator.Select(expr);

            iterator.MoveNext();

            if (iterator.Current is IHasXmlNode)
            {
                XmlNode ActionNode = ((IHasXmlNode)iterator.Current).GetNode();

                TLogging.Log(ActionNode.Name + " " + ActionNode.Attributes["ActionOpenScreen"].Value);

                // Check that the node does not give permission to user 'demo'
                Assert.AreEqual(false, TFrmMainWindowNew.HasAccessPermission(ActionNode, UserInfo.GUserInfo.UserID, false),
                                "user DEMO should not have permissions for TFrmMaintainUsers");

                string errorResult = TLstTasks.ExecuteAction(ActionNode, null);

                // The server should have rejected us
                Assert.AreNotEqual(String.Empty, errorResult, "Demo was able to open the screen!");
                Assert.IsTrue(errorResult.Equals(
                                  "No access for user DEMO to Module SYSMAN."), "Expected the fail reason to be module access permission");
            }
        }
Beispiel #3
0
        private void TestIndividualBrokenClientPermission(string XPath, string ScreenName)
        {
            // get the node that opens the screen, e.g. 'TFrmMaintainUsers'
            XPathExpression   expr     = FNavigator.Compile(XPath);
            XPathNodeIterator iterator = FNavigator.Select(expr);

            iterator.MoveNext();

            if (iterator.Current is IHasXmlNode)
            {
                XmlNode ActionNode = ((IHasXmlNode)iterator.Current).GetNode();

                TLogging.Log(ActionNode.Name + " " + ActionNode.Attributes["ActionOpenScreen"].Value);

                // Check that the node does not give permission to user 'demo'
                Assert.AreEqual(false, TFrmMainWindowNew.HasAccessPermission(ActionNode, UserInfo.GUserInfo.UserID, false),
                                "user DEMO should not have permissions for " + ScreenName);

                bool   gotServerException;
                string errorResult = ExecuteAction(ActionNode, out gotServerException);

                // The server should have rejected us
                Assert.IsTrue(gotServerException, "Demo was able to open the screen but the server shouldn't have allowed that! XPath: " + XPath);
                Assert.IsTrue(errorResult.Equals(
                                  "No access for user DEMO to Module SYSMAN."), "Expected the fail reason to be module access permission");
            }
        }
Beispiel #4
0
        /// <summary>
        /// start the gui program
        /// </summary>
        public override void Setup()
        {
            // Before Execution of any Test we should do something like
            // nant stopPetraServer
            // nant ResetDatabase
            // nant startPetraServer
            // this may take some time ....
            new TLogging("../../log/TestClient_MainNavigationTest.log");

            // clear the log file
            using (FileStream stream = new FileStream("TestClient_MainNavigationTest.log", FileMode.Create))
                using (TextWriter writer = new StreamWriter(stream))
                {
                    writer.WriteLine("");
                }

            FConnectedToServer = false;
            try
            {
                TPetraConnector.Connect("../../etc/TestClient.config");
                FConnectedToServer = true;
            }
            catch (Exception)
            {
                Assert.Fail("Failed to connect to the Petra Server.  Have you forgotten to launch the Server Console");
            }

            TLstTasks.Init(UserInfo.GUserInfo.UserID, TFrmMainWindowNew.HasAccessPermission);

            // load the UINavigation file (csharp\ICT\Petra\Definitions\UINavigation.yml)
            TLogging.Log("loading " + TAppSettingsManager.GetValue("UINavigation.File"));
            XmlNode MainMenuNode = TFrmMainWindowNew.BuildNavigationXml(false);

            // saving a xml file for better understanding how to use the XPath commands
            //StreamWriter sw = new StreamWriter(TAppSettingsManager.GetValue("UINavigation.File") + ".xml");
            //sw.WriteLine(TXMLParser.XmlToStringIndented(MainMenuNode.OwnerDocument));
            //sw.Close();

            FNavigator = MainMenuNode.OwnerDocument.CreateNavigator();

            TLogging.Log("Test Setup finished..." + Environment.NewLine);
        }