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

Add a module for nsldc support. #28

Merged
merged 1 commit into from
Sep 26, 2023
Merged

Add a module for nsldc support. #28

merged 1 commit into from
Sep 26, 2023

Conversation

aborah-sudo
Copy link
Contributor

Create a module that will configure nslcd in client machine.

@pbrezina
Copy link
Member

pbrezina commented Aug 7, 2023

Hi, how are we going to use nslcd for SSSD testing?

@aborah-sudo
Copy link
Contributor Author

Hi, how are we going to use nslcd for SSSD testing?

This is the one and only setup that used for nslcd setup for current test framework:

https://github.com/SSSD/sssd/blob/master/src/tests/multihost/alltests/conftest.py#L754

@pbrezina
Copy link
Member

pbrezina commented Aug 7, 2023

I went over the use cases and it seems that we only use it to test the proxy provider.

For this, I think it would be better create a generic function that would configure the proxy provider to SSSDCommonConfiguration.

Something like:

    def proxy(self, domain=None, proxy=$proxy, provider=$provider, role: MultihostRole = None):
        """
        ... $proxy can be ldap or files
        ... $provider can be one of sssd providers (id, auth, chpass, ...)
        """

       if domain is None:
           domain = self.default_domain

        match proxy:
           case "ldap":
               # configure and start nslcd, create pam stack for pam_ldap
               # uri is role.host.hostname
               # basedn is not needed, nslcd can figure it on its own
           case "files":
               # create pam stack for pam_unix

The usage would be like:

@pytest.mark.topology(KnownTopology.LDAP)
@pytest.mark.parametrize("proxy", ["files", "ldap"])
def test_proxy__id(client: Client, ldap: LDAP, proxy: str):
    ... create users either local or ldap based on proxy value

    client.sssd.common.proxy(proxy=proxy, provider="id", role=ldap)
    client.sssd.start()

    ... test

@ikerexxe ikerexxe self-assigned this Aug 8, 2023
Copy link
Member

@pbrezina pbrezina left a comment

Choose a reason for hiding this comment

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

Hi Anuj, thank you for implementing the idea, but there are lots of issues in your code.
https://tests.sssd.io/en/latest/concepts.html#core-concepts-and-coding-style
Please, also fix CI issues. It would be good if you create a habit to automatically check your code before submitting it (testing it since current code will yield error about host.host attribute missing) and checking the coding style - you can just run tox command to do it for you. See https://tests.sssd.io/en/latest/concepts.html#core-concepts-and-coding-style on what tools you should run.

sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
Copy link
Member

@pbrezina pbrezina left a comment

Choose a reason for hiding this comment

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

Please also:

  • rename commit to "sssd: add common configuration for proxy domain" and change the commit message since it is not really about nslcd
  • run black, isort, flake8 and mypy to automatically reformat and validate your code to pass the PR CI and follow the coding style

sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
Copy link
Member

@pbrezina pbrezina left a comment

Choose a reason for hiding this comment

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

Hi, thank you Anuj. From my perspective, the logic is there, we just need to move few lines after the if statement and fix types.

sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
sssd_test_framework/utils/sssd.py Outdated Show resolved Hide resolved
@pbrezina
Copy link
Member

Hi, we were going in a in circle - one thing is fixed, another issue created. So I took the liberty to fix documentation and parameter handling to move on with this pull request.

Diff: https://github.com/SSSD/sssd-test-framework/compare/fa556449d721aa363c181800e3e51f2f42532738..3240e9b61f7c0c0154a6f98cc3adc54934eea8e0

Sample tests:

@pytest.mark.topology(KnownTopology.Client)
def test_proxy__files(client: Client):
    client.local.user("tuser").add()
    client.sssd.common.proxy()
    client.sssd.start()

    result = client.tools.id(f"tuser@{client.sssd.default_domain}")
    assert result is not None
    assert result.user.name == "tuser"


@pytest.mark.topology(KnownTopology.LDAP)
def test_proxy__ldap(client: Client, ldap: LDAP):
    ldap.user("tuser").add()
    client.sssd.common.proxy("ldap", server_hostname=ldap.host.hostname)
    client.sssd.start()

    result = client.tools.id(f"tuser@{client.sssd.default_domain}")
    assert result is not None
    assert result.user.name == "tuser"

Now we need to add nss-pam-ldapd to containers before pushing this. @sidecontrol can you take care of that?

@danlavu
Copy link

danlavu commented Sep 11, 2023

@pbrezina , I don't know how to do it yet, but yes, I will figure it out and take care of it.

@danlavu
Copy link

danlavu commented Sep 12, 2023

@ikerexxe
Copy link
Contributor

Please review the unresolved conversations, if they are already fixed then resolve them. Apart from that rebase on top of master.

@pbrezina
Copy link
Member

I built nslcd in copr for downstream rhel9 testing and pushed Dan's container patch again. Once it is verified that we didn't break downstream CI again, we can push this.

Create a module that will configure proxy in client machine.
@pbrezina
Copy link
Member

@sidecontrol do you agree with latest version?

@danlavu
Copy link

danlavu commented Sep 25, 2023

@pbrezina Yes.

@aborah-sudo Thank you.

@pbrezina pbrezina merged commit 8bf8795 into SSSD:master Sep 26, 2023
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants