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

nss_checker: Make user/group names platform-dependent #248

Merged
merged 2 commits into from
Feb 21, 2022

Conversation

stanislavlevin
Copy link
Contributor

User/group names were hardcoded, this broke ipaplatforms having
different names.

Fixes: #247
Signed-off-by: Stanislav Levin slev@altlinux.org

@stanislavlevin
Copy link
Contributor Author

have to fix tests/test_ipa_nss.py as well.

def test_ipaapi_group_ok(self, mock_grp):
mock_grp.return_value = make_group('apache', ('apache', 'ipaapi',))

def test_ipaapi_group_ok(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that the test system is configured properly doesn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests require freeipa-server RPM package which pulls apache as well, both have RPM post-scripts creating system users for them. Thus, IPA (including underlying components) has all the needed system users upon installation, the configuration is not required. So, actually mocking is required only for negative test cases. But adding a mocking for the existing group is not a big deal.

@rcritten
Copy link
Collaborator

Just the one question, otherwise this looks great.

- make use of ipaplatform for user/group names to avoid hardcoded values
- correct mocking in tests

There were several issues with these tests:
- mocking of builtins on global level is discouraged, mock on
  target module level instead
- wrong mocked group, `IPAGroupMemberCheck` checks if apache user
  has supplementary group `ipaapi`, while test mocked `apache` group
- wrong mocked `struct_group`, it should include user names having
  given supplementary group, not a primary one:
  ipaapi: (ipaapi, apache) => ipaapi: (apache,)

Fixes: freeipa#247
Signed-off-by: Stanislav Levin <slev@altlinux.org>
- make use of ipaplatform for user/group names to avoid hardcoded values

Fixes: freeipa#247
Signed-off-by: Stanislav Levin <slev@altlinux.org>
@stanislavlevin
Copy link
Contributor Author

added platform dependent changes for files_checker

@rcritten
Copy link
Collaborator

PR looks good, thanks. ack.

@rcritten rcritten merged commit b4af69d into freeipa:master Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[IPAGroupMemberCheck] hardcoded user/group names
2 participants