URL: https://github.com/freeipa/freeipa/pull/1080 Author: stlaz Title: #1080: [Backport][ipa-4-6] travis: run the same tests in python2/3 Action: opened
PR body: """ This PR was opened automatically because PR #1052 was pushed to master and backport to ipa-4-6 is required. """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/1080/head:pr1080 git checkout pr1080
From a01b611d8c289b5218f50d0dce6fc69a7b2fcde6 Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka <slazn...@redhat.com> Date: Fri, 8 Sep 2017 12:49:04 +0200 Subject: [PATCH 1/4] ldap2: don't use decode() on str instance This was causing issues when adding/removing a CA in the CA plugin. https://pagure.io/freeipa/issue/7131 --- ipaserver/plugins/ldap2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipaserver/plugins/ldap2.py b/ipaserver/plugins/ldap2.py index 358b3f0ef3..07d6f354e0 100644 --- a/ipaserver/plugins/ldap2.py +++ b/ipaserver/plugins/ldap2.py @@ -353,7 +353,7 @@ def can_delete(self, dn): attrs = self.get_effective_rights(dn, ["*"]) if 'entrylevelrights' in attrs: - entry_rights = attrs['entrylevelrights'][0].decode('UTF-8') + entry_rights = attrs['entrylevelrights'][0] if 'd' in entry_rights: return True @@ -366,7 +366,7 @@ def can_add(self, dn): assert isinstance(dn, DN) attrs = self.get_effective_rights(dn, ["*"]) if 'entrylevelrights' in attrs: - entry_rights = attrs['entrylevelrights'][0].decode('UTF-8') + entry_rights = attrs['entrylevelrights'][0] if 'a' in entry_rights: return True From 752ac4ca3a3503892aab92d127b07577c4fc49a3 Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka <slazn...@redhat.com> Date: Fri, 8 Sep 2017 13:21:36 +0200 Subject: [PATCH 2/4] certmap testing: fix wrong cert construction `bytes` instances have no `.format()`, we can simply base64 decode the certificate and load it as DER instead. https://pagure.io/freeipa/issue/7131 --- ipatests/test_xmlrpc/tracker/certmapdata.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ipatests/test_xmlrpc/tracker/certmapdata.py b/ipatests/test_xmlrpc/tracker/certmapdata.py index b869640f88..47db97e4b6 100644 --- a/ipatests/test_xmlrpc/tracker/certmapdata.py +++ b/ipatests/test_xmlrpc/tracker/certmapdata.py @@ -1,6 +1,8 @@ # # Copyright (C) 2015 FreeIPA Contributors see COPYING for license # +import base64 + from cryptography import x509 from cryptography.hazmat.backends import default_backend from nose.tools import assert_raises @@ -50,11 +52,9 @@ def _data_from_options(self, **options): certs = [certs] for cert in certs: - cert = x509.load_pem_x509_certificate( - (b'-----BEGIN CERTIFICATE-----\n' - b'{}-----END CERTIFICATE-----\n' - .format(cert)), - default_backend() + cert = x509.load_der_x509_certificate( + base64.b64decode(cert), + backend=default_backend() ) issuer = DN(cert.issuer).x500_text() subject = DN(cert.subject).x500_text() From d95033afd1f3b5a4be16b1cd355556a5b4f75312 Mon Sep 17 00:00:00 2001 From: Martin Basti <mba...@redhat.com> Date: Wed, 12 Jul 2017 17:29:30 +0200 Subject: [PATCH 3/4] py3: set samba dependencies Set proper python3 dependencies for samba package https://pagure.io/freeipa/issue/7131 --- freeipa.spec.in | 26 +++++++++++++++++--------- ipaserver/dcerpc.py | 3 --- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/freeipa.spec.in b/freeipa.spec.in index 214731805b..638886af31 100644 --- a/freeipa.spec.in +++ b/freeipa.spec.in @@ -39,8 +39,8 @@ %global krb5_version 1.15.1-4 # 0.7.16: https://github.com/drkjam/netaddr/issues/71 %global python_netaddr_version 0.7.5-8 -# Require 4.6.0-4 which brings RC4 for FIPS + trust fixes to priv. separation -%global samba_version 4.6.0-4 +# Require 4.7.0 which brings Python 3 bindings +%global samba_version 4.7.0 %global selinux_policy_version 3.12.1-153 %global slapi_nis_version 0.56.0-4 %else @@ -48,8 +48,8 @@ %global krb5_version 1.15.1-7 # 0.7.16: https://github.com/drkjam/netaddr/issues/71 %global python_netaddr_version 0.7.16 -# Require 4.6.0-4 which brings RC4 for FIPS + trust fixes to priv. separation -%global samba_version 2:4.6.0-4 +# Require 4.7.0 which brings Python 3 bindings +%global samba_version 2:4.7.0 %global selinux_policy_version 3.13.1-158.4 %global slapi_nis_version 0.56.1 %endif @@ -209,8 +209,7 @@ BuildRequires: python2-jinja2 BuildRequires: python2-augeas %if 0%{?with_python3} -# FIXME: this depedency is missing - server will not work -#BuildRequires: python3-samba +BuildRequires: python3-samba # 1.6: x509.Name.rdns (https://github.com/pyca/cryptography/issues/3199) BuildRequires: python3-cryptography >= 1.6 BuildRequires: python3-gssapi >= 1.2.0 @@ -483,12 +482,21 @@ Summary: Virtual package to install packages required for Active Directory trust Group: System Environment/Base Requires: %{name}-server = %{version}-%{release} Requires: %{name}-common = %{version}-%{release} -Requires: samba-python + Requires: samba >= %{samba_version} Requires: samba-winbind Requires: libsss_idmap -Requires: python-libsss_nss_idmap -Requires: python-sss + +%if 0%{?with_python3} +Requires: python3-samba +Requires: python3-libsss_nss_idmap +Requires: python3-sss +%else +Requires: python2-samba +Requires: python2-libsss_nss_idmap +Requires: python2-sss +%endif # with_python3 + # We use alternatives to divert winbind_krb5_locator.so plugin to libkrb5 # on the installes where server-trust-ad subpackage is installed because # IPA AD trusts cannot be used at the same time with the locator plugin diff --git a/ipaserver/dcerpc.py b/ipaserver/dcerpc.py index ca822d7323..287122c516 100644 --- a/ipaserver/dcerpc.py +++ b/ipaserver/dcerpc.py @@ -37,8 +37,6 @@ import struct import random -# TODO: Remove pylint disable when Python 3 bindings are available. -# pylint: disable=import-error from samba import param from samba import credentials from samba.dcerpc import security, lsa, drsblobs, nbt, netlogon @@ -46,7 +44,6 @@ from samba import net from samba import arcfour_encrypt import samba -# pylint: enable=import-error import ldap as _ldap from ipapython import ipaldap From 8483055537c49f5f23bbb95e939143520cb865b1 Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka <slazn...@redhat.com> Date: Fri, 8 Sep 2017 09:45:06 +0200 Subject: [PATCH 4/4] travis: run the same tests in python2/3 We missed running some tests in python3 https://pagure.io/freeipa/issue/7131 --- .travis.yml | 58 +++++----------------------------------------------------- 1 file changed, 5 insertions(+), 53 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7deac89464..556232a17a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,67 +35,19 @@ env: - TASK_TO_RUN="run-tests" PYTHON=/usr/bin/python3 TEST_RUNNER_CONFIG=".test_runner_config_py3_temp.yaml" - TESTS_TO_RUN="test_xmlrpc/test_add_remove_cert_cmd.py - test_xmlrpc/test_attr.py - test_xmlrpc/test_automember_plugin.py - test_xmlrpc/test_automount_plugin.py - test_xmlrpc/test_baseldap_plugin.py - test_xmlrpc/test_batch_plugin.py - test_xmlrpc/test_cert_plugin.py - test_xmlrpc/test_certprofile_plugin.py - test_xmlrpc/test_config_plugin.py - test_xmlrpc/test_delegation_plugin.py - test_xmlrpc/test_group_plugin.py - test_xmlrpc/test_hbac_plugin.py - test_xmlrpc/test_hbacsvcgroup_plugin.py - test_xmlrpc/test_hbactest_plugin.py - test_xmlrpc/test_host_plugin.py - test_xmlrpc/test_hostgroup_plugin.py - test_xmlrpc/test_krbtpolicy.py - test_xmlrpc/test_kerberos_principal_aliases.py" - ### Tests which haven't been ported to py3 yet ### - ## test_xmlrpc/test_[a-k]*.py - # test_xmlrpc/test_ca_plugin.py - # test_xmlrpc/test_caacl_plugin.py - # test_xmlrpc/test_caacl_profile_enforcement.py - # test_xmlrpc/test_dns_plugin.py - # test_xmlrpc/test_dns_realmdomains_integration.py - # test_xmlrpc/test_external_members.py - # test_xmlrpc/test_idviews_plugin.py + TESTS_TO_RUN="test_xmlrpc/test_[a-k]*.py" - TASK_TO_RUN="run-tests" PYTHON=/usr/bin/python3 TEST_RUNNER_CONFIG=".test_runner_config_py3_temp.yaml" TESTS_TO_RUN="test_cmdline + test_install + test_ipaclient test_ipalib test_ipapython test_ipaserver test_pkcs10 - test_xmlrpc/test_location_plugin.py - test_xmlrpc/test_nesting.py - test_xmlrpc/test_netgroup_plugin.py - test_xmlrpc/test_old_permission_plugin.py - test_xmlrpc/test_passwd_plugin.py - test_xmlrpc/test_permission_plugin.py - test_xmlrpc/test_ping_plugin.py - test_xmlrpc/test_privilege_plugin.py - test_xmlrpc/test_pwpolicy_plugin.py - test_xmlrpc/test_radiusproxy_plugin.py - test_xmlrpc/test_realmdomains_plugin.py - test_xmlrpc/test_replace.py - test_xmlrpc/test_role_plugin.py - test_xmlrpc/test_selfservice_plugin.py - test_xmlrpc/test_selinuxusermap_plugin.py - test_xmlrpc/test_service_plugin.py - test_xmlrpc/test_servicedelegation_plugin.py - test_xmlrpc/test_stageuser_plugin.py - test_xmlrpc/test_sudocmd_plugin.py - test_xmlrpc/test_sudocmdgroup_plugin.py - test_xmlrpc/test_sudorule_plugin.py" - ### Tests which haven't been ported to py3 yet ### - ## test_xmlrpc/test_[l-z]*.py - # test_xmlrpc/test_range_plugin.py - # test_xmlrpc/test_trust_plugin.py - # test_xmlrpc/test_vault_plugin.py + test_xmlrpc/test_[l-uw-z]*.py" + # FIXME: add vault tests once PKI finally fixes vault install: - pip install --upgrade pip - pip3 install --upgrade pip
_______________________________________________ FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org