mirror of
https://github.com/altlinux/admc.git
synced 2025-03-31 02:50:17 +03:00
add password edit tests
remove password test from object menu tests
This commit is contained in:
parent
e6c77b4ab6
commit
b1a7b03326
@ -85,6 +85,7 @@ Tests for ADMC
|
||||
%_bindir/admc_test_logon_hours_dialog
|
||||
%_bindir/admc_test_logon_computers
|
||||
%_bindir/admc_test_expiry_edit
|
||||
%_bindir/admc_test_password_edit
|
||||
|
||||
%changelog
|
||||
* Fri Jul 09 2021 Dmitry Degtyarev <kevl@altlinux.org> 0.6.0-alt1
|
||||
|
@ -49,6 +49,7 @@ set(TEST_TARGETS
|
||||
admc_test_logon_hours_dialog
|
||||
admc_test_logon_computers
|
||||
admc_test_expiry_edit
|
||||
admc_test_password_edit
|
||||
)
|
||||
|
||||
foreach(target ${TEST_TARGETS})
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "find_object_dialog.h"
|
||||
#include "find_widget.h"
|
||||
#include "move_object_dialog.h"
|
||||
#include "password_dialog.h"
|
||||
#include "rename_object_dialog.h"
|
||||
#include "select_container_dialog.h"
|
||||
#include "select_object_advanced_dialog.h"
|
||||
@ -199,48 +198,6 @@ void ADMCTestObjectMenu::object_menu_move() {
|
||||
QVERIFY(true);
|
||||
}
|
||||
|
||||
void ADMCTestObjectMenu::object_menu_reset_password() {
|
||||
const QString user_name = TEST_USER;
|
||||
const QString user_dn = test_object_dn(user_name, CLASS_USER);
|
||||
const QString password = "pass123!";
|
||||
|
||||
// Create test user
|
||||
const bool create_user_success = ad.object_add(user_dn, CLASS_USER);
|
||||
QVERIFY2(create_user_success, "Failed to create user");
|
||||
QVERIFY2(object_exists(user_dn), "Created user doesn't exist");
|
||||
|
||||
const QByteArray pwdLastSet_value_before = [=]() {
|
||||
const AdObject object = ad.search_object(user_dn);
|
||||
|
||||
return object.get_value(ATTRIBUTE_PWD_LAST_SET);
|
||||
}();
|
||||
|
||||
// Open password dialog
|
||||
const auto password_dialog = new PasswordDialog({user_dn}, parent_widget);
|
||||
password_dialog->open();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(password_dialog, 1000));
|
||||
|
||||
// Enter password
|
||||
auto password_main_edit = password_dialog->findChild<QLineEdit *>("password_main_edit");
|
||||
QVERIFY(password_main_edit);
|
||||
password_main_edit->setText(password);
|
||||
|
||||
auto password_confirm_edit = password_dialog->findChild<QLineEdit *>("password_confirm_edit");
|
||||
QVERIFY(password_confirm_edit);
|
||||
password_confirm_edit->setText(password);
|
||||
|
||||
password_dialog->accept();
|
||||
|
||||
const QByteArray pwdLastSet_value_after = [=]() {
|
||||
const AdObject object = ad.search_object(user_dn);
|
||||
|
||||
return object.get_value(ATTRIBUTE_PWD_LAST_SET);
|
||||
}();
|
||||
|
||||
const bool password_changed = (pwdLastSet_value_before != pwdLastSet_value_after);
|
||||
QVERIFY2(password_changed, "Failed to change password");
|
||||
}
|
||||
|
||||
void ADMCTestObjectMenu::object_menu_disable_enable_account() {
|
||||
auto test_disable_enable = [=](const bool initial_disabled_state) {
|
||||
const QString dn = [=]() {
|
||||
|
@ -34,7 +34,6 @@ private slots:
|
||||
|
||||
void object_menu_move();
|
||||
void object_menu_rename();
|
||||
void object_menu_reset_password();
|
||||
void object_menu_disable_enable_account();
|
||||
|
||||
void object_menu_find_simple();
|
||||
|
108
tests/admc_test_password_edit.cpp
Normal file
108
tests/admc_test_password_edit.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* ADMC - AD Management Center
|
||||
*
|
||||
* Copyright (C) 2020-2021 BaseALT Ltd.
|
||||
* Copyright (C) 2020-2021 Dmitry Degtyarev
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "admc_test_password_edit.h"
|
||||
|
||||
#include "edits/password_edit.h"
|
||||
|
||||
#include <QFormLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QDateEdit>
|
||||
|
||||
void ADMCTestPasswordEdit::init() {
|
||||
ADMCTest::init();
|
||||
|
||||
// Embed unlock edit in parent widget
|
||||
QList<AttributeEdit *> edits;
|
||||
edit = new PasswordEdit(&edits, parent_widget);
|
||||
auto layout = new QFormLayout();
|
||||
parent_widget->setLayout(layout);
|
||||
edit->add_to_layout(layout);
|
||||
|
||||
parent_widget->show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(parent_widget, 1000));
|
||||
|
||||
main_edit = parent_widget->findChild<QLineEdit *>("password_main_edit");
|
||||
confirm_edit = parent_widget->findChild<QLineEdit *>("password_confirm_edit");
|
||||
|
||||
// Create test user
|
||||
const QString name = TEST_USER;
|
||||
dn = test_object_dn(name, CLASS_USER);
|
||||
const bool create_success = ad.object_add(dn, CLASS_USER);
|
||||
QVERIFY(create_success);
|
||||
}
|
||||
|
||||
void ADMCTestPasswordEdit::edited_signal() {
|
||||
bool edited_signal_emitted = false;
|
||||
connect(
|
||||
edit, &AttributeEdit::edited,
|
||||
[&edited_signal_emitted]() {
|
||||
edited_signal_emitted = true;
|
||||
});
|
||||
|
||||
main_edit->setText("test");
|
||||
QVERIFY(edited_signal_emitted);
|
||||
}
|
||||
|
||||
void ADMCTestPasswordEdit::load() {
|
||||
const AdObject object = ad.search_object(dn);
|
||||
edit->load(ad, object);
|
||||
|
||||
QVERIFY(main_edit->text().isEmpty());
|
||||
QVERIFY(confirm_edit->text().isEmpty());
|
||||
}
|
||||
|
||||
void ADMCTestPasswordEdit::apply_with_bad_confirm() {
|
||||
load();
|
||||
const QString password = "pass123!";
|
||||
|
||||
main_edit->setText("test");
|
||||
confirm_edit->setText("no-match");
|
||||
|
||||
qInfo() << "NOTE: the following error is to be expected";
|
||||
const bool apply_success = edit->apply(ad, dn);
|
||||
close_message_box();
|
||||
QVERIFY(!apply_success);
|
||||
}
|
||||
|
||||
void ADMCTestPasswordEdit::apply() {
|
||||
load();
|
||||
|
||||
main_edit->setText("pass123!");
|
||||
confirm_edit->setText("pass123!");
|
||||
|
||||
const QByteArray pwdLastSet_value_before = [=]() {
|
||||
const AdObject object = ad.search_object(dn);
|
||||
|
||||
return object.get_value(ATTRIBUTE_PWD_LAST_SET);
|
||||
}();
|
||||
|
||||
const bool apply_success = edit->apply(ad, dn);
|
||||
QVERIFY(apply_success);
|
||||
|
||||
const QByteArray pwdLastSet_value_after = [=]() {
|
||||
const AdObject object = ad.search_object(dn);
|
||||
|
||||
return object.get_value(ATTRIBUTE_PWD_LAST_SET);
|
||||
}();
|
||||
QVERIFY(pwdLastSet_value_after != pwdLastSet_value_before);
|
||||
}
|
||||
|
||||
QTEST_MAIN(ADMCTestPasswordEdit)
|
47
tests/admc_test_password_edit.h
Normal file
47
tests/admc_test_password_edit.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* ADMC - AD Management Center
|
||||
*
|
||||
* Copyright (C) 2020-2021 BaseALT Ltd.
|
||||
* Copyright (C) 2020-2021 Dmitry Degtyarev
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef ADMC_TEST_PASSWORD_EDIT_H
|
||||
#define ADMC_TEST_PASSWORD_EDIT_H
|
||||
|
||||
#include "admc_test.h"
|
||||
|
||||
class PasswordEdit;
|
||||
class QLineEdit;
|
||||
|
||||
class ADMCTestPasswordEdit : public ADMCTest {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void init() override;
|
||||
|
||||
void edited_signal();
|
||||
void load();
|
||||
void apply_with_bad_confirm();
|
||||
void apply();
|
||||
|
||||
private:
|
||||
PasswordEdit *edit;
|
||||
QString dn;
|
||||
QLineEdit *main_edit;
|
||||
QLineEdit *confirm_edit;
|
||||
};
|
||||
|
||||
#endif /* ADMC_TEST_PASSWORD_EDIT_H */
|
Loading…
x
Reference in New Issue
Block a user