@@ -1107,6 +1107,7 @@ def test_validate_config_options(harness):
1107
1107
harness .set_can_connect (POSTGRESQL_CONTAINER , True )
1108
1108
_charm_lib .return_value .get_postgresql_text_search_configs .return_value = []
1109
1109
_charm_lib .return_value .validate_date_style .return_value = []
1110
+ _charm_lib .return_value .validate_group_map .return_value = False
1110
1111
_charm_lib .return_value .get_postgresql_timezones .return_value = []
1111
1112
1112
1113
# Test instance_default_text_search_config exception
@@ -1124,6 +1125,17 @@ def test_validate_config_options(harness):
1124
1125
"pg_catalog.test"
1125
1126
]
1126
1127
1128
+ # Test ldap_map exception
1129
+ with harness .hooks_disabled ():
1130
+ harness .update_config ({"ldap_map" : "ldap_group=" })
1131
+
1132
+ with tc .assertRaises (ValueError ) as e :
1133
+ harness .charm ._validate_config_options ()
1134
+ assert e .msg == "ldap_map config option has an invalid value"
1135
+
1136
+ _charm_lib .return_value .validate_group_map .assert_called_once_with ("ldap_group=" )
1137
+ _charm_lib .return_value .validate_group_map .return_value = True
1138
+
1127
1139
# Test request_date_style exception
1128
1140
with harness .hooks_disabled ():
1129
1141
harness .update_config ({"request_date_style" : "ISO, TEST" })
@@ -1146,10 +1158,6 @@ def test_validate_config_options(harness):
1146
1158
_charm_lib .return_value .get_postgresql_timezones .assert_called_once_with ()
1147
1159
_charm_lib .return_value .get_postgresql_timezones .return_value = ["TEST_ZONE" ]
1148
1160
1149
- #
1150
- # Secrets
1151
- #
1152
-
1153
1161
1154
1162
def test_scope_obj (harness ):
1155
1163
assert harness .charm ._scope_obj ("app" ) == harness .charm .framework .model .app
@@ -1711,13 +1719,13 @@ def test_update_config(harness):
1711
1719
)
1712
1720
_handle_postgresql_restart_need .assert_called_once ()
1713
1721
_restart_metrics_service .assert_called_once ()
1714
- # _restart_ldap_sync_service.assert_called_once()
1722
+ _restart_ldap_sync_service .assert_called_once ()
1715
1723
assert "tls" not in harness .get_relation_data (rel_id , harness .charm .unit .name )
1716
1724
1717
1725
# Test with TLS files available.
1718
1726
_handle_postgresql_restart_need .reset_mock ()
1719
1727
_restart_metrics_service .reset_mock ()
1720
- # _restart_ldap_sync_service.reset_mock()
1728
+ _restart_ldap_sync_service .reset_mock ()
1721
1729
harness .update_relation_data (
1722
1730
rel_id , harness .charm .unit .name , {"tls" : "" }
1723
1731
) # Mock some data in the relation to test that it change.
@@ -1740,7 +1748,7 @@ def test_update_config(harness):
1740
1748
)
1741
1749
_handle_postgresql_restart_need .assert_called_once ()
1742
1750
_restart_metrics_service .assert_called_once ()
1743
- # _restart_ldap_sync_service.assert_called_once()
1751
+ _restart_ldap_sync_service .assert_called_once ()
1744
1752
assert "tls" not in harness .get_relation_data (
1745
1753
rel_id , harness .charm .unit .name
1746
1754
) # The "tls" flag is set in handle_postgresql_restart_need.
@@ -1751,11 +1759,11 @@ def test_update_config(harness):
1751
1759
) # Mock some data in the relation to test that it change.
1752
1760
_handle_postgresql_restart_need .reset_mock ()
1753
1761
_restart_metrics_service .reset_mock ()
1754
- # _restart_ldap_sync_service.reset_mock()
1762
+ _restart_ldap_sync_service .reset_mock ()
1755
1763
harness .charm .update_config ()
1756
1764
_handle_postgresql_restart_need .assert_not_called ()
1757
1765
_restart_metrics_service .assert_not_called ()
1758
- # _restart_ldap_sync_service.assert_not_called()
1766
+ _restart_ldap_sync_service .assert_not_called ()
1759
1767
assert harness .get_relation_data (rel_id , harness .charm .unit .name )["tls" ] == "enabled"
1760
1768
1761
1769
# Test with member not started yet.
@@ -1765,7 +1773,7 @@ def test_update_config(harness):
1765
1773
harness .charm .update_config ()
1766
1774
_handle_postgresql_restart_need .assert_not_called ()
1767
1775
_restart_metrics_service .assert_not_called ()
1768
- # _restart_ldap_sync_service.assert_not_called()
1776
+ _restart_ldap_sync_service .assert_not_called ()
1769
1777
assert "tls" not in harness .get_relation_data (rel_id , harness .charm .unit .name )
1770
1778
1771
1779
0 commit comments