1
0
mirror of https://github.com/altlinux/admc.git synced 2025-01-02 17:17:49 +03:00

Fix and refactor ad_security tests

This commit is contained in:
Semyon Knyazev 2024-11-25 18:22:04 +04:00
parent db186d56c3
commit fd7436d172

View File

@ -116,7 +116,7 @@ void ADMCTestAdSecurity::handle_generic_read_and_write_sharing_bit() {
for (const uint32_t &mask : opposite_map.keys()) {
const uint32_t opposite = opposite_map[mask];
SecurityRight right{mask, QByteArray(), QByteArray(), 0};
SecurityRight right_opposite{mask, QByteArray(), QByteArray(), 0};
SecurityRight right_opposite{opposite, QByteArray(), QByteArray(), 0};
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, right, true);
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, right_opposite, true);
@ -240,7 +240,7 @@ void ADMCTestAdSecurity::remove_to_set_subordinates_data() {
QTest::addColumn<int>("superior_mask");
QTest::addColumn<QByteArray>("subordinate_right_type");
QTest::addColumn<QList<int>>("subordinate_mask_list");
QTest::addColumn<TestAdSecurityType>("exptected_state");
QTest::addColumn<TestAdSecurityType>("expected_state");
const QByteArray type_web_info = ad.adconfig()->get_right_guid("Web-Information");
const QByteArray type_change_password = ad.adconfig()->get_right_guid("User-Change-Password");
@ -252,7 +252,6 @@ void ADMCTestAdSecurity::remove_to_set_subordinates_data() {
QTest::newRow("allow generic write") << true << SEC_ADS_GENERIC_WRITE << type_web_info << QList<int>({SEC_ADS_WRITE_PROP}) << TestAdSecurityType_Allow;
QTest::newRow("deny generic write") << false << SEC_ADS_GENERIC_WRITE << type_web_info << QList<int>({SEC_ADS_WRITE_PROP}) << TestAdSecurityType_Deny;
QTest::newRow("allow all extended rights") << true << SEC_ADS_CONTROL_ACCESS << type_change_password << QList<int>({SEC_ADS_CONTROL_ACCESS}) << TestAdSecurityType_Allow;
QTest::newRow("allow all extended rights") << true << SEC_ADS_CONTROL_ACCESS << type_change_password << QList<int>({SEC_ADS_CONTROL_ACCESS}) << TestAdSecurityType_Allow;
QTest::newRow("deny all extended rights") << false << SEC_ADS_CONTROL_ACCESS << type_change_password << QList<int>({SEC_ADS_CONTROL_ACCESS}) << TestAdSecurityType_Deny;
}
@ -261,7 +260,7 @@ void ADMCTestAdSecurity::remove_to_set_subordinates() {
QFETCH(int, superior_mask);
QFETCH(QByteArray, subordinate_right_type);
QFETCH(QList<int>, subordinate_mask_list);
QFETCH(TestAdSecurityType, exptected_state);
QFETCH(TestAdSecurityType, expected_state);
SecurityRight right{(uint32_t)superior_mask, QByteArray(), QByteArray(), 0};
@ -269,11 +268,11 @@ void ADMCTestAdSecurity::remove_to_set_subordinates() {
security_descriptor_add_right(sd, ad.adconfig(), class_list, test_trustee, right, allow_superior);
// Superior should be set
check_state(test_trustee, superior_mask, QByteArray(), exptected_state);
check_state(test_trustee, superior_mask, QByteArray(), expected_state);
// Subordinate should be set
for (const int &subordinate_mask : subordinate_mask_list) {
check_state(test_trustee, subordinate_mask, subordinate_right_type, exptected_state);
check_state(test_trustee, subordinate_mask, subordinate_right_type, expected_state);
}
// Remove superior
@ -282,9 +281,9 @@ void ADMCTestAdSecurity::remove_to_set_subordinates() {
// Superior should be unset
check_state(test_trustee, superior_mask, QByteArray(), TestAdSecurityType_None);
// But subordinates should remain
// But subordinates should be unset
for (const int &subordinate_mask : subordinate_mask_list) {
check_state(test_trustee, subordinate_mask, subordinate_right_type, exptected_state);
check_state(test_trustee, subordinate_mask, subordinate_right_type, TestAdSecurityType_None);
}
}