Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport][ipa-4-9] ipaldap: fix conversion from boolean OID to Python #6304

Closed

Conversation

flo-renaud
Copy link
Contributor

This PR was opened automatically because PR #6294 was pushed to master and backport to ipa-4-9 is required.

In IPA framework we don't properly convert to Python bool type and just
return a string (TRUE or FALSE). This can be seen with many boolean
attributes, like

        Bool('idnsallowdynupdate?',
            cli_name='dynamic_update',
            label=_('Dynamic update'),
            doc=_('Allow dynamic updates.'),
            attribute=True,
            default=False,
            autofill=True
        ),

in 'ipa dnszone-show':

> > > api.Command.dnszone_show('ipa.test')['result']['idnsallowdynupdate']
['TRUE']

This is because we don't have the reverse (from LDAP to Python) mapping
for the LDAP boolean OID 1.3.6.1.4.1.1466.115.121.1.7.

When Web UI asks for the entry, it gets back JSON output that contains
this 'TRUE' value:

            "idnsallowdynupdate": [
                "TRUE"
            ],

Add proper mapping from LDAP to Python bool type. With this, a simple
'checkbox' type can be used in Web UI instead of a complex radio-box
setup.

Note that when IPA API is asked to return raw values, 'TRUE' and 'FALSE'
still returned. These are the actual LDAP boolean attribute values. Care
needs to be done in tests:

 - if output is from a command with --raw option, 'TRUE' or 'FALSE'
   should be expected

 - if output if from a normal (non-raw) command, True or False would be
   returned

Fixes: https://pagure.io/freeipa/issue/9171

Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
@flo-renaud flo-renaud added the ack Pull Request approved, can be merged label Jun 10, 2022
@flo-renaud
Copy link
Contributor Author

PR was ACKed automatically because this is backport of PR #6294. Wait for CI to finish before pushing. In case of questions or problems contact @abbra who is author of the original PR.

@flo-renaud flo-renaud added the pushed Pull Request has already been pushed label Jun 10, 2022
@flo-renaud
Copy link
Contributor Author

ipa-4-9:

  • faeb656 ipaldap: fix conversion from boolean OID to Python

@flo-renaud flo-renaud closed this Jun 10, 2022
@flo-renaud flo-renaud deleted the backport_pr6294_ipa-4-9 branch June 10, 2022 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged pushed Pull Request has already been pushed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants