mirror of
https://github.com/altlinux/admc.git
synced 2025-03-16 14:50:13 +03:00
don't add duplicate links in gplink::add()
This commit is contained in:
parent
0590c92c1e
commit
a0c4f48abd
@ -82,7 +82,12 @@ QList<QString> Gplink::get_gpos() const {
|
||||
|
||||
void Gplink::add(const QString &gpo_case) {
|
||||
const QString gpo = gpo_case.toLower();
|
||||
|
||||
|
||||
const bool gpo_already_in_link = gpo_case_map.contains(gpo);
|
||||
if (gpo_already_in_link) {
|
||||
return;
|
||||
}
|
||||
|
||||
gpos_in_order.append(gpo);
|
||||
options[gpo] = 0;
|
||||
gpo_case_map[gpo] = gpo_case;
|
||||
|
@ -60,9 +60,15 @@ void ADMCTestGplink::test_add() {
|
||||
const QString gplink_string = "[LDAP://a;0][LDAP://b;0][LDAP://c;0][LDAP://UPPER;0]";
|
||||
Gplink gplink(gplink_string);
|
||||
|
||||
// Simple add
|
||||
gplink.add("added gpo");
|
||||
|
||||
// Test that case is preserved
|
||||
gplink.add("added gpo UPPERCASE");
|
||||
|
||||
// Test that duplicates are ignored
|
||||
gplink.add("a");
|
||||
|
||||
const QString correct_gplink_string = "[LDAP://a;0][LDAP://b;0][LDAP://c;0][LDAP://UPPER;0][LDAP://added gpo;0][LDAP://added gpo UPPERCASE;0]";
|
||||
|
||||
test_gplink_equality(gplink, correct_gplink_string);
|
||||
|
Loading…
x
Reference in New Issue
Block a user