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
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.

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.

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

@aborah-sudo aborah-sudo force-pushed the netgroup branch 2 times, most recently from b217f20 to 7eb8b21 Compare November 14, 2024 04:06
@ikerexxe
Copy link
Contributor

Before we move forward and merge this PR we need to fix the CI issues. python-system-tests report a set of issues regarding the static typing from mypy. You can run those same tests locally with mypy.

On top of that, there are some problems related to polarion in system tests. You can check them in the following link: system (fedora-39).

@aborah-sudo
Copy link
Contributor Author

aborah-sudo commented Nov 14, 2024

Before we move forward and merge this PR we need to fix the CI issues. python-system-tests report a set of issues regarding the static typing from mypy. You can run those same tests locally with mypy.

I do not see any of the error mentioned above, also test are running fine .

IPA does not support domain in netgroups, therefore the generic interface does not have it. Due to this there may be some mypy error, which are false positive .

============================================================================================================ test session starts =============================================================================================================
platform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0
rootdir: /home/aborah/Documents/Office/sssd/new_sssd/new_framwrok_repo/current/sssd_work/src/tests/system
configfile: pytest.ini
plugins: flaky-3.8.1, output-1.0.0
collecting ...

Selected tests will use the following hosts:
client: client.test
ad: dc.ad.test
samba: dc.samba.test
kdc: kdc.test
ldap: master.ldap.test
nfs: nfs.test

collected 15 items

tests_local/netgroup.py ............... [100%]

======================================================================================================= 15 passed in 116.36s (0:01:56) =======================================================================================================
(.venv) aborah:system:

(.venv) aborah:tests: mypy test_netgroups.py
test_netgroups.py:10: error: Cannot find implementation or library stub for module named "sssd_test_framework.roles.client" [import-not-found]
test_netgroups.py:10: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
test_netgroups.py:11: error: Cannot find implementation or library stub for module named "sssd_test_framework.roles.generic" [import-not-found]
test_netgroups.py:12: error: Cannot find implementation or library stub for module named "sssd_test_framework.topology" [import-not-found]
Found 3 errors in 1 file (checked 1 source file)
(.venv) aborah:tests:

On top of that, there are some problems related to polarion in system tests. You can check them in the following link: system (fedora-39).

Polarion problem is not related to this PR .

@ikerexxe
Copy link
Contributor

I do not see any of the error mentioned above, also test are running fine .

These are the problems reported:

tests/test_netgroups.py:143: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:146: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:148: error: "GenericNetgroup" has no attribute "dn"  [attr-defined]
tests/test_netgroups.py:153: error: Item "None" of "NetgroupEntry | None" has no attribute "members"  [union-attr]
tests/test_netgroups.py:180: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:183: error: "GenericNetgroup" has no attribute "dn"  [attr-defined]
tests/test_netgroups.py:184: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:187: error: "GenericNetgroup" has no attribute "dn"  [attr-defined]
tests/test_netgroups.py:191: error: Item "None" of "NetgroupEntry | None" has no attribute "members"  [union-attr]
tests/test_netgroups.py:224: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:227: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:229: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:235: error: Item "None" of "NetgroupEntry | None" has no attribute "members"  [union-attr]

Polarion problem is not related to this PR .

I don't agree. This is the problem reported:

ValueError: Required field 'customerscenario' is missing for 'tests/test_netgroups.py::test_netgroup__lookup_nested_groups (ldap)'

You added test_netgroup__lookup_nested_groups and it's true that customerscenario field is missing in that test case.

@aborah-sudo
Copy link
Contributor Author

I do not see any of the error mentioned above, also test are running fine .

These are the problems reported:

