Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-edgegrid-python for
openSUSE:Factory checked in at 2021-12-12 21:27:39
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-edgegrid-python (Old)
and /work/SRC/openSUSE:Factory/.python-edgegrid-python.new.2520 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-edgegrid-python"
Sun Dec 12 21:27:39 2021 rev:2 rq:939989 version:1.2.1
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-edgegrid-python/python-edgegrid-python.changes
2020-02-21 16:43:44.554199033 +0100
+++
/work/SRC/openSUSE:Factory/.python-edgegrid-python.new.2520/python-edgegrid-python.changes
2021-12-12 21:28:10.992361932 +0100
@@ -1,0 +2,10 @@
+Sat Dec 11 22:17:28 UTC 2021 - Dirk M??ller <[email protected]>
+
+- update to 1.2.1:
+ * recognize the ~ tilde character as home directory alias
+ * issues: add missing test resource files to PyPI package
+ * require PyOpenSSL >= v19.0.0 to avoid old OS packages
+ * split MANIFEST.in in several lines to properly include
+ in Python package all necessary resource files
+
+-------------------------------------------------------------------
Old:
----
edgegrid-python-1.1.1.tar.gz
New:
----
edgegrid-python-1.2.1.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-edgegrid-python.spec ++++++
--- /var/tmp/diff_new_pack.8yhUKC/_old 2021-12-12 21:28:11.484362223 +0100
+++ /var/tmp/diff_new_pack.8yhUKC/_new 2021-12-12 21:28:11.484362223 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-edgegrid-python
#
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-edgegrid-python
-Version: 1.1.1
+Version: 1.2.1
Release: 0
Summary: Client authentication protocol for python-requests
License: Apache-2.0
@@ -30,7 +30,7 @@
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-ndg-httpsclient
-Requires: python-pyOpenSSL >= 0.13
+Requires: python-pyOpenSSL >= 19.0.0
Requires: python-pyasn1
Requires: python-requests >= 2.3.0
Requires: python-urllib3
++++++ edgegrid-python-1.1.1.tar.gz -> edgegrid-python-1.2.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/edgegrid-python-1.1.1/MANIFEST.in
new/edgegrid-python-1.2.1/MANIFEST.in
--- old/edgegrid-python-1.1.1/MANIFEST.in 2015-02-28 18:25:38.000000000
+0100
+++ new/edgegrid-python-1.2.1/MANIFEST.in 2021-10-11 09:27:16.000000000
+0200
@@ -1 +1,6 @@
-include README.rst LICENSE requirements.txt akamai/edgegrid/test/testdata.json
+include README.rst
+include LICENSE
+include requirements.txt
+include akamai/edgegrid/test/testdata.json
+include akamai/edgegrid/test/sample_edgerc
+include akamai/edgegrid/test/edgerc_that_doesnt_parse
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/edgegrid-python-1.1.1/PKG-INFO
new/edgegrid-python-1.2.1/PKG-INFO
--- old/edgegrid-python-1.1.1/PKG-INFO 2018-07-16 21:37:19.000000000 +0200
+++ new/edgegrid-python-1.2.1/PKG-INFO 2021-10-11 09:39:22.888507000 +0200
@@ -1,10 +1,19 @@
-Metadata-Version: 1.0
+Metadata-Version: 2.1
Name: edgegrid-python
-Version: 1.1.1
+Version: 1.2.1
Summary: {OPEN} client authentication protocol for python-requests
-Home-page: https://github.com/akamai-open/AkamaiOPEN-edgegrid-python
+Home-page: https://github.com/akamai/AkamaiOPEN-edgegrid-python
Author: Jonathan Landis
Author-email: [email protected]
-License: LICENSE.txt
-Description: UNKNOWN
+Maintainer: Akamai Developer Experience team
+Maintainer-email: [email protected]
+License: Apache 2.0
Platform: UNKNOWN
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Requires-Python: >=2.7.10
+License-File: LICENSE
+
+UNKNOWN
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/edgegrid-python-1.1.1/README.rst
new/edgegrid-python-1.2.1/README.rst
--- old/edgegrid-python-1.1.1/README.rst 2018-07-16 21:33:09.000000000
+0200
+++ new/edgegrid-python-1.2.1/README.rst 2021-10-11 09:27:16.000000000
+0200
@@ -9,7 +9,7 @@
>>> import requests
>>> from akamai.edgegrid import EdgeGridAuth
- >>> from urlparse import urljoin
+ >>> from urllib.parse import urljoin
>>> baseurl = 'https://akaa-WWWWWWWWWWWW.luna.akamaiapis.net/'
>>> s = requests.Session()
>>> s.auth = EdgeGridAuth(
@@ -31,7 +31,7 @@
>>> import requests
>>> from akamai.edgegrid import EdgeGridAuth, EdgeRc
- >>> from urlparse import urljoin
+ >>> from urllib.parse import urljoin
>>> edgerc = EdgeRc('~/.edgerc')
>>> section = 'default'
@@ -47,6 +47,12 @@
Oakbrook, IL, United States
...
+If you intend to run the above examples with Python 2.7, remember that urljoin
is contained in a different package:
+
+.. code-block:: pycon
+
+ >>> from urlparse import urljoin
+
.. _`requests`: http://docs.python-requests.org
.. _`Akamai {OPEN} Edgegrid authentication`:
https://developer.akamai.com/introduction/Client_Auth.html
.. _`Akamai {OPEN} Developer Community`: https://developer.akamai.com
@@ -54,35 +60,65 @@
Installation
------------
-Pre-requisite
--------------
-If you are installing on a Linux based distribution, you will need to instal
the developer libraries for python, ssl and a ffi. On Ubuntu based systems, you
will need to do the following:
+**Prerequisite**
+
+For Linux-based distribution, install the developer libraries for Python, SSL
and FFI. For example, on Debian-based systems, run:
+
+.. code-block:: bash
+
+ $ sudo apt-get install ibssl-dev libffi-dev python-dev
+
+**To install from pip**
+
+We recommend using any recent Python 3 distribution. Starting from version 3.4
of the cryptography package, Python 2.7 is no longer supported.
+
+If you still want to use Python 2.7, first run:
.. code-block:: bash
- $ sudo apt-get install ibssl-dev libffi-dev python-dev
+ $ pip install --upgrade 'cryptography<3.4'
-To install from pip:
+To continue with the installation:
.. code-block:: bash
$ pip install edgegrid-python
-To install from sources:
+**To install from sources**
.. code-block:: bash
$ python setup.py install
-To run tests:
+**To run tests**
+
+Both Python 2 and Python 3 are supported. This example uses Python 2.7. Run:
.. code-block:: bash
$ virtualenv -p python2.7 venv
$ . venv/bin/activate
+ $ pip install 'cryptography<3.4' # just necessary for Python 2.7
$ pip install -r requirements.txt
$ python -m unittest discover
+For Python 3.3 or newer, replace the `virtualenv` module with `venv`. Run:
+
+.. code-block:: bash
+
+ $ python3 -m venv venv
+ $ . venv/bin/activate
+ $ pip install -r requirements.txt
+ $ python -m unittest discover
+
+Creating your own .edgerc
+----------
+
+#. Copy the `akamai/edgegrid/test/sample_edgerc` file to your home directory
and rename as `.edgerc`.
+#. Edit the copied file and provide your own credentials. For more information
on creating an `.edgerc` file, see `Get started with APIs`_.
+
+.. _`Get started with APIs`:
https://developer.akamai.com/api/getting-started#edgercfile
+
Contribute
----------
@@ -100,7 +136,7 @@
License
-------
- Copyright 2015 Akamai Technologies, Inc. All rights reserved.
+ Copyright 2021 Akamai Technologies, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/edgegrid-python-1.1.1/akamai/edgegrid/__init__.py
new/edgegrid-python-1.2.1/akamai/edgegrid/__init__.py
--- old/edgegrid-python-1.1.1/akamai/edgegrid/__init__.py 2017-09-11
21:27:36.000000000 +0200
+++ new/edgegrid-python-1.2.1/akamai/edgegrid/__init__.py 2021-10-11
09:27:16.000000000 +0200
@@ -2,8 +2,8 @@
akamai.edgegrid
~~~~~~~~~~~~~~~
-This library provides an authentication handler for Requests that implements
the
-Akamai {OPEN} EdgeGrid client authentication protocol as
+This library provides an authentication handler for Requests that implements
the
+Akamai {OPEN} EdgeGrid client authentication protocol as
specified by https://developer.akamai.com/introduction/Client_Auth.html.
For more information visit https://developer.akamai.com.
@@ -32,16 +32,17 @@
from .edgegrid import EdgeGridAuth
from .edgerc import EdgeRc
-__all__=['EdgeGridAuth', 'EdgeRc']
+__all__ = ['EdgeGridAuth', 'EdgeRc']
__title__ = 'edgegrid-python'
-__version__ = '1.1'
+__version__ = '1.2.1'
__author__ = 'Jonathan Landis <[email protected]>'
+__maintainer__ = 'Akamai Developer Experience team <[email protected]>'
__license__ = 'Apache 2.0'
-__copyright__ = 'Copyright 2014 Akamai Technologies'
+__copyright__ = 'Copyright 2021 Akamai Technologies'
-# Copyright 2014 Akamai Technologies, Inc. All Rights Reserved
-#
+# Copyright 2021 Akamai Technologies, Inc. All Rights Reserved
+#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/edgegrid-python-1.1.1/akamai/edgegrid/edgegrid.py
new/edgegrid-python-1.2.1/akamai/edgegrid/edgegrid.py
--- old/edgegrid-python-1.1.1/akamai/edgegrid/edgegrid.py 2017-09-11
21:16:24.000000000 +0200
+++ new/edgegrid-python-1.2.1/akamai/edgegrid/edgegrid.py 2021-06-24
16:17:32.000000000 +0200
@@ -3,11 +3,12 @@
# EdgeGrid requests Auth handler
#
# Original author: Jonathan Landis <[email protected]>
+# Package maintainer: Akamai Developer Experience team
<[email protected]>
#
# For more information visit https://developer.akamai.com
-# Copyright 2014 Akamai Technologies, Inc. All Rights Reserved
-#
+# Copyright 2021 Akamai Technologies, Inc. All Rights Reserved
+#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@@ -20,7 +21,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import requests
import logging
import uuid
import hashlib
@@ -28,38 +28,47 @@
import base64
import re
import sys
+import os
from requests.auth import AuthBase
from time import gmtime, strftime
if sys.version_info[0] >= 3:
# python3
- from urllib.parse import urlparse, parse_qsl, urlunparse
+ from urllib.parse import urlparse
else:
# python2.7
- from urlparse import urlparse, parse_qsl, urlunparse
+ from urlparse import urlparse
import urllib3.contrib.pyopenssl
urllib3.contrib.pyopenssl.inject_into_urllib3()
logger = logging.getLogger(__name__)
-__all__=['EdgeGridAuth']
+__all__ = ['EdgeGridAuth']
+
def eg_timestamp():
return strftime('%Y%m%dT%H:%M:%S+0000', gmtime())
+
def new_nonce():
return uuid.uuid4()
+
def base64_hmac_sha256(data, key):
return base64.b64encode(
- hmac.new(key.encode('utf8'), data.encode('utf8'),
hashlib.sha256).digest()
+ hmac.new(
+ key.encode('utf8'),
+ data.encode('utf8'),
+ hashlib.sha256).digest()
).decode('utf8')
+
def base64_sha256(data):
if isinstance(data, str):
data = data.encode('utf8')
return base64.b64encode(hashlib.sha256(data).digest()).decode('utf8')
+
class EdgeGridAuth(AuthBase):
"""A Requests authentication handler that provides Akamai {OPEN} EdgeGrid
support.
@@ -75,15 +84,15 @@
"""
- def __init__(self, client_token, client_secret, access_token,
+ def __init__(self, client_token, client_secret, access_token,
headers_to_sign=None, max_body=131072):
- """Initialize authentication using the given parameters from the Luna
Manage APIs
+ """Initialize authentication using the given parameters from the
Akamai OPEN APIs
Interface:
:param client_token: Client token provided by "Credentials" ui
:param client_secret: Client secret provided by "Credentials" ui
:param access_token: Access token provided by "Authorizations" ui
- :param headers_to_sign: An ordered list header names that will be
included in
+ :param headers_to_sign: An ordered list header names that will be
included in
the signature. This will be provided by specific APIs. (default
[])
:param max_body: Maximum content body size for POST requests. This
will be provided by
specific APIs. (default 131072)
@@ -93,7 +102,7 @@
self.client_secret = client_secret
self.access_token = access_token
if headers_to_sign:
- self.headers_to_sign = [ h.lower() for h in headers_to_sign ]
+ self.headers_to_sign = [h.lower() for h in headers_to_sign]
else:
self.headers_to_sign = []
self.max_body = max_body
@@ -102,15 +111,15 @@
@staticmethod
def from_edgerc(rcinput, section='default'):
- """Returns an EdgeGridAuth object from the configuration from the
given section of the
+ """Returns an EdgeGridAuth object from the configuration from the
given section of the
given edgerc file.
- :param filename: path to the edgerc file
- :param section: the section to use (this is the [bracketed] part of
the edgerc,
+ :param rcinput: EdgeRc instance or path to the edgerc file
+ :param section: the section to use (this is the [bracketed] part of
the edgerc,
default is 'default')
"""
- from .edgerc import EdgeRc
+ from .edgerc import EdgeRc
if isinstance(rcinput, EdgeRc):
rc = rcinput
else:
@@ -148,31 +157,61 @@
logger.debug("signing content: %s", prepared_body)
if len(prepared_body) > self.max_body:
logger.debug(
- "data length %d is larger than maximum %d",
+ "data length %d is larger than maximum %d",
len(prepared_body), self.max_body
)
prepared_body = prepared_body[0:self.max_body]
- logger.debug("data truncated to %d for computing the hash",
len(prepared_body))
+ logger.debug(
+ "data truncated to %d for computing the hash",
+ len(prepared_body))
content_hash = base64_sha256(prepared_body)
logger.debug("content hash is '%s'", content_hash)
return content_hash
+ def get_header_versions(self, header=None):
+ if header is None:
+ header = {}
+
+ version_header = ''
+ akamai_cli = os.getenv('AKAMAI_CLI')
+ akamai_cli_version = os.getenv('AKAMAI_CLI_VERSION')
+ if akamai_cli and akamai_cli_version:
+ version_header += " AkamaiCLI/" + akamai_cli_version
+
+ akamai_cli_command = os.getenv('AKAMAI_CLI_COMMAND')
+ akamai_cli_command_version = os.getenv('AKAMAI_CLI_COMMAND_VERSION')
+ if akamai_cli_command and akamai_cli_command_version:
+ version_header += " AkamaiCLI-" + akamai_cli_command + \
+ "/" + akamai_cli_command_version
+
+ if version_header != '':
+ if 'User-Agent' not in header:
+ header['User-Agent'] = version_header.strip()
+ else:
+ header['User-Agent'] += version_header
+
+ return header
+
def make_data_to_sign(self, r, auth_header):
parsed_url = urlparse(r.url)
- if (r.headers.get('Host', False)):
+ if r.headers.get('Host', False):
netloc = r.headers['Host']
else:
netloc = parsed_url.netloc
+ self.get_header_versions(r.headers)
+
data_to_sign = '\t'.join([
r.method,
parsed_url.scheme,
netloc,
- # Note: relative URL constraints are handled by requests when it
sets up 'r'
- parsed_url.path + ('?' + parsed_url.query if parsed_url.query else
""),
+ # Note: relative URL constraints are handled by requests when it
+ # sets up 'r'
+ parsed_url.path + \
+ ('?' + parsed_url.query if parsed_url.query else ""),
self.canonicalize_headers(r),
self.make_content_hash(r),
auth_header
@@ -182,7 +221,7 @@
def sign_request(self, r, timestamp, auth_header):
return base64_hmac_sha256(
- self.make_data_to_sign(r, auth_header),
+ self.make_data_to_sign(r, auth_header),
self.make_signing_key(timestamp)
)
@@ -193,7 +232,8 @@
('timestamp', timestamp),
('nonce', nonce),
]
- auth_header = "EG1-HMAC-SHA256 " + ';'.join([ "%s=%s" % kvp for kvp in
kvps ]) + ';'
+ auth_header = "EG1-HMAC-SHA256 " + \
+ ';'.join(["%s=%s" % kvp for kvp in kvps]) + ';'
logger.debug('unsigned authorization header: %s', auth_header)
signed_auth_header = auth_header + \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/edgegrid-python-1.1.1/akamai/edgegrid/edgerc.py
new/edgegrid-python-1.2.1/akamai/edgegrid/edgerc.py
--- old/edgegrid-python-1.1.1/akamai/edgegrid/edgerc.py 2018-07-16
21:33:09.000000000 +0200
+++ new/edgegrid-python-1.2.1/akamai/edgegrid/edgerc.py 2021-06-24
16:17:32.000000000 +0200
@@ -2,8 +2,8 @@
#
# support for .edgerc file format
#
-# Copyright 2014 Akamai Technologies, Inc. All Rights Reserved
-#
+# Copyright 2021 Akamai Technologies, Inc. All Rights Reserved
+#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@@ -18,6 +18,7 @@
import logging
import sys
+from os.path import expanduser
if sys.version_info[0] >= 3:
# python3
@@ -29,12 +30,19 @@
logger = logging.getLogger(__name__)
+
class EdgeRc(ConfigParser):
def __init__(self, filename):
- ConfigParser.__init__(self, {'client_token': '', 'client_secret':'',
'host':'', 'access_token':'','max_body': '131072', 'headers_to_sign': 'None'})
+ ConfigParser.__init__(self,
+ {'client_token': '',
+ 'client_secret': '',
+ 'host': '',
+ 'access_token': '',
+ 'max_body': '131072',
+ 'headers_to_sign': 'None'})
logger.debug("loading edgerc from %s", filename)
- self.read(filename)
+ self.read(expanduser(filename))
logger.debug("successfully loaded edgerc")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/edgegrid-python-1.1.1/akamai/edgegrid/test/edgerc_that_doesnt_parse
new/edgegrid-python-1.2.1/akamai/edgegrid/test/edgerc_that_doesnt_parse
--- old/edgegrid-python-1.1.1/akamai/edgegrid/test/edgerc_that_doesnt_parse
1970-01-01 01:00:00.000000000 +0100
+++ new/edgegrid-python-1.2.1/akamai/edgegrid/test/edgerc_that_doesnt_parse
2021-04-29 13:45:45.000000000 +0200
@@ -0,0 +1,4 @@
+[default]
+client_token = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx
+access_token = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx
+max_body = 131072
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/edgegrid-python-1.1.1/akamai/edgegrid/test/sample_edgerc
new/edgegrid-python-1.2.1/akamai/edgegrid/test/sample_edgerc
--- old/edgegrid-python-1.1.1/akamai/edgegrid/test/sample_edgerc
1970-01-01 01:00:00.000000000 +0100
+++ new/edgegrid-python-1.2.1/akamai/edgegrid/test/sample_edgerc
2021-04-29 13:45:45.000000000 +0200
@@ -0,0 +1,24 @@
+[default]
+host = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx.luna.akamaiapis.net/
+client_token = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx
+client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
+access_token = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx
+max_body = 131072
+[broken]
+host = "https://xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx.luna.akamaiapis.net/"
+client_token = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx
+client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
+access_token = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx
+[headers]
+host = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx.luna.akamaiapis.net/
+client_token = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx
+client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
+access_token = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx
+max_body = 131072
+headers_to_sign=X-MyThing1,X-MyThing2
+[dashes]
+host = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx.luna.akamaiapis.net/
+client-token = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx
+client-secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
+access-token = xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx
+max-body = 131072
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/edgegrid-python-1.1.1/akamai/edgegrid/test/test_edgegrid.py
new/edgegrid-python-1.2.1/akamai/edgegrid/test/test_edgegrid.py
--- old/edgegrid-python-1.1.1/akamai/edgegrid/test/test_edgegrid.py
2017-09-11 21:16:24.000000000 +0200
+++ new/edgegrid-python-1.2.1/akamai/edgegrid/test/test_edgegrid.py
2021-06-24 16:17:32.000000000 +0200
@@ -2,11 +2,12 @@
# unit tests for edgegrid. runs tests from testdata.json
#
# Original author: Jonathan Landis <[email protected]>
+# Package maintainer: Akamai Developer Experience team
<[email protected]>
#
# For more information visit https://developer.akamai.com
-# Copyright 2014 Akamai Technologies, Inc. All Rights Reserved
-#
+# Copyright 2021 Akamai Technologies, Inc. All Rights Reserved
+#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@@ -19,13 +20,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import akamai.edgegrid.edgegrid as eg
+from akamai.edgegrid import EdgeGridAuth, EdgeRc
import json
import logging
import os
import re
import requests
import sys
-import traceback
import unittest
PY_VER = sys.version_info[0]
@@ -36,19 +38,20 @@
# python2.7
from urlparse import urljoin
-from akamai.edgegrid import EdgeGridAuth, EdgeRc
-import akamai.edgegrid.edgegrid as eg
-mydir=os.path.abspath(os.path.dirname(__file__))
+mydir = os.path.abspath(os.path.dirname(__file__))
logger = logging.getLogger(__name__)
+expected_client_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx='
+
+
class EdgeGridTest(unittest.TestCase):
def __init__(self, testdata=None, testcase=None):
super(EdgeGridTest, self).__init__()
self.testdata = testdata
self.testcase = testcase
self.maxDiff = None
-
+
def runTest(self):
auth = EdgeGridAuth(
client_token=self.testdata['client_token'],
@@ -58,23 +61,26 @@
max_body=self.testdata['max_body']
)
- headers = { }
+ headers = {}
if 'headers' in self.testcase['request']:
for h in self.testcase['request']['headers']:
- for k,v in h.items():
+ for k, v in h.items():
headers[k] = v
request = requests.Request(
method=self.testcase['request']['method'],
-
url=urljoin(self.testdata['base_url'],self.testcase['request']['path']),
+ url=urljoin(
+ self.testdata['base_url'],
+ self.testcase['request']['path']),
headers=headers,
- data=self.testcase['request'].get('data') if
self.testcase['request'].get('data') \
- else None
+ data=self.testcase['request'].get('data') if
self.testcase['request'].get('data')
+ else None
)
try:
auth_header = auth.make_auth_header(
- request.prepare(), self.testdata['timestamp'],
self.testdata['nonce']
+ request.prepare(
+ ), self.testdata['timestamp'], self.testdata['nonce']
)
except Exception as e:
logger.debug('Got exception from make_auth_header', exc_info=True)
@@ -83,6 +89,7 @@
self.assertEqual(auth_header, self.testcase['expectedAuthorization'])
+
class EGSimpleTest(unittest.TestCase):
def test_nonce(self):
count = 100
@@ -98,7 +105,7 @@
\d{4} # year
[0-1][0-9] # month
[0-3][0-9] # day
- T
+ T
[0-2][0-9] # hour
:
[0-5][0-9] # minute
@@ -121,41 +128,109 @@
def test_edgerc_default(self):
auth = EdgeGridAuth.from_edgerc(os.path.join(mydir, 'sample_edgerc'))
- self.assertEqual(auth.client_token,
'xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx')
- self.assertEqual(auth.client_secret,
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=')
- self.assertEqual(auth.access_token,
'xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx')
+ self.assertEqual(
+ auth.client_token,
+ 'xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx')
+ self.assertEqual(
+ auth.client_secret,
+ expected_client_secret)
+ self.assertEqual(
+ auth.access_token,
+ 'xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx')
self.assertEqual(auth.max_body, 131072)
- self.assertEqual(auth.headers_to_sign, [])
+ self.assertEqual(auth.headers_to_sign, ['none'])
def test_edgerc_broken(self):
- auth = EdgeGridAuth.from_edgerc(os.path.join(mydir, 'sample_edgerc'),
'broken')
- self.assertEqual(auth.client_secret,
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=')
- self.assertEqual(auth.access_token,
'xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx')
- self.assertEqual(auth.max_body, 128*1024)
- self.assertEqual(auth.headers_to_sign, [])
+ auth = EdgeGridAuth.from_edgerc(
+ os.path.join(mydir, 'sample_edgerc'), 'broken')
+ self.assertEqual(
+ auth.client_secret,
+ expected_client_secret)
+ self.assertEqual(
+ auth.access_token,
+ 'xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx')
+ self.assertEqual(auth.max_body, 128 * 1024)
+ self.assertEqual(auth.headers_to_sign, ['none'])
def test_edgerc_unparseable(self):
+ # noinspection PyBroadException
try:
- auth = EdgeGridAuth.from_edgerc(os.path.join(mydir,
'edgerc_that_doesnt_parse'))
+ EdgeGridAuth.from_edgerc(
+ os.path.join(mydir, 'edgerc_that_doesnt_parse'))
self.fail("should have thrown an exception")
- except:
+ except BaseException:
pass
def test_edgerc_headers(self):
- auth = EdgeGridAuth.from_edgerc(os.path.join(mydir, 'sample_edgerc'),
'headers')
+ auth = EdgeGridAuth.from_edgerc(
+ os.path.join(mydir, 'sample_edgerc'), 'headers')
self.assertEqual(auth.headers_to_sign, ['x-mything1', 'x-mything2'])
+ def test_get_header_versions(self):
+ auth = EdgeGridAuth.from_edgerc(
+ os.path.join(mydir, 'sample_edgerc'), 'headers')
+ header = auth.get_header_versions()
+ self.assertFalse('user-agent' in header)
+
+ header = auth.get_header_versions({'User-Agent': 'testvalue'})
+ self.assertTrue('User-Agent' in header)
+
+ # setting environment variables with hardcoded `1.0.0` value, just for
this test.
+ # These variables are cleared at the end of this test.
+ os.environ["AKAMAI_CLI"] = '1.0.0'
+ os.environ["AKAMAI_CLI_VERSION"] = '1.0.0'
+
+ header = auth.get_header_versions()
+ self.assertTrue('User-Agent' in header)
+ self.assertEqual(header['User-Agent'], 'AkamaiCLI/1.0.0')
+
+ header = auth.get_header_versions({'User-Agent': 'test-agent'})
+ self.assertTrue('User-Agent' in header)
+ self.assertEqual(header['User-Agent'], 'test-agent AkamaiCLI/1.0.0')
+
+ os.environ["AKAMAI_CLI_COMMAND"] = '1.0.0'
+ os.environ["AKAMAI_CLI_COMMAND_VERSION"] = '1.0.0'
+
+ header = auth.get_header_versions()
+ self.assertTrue('User-Agent' in header)
+ self.assertEqual(header['User-Agent'],
+ 'AkamaiCLI/1.0.0 AkamaiCLI-1.0.0/1.0.0')
+
+ header = auth.get_header_versions({'User-Agent': 'testvalue'})
+ self.assertTrue('User-Agent' in header)
+ self.assertEqual(
+ header['User-Agent'],
+ 'testvalue AkamaiCLI/1.0.0 AkamaiCLI-1.0.0/1.0.0')
+
+ del os.environ['AKAMAI_CLI']
+ del os.environ['AKAMAI_CLI_VERSION']
+ del os.environ['AKAMAI_CLI_COMMAND']
+ del os.environ['AKAMAI_CLI_COMMAND_VERSION']
+
+ self.assertFalse('AKAMAI_CLI' in os.environ)
+ self.assertFalse('AKAMAI_CLI_VERSION' in os.environ)
+ self.assertFalse('AKAMAI_CLI_COMMAND' in os.environ)
+ self.assertFalse('AKAMAI_CLI_COMMAND_VERSION' in os.environ)
+
def test_edgerc_from_object(self):
- auth = EdgeGridAuth.from_edgerc(EdgeRc(os.path.join(mydir,
'sample_edgerc')))
- self.assertEqual(auth.client_token,
'xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx')
- self.assertEqual(auth.client_secret,
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=')
- self.assertEqual(auth.access_token,
'xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx')
+ auth = EdgeGridAuth.from_edgerc(
+ EdgeRc(os.path.join(mydir, 'sample_edgerc')))
+ self.assertEqual(
+ auth.client_token,
+ 'xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx')
+ self.assertEqual(
+ auth.client_secret,
+ expected_client_secret)
+ self.assertEqual(
+ auth.access_token,
+ 'xxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx')
self.assertEqual(auth.max_body, 131072)
- self.assertEqual(auth.headers_to_sign, [])
+ self.assertEqual(auth.headers_to_sign, ['none'])
def test_edgerc_dashes(self):
- auth = EdgeGridAuth.from_edgerc(os.path.join(mydir, 'sample_edgerc'),
'dashes')
- self.assertEqual(auth.max_body, 128*1024)
+ auth = EdgeGridAuth.from_edgerc(
+ os.path.join(mydir, 'sample_edgerc'), 'dashes')
+ self.assertEqual(auth.max_body, 128 * 1024)
class JsonTest(unittest.TestCase):
@@ -177,18 +252,19 @@
}
data = {
- 'key':'value',
+ 'key': 'value',
}
request = requests.Request(
method='POST',
- url=urljoin(self.testdata['base_url'],'/testapi/v1/t3'),
+ url=urljoin(self.testdata['base_url'], '/testapi/v1/t3'),
params=params,
json=data,
)
auth_header = auth.make_auth_header(
- request.prepare(), self.testdata['timestamp'],
self.testdata['nonce']
+ request.prepare(
+ ), self.testdata['timestamp'], self.testdata['nonce']
)
self.assertEqual(auth_header, self.testdata['jsontest_hash'])
@@ -214,13 +290,15 @@
suite.addTest(EGSimpleTest('test_edgerc_broken'))
suite.addTest(EGSimpleTest('test_edgerc_unparseable'))
suite.addTest(EGSimpleTest('test_edgerc_headers'))
+ suite.addTest(EGSimpleTest('test_get_header_versions'))
suite.addTest(EGSimpleTest('test_edgerc_from_object'))
return suite
+
def load_tests(loader=None, tests=None, pattern=None):
return suite()
+
if __name__ == '__main__':
runner = unittest.TextTestRunner().run(suite())
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/edgegrid-python-1.1.1/edgegrid_python.egg-info/PKG-INFO
new/edgegrid-python-1.2.1/edgegrid_python.egg-info/PKG-INFO
--- old/edgegrid-python-1.1.1/edgegrid_python.egg-info/PKG-INFO 2018-07-16
21:37:19.000000000 +0200
+++ new/edgegrid-python-1.2.1/edgegrid_python.egg-info/PKG-INFO 2021-10-11
09:39:22.000000000 +0200
@@ -1,10 +1,19 @@
-Metadata-Version: 1.0
+Metadata-Version: 2.1
Name: edgegrid-python
-Version: 1.1.1
+Version: 1.2.1
Summary: {OPEN} client authentication protocol for python-requests
-Home-page: https://github.com/akamai-open/AkamaiOPEN-edgegrid-python
+Home-page: https://github.com/akamai/AkamaiOPEN-edgegrid-python
Author: Jonathan Landis
Author-email: [email protected]
-License: LICENSE.txt
-Description: UNKNOWN
+Maintainer: Akamai Developer Experience team
+Maintainer-email: [email protected]
+License: Apache 2.0
Platform: UNKNOWN
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Requires-Python: >=2.7.10
+License-File: LICENSE
+
+UNKNOWN
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/edgegrid-python-1.1.1/edgegrid_python.egg-info/SOURCES.txt
new/edgegrid-python-1.2.1/edgegrid_python.egg-info/SOURCES.txt
--- old/edgegrid-python-1.1.1/edgegrid_python.egg-info/SOURCES.txt
2018-07-16 21:37:19.000000000 +0200
+++ new/edgegrid-python-1.2.1/edgegrid_python.egg-info/SOURCES.txt
2021-10-11 09:39:22.000000000 +0200
@@ -8,6 +8,8 @@
akamai/edgegrid/edgegrid.py
akamai/edgegrid/edgerc.py
akamai/edgegrid/test/__init__.py
+akamai/edgegrid/test/edgerc_that_doesnt_parse
+akamai/edgegrid/test/sample_edgerc
akamai/edgegrid/test/test_edgegrid.py
akamai/edgegrid/test/testdata.json
edgegrid_python.egg-info/PKG-INFO
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/edgegrid-python-1.1.1/edgegrid_python.egg-info/requires.txt
new/edgegrid-python-1.2.1/edgegrid_python.egg-info/requires.txt
--- old/edgegrid-python-1.1.1/edgegrid_python.egg-info/requires.txt
2018-07-16 21:37:19.000000000 +0200
+++ new/edgegrid-python-1.2.1/edgegrid_python.egg-info/requires.txt
2021-10-11 09:39:22.000000000 +0200
@@ -1,5 +1,5 @@
requests>=2.3.0
-pyOpenSSL >= 0.13
+pyOpenSSL>=19.0.0
ndg-httpsclient
pyasn1
urllib3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/edgegrid-python-1.1.1/requirements.txt
new/edgegrid-python-1.2.1/requirements.txt
--- old/edgegrid-python-1.1.1/requirements.txt 2015-06-24 03:02:59.000000000
+0200
+++ new/edgegrid-python-1.2.1/requirements.txt 2021-06-24 16:17:32.000000000
+0200
@@ -1,5 +1,5 @@
requests>=2.3.0
-pyopenssl
+pyopenssl>=19.0.0
ndg-httpsclient
pyasn1
urllib3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/edgegrid-python-1.1.1/setup.cfg
new/edgegrid-python-1.2.1/setup.cfg
--- old/edgegrid-python-1.1.1/setup.cfg 2018-07-16 21:37:19.000000000 +0200
+++ new/edgegrid-python-1.2.1/setup.cfg 2021-10-11 09:39:22.888973500 +0200
@@ -1,5 +1,4 @@
[egg_info]
tag_build =
tag_date = 0
-tag_svn_revision = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/edgegrid-python-1.1.1/setup.py
new/edgegrid-python-1.2.1/setup.py
--- old/edgegrid-python-1.1.1/setup.py 2018-07-16 21:34:33.000000000 +0200
+++ new/edgegrid-python-1.2.1/setup.py 2021-10-11 09:27:16.000000000 +0200
@@ -1,20 +1,28 @@
from setuptools import setup, find_packages
setup(
name='edgegrid-python',
- version='1.1.1',
+ version='1.2.1',
description='{OPEN} client authentication protocol for python-requests',
author='Jonathan Landis',
author_email='[email protected]',
- url='https://github.com/akamai-open/AkamaiOPEN-edgegrid-python',
+ maintainer='Akamai Developer Experience team',
+ maintainer_email='[email protected]',
+ url='https://github.com/akamai/AkamaiOPEN-edgegrid-python',
namespace_packages=['akamai'],
packages=find_packages(),
python_requires=">=2.7.10",
- install_requires = [
+ install_requires=[
'requests>=2.3.0',
- 'pyOpenSSL >= 0.13',
+ 'pyOpenSSL>=19.0.0',
'ndg-httpsclient',
'pyasn1',
'urllib3'
],
- license='LICENSE.txt'
+ include_package_data=True,
+ license='Apache 2.0',
+ classifiers=[
+ 'License :: OSI Approved :: Apache Software License',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ ]
)