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

Tests: Test transformation of bash-ldap-id-ldap-auth netgroup #7648

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aborah-sudo
Copy link
Contributor

Test transformation of bash-ldap-id-ldap-auth netgroup

Copy link
Contributor

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

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

Why are you using a specially created function to run libc's group membership, when the framework already provides an automation to check this?

As an example test_netgroups__add_remove_netgroup_member uses client.tools.getent.netgroup("ng-2") to check the membership.

Copy link

@danlavu danlavu left a comment

Choose a reason for hiding this comment

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

Please reference current code for examples to better conform to the new coding standards. Let's pause any other PRs until this one meets the new guidelines.

src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
@danlavu
Copy link

danlavu commented Oct 18, 2024

This is much better, but you resolved an issue that still needs to be resolved. These tests are specific to LDAP should go in test_ldap.py. Is there a reason why we cannot use the generic provider? We want to start using this for more coverage and reduce the amount of test cases.

Not related to this PR, here is an example of using one test to cover the same scenario for AD/IPA/LDAP/Samba, 12 lines of code instead of copying the test case. https://github.com/SSSD/sssd/blob/master/src/tests/system/tests/test_failover.py

I'll take a closer look later, all the checks need to be green before we merge, please resolve the ci failures, like the 'static code analysis' and the ci system tests.

@aborah-sudo
Copy link
Contributor Author

This is much better, but you resolved an issue that still needs to be resolved. These tests are specific to LDAP should go in test_ldap.py. Is there a reason why we cannot use the generic provider? We want to start using this for more coverage and reduce the amount of test cases.

Not related to this PR, here is an example of using one test to cover the same scenario for AD/IPA/LDAP/Samba, 12 lines of code instead of copying the test case. https://github.com/SSSD/sssd/blob/master/src/tests/system/tests/test_failover.py

I'll take a closer look later, all the checks need to be green before we merge, please resolve the ci failures, like the 'static code analysis' and the ci system tests.

These are ldap specific tests. I have tries running them against GenericProvider but its failed . So moving them to _test_ldap.py

@aborah-sudo aborah-sudo force-pushed the netgroup branch 8 times, most recently from 78ca7f8 to fe91a15 Compare October 18, 2024 06:56
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_ldap.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
Copy link
Contributor

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

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

I've consulted Sumit and although the netgroup functionality is provided, IPA's exposed interface is not the same as in LDAP or AD's environment. So I have an important question before I continue reviewing the code. Ultimately what do we want to test? Do we want to test that the high-level functionality works, or that the functionality of each provider works? According to the response, we can decide what to do with this PR.

@aborah-sudo
Copy link
Contributor Author

I've consulted Sumit and although the netgroup functionality is provided, IPA's exposed interface is not the same as in LDAP or AD's environment. So I have an important question before I continue reviewing the code. Ultimately what do we want to test? Do we want to test that the high-level functionality works, or that the functionality of each provider works? According to the response, we can decide what to do with this PR.

The high-level functionality works

Copy link
Contributor

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

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

Some minor comments added. I think there is not much time left to approve it.

src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
Comment on lines 206 to 211
client.sssd.restart()

member = client.tools.getent.netgroup("nested_netgroup").members
assert "(testhost1,ng1,ldap.test)" in member
assert "(-,ng3,)" in member
assert "(testhost5,ng2,ldap.test)" in member
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed? Are you expecting some change may happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this is assertion to make sure everything works

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean by everything? What is the exact use case you are trying to test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After sssd restart i want to make sure that Nesting netgroups works and i can remove that part if it does not make sense .

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it doesn't. @danlavu what do you think? Does it make sense to check again the nesting groups after restarting sssd?

src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
src/tests/system/tests/test_netgroups.py Outdated Show resolved Hide resolved
Copy link

@danlavu danlavu left a comment

Choose a reason for hiding this comment

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

Overall it looks good, mostly grammatical changes requested. I didn't go into why, the change, but if you would like to explain why moving forward I'm happy to do so or I can just provide the change.

There is one part of 'test_netgroup__lookup_nested_groups' that is out scope, thanks Anuj, good work.

for id in [1, 2]:
provider.user(f"ng{id}").add()

netgroup_qa = provider.netgroup("QAUsers").add()
Copy link

Choose a reason for hiding this comment

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

We should change the group names, it's more concise to call them "group" and "nested_group".

"""
:title: Netgroup contains a member that has a host and domain specified.
:setup:
1. Create users, groups.
Copy link

Choose a reason for hiding this comment

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

'Create users and groups.'

@pytest.mark.topology(KnownTopology.LDAP)
@pytest.mark.topology(KnownTopology.AD)
@pytest.mark.topology(KnownTopology.Samba)
def test_netgroup__host_and_domain(client: Client, provider: GenericProvider, user: str, domain: str, expected: str):
Copy link

Choose a reason for hiding this comment

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

A more descriptive name, like
'test_netgroup__lookup_nested_groups_with_host_and_domain_values_present'

"""
:title: Nesting netgroups and verifying user memberships using LDAP with sssd.
:setup:
1. Create users, groups.
Copy link

