mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-23 11:47:24 +01:00
Removed old unused file
This commit is contained in:
parent
ca64405f07
commit
cf8777a655
@ -1,1037 +0,0 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2010 NetCitadel, LLC
|
||||
|
||||
Author: Roman Bovsunivskiy a2k0001@gmail.com
|
||||
|
||||
$Id$
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
================================
|
||||
|
||||
Tests implemented in this module:
|
||||
|
||||
ticket 1089
|
||||
|
||||
* user clicks "compile" button in the topmost toolbar. The list
|
||||
should include all firewalls, but only those that require recompile
|
||||
should have "compile" checkboxes checked.
|
||||
|
||||
* user uses main menu "Rules/Compile". This is the same function as
|
||||
the previous one
|
||||
|
||||
* user opens Policy of the firewall "test1" and clicks button
|
||||
"Compile" in the toolbar right above rule set view. The list should
|
||||
include only firewall "test1" and checkbox "Compile" should be checked
|
||||
because it requires recompile
|
||||
|
||||
* the same test as the previous one, but with firewall test2. This
|
||||
one does not require recompile and checkbox "Compile" should not be
|
||||
checked.
|
||||
|
||||
* user selects firewall test1 in the tree and opens context menu,
|
||||
then clicks item "Compile". This is the same test as 3.
|
||||
|
||||
* user selects firewall test2 in the tree and opens context menu,
|
||||
then clicks item "Compile". This is the same test as 4.
|
||||
|
||||
* Select two firewalls in the tree (test1 and test2), open context
|
||||
menu and click "Compile". Should get a list with both firewalls, with
|
||||
checkbox "Compile" selected for test2 and not selected for test1.
|
||||
|
||||
* all previous tests tested "Compile" function. This test should test
|
||||
first step of the "Install" function.
|
||||
|
||||
* emulate clicking "Install" button in the main toolbar
|
||||
|
||||
* check that the first page of the dialog has column of "compile"
|
||||
checkboxes and column of "install" checkboxes
|
||||
|
||||
* check that "compile" checkboxes are checked according to the rules
|
||||
described above in this ticket
|
||||
|
||||
Tests for clusters:
|
||||
|
||||
* when user clicks "install", checkboxes "install" should appear only
|
||||
next to the firewalls and should not appear next to the clusters in
|
||||
the list
|
||||
|
||||
Ticket 1153:
|
||||
|
||||
* tests page1_5(), page1_6(), page1_7() should emulate opening
|
||||
context menu and clicking menu item "Compile" (see ticket
|
||||
#1089). Please add check that the menu item "Compile" is present
|
||||
and enabled
|
||||
|
||||
* test page1_8() should also check that checkboxes in column
|
||||
"compile" and "install" are visible and enabled. Right now it only
|
||||
checks their "checked" state
|
||||
|
||||
* test page1_8() should also test checkboxes next to the firewall
|
||||
objects test3 and test4
|
||||
|
||||
|
||||
Ticket 1308:
|
||||
|
||||
Using the same data file test.fwb, the test should do the following:
|
||||
|
||||
test1:
|
||||
|
||||
* select firewall object test3 in the tree
|
||||
|
||||
* using context menu associated with test3 in the tree, use menu
|
||||
item "Compile"
|
||||
|
||||
* verify that only firewall object test3 appears in the list in
|
||||
instDialog
|
||||
|
||||
* verify that the warning text (QFrame widget warning_space and
|
||||
QLabel widget warning_message) is visible in the dialog.
|
||||
|
||||
test2:
|
||||
|
||||
* select cluster "cluster1" in the tree and use context menu to
|
||||
compile it
|
||||
|
||||
* check that the list has objects "cluster1", "test3" and "test4"
|
||||
|
||||
* check that the warning message is hidden
|
||||
|
||||
test3:
|
||||
|
||||
* regardless of the selection in the tree, simulate clicking on the
|
||||
main toolbar button "Compile"
|
||||
|
||||
* check that the list includes objects "cluster1", "test3", "test4",
|
||||
"test1", "test2" and the warning message is hidden
|
||||
|
||||
the focus of these tests is on the warning message. We verify
|
||||
settings of the "Compile" checkboxes in other tests.
|
||||
|
||||
|
||||
Ticket 1357:
|
||||
|
||||
before running the test check if files "test1.fw", "test2.fw", "test3.fw", "test4.fw" exist and delete them if they are there. If delete operation fails for any reason, fail the test
|
||||
click on the toolbar button "Compile"
|
||||
click "CompileALL"
|
||||
click "Next"
|
||||
let it run until it is done
|
||||
check that status in the list in the column on the left is "Success" for all objects: cluster1, test1 and test2
|
||||
check that it produced files "test1.fw", "test2.fw", "test3.fw", "test4.fw"
|
||||
check that each of these files has non-zero length
|
||||
|
||||
|
||||
Ticket 1358:
|
||||
|
||||
using the same data file test.fwb but work with a copy because
|
||||
instDialog saves data to the disk and modifies the file
|
||||
|
||||
keep common parts of all these tests in a separate function. There
|
||||
will be more tests like these in the future, the difference will be
|
||||
in the installer parameters and in the options stored in the
|
||||
firewall object. These tests check the status in the column on the
|
||||
left (Success or Error) and status of the buttons in the dialog
|
||||
(Finish). They also check if the file has been created and look for
|
||||
certain lines in the progress output panel.
|
||||
|
||||
before running the test, check if files "test1.fw", "test2.fw",
|
||||
"test3.fw", "test4.fw" exist and delete them. If delete operation
|
||||
fails, fail the test. This should be done in the unit test code
|
||||
(C++) rather than in the runner shell script
|
||||
|
||||
create subdirectory "test_install" in the current directory. If this
|
||||
directory exists, remove files in it.
|
||||
|
||||
find firewall object test1, open it in the editor, click "Firewall
|
||||
settings" button and in the dialog change "Directory on the firewall
|
||||
where script should be installed" to the current
|
||||
directory. Alternatively, you can do this by manipulating data in
|
||||
the object instead of opening dialogs:
|
||||
|
||||
FWOptions *fwoptions = firewall_object->getOptionsObject();
|
||||
fwoptions->setStr("firewall_dir", current_dir + "/test_install");
|
||||
|
||||
test1
|
||||
|
||||
* click "Install" toolbar button
|
||||
* uncheck all checkboxes
|
||||
* check "compile" and "install" for test1
|
||||
* click Next
|
||||
* check that the status is "Success" in the list on the left
|
||||
* check that "Next" button is enabled and "Finish" button is disabled
|
||||
* check that file test1.fw has been created in directory "test_install"
|
||||
- delete file test1.fw in "test_install"
|
||||
- create this file again, with contents as follows:
|
||||
|
||||
#!/bin/sh
|
||||
echo "Testing policy activation script"
|
||||
|
||||
* set executable bit on this file (equivalent to chmod +x)
|
||||
* now click "Next"
|
||||
* set user name to the name of the account that is running the test
|
||||
* leave password empty
|
||||
* replace the address of the firewall with 127.0.0.1
|
||||
* click OK to start install
|
||||
* note that since you left password empty, you should have ssh authentication via ssh-agent set up for this to work
|
||||
* read lines from the installer progress output. Look for the line "Testing policy activation script". If you can't find it, fail the test
|
||||
* in all tests verify status in the column on the left.
|
||||
* most likely during debugging you are going to run into different errors with ssh. Make a note of these errors and add lines to the test to fail it if they appear in the installer progress output
|
||||
- delete file test1.fw in "test_install" and delete directory "test_install"
|
||||
|
||||
test2
|
||||
|
||||
test for "authentication failed" error:
|
||||
|
||||
* before compiling and installing, set environment variable
|
||||
"SSH_AUTH_SOCK" to empty string. Save its value before destroying it
|
||||
and then restore when this test is done
|
||||
|
||||
* repeat the test1 with address 127.0.0.1. Since you have turned off
|
||||
ssh-agent and left password field empty, the program should not be
|
||||
able to authenticate and you should see "Permission denied" in the
|
||||
progress output
|
||||
|
||||
test3
|
||||
|
||||
another kind of error is a timeout.
|
||||
|
||||
* To simulate timeout repeat the test with ip address 127.0.0.2. Ssh
|
||||
should time out after some considerable time with appropriate error
|
||||
message in the output. Check for this message and make sure at that
|
||||
point button "Finish" is enabled and status is "Failed" (or is it
|
||||
"Error" ? )
|
||||
|
||||
test4
|
||||
|
||||
test cancellation.
|
||||
|
||||
* Repeat the test using address 127.0.0.2 but click "Cancel" 1 sec
|
||||
after you start installation (this is too short for the ssh timeout
|
||||
to occur). Wait after that until the line "Stopping background
|
||||
process" appears, then check that the installer dialog closes.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "instDialogTest.h"
|
||||
|
||||
#include "unistd.h"
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
#include <QMenuBar>
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "FWObjectClipboard.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace QTest;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
void instDialogTest::initTestCase()
|
||||
{
|
||||
mw = new FWWindow();
|
||||
mw->show();
|
||||
mw->loadFile("test_work.fwb", false);
|
||||
FWObjectClipboard *clip = new FWObjectClipboard();
|
||||
ssh_auth_sock = getenv("SSH_AUTH_SOCK");
|
||||
}
|
||||
|
||||
void instDialogTest::cleanupTestCase()
|
||||
{
|
||||
setenv("SSH_AUTH_SOCK", ssh_auth_sock, 1);
|
||||
QDir().rmdir("test_install");
|
||||
QFile::remove("test1.fw");
|
||||
}
|
||||
|
||||
void instDialogTest::openPolicy(QString fwname)
|
||||
{
|
||||
Policy *p = NULL;
|
||||
foreach (FWObject *fw, mw->db()->getByTypeDeep(Firewall::TYPENAME))
|
||||
{
|
||||
if (fw->getName() == fwname.toStdString())
|
||||
{
|
||||
p = Firewall::cast(fw)->getPolicy();
|
||||
}
|
||||
}
|
||||
QVERIFY (p != NULL);
|
||||
QCoreApplication::postEvent(mw, new openRulesetImmediatelyEvent(mw->activeProject()->getFileName(), p->getId()));
|
||||
QTest::qWait(100);
|
||||
}
|
||||
|
||||
void instDialogTest::verifyDialog(instDialog *dlg, int items)
|
||||
{
|
||||
QVERIFY(dlg != NULL);
|
||||
|
||||
QTreeWidget *table = dlg->findChild<QTreeWidget*>("selectTable");
|
||||
QVERIFY(table != NULL);
|
||||
if (items != -1)
|
||||
QVERIFY(table->topLevelItemCount() == items);
|
||||
QTreeWidgetItemIterator it(table, QTreeWidgetItemIterator::Enabled);
|
||||
while (*it)
|
||||
{
|
||||
if ((*it)->text(0) == "cluster1") QVERIFY((*it)->checkState(1) == Qt::Checked);
|
||||
if ((*it)->text(0) == "test1") QVERIFY((*it)->checkState(1) == Qt::Unchecked);
|
||||
if ((*it)->text(0) == "test2") QVERIFY((*it)->checkState(1) == Qt::Checked);
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
QPoint findItemPos(ObjectTreeViewItem *item, ObjectTreeView *tree)
|
||||
{
|
||||
for (int h=10; h<tree->height(); h+=1)
|
||||
{
|
||||
for (int w=75; w<tree->width(); w+=1)
|
||||
{
|
||||
if(tree->itemAt(w,h) == item)
|
||||
return QPoint(w, h);
|
||||
}
|
||||
}
|
||||
return QPoint(-1,-1);
|
||||
}
|
||||
|
||||
void instDialogTest::closeContextMenu()
|
||||
{
|
||||
QMenu *menu;
|
||||
foreach(QWidget *w, QApplication::allWidgets())
|
||||
{
|
||||
if (w->objectName() == "objectTreeContextMenu")
|
||||
{
|
||||
menu = dynamic_cast<QMenu*>(w);
|
||||
break;
|
||||
}
|
||||
}
|
||||
menu->hide();
|
||||
}
|
||||
|
||||
void instDialogTest::openContextMenu(ObjectManipulator *om, ObjectTreeViewItem *item, ObjectTreeView *tree, const QString &actionText)
|
||||
{
|
||||
QTimer::singleShot(100, this, SLOT(closeContextMenu()));
|
||||
om->contextMenuRequested(findItemPos(item, tree));
|
||||
QMenu *menu;
|
||||
foreach(QWidget *w, QApplication::allWidgets())
|
||||
{
|
||||
if (w->objectName() == "objectTreeContextMenu")
|
||||
{
|
||||
menu = dynamic_cast<QMenu*>(w);
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (QObject *act, menu->children())
|
||||
{
|
||||
QAction *action = dynamic_cast<QAction*>(act);
|
||||
if (action == NULL) continue;
|
||||
if (action->text() == actionText)
|
||||
{
|
||||
action->activate(QAction::Trigger);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void instDialogTest::page1_1()
|
||||
{
|
||||
QAction *compile = mw->findChild<QAction*>("compileAction");
|
||||
compile->activate(QAction::Trigger);
|
||||
QTest::qWait(100);
|
||||
instDialog *dlg = NULL;
|
||||
foreach (QWidget *w, app->allWidgets())
|
||||
if (dynamic_cast<instDialog*>(w) != NULL)
|
||||
dlg = dynamic_cast<instDialog*>(w);
|
||||
verifyDialog(dlg, 3);
|
||||
QTest::qWait(1000);
|
||||
dlg->findChild<QPushButton*>("cancelButton")->click();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void instDialogTest::page1_2()
|
||||
{
|
||||
QMenu *rules = mw->menuBar()->findChild<QMenu*>("RulesMenu");
|
||||
QAction *compile = NULL;
|
||||
|
||||
foreach(QAction *itm, rules->actions())
|
||||
if (itm->objectName() == "compileAction")
|
||||
compile = dynamic_cast<QAction*>(itm);
|
||||
QVERIFY(compile != NULL);
|
||||
compile->activate(QAction::Trigger);
|
||||
QTest::qWait(100);
|
||||
instDialog *dlg = NULL;
|
||||
foreach (QWidget *w, app->allWidgets())
|
||||
if (dynamic_cast<instDialog*>(w) != NULL)
|
||||
dlg = dynamic_cast<instDialog*>(w);
|
||||
verifyDialog(dlg, 3);
|
||||
QTest::qWait(1000);
|
||||
dlg->findChild<QPushButton*>("cancelButton")->click();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void instDialogTest::page1_3()
|
||||
{
|
||||
openPolicy("test1");
|
||||
QTest::qWait(10);
|
||||
QToolButton* compileThis = mw->findChild<QToolButton*>("compile_this_fw");
|
||||
QVERIFY(compileThis != NULL);
|
||||
QTest::mouseClick (compileThis, Qt::LeftButton);
|
||||
QTest::qWait(100);
|
||||
instDialog *dlg = NULL;
|
||||
foreach (QWidget *w, app->allWidgets())
|
||||
if (dynamic_cast<instDialog*>(w) != NULL)
|
||||
dlg = dynamic_cast<instDialog*>(w);
|
||||
verifyDialog(dlg, 1);
|
||||
QTest::qWait(1000);
|
||||
dlg->findChild<QPushButton*>("cancelButton")->click();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void instDialogTest::page1_4()
|
||||
{
|
||||
openPolicy("test2");
|
||||
QTest::qWait(100);
|
||||
QToolButton* compileThis = mw->findChild<QToolButton*>("compile_this_fw");
|
||||
QVERIFY(compileThis != NULL);
|
||||
QTest::mouseClick (compileThis, Qt::LeftButton);
|
||||
QTest::qWait(100);
|
||||
instDialog *dlg = NULL;
|
||||
foreach (QWidget *w, app->allWidgets())
|
||||
if (dynamic_cast<instDialog*>(w) != NULL)
|
||||
dlg = dynamic_cast<instDialog*>(w);
|
||||
verifyDialog(dlg, 1);
|
||||
QTest::qWait(1000);
|
||||
dlg->findChild<QPushButton*>("cancelButton")->click();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void instDialogTest::page1_5()
|
||||
{
|
||||
ObjectTreeView *tree = mw->getCurrentObjectTree();
|
||||
tree->expandAll();
|
||||
ObjectTreeViewItem *test1 = dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
|
||||
ObjectTreeViewItem *test2 = dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test2", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
|
||||
tree->scrollToItem(test1);
|
||||
tree->selectionModel()->select(tree->indexAt(findItemPos(test1, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
|
||||
tree->setCurrentItem(test1);
|
||||
ObjectManipulator *om = mw->findChild<ObjectManipulator*>("om");
|
||||
openContextMenu(om, test1, tree, "Compile");
|
||||
instDialog *dlg = NULL;
|
||||
foreach (QWidget *w, app->allWidgets())
|
||||
if (dynamic_cast<instDialog*>(w) != NULL)
|
||||
dlg = dynamic_cast<instDialog*>(w);
|
||||
verifyDialog(dlg, 1);
|
||||
QTest::qWait(1000);
|
||||
dlg->findChild<QPushButton*>("cancelButton")->click();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void instDialogTest::page1_6()
|
||||
{
|
||||
ObjectTreeView *tree = mw->getCurrentObjectTree();
|
||||
tree->expandAll();
|
||||
ObjectTreeViewItem *test1 = dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
|
||||
ObjectTreeViewItem *test2 = dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test2", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
|
||||
tree->scrollToItem(test2);
|
||||
tree->selectionModel()->select(tree->indexAt(findItemPos(test2, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
|
||||
tree->setCurrentItem(test2);
|
||||
ObjectManipulator *om = mw->findChild<ObjectManipulator*>("om");
|
||||
openContextMenu(om, test2, tree, "Compile");
|
||||
instDialog *dlg = NULL;
|
||||
foreach (QWidget *w, app->allWidgets())
|
||||
if (dynamic_cast<instDialog*>(w) != NULL)
|
||||
dlg = dynamic_cast<instDialog*>(w);
|
||||
verifyDialog(dlg, 1);
|
||||
QTest::qWait(1000);
|
||||
dlg->findChild<QPushButton*>("cancelButton")->click();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void instDialogTest::page1_7()
|
||||
{
|
||||
ObjectTreeView *tree = mw->getCurrentObjectTree();
|
||||
tree->expandAll();
|
||||
ObjectTreeViewItem *test1 = dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
|
||||
ObjectTreeViewItem *test2 = dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test2", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
|
||||
tree->scrollToItem(test1);
|
||||
tree->selectionModel()->select(tree->indexAt(findItemPos(test1, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
|
||||
tree->setCurrentItem(test1);
|
||||
tree->selectionModel()->select(tree->indexAt(findItemPos(test2, tree)), QItemSelectionModel::Select);
|
||||
ObjectManipulator *om = mw->findChild<ObjectManipulator*>("om");
|
||||
openContextMenu(om, test2, tree, "Compile");
|
||||
instDialog *dlg = NULL;
|
||||
foreach (QWidget *w, app->allWidgets())
|
||||
if (dynamic_cast<instDialog*>(w) != NULL)
|
||||
dlg = dynamic_cast<instDialog*>(w);
|
||||
verifyDialog(dlg, 2);
|
||||
QTest::qWait(1000);
|
||||
dlg->findChild<QPushButton*>("cancelButton")->click();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void instDialogTest::page1_8()
|
||||
{
|
||||
ObjectTreeView *tree = mw->getCurrentObjectTree();
|
||||
ObjectTreeViewItem *test3 = dynamic_cast<ObjectTreeViewItem*>(tree->findItems("test3", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
|
||||
tree->selectionModel()->select(tree->indexAt(findItemPos(test3, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
|
||||
tree->setCurrentItem(test3);
|
||||
ObjectManipulator *om = mw->findChild<ObjectManipulator*>("om");
|
||||
openContextMenu(om, test3, tree, "Compile");
|
||||
instDialog *dlg = NULL;
|
||||
foreach (QWidget *w, app->allWidgets())
|
||||
if (dynamic_cast<instDialog*>(w) != NULL)
|
||||
dlg = dynamic_cast<instDialog*>(w);
|
||||
QVERIFY(dlg != NULL);
|
||||
|
||||
QTreeWidget *table = dlg->findChild<QTreeWidget*>("selectTable");
|
||||
QVERIFY(table != NULL);
|
||||
QVERIFY(table->topLevelItemCount() == 1);
|
||||
QVERIFY(table->topLevelItem(0)->text(0) == "test3");
|
||||
|
||||
QFrame *warning_space = dlg->findChild<QFrame*>("warning_space");
|
||||
QLabel *warning_message_1 = dlg->findChild<QLabel*>("warning_message_1");
|
||||
QLabel *warning_message_2 = dlg->findChild<QLabel*>("warning_message_2");
|
||||
|
||||
QVERIFY(warning_space->isVisible());
|
||||
QVERIFY(warning_message_1->isVisible());
|
||||
QVERIFY(warning_message_2->isVisible());
|
||||
|
||||
QTest::qWait(1000);
|
||||
dlg->findChild<QPushButton*>("cancelButton")->click();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void instDialogTest::page1_9()
|
||||
{
|
||||
ObjectTreeView *tree = mw->getCurrentObjectTree();
|
||||
ObjectTreeViewItem *cluster1 = dynamic_cast<ObjectTreeViewItem*>(tree->findItems("cluster1", Qt::MatchExactly | Qt::MatchRecursive, 0).first());
|
||||
tree->selectionModel()->select(tree->indexAt(findItemPos(cluster1, tree)), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent);
|
||||
tree->setCurrentItem(cluster1);
|
||||
ObjectManipulator *om = mw->findChild<ObjectManipulator*>("om");
|
||||
openContextMenu(om, cluster1, tree, "Compile");
|
||||
instDialog *dlg = NULL;
|
||||
foreach (QWidget *w, app->allWidgets())
|
||||
if (dynamic_cast<instDialog*>(w) != NULL)
|
||||
dlg = dynamic_cast<instDialog*>(w);
|
||||
QVERIFY(dlg != NULL);
|
||||
|
||||
QTreeWidget *table = dlg->findChild<QTreeWidget*>("selectTable");
|
||||
QVERIFY(table != NULL);
|
||||
QVERIFY(table->topLevelItemCount() == 1);
|
||||
QVERIFY(table->topLevelItem(0)->text(0) == "cluster1");
|
||||
QVERIFY(table->topLevelItem(0)->childCount() == 2);
|
||||
QVERIFY(table->topLevelItem(0)->child(0)->text(0) == "test3");
|
||||
QVERIFY(table->topLevelItem(0)->child(1)->text(0) == "test4");
|
||||
|
||||
QFrame *warning_space = dlg->findChild<QFrame*>("warning_space");
|
||||
QVERIFY(warning_space->isHidden());
|
||||
|
||||
QTest::qWait(1000);
|
||||
dlg->findChild<QPushButton*>("cancelButton")->click();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void instDialogTest::page1_10()
|
||||
{
|
||||
QAction *compile = mw->findChild<QAction*>("compileAction");
|
||||
compile->activate(QAction::Trigger);
|
||||
QTest::qWait(100);
|
||||
instDialog *dlg = NULL;
|
||||
foreach (QWidget *w, app->allWidgets())
|
||||
if (dynamic_cast<instDialog*>(w) != NULL)
|
||||
dlg = dynamic_cast<instDialog*>(w);
|
||||
QVERIFY(dlg != NULL);
|
||||
|
||||
QTreeWidget *table = dlg->findChild<QTreeWidget*>("selectTable");
|
||||
QVERIFY(table != NULL);
|
||||
QVERIFY(table->topLevelItemCount() == 3);
|
||||
QVERIFY(! table->findItems("cluster1", Qt::MatchExactly, 0).isEmpty());
|
||||
QVERIFY(! table->findItems("test1", Qt::MatchExactly, 0).isEmpty());
|
||||
QVERIFY(! table->findItems("test2", Qt::MatchExactly, 0).isEmpty());
|
||||
QVERIFY(! table->findItems("test3", Qt::MatchExactly | Qt::MatchRecursive, 0).isEmpty());
|
||||
QVERIFY(! table->findItems("test4", Qt::MatchExactly | Qt::MatchRecursive, 0).isEmpty());
|
||||
QFrame *warning_space = dlg->findChild<QFrame*>("warning_space");
|
||||
QVERIFY(warning_space->isHidden());
|
||||
QTest::qWait(1000);
|
||||
dlg->findChild<QPushButton*>("cancelButton")->click();
|
||||
QTest::qWait(1000);
|
||||
|
||||
}
|
||||
|
||||
void instDialogTest::page1_11()
|
||||
{
|
||||
QAction *compile = mw->findChild<QAction*>("installAction");
|
||||
compile->activate(QAction::Trigger);
|
||||
QTest::qWait(100);
|
||||
instDialog *dlg = NULL;
|
||||
foreach (QWidget *w, app->allWidgets())
|
||||
if (dynamic_cast<instDialog*>(w) != NULL)
|
||||
dlg = dynamic_cast<instDialog*>(w);
|
||||
QVERIFY(dlg != NULL);
|
||||
|
||||
QTreeWidget *table = dlg->findChild<QTreeWidget*>("selectTable");
|
||||
QVERIFY(table != NULL);
|
||||
QVERIFY(table->topLevelItemCount() == 3);
|
||||
//QTest::qWait(100000);
|
||||
for (int i=0; i< table->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem *item = table->topLevelItem(i);
|
||||
if (item->text(0) == "cluster1")
|
||||
{
|
||||
QVERIFY(item->checkState(2) == Qt::Unchecked);
|
||||
QVERIFY(item->checkState(1) == Qt::Checked);
|
||||
QVERIFY(item->child(0)->checkState(1) == Qt::Unchecked);
|
||||
QVERIFY(item->child(0)->checkState(2) == Qt::Checked);
|
||||
QVERIFY(item->child(1)->checkState(1) == Qt::Unchecked);
|
||||
QVERIFY(item->child(1)->checkState(2) == Qt::Checked);
|
||||
}
|
||||
if (item->text(0) == "test1")
|
||||
{
|
||||
QVERIFY(item->checkState(1) == Qt::Unchecked);
|
||||
QVERIFY(item->checkState(2) == Qt::Checked);
|
||||
}
|
||||
if (item->text(0) == "test2")
|
||||
{
|
||||
QVERIFY(item->checkState(1) == Qt::Checked);
|
||||
QVERIFY(item->checkState(2) == Qt::Checked);
|
||||
}
|
||||
|
||||
}
|
||||
QTest::qWait(1000);
|
||||
//dlg->findChild<QPushButton*>("cancelButton")->click();
|
||||
dlg->reject();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
bool checkProgress(QTreeWidget *list)
|
||||
{
|
||||
for(int i=0; i<list->topLevelItemCount(); i++)
|
||||
{
|
||||
if ( (list->topLevelItem(i)->text(1).toStdString() == "Compiling ...") ||
|
||||
(list->topLevelItem(i)->text(1).toStdString() == "Installing ...") )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void instDialogTest::testCompile()
|
||||
{
|
||||
if (QFileInfo("test1.fw").exists())
|
||||
QVERIFY(QFile("test1.fw").remove());
|
||||
if (QFileInfo("test2.fw").exists())
|
||||
QVERIFY(QFile("test2.fw").remove());
|
||||
if (QFileInfo("test3.fw").exists())
|
||||
QVERIFY(QFile("test3.fw").remove());
|
||||
if (QFileInfo("test4.fw").exists())
|
||||
QVERIFY(QFile("test4.fw").remove());
|
||||
|
||||
mw->findChild<QAction*>("compileAction")->trigger();
|
||||
QTest::qWait(500);
|
||||
|
||||
instDialog *dlg = mw->findChild<instDialog*>();
|
||||
dlg->findChild<QPushButton*>("pushButton16")->click();
|
||||
QTest::qWait(500);
|
||||
dlg->findChild<QPushButton*>("nextButton")->click();
|
||||
|
||||
QTreeWidget *list= dlg->findChild<QTreeWidget*>("fwWorkList");
|
||||
|
||||
int waited = 0;
|
||||
|
||||
while (!checkProgress(list))
|
||||
{
|
||||
QTest::qWait(500);
|
||||
waited += 500;
|
||||
QVERIFY(waited < 10000);
|
||||
}
|
||||
|
||||
for(int i=0; i<list->topLevelItemCount(); i++)
|
||||
{
|
||||
QVERIFY(list->topLevelItem(i)->text(1) == "Success");
|
||||
}
|
||||
dlg->reject();
|
||||
|
||||
QVERIFY(QFileInfo("test1.fw").exists() && QFileInfo("test1.fw").size());
|
||||
QVERIFY(QFileInfo("test2.fw").exists() && QFileInfo("test2.fw").size());
|
||||
QVERIFY(QFileInfo("test3.fw").exists() && QFileInfo("test3.fw").size());
|
||||
QVERIFY(QFileInfo("test4.fw").exists() && QFileInfo("test4.fw").size());
|
||||
QFile::remove("test1.fw");
|
||||
QFile::remove("test2.fw");
|
||||
QFile::remove("test3.fw");
|
||||
QFile::remove("test4.fw");
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void instDialogTest::removeFiles()
|
||||
{
|
||||
if (QFileInfo("test1.fw").exists())
|
||||
QVERIFY(QFile::remove("test1.fw"));
|
||||
if (QFileInfo("test2.fw").exists())
|
||||
QVERIFY(QFile::remove("test2.fw"));
|
||||
if (QFileInfo("test3.fw").exists())
|
||||
QVERIFY(QFile::remove("test3.fw"));
|
||||
if (QFileInfo("test4.fw").exists())
|
||||
QVERIFY(QFile::remove("test4.fw"));
|
||||
if (QDir("test_install").exists())
|
||||
{
|
||||
foreach(QString file, QDir("test_install").entryList())
|
||||
{
|
||||
if (QFileInfo("test_install/"+file).isFile())
|
||||
QVERIFY(QFile::remove("test_install/"+file));
|
||||
}
|
||||
QVERIFY(QDir().rmdir("test_install"));
|
||||
}
|
||||
QVERIFY(QDir().mkdir("test_install"));
|
||||
}
|
||||
|
||||
void instDialogTest::testInstall1()
|
||||
{
|
||||
removeFiles();
|
||||
Firewall *test1 = NULL;
|
||||
foreach(FWObject *fw, mw->db()->getByTypeDeep(Firewall::TYPENAME))
|
||||
{
|
||||
if (fw->getName() == "test1")
|
||||
{
|
||||
test1 = Firewall::cast(fw);
|
||||
break;
|
||||
}
|
||||
}
|
||||
QVERIFY(test1 != NULL);
|
||||
FWOptions *fwoptions = test1->getOptionsObject();
|
||||
fwoptions->setStr("firewall_dir", (QDir::currentPath()+"/test_install").toStdString());
|
||||
|
||||
mw->findChild<QAction*>("installAction")->trigger();
|
||||
QTest::qWait(500);
|
||||
|
||||
instDialog *dlg = mw->findChild<instDialog*>();
|
||||
dlg->findChild<QPushButton*>("pushButton17")->click();
|
||||
|
||||
QTreeWidget *selectTable = dlg->findChild<QTreeWidget*>("selectTable");
|
||||
QTreeWidgetItem *test1item = selectTable->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first();
|
||||
test1item->setCheckState(1, Qt::Checked);
|
||||
test1item->setCheckState(2, Qt::Checked);
|
||||
QTest::qWait(500);
|
||||
dlg->findChild<QPushButton*>("nextButton")->click();
|
||||
|
||||
QTreeWidget *list= dlg->findChild<QTreeWidget*>("fwWorkList");
|
||||
|
||||
int waited = 0;
|
||||
|
||||
while (!checkProgress(list))
|
||||
{
|
||||
QTest::qWait(500);
|
||||
waited += 500;
|
||||
QVERIFY(waited < 10000);
|
||||
}
|
||||
|
||||
for(int i=0; i<list->topLevelItemCount(); i++)
|
||||
{
|
||||
QVERIFY(list->topLevelItem(i)->text(1) == "Success");
|
||||
}
|
||||
QTest::qWait(500);
|
||||
|
||||
QVERIFY(dlg->findChild<QPushButton*>("nextButton")->isEnabled());
|
||||
QVERIFY(!dlg->findChild<QPushButton*>("finishButton")->isEnabled());
|
||||
|
||||
QVERIFY(QFile::exists("test1.fw"));
|
||||
QVERIFY(QFile::remove("test1.fw"));
|
||||
QFile testfile("test1.fw");
|
||||
testfile.open(QFile::WriteOnly);
|
||||
testfile.write("#!/bin/sh\n#\n# This is automatically generated file. DO NOT MODIFY !\n#\n# Firewall Builder fwb_ipt v4.0.0-2784\n#\n# Generated Wed Mar 31 16:41:46 2010 EEST by a2k\n#\n# files: * test1.fw\n#\n# Compiled for iptables (any version)\n#\n# This firewall has two interfaces. Eth0 faces outside and has a dynamic address; eth1 faces inside.\n# Policy includes basic rules to permit unrestricted outbound access and anti-spoofing rules. Access to the firewall is permitted only from internal network and only using SSH. The firewall uses one of the machines on internal network for DNS. Internal network is configured with address 192.168.1.0/255.255.255.0\n\n\necho \"Testing policy activation script\"\n");
|
||||
testfile.close();
|
||||
testfile.setPermissions(testfile.permissions() | QFile::ExeOwner);
|
||||
|
||||
QTimer::singleShot(200, this, SLOT(testInstall1_part2()));
|
||||
dlg->findChild<QPushButton*>("nextButton")->click();
|
||||
// now runs testInstall_part2 and fills install options dialog
|
||||
waited = 0;
|
||||
while (!checkProgress(list))
|
||||
{
|
||||
QTest::qWait(500);
|
||||
waited += 500;
|
||||
QVERIFY(waited < 10000);
|
||||
}
|
||||
|
||||
for(int i=0; i<list->topLevelItemCount(); i++)
|
||||
{
|
||||
QVERIFY(list->topLevelItem(i)->text(1) == "Success");
|
||||
}
|
||||
|
||||
QString text = dlg->findChild<QTextBrowser*>("procLogDisplay")->toPlainText();
|
||||
QVERIFY(text.contains("Testing policy activation script"));
|
||||
QVERIFY(!text.contains("*** Fatal error"));
|
||||
QVERIFY(!text.isEmpty());
|
||||
dlg->reject();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void instDialogTest::testInstall1_part2() // sets install options in modal dialog
|
||||
{
|
||||
instOptionsDialog *optdlg = mw->findChild<instOptionsDialog*>("instOptionsDialog_q");
|
||||
QLineEdit *uname = optdlg->findChild<QLineEdit*>("uname");
|
||||
QLineEdit *pwd = optdlg->findChild<QLineEdit*>("pwd");
|
||||
QLineEdit *altAddress = optdlg->findChild<QLineEdit*>("altAddress");
|
||||
uname->setText(getenv("USER"));
|
||||
altAddress->setText("127.0.0.1");
|
||||
optdlg->findChild<QPushButton*>("okButton")->click();
|
||||
}
|
||||
|
||||
void instDialogTest::testInstall2()
|
||||
{
|
||||
removeFiles();
|
||||
Firewall *test1 = NULL;
|
||||
foreach(FWObject *fw, mw->db()->getByTypeDeep(Firewall::TYPENAME))
|
||||
{
|
||||
if (fw->getName() == "test1")
|
||||
{
|
||||
test1 = Firewall::cast(fw);
|
||||
break;
|
||||
}
|
||||
}
|
||||
QVERIFY(test1 != NULL);
|
||||
FWOptions *fwoptions = test1->getOptionsObject();
|
||||
fwoptions->setStr("firewall_dir", (QDir::currentPath()+"/test_install").toStdString());
|
||||
|
||||
setenv("SSH_AUTH_SOCK", "nothinghere", 1);
|
||||
QTest::qWait(500);
|
||||
mw->findChild<QAction*>("installAction")->trigger();
|
||||
QTest::qWait(500);
|
||||
|
||||
instDialog *dlg = mw->findChild<instDialog*>();
|
||||
dlg->findChild<QPushButton*>("pushButton17")->click();
|
||||
|
||||
QTreeWidget *selectTable = dlg->findChild<QTreeWidget*>("selectTable");
|
||||
QTreeWidgetItem *test1item = selectTable->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first();
|
||||
test1item->setCheckState(1, Qt::Checked);
|
||||
test1item->setCheckState(2, Qt::Checked);
|
||||
QTest::qWait(500);
|
||||
dlg->findChild<QPushButton*>("nextButton")->click();
|
||||
|
||||
QTreeWidget *list= dlg->findChild<QTreeWidget*>("fwWorkList");
|
||||
|
||||
int waited = 0;
|
||||
|
||||
while (!checkProgress(list))
|
||||
{
|
||||
QTest::qWait(500);
|
||||
waited += 500;
|
||||
QVERIFY(waited < 10000);
|
||||
}
|
||||
|
||||
for(int i=0; i<list->topLevelItemCount(); i++)
|
||||
{
|
||||
QVERIFY(list->topLevelItem(i)->text(1) == "Success");
|
||||
}
|
||||
QTest::qWait(1000);
|
||||
|
||||
QVERIFY(dlg->findChild<QPushButton*>("nextButton")->isEnabled());
|
||||
QVERIFY(!dlg->findChild<QPushButton*>("finishButton")->isEnabled());
|
||||
|
||||
QVERIFY(QFile::exists("test1.fw"));
|
||||
QVERIFY(QFile::remove("test1.fw"));
|
||||
QFile testfile("test1.fw");
|
||||
testfile.open(QFile::WriteOnly);
|
||||
testfile.write("#!/bin/sh\n#\n# This is automatically generated file. DO NOT MODIFY !\n#\n# Firewall Builder fwb_ipt v4.0.0-2784\n#\n# Generated Wed Mar 31 16:41:46 2010 EEST by a2k\n#\n# files: * test1.fw\n#\n# Compiled for iptables (any version)\n#\n# This firewall has two interfaces. Eth0 faces outside and has a dynamic address; eth1 faces inside.\n# Policy includes basic rules to permit unrestricted outbound access and anti-spoofing rules. Access to the firewall is permitted only from internal network and only using SSH. The firewall uses one of the machines on internal network for DNS. Internal network is configured with address 192.168.1.0/255.255.255.0\n\n\necho \"Testing policy activation script\"\n");
|
||||
testfile.close();
|
||||
testfile.setPermissions(testfile.permissions() | QFile::ExeOwner);
|
||||
|
||||
QTimer::singleShot(200, this, SLOT(testInstall1_part2()));
|
||||
dlg->findChild<QPushButton*>("nextButton")->click();
|
||||
// now runs testInstall_part2 and fills install options dialog
|
||||
waited = 0;
|
||||
while (!checkProgress(list))
|
||||
{
|
||||
QTest::qWait(500);
|
||||
waited += 500;
|
||||
QVERIFY(waited < 10000);
|
||||
}
|
||||
|
||||
QTest::qWait(500);
|
||||
for(int i=0; i<list->topLevelItemCount(); i++)
|
||||
{
|
||||
QVERIFY(list->topLevelItem(i)->text(1) == "Failure");
|
||||
}
|
||||
setenv("SSH_AUTH_SOCK", ssh_auth_sock, 1);
|
||||
QString text = dlg->findChild<QTextBrowser*>("procLogDisplay")->toPlainText();
|
||||
QVERIFY(!text.isEmpty());
|
||||
QVERIFY(text.contains("lost connection"));
|
||||
QVERIFY(text.contains("SSH session terminated, exit status: 1"));
|
||||
|
||||
dlg->reject();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
|
||||
void instDialogTest::testInstall3()
|
||||
{
|
||||
removeFiles();
|
||||
Firewall *test1 = NULL;
|
||||
foreach(FWObject *fw, mw->db()->getByTypeDeep(Firewall::TYPENAME))
|
||||
{
|
||||
if (fw->getName() == "test1")
|
||||
{
|
||||
test1 = Firewall::cast(fw);
|
||||
break;
|
||||
}
|
||||
}
|
||||
QVERIFY(test1 != NULL);
|
||||
FWOptions *fwoptions = test1->getOptionsObject();
|
||||
fwoptions->setStr("firewall_dir", (QDir::currentPath()+"/test_install").toStdString());
|
||||
|
||||
mw->findChild<QAction*>("installAction")->trigger();
|
||||
QTest::qWait(500);
|
||||
|
||||
instDialog *dlg = mw->findChild<instDialog*>();
|
||||
dlg->findChild<QPushButton*>("pushButton17")->click();
|
||||
|
||||
QTreeWidget *selectTable = dlg->findChild<QTreeWidget*>("selectTable");
|
||||
QTreeWidgetItem *test1item = selectTable->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first();
|
||||
test1item->setCheckState(1, Qt::Checked);
|
||||
test1item->setCheckState(2, Qt::Checked);
|
||||
QTest::qWait(500);
|
||||
dlg->findChild<QPushButton*>("nextButton")->click();
|
||||
|
||||
QTreeWidget *list= dlg->findChild<QTreeWidget*>("fwWorkList");
|
||||
|
||||
int waited = 0;
|
||||
|
||||
while (!checkProgress(list))
|
||||
{
|
||||
QTest::qWait(500);
|
||||
waited += 500;
|
||||
QVERIFY(waited < 10000);
|
||||
}
|
||||
|
||||
for(int i=0; i<list->topLevelItemCount(); i++)
|
||||
{
|
||||
QVERIFY(list->topLevelItem(i)->text(1) == "Success");
|
||||
}
|
||||
QTest::qWait(500);
|
||||
|
||||
QVERIFY(dlg->findChild<QPushButton*>("nextButton")->isEnabled());
|
||||
QVERIFY(!dlg->findChild<QPushButton*>("finishButton")->isEnabled());
|
||||
|
||||
QVERIFY(QFile::exists("test1.fw"));
|
||||
QVERIFY(QFile::remove("test1.fw"));
|
||||
QFile testfile("test1.fw");
|
||||
testfile.open(QFile::WriteOnly);
|
||||
testfile.write("#!/bin/sh\n#\n# This is automatically generated file. DO NOT MODIFY !\n#\n# Firewall Builder fwb_ipt v4.0.0-2784\n#\n# Generated Wed Mar 31 16:41:46 2010 EEST by a2k\n#\n# files: * test1.fw\n#\n# Compiled for iptables (any version)\n#\n# This firewall has two interfaces. Eth0 faces outside and has a dynamic address; eth1 faces inside.\n# Policy includes basic rules to permit unrestricted outbound access and anti-spoofing rules. Access to the firewall is permitted only from internal network and only using SSH. The firewall uses one of the machines on internal network for DNS. Internal network is configured with address 192.168.1.0/255.255.255.0\n\n\necho \"Testing policy activation script\"\n");
|
||||
testfile.close();
|
||||
testfile.setPermissions(testfile.permissions() | QFile::ExeOwner);
|
||||
|
||||
QTimer::singleShot(200, this, SLOT(testInstall3_part2()));
|
||||
dlg->findChild<QPushButton*>("nextButton")->click();
|
||||
// now runs testInstall_part2 and fills install options dialog
|
||||
waited = 0;
|
||||
while (!checkProgress(list))
|
||||
{
|
||||
QTest::qWait(500);
|
||||
waited += 500;
|
||||
QVERIFY(waited < 1000000);
|
||||
}
|
||||
|
||||
for(int i=0; i<list->topLevelItemCount(); i++)
|
||||
{
|
||||
QVERIFY(list->topLevelItem(i)->text(1) == "Failure");
|
||||
}
|
||||
|
||||
QString text = dlg->findChild<QTextBrowser*>("procLogDisplay")->toPlainText();
|
||||
QVERIFY(text.contains("lost connection"));
|
||||
QVERIFY(text.contains("SSH session terminated, exit status: 1"));
|
||||
QVERIFY(!text.isEmpty());
|
||||
dlg->reject();
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void instDialogTest::testInstall3_part2() // sets install options in modal dialog
|
||||
{
|
||||
instOptionsDialog *optdlg = mw->findChild<instOptionsDialog*>("instOptionsDialog_q");
|
||||
QLineEdit *uname = optdlg->findChild<QLineEdit*>("uname");
|
||||
QLineEdit *pwd = optdlg->findChild<QLineEdit*>("pwd");
|
||||
QLineEdit *altAddress = optdlg->findChild<QLineEdit*>("altAddress");
|
||||
uname->setText(getenv("USER"));
|
||||
altAddress->setText("1.2.3.4");
|
||||
optdlg->findChild<QPushButton*>("okButton")->click();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void instDialogTest::testInstall4()
|
||||
{
|
||||
removeFiles();
|
||||
Firewall *test1 = NULL;
|
||||
foreach(FWObject *fw, mw->db()->getByTypeDeep(Firewall::TYPENAME))
|
||||
{
|
||||
if (fw->getName() == "test1")
|
||||
{
|
||||
test1 = Firewall::cast(fw);
|
||||
break;
|
||||
}
|
||||
}
|
||||
QVERIFY(test1 != NULL);
|
||||
FWOptions *fwoptions = test1->getOptionsObject();
|
||||
fwoptions->setStr("firewall_dir", (QDir::currentPath()+"/test_install").toStdString());
|
||||
|
||||
mw->findChild<QAction*>("installAction")->trigger();
|
||||
QTest::qWait(500);
|
||||
|
||||
instDialog *dlg = mw->findChild<instDialog*>();
|
||||
dlg->findChild<QPushButton*>("pushButton17")->click();
|
||||
|
||||
QTreeWidget *selectTable = dlg->findChild<QTreeWidget*>("selectTable");
|
||||
QTreeWidgetItem *test1item = selectTable->findItems("test1", Qt::MatchExactly | Qt::MatchRecursive, 0).first();
|
||||
test1item->setCheckState(1, Qt::Checked);
|
||||
test1item->setCheckState(2, Qt::Checked);
|
||||
QTest::qWait(500);
|
||||
dlg->findChild<QPushButton*>("nextButton")->click();
|
||||
|
||||
QTreeWidget *list= dlg->findChild<QTreeWidget*>("fwWorkList");
|
||||
|
||||
int waited = 0;
|
||||
|
||||
while (!checkProgress(list))
|
||||
{
|
||||
QTest::qWait(500);
|
||||
waited += 500;
|
||||
QVERIFY(waited < 10000);
|
||||
}
|
||||
|
||||
for(int i=0; i<list->topLevelItemCount(); i++)
|
||||
{
|
||||
QVERIFY(list->topLevelItem(i)->text(1) == "Success");
|
||||
}
|
||||
QTest::qWait(500);
|
||||
|
||||
QVERIFY(dlg->findChild<QPushButton*>("nextButton")->isEnabled());
|
||||
QVERIFY(!dlg->findChild<QPushButton*>("finishButton")->isEnabled());
|
||||
|
||||
QVERIFY(QFile::exists("test1.fw"));
|
||||
QVERIFY(QFile::remove("test1.fw"));
|
||||
QFile testfile("test1.fw");
|
||||
testfile.open(QFile::WriteOnly);
|
||||
testfile.write("#!/bin/sh\n#\n# This is automatically generated file. DO NOT MODIFY !\n#\n# Firewall Builder fwb_ipt v4.0.0-2784\n#\n# Generated Wed Mar 31 16:41:46 2010 EEST by a2k\n#\n# files: * test1.fw\n#\n# Compiled for iptables (any version)\n#\n# This firewall has two interfaces. Eth0 faces outside and has a dynamic address; eth1 faces inside.\n# Policy includes basic rules to permit unrestricted outbound access and anti-spoofing rules. Access to the firewall is permitted only from internal network and only using SSH. The firewall uses one of the machines on internal network for DNS. Internal network is configured with address 192.168.1.0/255.255.255.0\n\n\necho \"Testing policy activation script\"\n");
|
||||
testfile.close();
|
||||
testfile.setPermissions(testfile.permissions() | QFile::ExeOwner);
|
||||
|
||||
QTimer::singleShot(200, this, SLOT(testInstall3_part2()));
|
||||
dlg->findChild<QPushButton*>("nextButton")->click();
|
||||
// now runs testInstall_part2 and fills install options dialog
|
||||
QTest::qWait(1000);
|
||||
dlg->findChild<QPushButton*>("cancelButton")->click();
|
||||
QString text = dlg->findChild<QTextBrowser*>("procLogDisplay")->toPlainText();
|
||||
QVERIFY(text.contains("Stopping background process"));
|
||||
QTest::qWait(3000);
|
||||
QVERIFY(mw->findChild<instDialog*>() == NULL); // check that dialog is closed
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user