mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Sprinkle raw strings across the code base
tox / pytest is complaining about lots and lots of invalid escape sequences in our code base. Sprinkle raw strings or backslash escapes across the code base to fix most occurences of: DeprecationWarning: invalid escape sequence There is still one warning that keeps repeating, though: source:264: DeprecationWarning: invalid escape sequence \d Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
This commit is contained in:
@@ -127,7 +127,7 @@ class ACI(object):
|
||||
|
||||
if var == 'targetattr':
|
||||
# Make a string of the form attr || attr || ... into a list
|
||||
t = re.split('[^a-zA-Z0-9;\*]+', val)
|
||||
t = re.split(r'[^a-zA-Z0-9;\*]+', val)
|
||||
self.target[var] = {}
|
||||
self.target[var]['operator'] = op
|
||||
self.target[var]['expression'] = t
|
||||
|
||||
@@ -158,8 +158,8 @@ def isvalid_base64(data):
|
||||
|
||||
data = ''.join(data.split())
|
||||
|
||||
if len(data) % 4 > 0 or \
|
||||
re.match('^[a-zA-Z0-9\+\/]+\={0,2}$', data) is None:
|
||||
if (len(data) % 4 > 0 or
|
||||
re.match(r'^[a-zA-Z0-9\+\/]+\={0,2}$', data) is None):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
@@ -109,7 +109,7 @@ class Principal(object):
|
||||
return hash(self.components + (self.realm,))
|
||||
|
||||
def _parse_from_text(self, principal, realm=None):
|
||||
"""
|
||||
r"""
|
||||
parse individual principal name components from the string
|
||||
representation of the principal. This is done in three steps:
|
||||
1.) split the string at the unescaped '@'
|
||||
|
||||
@@ -167,8 +167,8 @@ class config_server_for_smart_card_auth(common_smart_card_auth_config):
|
||||
],
|
||||
commands_to_run_when_false=[
|
||||
self._interpolate_ocsp_directive_file_into_command(
|
||||
"sed -i.ipabkp '/<\/VirtualHost>/i {directive} on' "
|
||||
"{filename}")
|
||||
r"sed -i.ipabkp '/<\/VirtualHost>/i {directive} on' "
|
||||
r"{filename}")
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ class update_ipaconfigstring_dnsversion_to_ipadnsversion(Updater):
|
||||
container_entry['objectclass'].append('ipadnscontainer')
|
||||
version = 0
|
||||
for config_option in container_entry.get("ipaConfigString", []):
|
||||
matched = re.match("^DNSVersion\s+(?P<version>\d+)$",
|
||||
matched = re.match(r"^DNSVersion\s+(?P<version>\d+)$",
|
||||
config_option, flags=re.I)
|
||||
if matched:
|
||||
version = int(matched.group("version"))
|
||||
|
||||
@@ -358,8 +358,12 @@ class baseuser(LDAPObject):
|
||||
),
|
||||
Str('preferredlanguage?',
|
||||
label=_('Preferred Language'),
|
||||
pattern='^(([a-zA-Z]{1,8}(-[a-zA-Z]{1,8})?(;q\=((0(\.[0-9]{0,3})?)|(1(\.0{0,3})?)))?' \
|
||||
+ '(\s*,\s*[a-zA-Z]{1,8}(-[a-zA-Z]{1,8})?(;q\=((0(\.[0-9]{0,3})?)|(1(\.0{0,3})?)))?)*)|(\*))$',
|
||||
pattern=(
|
||||
r'^(([a-zA-Z]{1,8}(-[a-zA-Z]{1,8})?'
|
||||
r'(;q\=((0(\.[0-9]{0,3})?)|(1(\.0{0,3})?)))?'
|
||||
r'(\s*,\s*[a-zA-Z]{1,8}(-[a-zA-Z]{1,8})?'
|
||||
r'(;q\=((0(\.[0-9]{0,3})?)|(1(\.0{0,3})?)))?)*)|(\*))$'
|
||||
),
|
||||
pattern_errmsg='must match RFC 2068 - 14.4, e.g., "da, en-gb;q=0.8, en;q=0.7"',
|
||||
),
|
||||
Certificate('usercertificate*',
|
||||
|
||||
@@ -86,7 +86,7 @@ def ca_enabled_check(_api):
|
||||
raise errors.NotFound(reason=_('CA is not configured'))
|
||||
|
||||
|
||||
profile_id_pattern = re.compile('^[a-zA-Z]\w*$')
|
||||
profile_id_pattern = re.compile(r'^[a-zA-Z]\w*$')
|
||||
|
||||
|
||||
def validate_profile_id(ugettext, value):
|
||||
@@ -230,7 +230,7 @@ class certprofile_import(LDAPCreate):
|
||||
),
|
||||
)
|
||||
|
||||
PROFILE_ID_PATTERN = re.compile('^profileId=([a-zA-Z]\w*)', re.MULTILINE)
|
||||
PROFILE_ID_PATTERN = re.compile(r'^profileId=([a-zA-Z]\w*)', re.MULTILINE)
|
||||
|
||||
def pre_callback(self, ldap, dn, entry, entry_attrs, *keys, **options):
|
||||
ca_enabled_check(self.api)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
'''
|
||||
r'''
|
||||
|
||||
==============================================
|
||||
Backend plugin for RA using Dogtag (e.g. CMS)
|
||||
|
||||
@@ -469,7 +469,7 @@ def construct_filter(template, oc_list):
|
||||
return template % oc_subfilter
|
||||
|
||||
def validate_ldapuri(ugettext, ldapuri):
|
||||
m = re.match('^ldaps?://[-\w\.]+(:\d+)?$', ldapuri)
|
||||
m = re.match(r'^ldaps?://[-\w\.]+(:\d+)?$', ldapuri)
|
||||
if not m:
|
||||
err_msg = _('Invalid LDAP URI.')
|
||||
raise errors.ValidationError(name='ldap_uri', error=err_msg)
|
||||
|
||||
@@ -101,13 +101,13 @@ _shell_substitution_regexp = re.compile(
|
||||
# group 5: ending delimiter
|
||||
|
||||
printf_fmt_re = re.compile(
|
||||
r"%" # start
|
||||
"(\d+\$)?" # fmt_arg (group 1)
|
||||
"(([#0 +'I]|-(?!\d))*)" # flags (group 2)
|
||||
"(([+-]?([1-9][0-9]*)?)|(\*|\*\d+\$))?" # width (group 4)
|
||||
"(\.((-?\d*)|(\*|)|(\*\d+\$)))?" # precision (group 8)
|
||||
"(h|hh|l|ll|L|j|z|t)?" # length (group 13)
|
||||
"([diouxXeEfFgGaAcspnm%])") # conversion (group 14)
|
||||
r"%" # start
|
||||
r"(\d+\$)?" # fmt_arg (group 1)
|
||||
r"(([#0 +'I]|-(?!\d))*)" # flags (group 2)
|
||||
r"(([+-]?([1-9][0-9]*)?)|(\*|\*\d+\$))?" # width (group 4)
|
||||
r"(\.((-?\d*)|(\*|)|(\*\d+\$)))?" # precision (group 8)
|
||||
r"(h|hh|l|ll|L|j|z|t)?" # length (group 13)
|
||||
r"([diouxXeEfFgGaAcspnm%])") # conversion (group 14)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ def restore_files(host):
|
||||
rmname = os.path.join(host.config.test_dir, 'file_remove')
|
||||
|
||||
# Prepare command for restoring context of the backed-up files
|
||||
sed_remove_backupdir = 's/%s//g' % backupname.replace('/', '\/')
|
||||
sed_remove_backupdir = 's/%s//g' % backupname.replace('/', r'\/')
|
||||
restorecon_command = (
|
||||
"find %s | "
|
||||
"sed '%s' | "
|
||||
@@ -361,7 +361,7 @@ def domainlevel(host):
|
||||
kinit_admin(host, raiseonerr=False)
|
||||
result = host.run_command(['ipa', 'domainlevel-get'], raiseonerr=False)
|
||||
level = MIN_DOMAIN_LEVEL
|
||||
domlevel_re = re.compile('.*(\d)')
|
||||
domlevel_re = re.compile(r'.*(\d)')
|
||||
if result.returncode == 0:
|
||||
# "domainlevel-get" command doesn't exist on ipa versions prior to 4.3
|
||||
level = int(domlevel_re.findall(result.stdout_text)[0])
|
||||
@@ -601,7 +601,7 @@ def setup_sssd_debugging(host):
|
||||
|
||||
# Add the debug directive to each section
|
||||
host.run_command(['sed', '-i',
|
||||
'/\[*\]/ a\debug_level = 7',
|
||||
r'/\[*\]/ a\debug_level = 7',
|
||||
paths.SSSD_CONF],
|
||||
raiseonerr=False)
|
||||
|
||||
@@ -1000,7 +1000,7 @@ def two_connected_topo(master, replicas):
|
||||
|
||||
@_topo('double-circle')
|
||||
def double_circle_topo(master, replicas, site_size=6):
|
||||
"""
|
||||
r"""
|
||||
R--R
|
||||
|\/|
|
||||
|/\|
|
||||
|
||||
@@ -49,8 +49,8 @@ class TestAdvice(IntegrationTest):
|
||||
topology = 'line'
|
||||
|
||||
def test_invalid_advice(self):
|
||||
advice_id = 'invalid-advise-param'
|
||||
advice_regex = "invalid[\s]+\'advice\'.*"
|
||||
advice_id = r'invalid-advise-param'
|
||||
advice_regex = r"invalid[\s]+\'advice\'.*"
|
||||
raiseerr = False
|
||||
|
||||
run_advice(self.master, advice_id, advice_regex, raiseerr)
|
||||
@@ -58,9 +58,9 @@ class TestAdvice(IntegrationTest):
|
||||
|
||||
def test_advice_FreeBSDNSSPAM(self):
|
||||
advice_id = 'config-freebsd-nss-pam-ldapd'
|
||||
advice_regex = "\#\!\/bin\/sh.*" \
|
||||
"pkg_add[\s]+\-r[\s]+nss\-pam\-ldapd[\s]+curl.*" \
|
||||
"\/usr\/local\/etc\/rc\.d\/nslcd[\s]+restart"
|
||||
advice_regex = r"\#\!\/bin\/sh.*" \
|
||||
r"pkg_add[\s]+\-r[\s]+nss\-pam\-ldapd[\s]+curl.*" \
|
||||
r"\/usr\/local\/etc\/rc\.d\/nslcd[\s]+restart"
|
||||
raiseerr = True
|
||||
|
||||
run_advice(self.master, advice_id, advice_regex, raiseerr)
|
||||
@@ -68,21 +68,23 @@ class TestAdvice(IntegrationTest):
|
||||
|
||||
def test_advice_GenericNSSPAM(self):
|
||||
advice_id = 'config-generic-linux-nss-pam-ldapd'
|
||||
advice_regex = "\#\!\/bin\/sh.*" \
|
||||
"apt\-get[\s]+\-y[\s]+install[\s]+curl[\s]+openssl[\s]+" \
|
||||
"libnss\-ldapd[\s]+libpam\-ldapd[\s]+nslcd.*" \
|
||||
"service[\s]+nscd[\s]+stop[\s]+\&\&[\s]+service[\s]+" \
|
||||
"nslcd[\s]+restart"
|
||||
advice_regex = (
|
||||
r"\#\!\/bin\/sh.*"
|
||||
r"apt\-get[\s]+\-y[\s]+install[\s]+curl[\s]+openssl[\s]+"
|
||||
r"libnss\-ldapd[\s]+libpam\-ldapd[\s]+nslcd.*"
|
||||
r"service[\s]+nscd[\s]+stop[\s]+\&\&[\s]+service[\s]+"
|
||||
r"nslcd[\s]+restart"
|
||||
)
|
||||
raiseerr = True
|
||||
|
||||
run_advice(self.master, advice_id, advice_regex, raiseerr)
|
||||
|
||||
|
||||
def test_advice_GenericSSSDBefore19(self):
|
||||
advice_id = 'config-generic-linux-sssd-before-1-9'
|
||||
advice_regex = "\#\!\/bin\/sh.*" \
|
||||
"apt\-get[\s]+\-y[\s]+install sssd curl openssl.*" \
|
||||
"service[\s]+sssd[\s]+start"
|
||||
advice_id = r'config-generic-linux-sssd-before-1-9'
|
||||
advice_regex = r"\#\!\/bin\/sh.*" \
|
||||
r"apt\-get[\s]+\-y[\s]+install sssd curl openssl.*" \
|
||||
r"service[\s]+sssd[\s]+start"
|
||||
raiseerr = True
|
||||
|
||||
run_advice(self.master, advice_id, advice_regex, raiseerr)
|
||||
@@ -90,12 +92,14 @@ class TestAdvice(IntegrationTest):
|
||||
|
||||
def test_advice_RedHatNSS(self):
|
||||
advice_id = 'config-redhat-nss-ldap'
|
||||
advice_regex = "\#\!\/bin\/sh.*" \
|
||||
"yum[\s]+install[\s]+\-y[\s]+curl[\s]+openssl[\s]+nss_ldap" \
|
||||
"[\s]+authconfig.*authconfig[\s]+\-\-updateall" \
|
||||
"[\s]+\-\-enableldap[\s]+\-\-enableldaptls"\
|
||||
"[\s]+\-\-enableldapauth[\s]+" \
|
||||
"\-\-ldapserver=.*[\s]+\-\-ldapbasedn=.*"
|
||||
advice_regex = (
|
||||
r"\#\!\/bin\/sh.*"
|
||||
r"yum[\s]+install[\s]+\-y[\s]+curl[\s]+openssl[\s]+nss_ldap"
|
||||
r"[\s]+authconfig.*authconfig[\s]+\-\-updateall"
|
||||
r"[\s]+\-\-enableldap[\s]+\-\-enableldaptls"
|
||||
r"[\s]+\-\-enableldapauth[\s]+"
|
||||
r"\-\-ldapserver=.*[\s]+\-\-ldapbasedn=.*"
|
||||
)
|
||||
raiseerr = True
|
||||
|
||||
run_advice(self.master, advice_id, advice_regex, raiseerr)
|
||||
@@ -103,12 +107,12 @@ class TestAdvice(IntegrationTest):
|
||||
|
||||
def test_advice_RedHatNSSPAM(self):
|
||||
advice_id = 'config-redhat-nss-pam-ldapd'
|
||||
advice_regex = "\#\!\/bin\/sh.*" \
|
||||
"yum[\s]+install[\s]+\-y[\s]+curl[\s]+openssl[\s]+" \
|
||||
"nss\-pam\-ldapd[\s]+pam_ldap[\s]+authconfig.*" \
|
||||
"authconfig[\s]+\-\-updateall[\s]+\-\-enableldap"\
|
||||
"[\s]+\-\-enableldaptls[\s]+\-\-enableldapauth[\s]+" \
|
||||
"\-\-ldapserver=.*[\s]+\-\-ldapbasedn=.*"
|
||||
advice_regex = r"\#\!\/bin\/sh.*" \
|
||||
r"yum[\s]+install[\s]+\-y[\s]+curl[\s]+openssl[\s]+" \
|
||||
r"nss\-pam\-ldapd[\s]+pam_ldap[\s]+authconfig.*" \
|
||||
r"authconfig[\s]+\-\-updateall[\s]+\-\-enableldap"\
|
||||
r"[\s]+\-\-enableldaptls[\s]+\-\-enableldapauth[\s]+" \
|
||||
r"\-\-ldapserver=.*[\s]+\-\-ldapbasedn=.*"
|
||||
raiseerr = True
|
||||
|
||||
run_advice(self.master, advice_id, advice_regex, raiseerr)
|
||||
@@ -116,9 +120,11 @@ class TestAdvice(IntegrationTest):
|
||||
|
||||
def test_advice_RedHatSSSDBefore19(self):
|
||||
advice_id = 'config-redhat-sssd-before-1-9'
|
||||
advice_regex = "\#\!\/bin\/sh.*" \
|
||||
"yum[\s]+install[\s]+\-y[\s]+sssd[\s]+authconfig[\s]+" \
|
||||
"curl[\s]+openssl.*service[\s]+sssd[\s]+start"
|
||||
advice_regex = (
|
||||
r"\#\!\/bin\/sh.*"
|
||||
r"yum[\s]+install[\s]+\-y[\s]+sssd[\s]+authconfig[\s]+"
|
||||
r"curl[\s]+openssl.*service[\s]+sssd[\s]+start"
|
||||
)
|
||||
raiseerr = True
|
||||
|
||||
run_advice(self.master, advice_id, advice_regex, raiseerr)
|
||||
|
||||
@@ -91,7 +91,7 @@ def check_admin_in_id(host):
|
||||
|
||||
def check_certs(host):
|
||||
result = host.run_command(['ipa', 'cert-find'])
|
||||
assert re.search('^Number of entries returned [1-9]\d*$',
|
||||
assert re.search(r'^Number of entries returned [1-9]\d*$',
|
||||
result.stdout_text, re.MULTILINE), result.stdout_text
|
||||
return result
|
||||
|
||||
|
||||
@@ -36,12 +36,12 @@ class TestHttpKdcProxy(IntegrationTest):
|
||||
'--dport', '88', '-j', 'DROP'])
|
||||
# configure client
|
||||
cls.clients[0].run_command(
|
||||
"sed -i 's/ kdc = .*$/ kdc = https:\/\/%s\/KdcProxy/' %s" % (
|
||||
r"sed -i 's/ kdc = .*$/ kdc = https:\/\/%s\/KdcProxy/' %s" % (
|
||||
cls.master.hostname, paths.KRB5_CONF)
|
||||
)
|
||||
cls.clients[0].run_command(
|
||||
"sed -i 's/master_kdc = .*$/master_kdc"
|
||||
" = https:\/\/%s\/KdcProxy/' %s" % (
|
||||
r"sed -i 's/master_kdc = .*$/master_kdc"
|
||||
r" = https:\/\/%s\/KdcProxy/' %s" % (
|
||||
cls.master.hostname, paths.KRB5_CONF)
|
||||
)
|
||||
# Workaround for https://fedorahosted.org/freeipa/ticket/6443
|
||||
|
||||
@@ -90,8 +90,8 @@ class BaseTestLegacyClient(object):
|
||||
self.clear_sssd_caches()
|
||||
result = self.legacy_client.run_command(['getent', 'passwd', 'admin'])
|
||||
|
||||
admin_regex = "admin:\*:(\d+):(\d+):"\
|
||||
"Administrator:/home/admin:/bin/bash"
|
||||
admin_regex = r"admin:\*:(\d+):(\d+):"\
|
||||
r"Administrator:/home/admin:/bin/bash"
|
||||
|
||||
assert re.search(admin_regex, result.stdout_text)
|
||||
|
||||
@@ -99,7 +99,7 @@ class BaseTestLegacyClient(object):
|
||||
self.clear_sssd_caches()
|
||||
result = self.legacy_client.run_command(['getent', 'group', 'admins'])
|
||||
|
||||
admin_group_regex = "admins:\*:(\d+):admin"
|
||||
admin_group_regex = r"admins:\*:(\d+):admin"
|
||||
|
||||
assert re.search(admin_group_regex, result.stdout_text)
|
||||
|
||||
@@ -107,9 +107,9 @@ class BaseTestLegacyClient(object):
|
||||
self.clear_sssd_caches()
|
||||
result = self.legacy_client.run_command(['id', 'admin'])
|
||||
|
||||
uid_regex = "uid=(\d+)\(admin\)"
|
||||
gid_regex = "gid=(\d+)\(admins\)"
|
||||
groups_regex = "groups=(\d+)\(admins\)"
|
||||
uid_regex = r"uid=(\d+)\(admin\)"
|
||||
gid_regex = r"gid=(\d+)\(admins\)"
|
||||
groups_regex = r"groups=(\d+)\(admins\)"
|
||||
|
||||
assert re.search(uid_regex, result.stdout_text)
|
||||
assert re.search(gid_regex, result.stdout_text)
|
||||
@@ -120,8 +120,8 @@ class BaseTestLegacyClient(object):
|
||||
testuser = 'testuser@%s' % self.ad.domain.name
|
||||
result = self.legacy_client.run_command(['getent', 'passwd', testuser])
|
||||
|
||||
testuser_regex = "testuser@%s:\*:%s:%s:"\
|
||||
"Test User:%s:/bin/sh"\
|
||||
testuser_regex = r"testuser@%s:\*:%s:%s:"\
|
||||
r"Test User:%s:/bin/sh"\
|
||||
% (re.escape(self.ad.domain.name),
|
||||
self.testuser_uid_regex,
|
||||
self.testuser_gid_regex,
|
||||
@@ -137,7 +137,7 @@ class BaseTestLegacyClient(object):
|
||||
testgroup = 'testgroup@%s' % self.ad.domain.name
|
||||
result = self.legacy_client.run_command(['getent', 'group', testgroup])
|
||||
|
||||
testgroup_regex = "%s:\*:%s:" % (testgroup, self.testuser_gid_regex)
|
||||
testgroup_regex = r"%s:\*:%s:" % (testgroup, self.testuser_gid_regex)
|
||||
assert re.search(testgroup_regex, result.stdout_text)
|
||||
|
||||
def test_id_ad_user(self):
|
||||
@@ -239,9 +239,9 @@ class BaseTestLegacyClient(object):
|
||||
testuser = 'subdomaintestuser@%s' % self.ad_subdomain
|
||||
result = self.legacy_client.run_command(['getent', 'passwd', testuser])
|
||||
|
||||
testuser_regex = "subdomaintestuser@%s:\*:%s:%s:"\
|
||||
"Subdomaintest User:%s:"\
|
||||
"/bin/sh"\
|
||||
testuser_regex = r"subdomaintestuser@%s:\*:%s:%s:"\
|
||||
r"Subdomaintest User:%s:"\
|
||||
r"/bin/sh"\
|
||||
% (re.escape(self.ad_subdomain),
|
||||
self.subdomain_testuser_uid_regex,
|
||||
self.subdomain_testuser_gid_regex,
|
||||
@@ -260,7 +260,7 @@ class BaseTestLegacyClient(object):
|
||||
testgroup = 'subdomaintestgroup@%s' % self.ad_subdomain
|
||||
result = self.legacy_client.run_command(['getent', 'group', testgroup])
|
||||
|
||||
testgroup_stdout = "%s:\*:%s:" % (testgroup,
|
||||
testgroup_stdout = r"%s:\*:%s:" % (testgroup,
|
||||
self.subdomain_testuser_gid_regex)
|
||||
assert re.search(testgroup_stdout, result.stdout_text)
|
||||
|
||||
@@ -338,8 +338,8 @@ class BaseTestLegacyClient(object):
|
||||
testuser = 'treetestuser@{0}'.format(self.ad_treedomain)
|
||||
result = self.legacy_client.run_command(['getent', 'passwd', testuser])
|
||||
|
||||
testuser_regex = ("treetestuser@{0}:\*:{1}:{2}:TreeTest User:"
|
||||
"/home/{0}/treetestuser:/bin/sh".format(
|
||||
testuser_regex = (r"treetestuser@{0}:\*:{1}:{2}:TreeTest User:"
|
||||
r"/home/{0}/treetestuser:/bin/sh".format(
|
||||
re.escape(self.ad_treedomain),
|
||||
self.treedomain_testuser_uid_regex,
|
||||
self.treedomain_testuser_gid_regex))
|
||||
@@ -354,7 +354,7 @@ class BaseTestLegacyClient(object):
|
||||
testgroup = 'treetestgroup@{0}'.format(self.ad_treedomain)
|
||||
result = self.legacy_client.run_command(['getent', 'group', testgroup])
|
||||
|
||||
testgroup_stdout = "{0}:\*:{1}:".format(
|
||||
testgroup_stdout = r"{0}:\*:{1}:".format(
|
||||
testgroup, self.treedomain_testuser_gid_regex)
|
||||
|
||||
assert re.search(testgroup_stdout, result.stdout_text)
|
||||
@@ -518,12 +518,12 @@ class BaseTestLegacyClientPosix(BaseTestLegacyClient,
|
||||
class BaseTestLegacyClientNonPosix(BaseTestLegacyClient,
|
||||
trust_tests.TestBasicADTrust):
|
||||
|
||||
testuser_uid_regex = '(?!10042)(\d+)'
|
||||
testuser_gid_regex = '(?!10047)(\d+)'
|
||||
subdomain_testuser_uid_regex = '(?!10142)(\d+)'
|
||||
subdomain_testuser_gid_regex = '(?!10147)(\d+)'
|
||||
treedomain_testuser_uid_regex = '(?!10242)(\d+)'
|
||||
treedomain_testuser_gid_regex = '(?!10247)(\d+)'
|
||||
testuser_uid_regex = r'(?!10042)(\d+)'
|
||||
testuser_gid_regex = r'(?!10047)(\d+)'
|
||||
subdomain_testuser_uid_regex = r'(?!10142)(\d+)'
|
||||
subdomain_testuser_gid_regex = r'(?!10147)(\d+)'
|
||||
treedomain_testuser_uid_regex = r'(?!10242)(\d+)'
|
||||
treedomain_testuser_gid_regex = r'(?!10247)(\d+)'
|
||||
|
||||
def test_remove_nonposix_trust(self):
|
||||
pass
|
||||
|
||||
@@ -31,13 +31,13 @@ def find_segment(master, replica):
|
||||
class TestTopologyOptions(IntegrationTest):
|
||||
num_replicas = 2
|
||||
topology = 'star'
|
||||
rawsegment_re = ('Segment name: (?P<name>.*?)',
|
||||
'\s+Left node: (?P<lnode>.*?)',
|
||||
'\s+Right node: (?P<rnode>.*?)',
|
||||
'\s+Connectivity: (?P<connectivity>\S+)')
|
||||
rawsegment_re = (r'Segment name: (?P<name>.*?)',
|
||||
r'\s+Left node: (?P<lnode>.*?)',
|
||||
r'\s+Right node: (?P<rnode>.*?)',
|
||||
r'\s+Connectivity: (?P<connectivity>\S+)')
|
||||
segment_re = re.compile("\n".join(rawsegment_re))
|
||||
noentries_re = re.compile("Number of entries returned (\d+)")
|
||||
segmentnames_re = re.compile('.*Segment name: (\S+?)\n.*')
|
||||
noentries_re = re.compile(r"Number of entries returned (\d+)")
|
||||
segmentnames_re = re.compile(r'.*Segment name: (\S+?)\n.*')
|
||||
|
||||
@classmethod
|
||||
def install(cls, mh):
|
||||
@@ -196,7 +196,7 @@ class TestCASpecificRUVs(IntegrationTest):
|
||||
"Certificate Server Replica"
|
||||
" Update Vectors" in res1.stdout_text), (
|
||||
"CA-specific RUVs are not displayed")
|
||||
ruvid_re = re.compile(".*%s:389: (\d+).*" % replica.hostname)
|
||||
ruvid_re = re.compile(r".*%s:389: (\d+).*" % replica.hostname)
|
||||
replica_ruvs = ruvid_re.findall(res1.stdout_text)
|
||||
# Find out the number of RUVids
|
||||
assert(len(replica_ruvs) == 2), (
|
||||
@@ -271,7 +271,7 @@ class TestReplicaManageDel(IntegrationTest):
|
||||
num_ruvs = result.stdout_text.count(replica.hostname)
|
||||
assert(num_ruvs == 1), ("Expected to find 1 replica's RUV, found %s" %
|
||||
num_ruvs)
|
||||
ruvid_re = re.compile(".*%s:389: (\d+).*" % replica.hostname)
|
||||
ruvid_re = re.compile(r".*%s:389: (\d+).*" % replica.hostname)
|
||||
replica_ruvs = ruvid_re.findall(result.stdout_text)
|
||||
master.run_command(['ipa-replica-manage', 'clean-ruv', '-f',
|
||||
'-p', master.config.dirman_password,
|
||||
@@ -294,7 +294,7 @@ class TestReplicaManageDel(IntegrationTest):
|
||||
master.config.dirman_password, replica.hostname])
|
||||
result1 = master.run_command(['ipa-replica-manage', 'list-ruv', '-p',
|
||||
master.config.dirman_password])
|
||||
ruvid_re = re.compile(".*%s:389: (\d+).*" % replica.hostname)
|
||||
ruvid_re = re.compile(r".*%s:389: (\d+).*" % replica.hostname)
|
||||
assert(ruvid_re.search(result1.stdout_text)), (
|
||||
"Replica's RUV should not be removed under domain level 0")
|
||||
master.run_command(['ipa-replica-manage', 'clean-dangling-ruv', '-p',
|
||||
|
||||
@@ -172,8 +172,8 @@ class TestBasicADTrust(ADTrustBase):
|
||||
|
||||
# This regex checks that Test User does not have UID 10042 nor belongs
|
||||
# to the group with GID 10047
|
||||
testuser_regex = "^testuser@%s:\*:(?!10042)(\d+):(?!10047)(\d+):"\
|
||||
"Test User:/home/%s/testuser:/bin/sh$"\
|
||||
testuser_regex = r"^testuser@%s:\*:(?!10042)(\d+):(?!10047)(\d+):"\
|
||||
r"Test User:/home/%s/testuser:/bin/sh$"\
|
||||
% (re.escape(self.ad_domain),
|
||||
re.escape(self.ad_domain))
|
||||
|
||||
@@ -321,9 +321,9 @@ class TestExternalTrustWithSubdomain(ADTrustSubdomainBase):
|
||||
testuser = 'subdomaintestuser@{0}'.format(self.ad_subdomain)
|
||||
result = self.master.run_command(['getent', 'passwd', testuser])
|
||||
|
||||
testuser_regex = ("^subdomaintestuser@{0}:\*:(?!10142)(\d+):"
|
||||
"(?!10147)(\d+):Subdomaintest User:"
|
||||
"/home/{1}/subdomaintestuser:/bin/sh$".format(
|
||||
testuser_regex = (r"^subdomaintestuser@{0}:\*:(?!10142)(\d+):"
|
||||
r"(?!10147)(\d+):Subdomaintest User:"
|
||||
r"/home/{1}/subdomaintestuser:/bin/sh$".format(
|
||||
re.escape(self.ad_subdomain),
|
||||
re.escape(self.ad_subdomain)))
|
||||
|
||||
@@ -388,9 +388,9 @@ class TestExternalTrustWithTreedomain(ADTrustTreedomainBase):
|
||||
testuser = 'treetestuser@{0}'.format(self.ad_treedomain)
|
||||
result = self.master.run_command(['getent', 'passwd', testuser])
|
||||
|
||||
testuser_regex = ("^treetestuser@{0}:\*:(?!10242)(\d+):"
|
||||
"(?!10247)(\d+):TreeTest User:"
|
||||
"/home/{1}/treetestuser:/bin/sh$".format(
|
||||
testuser_regex = (r"^treetestuser@{0}:\*:(?!10242)(\d+):"
|
||||
r"(?!10247)(\d+):TreeTest User:"
|
||||
r"/home/{1}/treetestuser:/bin/sh$".format(
|
||||
re.escape(self.ad_treedomain),
|
||||
re.escape(self.ad_treedomain)))
|
||||
|
||||
@@ -483,9 +483,11 @@ class TestTrustWithUPN(ADTrustBase):
|
||||
self.upn_principal])
|
||||
|
||||
# result will contain AD domain, not UPN
|
||||
upnuser_regex = "^{}@{}:\*:(\d+):(\d+):{}:/home/{}/{}:/bin/sh$".format(
|
||||
self.upn_username, self.ad_domain, self.upn_name,
|
||||
self.ad_domain, self.upn_username)
|
||||
upnuser_regex = (
|
||||
r"^{}@{}:\*:(\d+):(\d+):{}:/home/{}/{}:/bin/sh$".format(
|
||||
self.upn_username, self.ad_domain, self.upn_name,
|
||||
self.ad_domain, self.upn_username)
|
||||
)
|
||||
assert re.search(upnuser_regex, result.stdout_text)
|
||||
|
||||
def test_upn_user_authentication(self):
|
||||
|
||||
@@ -866,7 +866,7 @@ class test_Bytes(ClassChecker):
|
||||
Test the `ipalib.parameters.Bytes._rule_pattern` method.
|
||||
"""
|
||||
# Test our assumptions about Python re module and Unicode:
|
||||
pat = b'\w+$'
|
||||
pat = br'\w+$'
|
||||
r = re.compile(pat)
|
||||
assert r.match(b'Hello_World') is not None
|
||||
assert r.match(utf8_bytes) is None
|
||||
@@ -1016,7 +1016,7 @@ class test_Str(ClassChecker):
|
||||
Test the `ipalib.parameters.Str._rule_pattern` method.
|
||||
"""
|
||||
# Test our assumptions about Python re module and Unicode:
|
||||
pat = '\w{5}$'
|
||||
pat = r'\w{5}$'
|
||||
r1 = re.compile(pat)
|
||||
r2 = re.compile(pat, re.UNICODE)
|
||||
if six.PY2:
|
||||
|
||||
@@ -389,7 +389,8 @@ class test_rpcclient_context(PluginTester):
|
||||
"""
|
||||
Test that session_cookie is set in `ipalib.rpc.rpcclient.connect`
|
||||
"""
|
||||
fuzzy_cookie = Fuzzy('^ipa_session=MagBearerToken=[A-Za-z0-9+\/]+=*;$')
|
||||
fuzzy_cookie = Fuzzy(
|
||||
r'^ipa_session=MagBearerToken=[A-Za-z0-9+\/]+=*;$')
|
||||
|
||||
session_cookie = getattr(context, 'session_cookie', None)
|
||||
# pylint-2 is incorrectly spewing Too many positional arguments
|
||||
|
||||
@@ -16,7 +16,7 @@ valid_principals = {
|
||||
'realm': u'REALM.TEST',
|
||||
'username': u'tuser'
|
||||
},
|
||||
u'tuser\@tupn.test@REALM.TEST': {
|
||||
u'tuser\\@tupn.test@REALM.TEST': {
|
||||
'components': (u'tuser@tupn.test',),
|
||||
'realm': u'REALM.TEST',
|
||||
'username': u'tuser@tupn.test',
|
||||
@@ -54,11 +54,11 @@ valid_principals = {
|
||||
'hostname': u'$%^.ipa.t%$t',
|
||||
'service_name': u's$c'
|
||||
},
|
||||
u'test\/service/test\/host@REALM\@TEST': {
|
||||
u'test\\/service/test\\/host@REALM\\@TEST': {
|
||||
'components': (u'test/service', u'test/host'),
|
||||
'realm': u'REALM@TEST',
|
||||
'hostname': u'test/host',
|
||||
'service_name': u'test\/service'
|
||||
'service_name': r'test\/service'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ principals_properties = {
|
||||
'property_true': ('is_service'),
|
||||
'property_raises': ('username', 'upn_suffix')
|
||||
},
|
||||
u'user\@domain@REALM': {
|
||||
u'user\\@domain@REALM': {
|
||||
'property_true': ('is_user', 'is_enterprise'),
|
||||
'property_raises': ('hostname', 'service_name')
|
||||
}
|
||||
|
||||
@@ -914,7 +914,7 @@ class UI_driver(object):
|
||||
self.del_multivalued(name, value, parent)
|
||||
|
||||
def check_option(self, name, value=None, parent=None):
|
||||
"""
|
||||
r"""
|
||||
Find checkbox or radio with name which matches ^NAME\d$ and
|
||||
check it by clicking on a label.
|
||||
"""
|
||||
@@ -929,7 +929,7 @@ class UI_driver(object):
|
||||
# Select only the one which matches exactly the name
|
||||
for o in opts:
|
||||
n = o.get_attribute("name")
|
||||
if n == name or re.match("^%s\d+$" % name, n):
|
||||
if n == name or re.match(r"^%s\d+$" % name, n):
|
||||
s = "label[for='%s']" % o.get_attribute("id")
|
||||
label = self.find(s, By.CSS_SELECTOR, parent, strict=True)
|
||||
checkbox = o
|
||||
|
||||
@@ -255,7 +255,7 @@ class TestKerberosAliasExceptions(XMLRPC_test):
|
||||
# Add an alias overlapping the trusted domain realm
|
||||
with pytest.raises(errors.ValidationError):
|
||||
krbalias_user.add_principal(
|
||||
u'{username}\@{trusted_domain}@{realm}'.format(
|
||||
u'{username}\\@{trusted_domain}@{realm}'.format(
|
||||
username=krbalias_user.name,
|
||||
trusted_domain=trusted_domain['name'],
|
||||
realm=api.env.realm
|
||||
@@ -273,7 +273,7 @@ class TestKerberosAliasExceptions(XMLRPC_test):
|
||||
|
||||
with pytest.raises(errors.ValidationError):
|
||||
krbalias_user.add_principal(
|
||||
u'{username}\@{trusted_domain}@{realm}'.format(
|
||||
u'{username}\\@{trusted_domain}@{realm}'.format(
|
||||
username=krbalias_user.name,
|
||||
trusted_domain=upn_suffix,
|
||||
realm=api.env.realm
|
||||
@@ -291,7 +291,7 @@ class TestKerberosAliasExceptions(XMLRPC_test):
|
||||
|
||||
with pytest.raises(errors.ValidationError):
|
||||
krbalias_user.add_principal(
|
||||
u'{username}\@{trusted_domain}@{realm}'.format(
|
||||
u'{username}\\@{trusted_domain}@{realm}'.format(
|
||||
username=krbalias_user.name,
|
||||
trusted_domain=netbios_name,
|
||||
realm=api.env.realm
|
||||
|
||||
@@ -76,7 +76,7 @@ invalid_expiration_string = "2020-12-07 19:54:13"
|
||||
expired_expiration_string = "1991-12-07T19:54:13Z"
|
||||
|
||||
# Date in ISO format (2013-12-10T12:00:00)
|
||||
isodate_re = re.compile('^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$')
|
||||
isodate_re = re.compile(r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$')
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
|
||||
@@ -43,7 +43,7 @@ else:
|
||||
# Matches a gidnumber like '1391016742'
|
||||
# FIXME: Does it make more sense to return gidnumber, uidnumber, etc. as `int`
|
||||
# or `long`? If not, we still need to return them as `unicode` instead of `str`.
|
||||
fuzzy_digits = Fuzzy('^\d+$', type=six.string_types)
|
||||
fuzzy_digits = Fuzzy(r'^\d+$', type=six.string_types)
|
||||
|
||||
uuid_re = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
|
||||
|
||||
@@ -71,7 +71,7 @@ def fuzzy_sequence_of(fuzzy):
|
||||
|
||||
# Matches an automember task finish message
|
||||
fuzzy_automember_message = Fuzzy(
|
||||
'^Automember rebuild task finished\. Processed \(\d+\) entries\.$'
|
||||
r'^Automember rebuild task finished\. Processed \(\d+\) entries\.$'
|
||||
)
|
||||
|
||||
# Matches trusted domain GUID, like u'463bf2be-3456-4a57-979e-120304f2a0eb'
|
||||
@@ -109,19 +109,23 @@ fuzzy_caid = fuzzy_uuid
|
||||
fuzzy_ipauniqueid = Fuzzy('(?i)ipauniqueid=%s' % uuid_re)
|
||||
|
||||
# Matches a hash signature, not enforcing length
|
||||
fuzzy_hash = Fuzzy('^([a-f0-9][a-f0-9]:)+[a-f0-9][a-f0-9]$', type=six.string_types)
|
||||
fuzzy_hash = Fuzzy(
|
||||
r'^([a-f0-9][a-f0-9]:)+[a-f0-9][a-f0-9]$', type=six.string_types
|
||||
)
|
||||
|
||||
# Matches a date, like Tue Apr 26 17:45:35 2016 UTC
|
||||
fuzzy_date = Fuzzy('^[a-zA-Z]{3} [a-zA-Z]{3} \d{2} \d{2}:\d{2}:\d{2} \d{4} UTC$')
|
||||
fuzzy_date = Fuzzy(
|
||||
r'^[a-zA-Z]{3} [a-zA-Z]{3} \d{2} \d{2}:\d{2}:\d{2} \d{4} UTC$'
|
||||
)
|
||||
|
||||
fuzzy_issuer = Fuzzy(type=six.string_types)
|
||||
|
||||
fuzzy_hex = Fuzzy('^0x[0-9a-fA-F]+$', type=six.string_types)
|
||||
fuzzy_hex = Fuzzy(r'^0x[0-9a-fA-F]+$', type=six.string_types)
|
||||
|
||||
# Matches password - password consists of all printable characters without
|
||||
# whitespaces. The only exception is space, but space cannot be at the
|
||||
# beginning or end of the pwd.
|
||||
fuzzy_password = Fuzzy('^\S([\S ]*\S)*$')
|
||||
fuzzy_password = Fuzzy(r'^\S([\S ]*\S)*$')
|
||||
|
||||
# Matches generalized time value. Time format is: %Y%m%d%H%M%SZ
|
||||
fuzzy_dergeneralizedtime = Fuzzy(type=datetime.datetime)
|
||||
|
||||
@@ -203,7 +203,7 @@ class Fuzzy(object):
|
||||
The first optional argument *regex* is a regular expression pattern to
|
||||
match. For example, you could match a phone number like this:
|
||||
|
||||
>>> phone = Fuzzy('^\d{3}-\d{3}-\d{4}$')
|
||||
>>> phone = Fuzzy(r'^\d{3}-\d{3}-\d{4}$')
|
||||
>>> u'123-456-7890' == phone
|
||||
True
|
||||
|
||||
@@ -218,7 +218,7 @@ class Fuzzy(object):
|
||||
The *type* kwarg allows you to specify a type constraint, so you can force
|
||||
the above to work on ``str`` instances instead:
|
||||
|
||||
>>> '123-456-7890' == Fuzzy('^\d{3}-\d{3}-\d{4}$', type=str)
|
||||
>>> '123-456-7890' == Fuzzy(r'^\d{3}-\d{3}-\d{4}$', type=str)
|
||||
True
|
||||
|
||||
You can also use the *type* constraint on its own without the *regex*, for
|
||||
@@ -266,7 +266,7 @@ class Fuzzy(object):
|
||||
__hash__ = None
|
||||
|
||||
def __init__(self, regex=None, type=None, test=None):
|
||||
"""
|
||||
r"""
|
||||
Initialize.
|
||||
|
||||
:param regex: A regular expression pattern to match, e.g.
|
||||
@@ -593,7 +593,7 @@ class PluginTester(object):
|
||||
plugin = property(__get_plugin)
|
||||
|
||||
def register(self, *plugins, **kw):
|
||||
"""
|
||||
r"""
|
||||
Create a testing api and register ``self.plugin``.
|
||||
|
||||
This method returns an (api, home) tuple.
|
||||
|
||||
Reference in New Issue
Block a user