Choose a reason for hiding this comment

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

'Create users and groups.'

@pytest.mark.topology(KnownTopology.Samba)
def test_netgroup__lookup_nested_groups(client: Client, provider: GenericProvider):
"""
:title: Nesting netgroups and verifying user memberships using LDAP with sssd.
Copy link

Choose a reason for hiding this comment

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

'Looking up nested netgroups' is sufficient as the title.

5. Add Circular Netgroup Nesting to nested_netgroup
6. Start sssd
:steps:
1. Retrieves all members of the "nested_netgroup" group using the getent netgroup tool.
Copy link

Choose a reason for hiding this comment

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

'Lookup nested_netgroup'

We can drop steps 2 and 3.

3. Checks if a user who is not in any netgroup is part of "nested_netgroup".
4. After the SSSD restart, it retrieves the members of "nested_netgroup" again to ensure they still intact.
:expectedresults:
1. All members of the "nested_netgroup" group be there
Copy link

Choose a reason for hiding this comment

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

"Netgroup is found, and both netgroups and users are members"

We can drop all the other steps.

"""
:title: User's 'memberNisNetgroup' attribute values are the DN of the group.
:setup:
1. Create users, groups.
Copy link

Choose a reason for hiding this comment

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

I made a lot of comments to the following test case, all of those comments apply here.

"""
:title: User's 'memberNisNetgroup' attribute values are the DN of the group.
:setup:
1. Create users, groups.
Copy link

Choose a reason for hiding this comment

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

I made a lot of comments to the following test case, all of those comments apply here.

client: Client, provider: GenericProvider, operation: str
):
"""
:title: User's 'memberNisNetgroup' attribute values are the DN of the group.
Copy link

Choose a reason for hiding this comment

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

Remove . from all titles and steps. Let's try and make it consistent.

:setup:
1. Create users and groups
2. Create netgroups and add member
3. Add Members to nested_netgroup
Copy link

Choose a reason for hiding this comment

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

lower case M in members

:setup:
1. Create users and groups
2. Create netgroups and add member
3. Start sssd
Copy link

Choose a reason for hiding this comment

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

Start SSSD

:steps:
1. Check whether the expected member is present in the nested_group netgroup
:expectedresults:
1. Member is present in the nested_group netgroup
Copy link

Choose a reason for hiding this comment

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

This is confusing, either

'Member is present in nested netgroup'
"Member is present in netgroup 'nested_netgroup'"

2. Create netgroups and add member
3. Start sssd
:steps:
1. Check whether the expected member is present in the nested_group netgroup
Copy link

Choose a reason for hiding this comment

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

'Lookup netgroup', the extra wording is not necessary.

4. Make netgroup and nested_netgroup members of one another, looping the groups
5. Start sssd
:steps:
1. Lookup nested_netgroup
Copy link

Choose a reason for hiding this comment

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

Let's keep names, in quotes,

  1. Lookup 'nested_netgroup'

:setup:
1. Create users and groups
2. Create netgroups and add member
3. Add Members to nested_netgroup
Copy link

Choose a reason for hiding this comment

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

Quotes, if you are using the variable name.

  1. Add members to netgroup 'nested_netgroup'
    or
  2. Add members to nested netgroup

One specifies the actual group name and the other option is more general. I don't care which you choose, but I'd like to see it consistent through the file.

2. Create a new netgroup called group and add a member (ng1) to group
3. Create another netgroup named nested_group and add a member (ng2) to nested_group
4. Modify the nested_group to replace its members with the members of group
5. Start sssd
Copy link

Choose a reason for hiding this comment

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

uppercase SSSD

Copy link
Contributor

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

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

Just a minor improvement. You should also check the python-system-tests result since mypy is reporting several errors.

2. Create netgroups and add member
3. Start SSSD
:steps:
1. Lookup netgroup
Copy link
Contributor

Choose a reason for hiding this comment

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

There is an extra space between the period and the text

Copy link

@danlavu danlavu left a comment

Choose a reason for hiding this comment

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

Just the three minor typos, but approved. Thank you Anuij.

2. Create netgroups and add member
3. Start SSSD
:steps:
1. Lookup netgroup
Copy link

Choose a reason for hiding this comment

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

Lookup netgroup "nested_group"

:title: Netgroup contains a member that has a host and domain specified
:setup:
1. Create users and groups
2. Create netgroups and add member
Copy link

Choose a reason for hiding this comment

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

'members' plural

:title: Looking up nested netgroups
:setup:
1. Create users and groups
2. Create netgroups and add member
Copy link

Choose a reason for hiding this comment

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

'members' plural

Test transformation of bash-ldap-id-ldap-auth netgroup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants