Compare commits

...

3 Commits

Author SHA1 Message Date
Rafael Guterres Jeffman
22700620c6 ipaconfig: Validate emaildomain
When setting the default email domain, there was no validation on the
provide value. Using ipapython.validate.Email applies the same
validation method as implemented in IPA.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-03-05 16:49:11 -03:00
Rafael Guterres Jeffman
e8688d4cf5 Merge pull request #1337 from t-woerner/ipagroup_fix_externalmember_client_context_fail
ipagroup: Fix test for externalmember use in client context
2025-02-04 11:54:15 -03:00
Thomas Woerner
d540be425a ipagroup: Fix test for externalmember use in client context
The test has been changed with the management fix for AD objects. The
conditional was lacking brackets and therefore did not properly work.
The brackets have been added.

Related: https://issues.redhat.com/browse/RHEL-70023
2025-02-04 12:32:42 +01:00
4 changed files with 22 additions and 4 deletions

View File

@@ -33,7 +33,7 @@ __all__ = ["DEBUG_COMMAND_ALL", "DEBUG_COMMAND_LIST",
"paths", "tasks", "get_credentials_if_valid", "Encoding",
"DNSName", "getargspec", "certificate_loader",
"write_certificate_list", "boolean", "template_str",
"urlparse", "normalize_sshpubkey"]
"urlparse", "normalize_sshpubkey", "Email"]
DEBUG_COMMAND_ALL = 0b1111
# Print the while command list:
@@ -116,6 +116,7 @@ try:
from ipalib.krb_utils import get_credentials_if_valid
from ipapython.dnsutil import DNSName
from ipapython import kerberos
from ipapython.ipavalidate import Email
try:
from ipalib.x509 import Encoding

View File

@@ -344,7 +344,7 @@ config:
from ansible.module_utils.ansible_freeipa_module import \
IPAAnsibleModule, compare_args_ipa, ipalib_errors
IPAAnsibleModule, compare_args_ipa, ipalib_errors, Email
def config_show(module):
@@ -515,6 +515,13 @@ def main():
msg="Argument '%s' must be between %d and %d."
% (arg, minimum, maximum))
# verify email domain
emaildomain = params.get("ipadefaultemaildomain", None)
if emaildomain:
if not Email("test@{0}".format(emaildomain)):
ansible_module.fail_json(
msg="Invalid 'emaildomain' value: %s" % emaildomain)
changed = False
exit_args = {}

View File

@@ -581,8 +581,8 @@ def main():
"https://pagure.io/freeipa/issue/9349")
if (
externalmember is not None
or idoverrideuser is not None
(externalmember is not None
or idoverrideuser is not None)
and context == "client"
):
ansible_module.fail_json(

View File

@@ -34,6 +34,16 @@
ipaapi_context: "{{ ipa_context | default(omit) }}"
emaildomain: ipa.test
- name: Ensure the default e-mail domain cannot be set to an invalid email domain.
ipaconfig:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
emaildomain: invalid@emaildomain
register: invalid_emaildomain
failed_when:
invalid_emaildomain.changed
or not (invalid_emaildomain.failed and "Invalid 'emaildomain' value:" in invalid_emaildomain.msg)
- name: Set default shell to '/bin/sh'
ipaconfig:
ipaadmin_password: SomeADMINpassword