#50740 Issue: 48851 - investigate and port TET matching rules filter tests(cert)
Closed 3 years ago by spichugi. Opened 4 years ago by aborah.
aborah/389-ds-base cert  into  master

@@ -0,0 +1,69 @@ 

+ # --- BEGIN COPYRIGHT BLOCK ---

+ # Copyright (C) 2019 Red Hat, Inc.

+ # All rights reserved.

+ #

+ # License: GPL (version 3 or any later version).

+ # See LICENSE for details.

+ # --- END COPYRIGHT BLOCK ----

+ 

+ 

+ """

+ verify and testing  Filter from a search

+ """

+ 

+ import os

+ import pytest

+ 

+ from lib389._constants import DEFAULT_SUFFIX

+ from lib389.topologies import topology_st as topo

+ from lib389.idm.user import UserAccounts

+ from lib389.idm.account import Accounts

+ from lib389.nss_ssl import NssSsl

+ from lib389.utils import search_filter_escape_bytes

+ 

+ pytestmark = pytest.mark.tier1

+ 

+ 

+ def test_positive(topo):

+     """Test User certificate field

+         :id: e984ac40-63d1-4176-ad1e-0cbe71391b5f

+         :setup: Standalone

+         :steps:

+             1. Create entries with userCertificate field.

+             2. Try to search/filter them with userCertificate field.

+         :expected results:

+             1. Pass

+             2. Pass

+     """

+     # SETUP TLS

+     topo.standalone.stop()

+     NssSsl(topo.standalone).reinit()

+     NssSsl(topo.standalone).create_rsa_ca()

+     NssSsl(topo.standalone).create_rsa_key_and_cert()

+     # Create  user

+     NssSsl(topo.standalone).create_rsa_user('testuser1')

+     NssSsl(topo.standalone).create_rsa_user('testuser2')

+     # Creating cert users

+     topo.standalone.start()

+     users_people = UserAccounts(topo.standalone, DEFAULT_SUFFIX)

+     for count in range(1, 3):

+         user = users_people.create_test_user(uid=count, gid=count)

+         tls_locs = NssSsl(topo.standalone).get_rsa_user(f'testuser{count}')

+         #  {'ca': ca_path, 'key': key_path, 'crt': crt_path}

+         user.enroll_certificate(tls_locs['crt_der_path'])

+ 

+     assert Accounts(topo.standalone, DEFAULT_SUFFIX).filter("(usercertificate=*)")

+     assert Accounts(topo.standalone, DEFAULT_SUFFIX).filter("(userCertificate;binary=*)")

+     user1_cert = users_people.list()[0].get_attr_val("userCertificate;binary")

+     assert Accounts(topo.standalone, DEFAULT_SUFFIX).filter(

+         f'(userCertificate;binary={search_filter_escape_bytes(user1_cert)})')[0].dn == \

+            'uid=test_user_1,ou=People,dc=example,dc=com'

+     user2_cert = users_people.list()[1].get_attr_val("userCertificate;binary")

+     assert Accounts(topo.standalone, DEFAULT_SUFFIX).filter(

+         f'(userCertificate;binary={search_filter_escape_bytes(user2_cert)})')[0].dn == \

+            'uid=test_user_2,ou=People,dc=example,dc=com'

+ 

+ 

+ if __name__ == '__main__':

+     CURRENT_FILE = os.path.realpath(__file__)

+     pytest.main("-s -v %s" % CURRENT_FILE)

Investigate and port TET matching rules filter tests(cert)

Relates: https://pagure.io/389-ds-base/issue/48851

Author: aborah

Reviewed by: ???

This PR depends on #50739, if I am not mistaken. You correctly fixed the misspelled function's name in that PR, so update it in this PR as well, please.

rebased onto b2f37d30baebe29e641125759c1ada1ae75c796b

4 years ago

This PR depends on #50739, if I am not mistaken. You correctly fixed the misspelled function's name in that PR, so update it in this PR as well, please.

Corrected

rebased onto 5634c3b1c31b1172b6cf31dfdcec1fdaf8cd5cd1

4 years ago

rebased onto 31418242afe18b509a81d709925d817d4fa11fe5

4 years ago

rebased onto 7d3518c443abfb9182f568c44575307dd10e4063

4 years ago

rebased onto 9caf7ab

4 years ago

Pull-Request has been merged by vashirov

4 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/3795

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago
Metadata