2021-02-05 17:56:49 +04:00
/*
* ADMC - AD Management Center
*
* Copyright ( C ) 2020 BaseALT Ltd .
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 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 .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
2021-02-11 14:54:40 +04:00
# ifndef ADMC_TEST_H
# define ADMC_TEST_H
2021-02-05 17:56:49 +04:00
2021-02-19 15:23:43 +04:00
/**
* Base test class for testing ADMC . Implements init and
* cleanup f - ns that create a fresh testing environment for
* each test .
2021-02-05 17:56:49 +04:00
*/
# include <QObject>
2021-02-19 14:51:11 +04:00
# include "ad_interface.h"
2021-02-05 17:56:49 +04:00
# include <QTest>
class QString ;
2021-02-09 15:22:46 +04:00
class QTreeView ;
2021-02-19 15:23:43 +04:00
# define TEST_USER "test-user"
# define TEST_USER_LOGON "test-user-logon"
# define TEST_PASSWORD "pass123!"
# define TEST_OU "test-ou"
# define TEST_GROUP "test-group"
# define TEST_COMPUTER "test-computer"
2021-02-05 17:56:49 +04:00
2021-02-11 14:54:40 +04:00
class ADMCTest : public QObject {
2021-02-05 17:56:49 +04:00
Q_OBJECT
2021-02-19 15:23:43 +04:00
public slots :
2021-02-08 12:38:23 +04:00
// NOTE: initTestCase(), cleanupTestCase(), init() and
// cleanup() are special slots called by QTest.
2021-02-05 17:56:49 +04:00
// Called before first test
void initTestCase ( ) ;
// Called after last test
void cleanupTestCase ( ) ;
2021-02-19 15:23:43 +04:00
// Called before and after each test
virtual void init ( ) ;
2021-02-05 17:56:49 +04:00
void cleanup ( ) ;
2021-02-19 14:51:11 +04:00
protected :
AdInterface ad ;
2021-02-05 17:56:49 +04:00
// Use this as parents for widgets used inside tests.
// For every test a new parent will be created and after
// test completes, parent is deleted which deletes all
// child widgets as well.
QWidget * parent_widget = nullptr ;
2021-02-19 15:23:43 +04:00
void init_test_case ( ) ;
2021-02-05 17:56:49 +04:00
// For easy setup and cleanup of each test, we use an
// object named "test-arena" which is an OU. It is
// created before every test and deleted after every
// test. All test activity should happen inside this
// object.
QString test_arena_dn ( ) ;
// Creates dn for object with given name whose parent is
// test arena. Class is used to determine suffix.
QString test_object_dn ( const QString & name , const QString & object_class ) ;
2021-02-05 18:04:07 +04:00
// Tests object's existance on the server.
2021-02-05 17:56:49 +04:00
bool object_exists ( const QString & dn ) ;
2021-02-05 18:04:07 +04:00
2021-02-05 17:56:49 +04:00
} ;
2021-02-19 15:23:43 +04:00
void navigate_until_object ( QTreeView * view , const QString & target_dn ) ;
// Presses the Tab button. Use to cycle through input
// widgets.
void tab ( const int n = 1 ) ;
2021-02-11 14:54:40 +04:00
# endif /* ADMC_TEST_H */
2021-02-19 15:23:43 +04:00