tests/test_netgroups.py:143: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:146: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:148: error: "GenericNetgroup" has no attribute "dn"  [attr-defined]
tests/test_netgroups.py:153: error: Item "None" of "NetgroupEntry | None" has no attribute "members"  [union-attr]
tests/test_netgroups.py:180: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:183: error: "GenericNetgroup" has no attribute "dn"  [attr-defined]
tests/test_netgroups.py:184: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:187: error: "GenericNetgroup" has no attribute "dn"  [attr-defined]
tests/test_netgroups.py:191: error: Item "None" of "NetgroupEntry | None" has no attribute "members"  [union-attr]
tests/test_netgroups.py:224: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:227: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:229: error: Unexpected keyword argument "domain" for "add_member" of "GenericNetgroup"  [call-arg]
.venv/lib/python3.11/site-packages/sssd_test_framework/roles/generic.py:794: note: "add_member" of "GenericNetgroup" defined here
tests/test_netgroups.py:235: error: Item "None" of "NetgroupEntry | None" has no attribute "members"  [union-attr]

IPA does not support domain in netgroups, therefore the generic interface does not have it. This is the reason for this error.

Polarion problem is not related to this PR .

I don't agree. This is the problem reported:

ValueError: Required field 'customerscenario' is missing for 'tests/test_netgroups.py::test_netgroup__lookup_nested_groups (ldap)'

You added test_netgroup__lookup_nested_groups and it's true that customerscenario field is missing in that test case.

Above problem is fixed now .

@ikerexxe
Copy link
Contributor

IPA does not support domain in netgroups, therefore the generic interface does not have it. This is the reason for this error.

I've been investigating it and that's not the reason. This is the interface definition:

def add_member(
        self,
        *,
        host: str | None = None,
        user: GenericUser | str | None = None,
        ng: GenericNetgroup | str | None = None,
) -> GenericNetgroup:

Link to source: https://github.com/SSSD/sssd-test-framework/blob/master/sssd_test_framework/roles/generic.py#L794

As you can see host and user are defined as arguments, but domain isn't. Unless I'm mistaken I think you can safely remove domain when adding the member.

That's one of the failures, I'd recommend you to read the complete list and understand what's failing in each case.

Above problem is fixed now .

Good!

@aborah-sudo
Copy link
Contributor Author

IPA does not support domain in netgroups, therefore the generic interface does not have it. This is the reason for this error.

I've been investigating it and that's not the reason. This is the interface definition:

def add_member(
        self,
        *,
        host: str | None = None,
        user: GenericUser | str | None = None,
        ng: GenericNetgroup | str | None = None,
) -> GenericNetgroup:

Link to source: https://github.com/SSSD/sssd-test-framework/blob/master/sssd_test_framework/roles/generic.py#L794

As you can see host and user are defined as arguments, but domain isn't. Unless I'm mistaken I think you can safely remove domain when adding the member.

Domain is needed for the test . @pbrezina can help ?

That's one of the failures, I'd recommend you to read the complete list and understand what's failing in each case.

Above problem is fixed now .

Good!

@aborah-sudo aborah-sudo force-pushed the netgroup branch 5 times, most recently from fe556d0 to 1ddbe88 Compare November 14, 2024 14:26
Test transformation of bash-ldap-id-ldap-auth netgroup
@aborah-sudo
Copy link
Contributor Author

aborah-sudo commented Nov 14, 2024

IPA does not support domain in netgroups, therefore the generic interface does not have it. This is the reason for this error.

I've been investigating it and that's not the reason. This is the interface definition:

def add_member(
        self,
        *,
        host: str | None = None,
        user: GenericUser | str | None = None,
        ng: GenericNetgroup | str | None = None,
) -> GenericNetgroup:

Link to source: https://github.com/SSSD/sssd-test-framework/blob/master/sssd_test_framework/roles/generic.py#L794
As you can see host and user are defined as arguments, but domain isn't. Unless I'm mistaken I think you can safely remove domain when adding the member.

Domain is needed for the test . @pbrezina can help ?

That's one of the failures, I'd recommend you to read the complete list and understand what's failing in each case.

Above problem is fixed now .

Good!

All Good now !!

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