asfpy 0.51__tar.gz → 0.52__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: asfpy
3
- Version: 0.51
3
+ Version: 0.52
4
4
  Summary: ASF Common Python Methods
5
5
  Home-page: https://github.com/apache/infrastructure-asfpy/
6
6
  Author: ASF Infrastructure
7
7
  Author-email: users@infra.apache.org
8
8
  License: Apache
9
+ Platform: UNKNOWN
9
10
  Description-Content-Type: text/plain
10
11
  Provides-Extra: ldap
11
12
  Provides-Extra: aioldap
12
13
 
13
14
  This is a common set of functions used by the ASF Infrastructure team such as libraries for sending email, ldap management and generic process daemonization.
15
+
@@ -26,6 +26,7 @@ The above command will upload the `.whl` and the `.tar.gz` (the glob-asterisk is
26
26
 
27
27
  See [this guide](https://realpython.com/pypi-publish-python-package/#publish-your-package-to-pypi) for more details on working with PyPi.
28
28
 
29
+ Please also create a tag for the release.
29
30
 
30
31
  ### for testing
31
32
 
@@ -65,7 +65,7 @@ def ldapsearch_cli(
65
65
 
66
66
  # Run asfldapsearch tool, parse the output and return the data structure
67
67
  cliargs = ldapsearch_cliargs(ldap_base, ldap_scope, ldap_query, ldap_attrs, ldap_exec)
68
- output = subprocess.run(cliargs, stdout=subprocess.PIPE).stdout.decode("us-ascii")
68
+ output = subprocess.run(cliargs, stdout=subprocess.PIPE, check=True).stdout.decode("us-ascii")
69
69
  return ldapsearch_parse(output)
70
70
 
71
71
 
@@ -86,5 +86,5 @@ async def ldapsearch_cli_async(
86
86
  # Run asfldapsearch tool, parse the output and return the data structure
87
87
  cliargs = ldapsearch_cliargs(ldap_base, ldap_scope, ldap_query, ldap_attrs, ldap_exec)
88
88
  proc = await asyncio.subprocess.create_subprocess_exec(cliargs[0], *cliargs[1:], stdout=asyncio.subprocess.PIPE) # pylint: disable=no-member
89
- stdout, stderr = await proc.communicate() # "await proc.wait()" can deadlock inside async servers, so avoid using it.
89
+ stdout, _stderr = await proc.communicate() # "await proc.wait()" can deadlock inside async servers, so avoid using it.
90
90
  return ldapsearch_parse(stdout.decode("us-ascii"))
@@ -25,7 +25,6 @@ assert sys.version_info >= (3, 2)
25
25
 
26
26
  import ldap
27
27
  import ldap.modlist
28
- import ldif
29
28
  import re
30
29
  import crypt
31
30
  import random
@@ -45,6 +44,7 @@ LDAP_CN = 'cn=%s,%s'
45
44
 
46
45
  # INFRA-21590 ApacheID cannot have dashes.
47
46
  LDAP_VALID_UID_RE = re.compile(r"^[a-z0-9][a-z0-9_]+$")
47
+ LDAP_VALID_CN_RE = re.compile(r"^[-._a-z0-9]+$") # Valid cn, not necessarily what we consider a valid UID
48
48
  # New user account UIDs will be larger than this value.
49
49
  # Conversely: service accounts will be less than this.
50
50
  # NOTE: this value was chosen to ensure enough lower-value
@@ -303,6 +303,8 @@ class manager:
303
303
  return(uid)
304
304
  continue
305
305
 
306
+ raise ConnectionException('Unable to find a UID') # Should not happen, but ...
307
+
306
308
  except ldap.TIMEOUT:
307
309
  raise ConnectionException(BACKEND_TIMEOUT)
308
310
  except AssertionError:
@@ -336,6 +338,14 @@ class manager:
336
338
  uidnumber = self.next_user_uid()
337
339
 
338
340
  # Get surname and given name, validate against spurious whitespace
341
+
342
+ # N.B. in general, it is not possible to reliably extract these from a full name
343
+ # e.g. if the full name consists of more that 2 parts, how many are surnames?
344
+ # Also some cultures may reverse the order. Etc. Human namimg is very complicated.
345
+ # [The sn and givenName LDAP attributes don't apply to all cultures.]
346
+ # Luckily sn and givenName are not actually used, so this code can just satisfy the
347
+ # LDAP schema requirements without needing to be 100% accurate.
348
+
339
349
  names = fullname.split(' ')
340
350
  if len(names) < 2 and requireTwo:
341
351
  raise ValidatorException("Full name needs at least two parts!", 'fullname')
@@ -371,6 +381,10 @@ class manager:
371
381
  'host': 'home.apache.org',
372
382
  }
373
383
 
384
+ # givenName is optional; drop it if there is a single name
385
+ if len(names) == 1:
386
+ del ldiff['givenName']
387
+
374
388
  # Convert everything to bytestrings because ldap demands it...
375
389
  bytify(ldiff)
376
390
 
@@ -390,8 +404,8 @@ class manager:
390
404
  to_uid = to_uid.decode('ascii')
391
405
 
392
406
  # Validate from_uid and to_uid
393
- if not LDAP_VALID_UID_RE.match(from_uid):
394
- raise ValidatorException(f"Invalid UID '{from_uid}', must match ^[a-z0-9][a-z0-9_]+$")
407
+ if not LDAP_VALID_CN_RE.match(from_uid):
408
+ raise ValidatorException(f"Invalid UID '{from_uid}', must match ^[-._a-z0-9]+$")
395
409
  if not LDAP_VALID_UID_RE.match(to_uid):
396
410
  raise ValidatorException(f"Invalid UID '{to_uid}', must match ^[a-z0-9][a-z0-9_]+$")
397
411
 
@@ -1,13 +1,15 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: asfpy
3
- Version: 0.51
3
+ Version: 0.52
4
4
  Summary: ASF Common Python Methods
5
5
  Home-page: https://github.com/apache/infrastructure-asfpy/
6
6
  Author: ASF Infrastructure
7
7
  Author-email: users@infra.apache.org
8
8
  License: Apache
9
+ Platform: UNKNOWN
9
10
  Description-Content-Type: text/plain
10
11
  Provides-Extra: ldap
11
12
  Provides-Extra: aioldap
12
13
 
13
14
  This is a common set of functions used by the ASF Infrastructure team such as libraries for sending email, ldap management and generic process daemonization.
15
+
@@ -20,7 +20,7 @@ import setuptools
20
20
 
21
21
  def main():
22
22
  setuptools.setup(name='asfpy',
23
- version='0.51',
23
+ version='0.52',
24
24
  description='ASF Common Python Methods',
25
25
  long_description="This is a common set of functions used by the ASF Infrastructure team such as libraries for sending email, ldap management and generic process daemonization.",
26
26
  long_description_content_type = "text/plain",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes