|
204 | 204 | expect(described_class.config_status).to eq("External Auth SAML") |
205 | 205 | end |
206 | 206 | end |
| 207 | + |
| 208 | + context "#configure_sssd_domain" do |
| 209 | + let(:domain) { "example.com" } |
| 210 | + let(:base_config) do |
| 211 | + <<~CONFIG |
| 212 | + [sssd] |
| 213 | + services = nss, pam |
| 214 | +
|
| 215 | + [domain/example.com] |
| 216 | + id_provider = ipa |
| 217 | + ipa_server = ipa.example.com |
| 218 | + CONFIG |
| 219 | + end |
| 220 | + |
| 221 | + it "adds ldap_user_extra_attrs when not present" do |
| 222 | + config = base_config.dup |
| 223 | + subject.send(:configure_sssd_domain, config, domain) |
| 224 | + expect(config).to include("ldap_user_extra_attrs = mail, givenname, sn, displayname, domainname, krbPrincipalName") |
| 225 | + end |
| 226 | + |
| 227 | + it "updates existing ldap_user_extra_attrs" do |
| 228 | + config = base_config + "ldap_user_extra_attrs = mail\n" |
| 229 | + subject.send(:configure_sssd_domain, config, domain) |
| 230 | + |
| 231 | + # Verify the line contains all expected attributes |
| 232 | + expect(config).to include("ldap_user_extra_attrs = mail, givenname, sn, displayname, domainname, krbPrincipalName") |
| 233 | + |
| 234 | + # Verify there's only one ldap_user_extra_attrs line |
| 235 | + expect(config.scan(/ldap_user_extra_attrs/).length).to eq(1) |
| 236 | + |
| 237 | + # Verify the original "mail" only value was replaced, not just appended |
| 238 | + expect(config).not_to include("ldap_user_extra_attrs = mail\n") |
| 239 | + end |
| 240 | + |
| 241 | + it "preserves existing configuration while adding attributes" do |
| 242 | + config = base_config.dup |
| 243 | + subject.send(:configure_sssd_domain, config, domain) |
| 244 | + expect(config).to include("id_provider = ipa") |
| 245 | + expect(config).to include("ipa_server = ipa.example.com") |
| 246 | + end |
| 247 | + end |
| 248 | + |
| 249 | + context "#configure_sssd_ifp" do |
| 250 | + let(:base_config) do |
| 251 | + <<~CONFIG |
| 252 | + [sssd] |
| 253 | + services = nss, pam |
| 254 | + CONFIG |
| 255 | + end |
| 256 | + |
| 257 | + it "adds [ifp] section when not present" do |
| 258 | + config = base_config.dup |
| 259 | + subject.send(:configure_sssd_ifp, config) |
| 260 | + expect(config).to include("[ifp]") |
| 261 | + expect(config).to include("allowed_uids = apache, root, manageiq") |
| 262 | + expect(config).to include("user_attributes = +mail, +givenname, +sn, +displayname, +domainname, +krbPrincipalName") |
| 263 | + end |
| 264 | + |
| 265 | + it "updates user_attributes in existing [ifp] section" do |
| 266 | + config = base_config + "\n[ifp]\nallowed_uids = apache\nuser_attributes = +mail\n" |
| 267 | + subject.send(:configure_sssd_ifp, config) |
| 268 | + expect(config).to include("user_attributes = +mail, +givenname, +sn, +displayname, +domainname, +krbPrincipalName") |
| 269 | + expect(config.scan(/user_attributes/).length).to eq(1) |
| 270 | + end |
| 271 | + |
| 272 | + it "adds user_attributes when [ifp] exists but user_attributes doesn't" do |
| 273 | + config = base_config + "\n[ifp]\nallowed_uids = apache\n" |
| 274 | + subject.send(:configure_sssd_ifp, config) |
| 275 | + expect(config).to include("user_attributes = +mail, +givenname, +sn, +displayname, +domainname, +krbPrincipalName") |
| 276 | + end |
| 277 | + end |
207 | 278 | end |
0 commit comments