Skip to content

Commit

Permalink
fix upn edit tests (should be final)
Browse files Browse the repository at this point in the history
figured out the problem
the domain used by testers somehow was configured to enforce
\ unique upn's, while mine didn't
so on tester's domain, during creation of conflicting user
\ server didn't allow the upn to be replaced
bring back test suffix, since it wasn't a problem
change conflict test case to setup conflicting upn uniquely
\ from base test user first, and then change input of upn
\ edit to create a conflict
  • Loading branch information
Kvel2D committed Feb 1, 2022
1 parent 8782f1c commit abfcaa8
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions tests/admc_test_upn_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
#include <QFormLayout>
#include <QLineEdit>

// NOTE: we have to make sure that test suffix doesn't
// already exist on the test domain, hence the wacky
// name
#define TEST_SUFFIX "totally-unique-test-suffix.zone"

void ADMCTestUpnEdit::init() {
ADMCTest::init();

Expand All @@ -35,19 +40,13 @@ void ADMCTestUpnEdit::init() {
upn_edit = new UpnEdit(prefix_edit, suffix_edit, parent_widget);
upn_edit->init_suffixes(ad);

// Get default suffix that will be used for tests
// from default value that was loaded into suffix
// combo when upn edit's init_suffixes() was called
const QString test_suffix = suffix_edit->currentText();
QVERIFY(!test_suffix.isEmpty());

// 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);

const QString test_upn = QString("%1@%2").arg(name, test_suffix);
const QString test_upn = QString("%1@%2").arg(name, TEST_SUFFIX);
const bool replace_success = ad.attribute_replace_string(dn, ATTRIBUTE_USER_PRINCIPAL_NAME, test_upn);
QVERIFY(replace_success);

Expand All @@ -72,6 +71,9 @@ void ADMCTestUpnEdit::length_limit() {
void ADMCTestUpnEdit::test_load() {
const QString prefix = prefix_edit->text();
QCOMPARE(prefix, TEST_USER);

const QString suffix = suffix_edit->currentText();
QCOMPARE(suffix, TEST_SUFFIX);
}

// edited() signal should be emitted when prefix or suffix
Expand Down Expand Up @@ -227,11 +229,15 @@ void ADMCTestUpnEdit::verify_conflict() {
const bool create_success = ad.object_add(conflict_dn, CLASS_USER);
QVERIFY(create_success);

const QString conflicting_upn = get_current_upn();
const QString conflicting_upn = QString("%1@%2").arg(conflict_name, TEST_SUFFIX);
const bool replace_success = ad.attribute_replace_string(conflict_dn, ATTRIBUTE_USER_PRINCIPAL_NAME, conflicting_upn);
QVERIFY(replace_success);

// Verify should fail
// Set input of upn edit so that it conflicts with
// the conflicting user that we have setup. After
// that verify should fail.
prefix_edit->setText(conflict_name);
suffix_edit->setCurrentText(TEST_SUFFIX);
const bool verify_success = upn_edit->verify(ad, dn);

QVERIFY2(!verify_success, "verify() didn't notice upn conflict");
Expand Down

0 comments on commit abfcaa8

Please sign in to comment.