예제 #1
0
파일: test.cs 프로젝트: hoangduit/openpetra
        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");
            }
        }
        /// <summary>
        /// load or reload the navigation
        /// </summary>
        public void LoadNavigationUI(bool ADontUseDefaultLedger = false)
        {
            // Force re-calculation of available Ledgers and correct setting of FCurrentLedger
            FLedgersAvailableToUser = null;

            XmlNode MainMenuNode   = BuildNavigationXml(ADontUseDefaultLedger);
            XmlNode DepartmentNode = MainMenuNode.FirstChild;

            lstFolders.MultiLedgerSite    = FMultiLedgerSite;
            lstFolders.CurrentLedger      = FCurrentLedger;
            lstFolders.ConferenceSelected = FConferenceSelected;

            lstFolders.ClearFolders();

            lstFolders.SubmoduleChanged += delegate(TTaskList ATaskList, XmlNode ATaskListNode, LinkLabel AItemClicked, object AOtherData)
            {
                OnSubmoduleChanged(ATaskList, ATaskListNode, AItemClicked);
            };
            lstFolders.LedgerChanged += delegate(int ALedgerNr, string ALedgerName)
            {
                OnLedgerChanged(ALedgerNr, ALedgerName);
            };

            TPnlModuleNavigation.SubSystemLinkStatus += delegate(int ALedgerNr, TPnlCollapsible APnlCollapsible)
            {
                UpdateSubsystemLinkStatus(ALedgerNr, APnlCollapsible);
            };

            TFrmGLEnableSubsystems.FinanceSubSystemLinkStatus += delegate()
            {
                UpdateFinanceSubsystemLinkStatus();
            };

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

            while (DepartmentNode != null)
            {
                lstFolders.AddFolder(DepartmentNode, UserInfo.GUserInfo.UserID, HasAccessPermission);

                DepartmentNode = DepartmentNode.NextSibling;
            }

            lstFolders.Dashboard = this.dsbContent;
            lstFolders.Statusbar = this.stbMain;

            SetTaskTileSize(TUserDefaults.GetInt16Default(TUserDefaults.MAINMENU_VIEWOPTIONS_TILESIZE, 2));

            SetTasksSingleClickExecution(TUserDefaults.GetBooleanDefault(TUserDefaults.MAINMENU_VIEWOPTIONS_SINGLECLICKEXECUTION, false));

            if (TUserDefaults.GetStringDefault(TUserDefaults.MAINMENU_VIEWOPTIONS_VIEWTASKS, VIEWTASKS_TILES) == VIEWTASKS_TILES)
            {
                ViewTasksAsTiles(this, null);
            }
            else
            {
                ViewTasksAsList(this, null);
            }

            lstFolders.SelectFirstAvailableFolder();
        }
예제 #3
0
파일: test.cs 프로젝트: hoangduit/openpetra
        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));
            }
        }
예제 #4
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");

            // Now run the individual tests
            TestIndividualBrokenClientPermission("//*[@ActionOpenScreen='TFrmMaintainUsers']", "TFrmMaintainUsers");
            TestIndividualBrokenClientPermission("//*[@ActionOpenScreen='TFrmSystemSettingsSetup']", "TFrmSystemSettingsSetup");
            TestIndividualBrokenClientPermission("//*[@ActionOpenScreen='TFrmSecurityGroupSetup']", "TFrmSecurityGroupSetup");
        }
예제 #5
0
파일: test.cs 프로젝트: hoangduit/openpetra
        /// <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);
        }