Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- testbed/boto__botocore/.codecov.yml +2 -0
- testbed/boto__botocore/.coveragerc +10 -0
- testbed/boto__botocore/.git-blame-ignore-revs +17 -0
- testbed/boto__botocore/.gitignore +42 -0
- testbed/boto__botocore/.pre-commit-config.yaml +31 -0
- testbed/boto__botocore/CHANGELOG.rst +0 -0
- testbed/boto__botocore/CODE_OF_CONDUCT.md +4 -0
- testbed/boto__botocore/CONTRIBUTING.rst +95 -0
- testbed/boto__botocore/LICENSE.txt +177 -0
- testbed/boto__botocore/MANIFEST.in +11 -0
- testbed/boto__botocore/NOTICE +60 -0
- testbed/boto__botocore/README.rst +116 -0
- testbed/boto__botocore/pyproject.toml +72 -0
- testbed/boto__botocore/requirements-dev-lock.txt +285 -0
- testbed/boto__botocore/requirements-dev.txt +13 -0
- testbed/boto__botocore/requirements-docs-lock.txt +281 -0
- testbed/boto__botocore/requirements-docs.txt +6 -0
- testbed/boto__botocore/requirements.txt +1 -0
- testbed/boto__botocore/setup.cfg +12 -0
- testbed/boto__botocore/setup.py +72 -0
- testbed/boto__botocore/tests/__init__.py +599 -0
- testbed/boto__botocore/tests/cmd-runner +220 -0
- testbed/boto__botocore/tests/unit/__init__.py +46 -0
- testbed/boto__botocore/tests/unit/put_object_data +1 -0
- testbed/boto__botocore/tests/unit/response_parsing/README.rst +34 -0
- testbed/boto__botocore/tests/unit/response_parsing/test_response_parsing.py +195 -0
- testbed/boto__botocore/tests/unit/response_parsing/xml/responses/cloudwatch-describe-alarm-history.json +6 -0
- testbed/boto__botocore/tests/unit/response_parsing/xml/responses/cloudwatch-describe-alarm-history.xml +8 -0
- testbed/boto__botocore/tests/unit/response_parsing/xml/responses/cloudwatch-list-metrics.xml +819 -0
- testbed/boto__botocore/tests/unit/response_parsing/xml/responses/sqs-change-message-visibility-batch.json +13 -0
- testbed/boto__botocore/tests/unit/response_parsing/xml/responses/sqs-list-queues.json +9 -0
- testbed/boto__botocore/tests/unit/response_parsing/xml/responses/sts-get-session-token.xml +16 -0
- testbed/boto__botocore/tests/unit/retries/__init__.py +0 -0
- testbed/boto__botocore/tests/unit/retries/test_adaptive.py +167 -0
- testbed/boto__botocore/tests/unit/retries/test_special.py +143 -0
- testbed/boto__botocore/tests/unit/test_args.py +844 -0
- testbed/boto__botocore/tests/unit/test_auth_bearer.py +72 -0
- testbed/boto__botocore/tests/unit/test_auth_sigv4.py +53 -0
- testbed/boto__botocore/tests/unit/test_awsrequest.py +802 -0
- testbed/boto__botocore/tests/unit/test_client.py +2368 -0
- testbed/boto__botocore/tests/unit/test_compress.py +322 -0
- testbed/boto__botocore/tests/unit/test_config_provider.py +1148 -0
- testbed/boto__botocore/tests/unit/test_configloader.py +211 -0
- testbed/boto__botocore/tests/unit/test_credentials.py +0 -0
- testbed/boto__botocore/tests/unit/test_discovery.py +495 -0
- testbed/boto__botocore/tests/unit/test_endpoint.py +490 -0
- testbed/boto__botocore/tests/unit/test_endpoint_provider.py +512 -0
- testbed/boto__botocore/tests/unit/test_errorfactory.py +139 -0
- testbed/boto__botocore/tests/unit/test_eventstream.py +568 -0
- testbed/boto__botocore/tests/unit/test_exceptions.py +169 -0
testbed/boto__botocore/.codecov.yml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ignore:
|
| 2 |
+
- "botocore/vendored"
|
testbed/boto__botocore/.coveragerc
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[run]
|
| 2 |
+
branch = True
|
| 3 |
+
omit =
|
| 4 |
+
botocore/vendored/*
|
| 5 |
+
|
| 6 |
+
[report]
|
| 7 |
+
exclude_lines =
|
| 8 |
+
raise NotImplementedError.*
|
| 9 |
+
include =
|
| 10 |
+
botocore/*
|
testbed/boto__botocore/.git-blame-ignore-revs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# You can configure git to automatically use this file with the following config:
|
| 2 |
+
# git config --global blame.ignoreRevsFile .git-blame-ignore-revs
|
| 3 |
+
|
| 4 |
+
# Reformat using isort
|
| 5 |
+
e34b6a36ae0c1571bcb5fd7034e817d3b397e283
|
| 6 |
+
|
| 7 |
+
# Add Black and Pyupgrade to botocore directory
|
| 8 |
+
321ed9bb9345f05528e61a9edccb811012f7dc2a
|
| 9 |
+
|
| 10 |
+
# Cleanup pyupgrade misses
|
| 11 |
+
a2c2fe68a2f9ae259dd1d72b172d41c7c81808cd
|
| 12 |
+
|
| 13 |
+
# Run Black and PyUpgrade over tests directory
|
| 14 |
+
10747e5e2f2f97a9493b91b5c886bda71678e3be
|
| 15 |
+
|
| 16 |
+
# Update to black 23
|
| 17 |
+
459a6a370ea1a4ab52b792f3d6e8311bc774b583
|
testbed/boto__botocore/.gitignore
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.DS_Store
|
| 2 |
+
*.py[co]
|
| 3 |
+
|
| 4 |
+
# Packages
|
| 5 |
+
*.egg
|
| 6 |
+
*.egg-info
|
| 7 |
+
dist
|
| 8 |
+
build
|
| 9 |
+
eggs
|
| 10 |
+
parts
|
| 11 |
+
var
|
| 12 |
+
sdist
|
| 13 |
+
develop-eggs
|
| 14 |
+
.installed.cfg
|
| 15 |
+
|
| 16 |
+
# Installer logs
|
| 17 |
+
pip-log.txt
|
| 18 |
+
|
| 19 |
+
# Unit test / coverage reports
|
| 20 |
+
.coverage
|
| 21 |
+
.tox
|
| 22 |
+
|
| 23 |
+
#Translations
|
| 24 |
+
*.mo
|
| 25 |
+
|
| 26 |
+
#Mr Developer
|
| 27 |
+
.mr.developer.cfg
|
| 28 |
+
|
| 29 |
+
# Emacs backup files
|
| 30 |
+
*~
|
| 31 |
+
|
| 32 |
+
# IDEA / PyCharm IDE
|
| 33 |
+
.idea/
|
| 34 |
+
|
| 35 |
+
# Virtualenvs
|
| 36 |
+
env
|
| 37 |
+
env2
|
| 38 |
+
env3
|
| 39 |
+
|
| 40 |
+
docs/source/reference/services
|
| 41 |
+
tests/coverage.xml
|
| 42 |
+
tests/nosetests.xml
|
testbed/boto__botocore/.pre-commit-config.yaml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
exclude: "\
|
| 2 |
+
^(\
|
| 3 |
+
.github|\
|
| 4 |
+
.changes|\
|
| 5 |
+
botocore/data|\
|
| 6 |
+
botocore/vendored|\
|
| 7 |
+
botocore/compat.py|\
|
| 8 |
+
docs/|\
|
| 9 |
+
tests/functional/endpoint-rules|\
|
| 10 |
+
tests/unit/auth/aws4_testsuite|\
|
| 11 |
+
tests/unit/data/endpoints/|\
|
| 12 |
+
tests/unit/response_parsing/xml|\
|
| 13 |
+
CHANGELOG.rst\
|
| 14 |
+
)"
|
| 15 |
+
repos:
|
| 16 |
+
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
|
| 17 |
+
rev: v4.5.0
|
| 18 |
+
hooks:
|
| 19 |
+
- id: check-yaml
|
| 20 |
+
- id: end-of-file-fixer
|
| 21 |
+
- id: trailing-whitespace
|
| 22 |
+
- repo: 'https://github.com/PyCQA/isort'
|
| 23 |
+
rev: 5.12.0
|
| 24 |
+
hooks:
|
| 25 |
+
- id: isort
|
| 26 |
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
| 27 |
+
rev: v0.4.8
|
| 28 |
+
hooks:
|
| 29 |
+
- id: ruff
|
| 30 |
+
args: [ --fix ]
|
| 31 |
+
- id: ruff-format
|
testbed/boto__botocore/CHANGELOG.rst
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
testbed/boto__botocore/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Code of Conduct
|
| 2 |
+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
|
| 3 |
+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
|
| 4 |
+
opensource-codeofconduct@amazon.com with any additional questions or comments.
|
testbed/boto__botocore/CONTRIBUTING.rst
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Contributing
|
| 2 |
+
============
|
| 3 |
+
|
| 4 |
+
We work hard to provide a high-quality and useful SDK, and we greatly value
|
| 5 |
+
feedback and contributions from our community. Whether it's a new feature,
|
| 6 |
+
correction, or additional documentation, we welcome your pull requests. Please
|
| 7 |
+
submit any `issues <https://github.com/boto/botocore/issues>`__
|
| 8 |
+
or `pull requests <https://github.com/boto/botocore/pulls>`__ through GitHub.
|
| 9 |
+
|
| 10 |
+
This document contains guidelines for contributing code and filing issues.
|
| 11 |
+
|
| 12 |
+
Contributing Code
|
| 13 |
+
-----------------
|
| 14 |
+
|
| 15 |
+
The list below are guidelines to use when submitting pull requests.
|
| 16 |
+
These are the same set of guidelines that the core contributors use
|
| 17 |
+
when submitting changes, and we ask the same of all community
|
| 18 |
+
contributions as well:
|
| 19 |
+
|
| 20 |
+
* The SDK is released under the
|
| 21 |
+
`Apache license <http://aws.amazon.com/apache2.0/>`__.
|
| 22 |
+
Any code you submit will be released under that license.
|
| 23 |
+
* We maintain a high percentage of code coverage in our unit tests. As
|
| 24 |
+
a general rule of thumb, code changes should not lower the overall
|
| 25 |
+
code coverage percentage for the project. To help with this,
|
| 26 |
+
we use `coveralls <https://coveralls.io/r/boto/botocore>`__, which will
|
| 27 |
+
comment on changes in code coverage for every pull request.
|
| 28 |
+
In practice, this means that every bug fix and feature addition should
|
| 29 |
+
include unit tests.
|
| 30 |
+
* If you identify an issue with the JSON service descriptions,
|
| 31 |
+
such as ``botocore/data/aws/s3/2006-03-01/service-2.json``, please submit an
|
| 32 |
+
`issue <https://github.com/boto/botocore/issues>`__ so we can get it
|
| 33 |
+
fixed upstream.
|
| 34 |
+
* Changes to paginators, waiters, and endpoints are also generated upstream based on our internal knowledge of the AWS services.
|
| 35 |
+
These include any of the following files in ``botocore/data/``:
|
| 36 |
+
|
| 37 |
+
* ``_endpoints.json``
|
| 38 |
+
* ``*.paginators-1.json``
|
| 39 |
+
* ``*.waiters-2.json``
|
| 40 |
+
|
| 41 |
+
If you identify an issue with these files, such as a missing paginator or waiter, please submit an
|
| 42 |
+
`issue <https://github.com/boto/botocore/issues>`__ so we can get it fixed upstream.
|
| 43 |
+
* We do accept, and encourage, changes to the ``botocore/data/_retry.json`` file.
|
| 44 |
+
* Code should follow the guidelines listed in the Codestyle section below.
|
| 45 |
+
* Code must work on all versions of Python supported by Botocore.
|
| 46 |
+
* Botocore is cross platform and code must work on at least linux, Windows,
|
| 47 |
+
and Mac OS X.
|
| 48 |
+
* If you would like to implement support for a significant feature that is not
|
| 49 |
+
yet available in botocore, please talk to us beforehand to avoid any duplication
|
| 50 |
+
of effort. You can file an
|
| 51 |
+
`issue <https://github.com/boto/botocore/issues>`__
|
| 52 |
+
to discuss the feature request further.
|
| 53 |
+
|
| 54 |
+
Reporting An Issue/Feature
|
| 55 |
+
--------------------------
|
| 56 |
+
|
| 57 |
+
* Check to see if there's an existing issue/pull request for the
|
| 58 |
+
bug/feature. All issues are at
|
| 59 |
+
https://github.com/boto/botocore/issues and pull reqs are at
|
| 60 |
+
https://github.com/boto/botocore/pulls.
|
| 61 |
+
* If there isn't an existing issue there, please file an issue. The
|
| 62 |
+
ideal report includes:
|
| 63 |
+
|
| 64 |
+
* A description of the problem/suggestion.
|
| 65 |
+
* A code sample that demonstrates the issue.
|
| 66 |
+
* Including the versions of your:
|
| 67 |
+
|
| 68 |
+
* python interpreter
|
| 69 |
+
* OS
|
| 70 |
+
* botocore (accessible via ``botocore.__version__``)
|
| 71 |
+
* optionally any other python dependencies involved
|
| 72 |
+
|
| 73 |
+
Codestyle
|
| 74 |
+
---------
|
| 75 |
+
This project uses `ruff <https://github.com/astral-sh/ruff>`__ to enforce
|
| 76 |
+
codstyle requirements. We've codified this process using a tool called
|
| 77 |
+
`pre-commit <https://pre-commit.com/>`__. pre-commit allows us to specify a
|
| 78 |
+
config file with all tools required for code linting, and surfaces either a
|
| 79 |
+
git commit hook, or single command, for enforcing these.
|
| 80 |
+
|
| 81 |
+
To validate your PR prior to publishing, you can use the following
|
| 82 |
+
`installation guide <https://pre-commit.com/#install>`__ to setup pre-commit.
|
| 83 |
+
|
| 84 |
+
If you don't want to use the git commit hook, you can run the below command
|
| 85 |
+
to automatically perform the codestyle validation:
|
| 86 |
+
|
| 87 |
+
.. code-block:: bash
|
| 88 |
+
|
| 89 |
+
$ pre-commit run
|
| 90 |
+
|
| 91 |
+
This will automatically perform simple updates (such as white space clean up)
|
| 92 |
+
and provide a list of any failing checks. After these are addressed,
|
| 93 |
+
you can commit the changes prior to publishing the PR.
|
| 94 |
+
These checks are also included in our CI setup under the "Lint" workflow which
|
| 95 |
+
will provide output on Github for anything missed locally.
|
testbed/boto__botocore/LICENSE.txt
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Apache License
|
| 3 |
+
Version 2.0, January 2004
|
| 4 |
+
http://www.apache.org/licenses/
|
| 5 |
+
|
| 6 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 7 |
+
|
| 8 |
+
1. Definitions.
|
| 9 |
+
|
| 10 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 11 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 12 |
+
|
| 13 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 14 |
+
the copyright owner that is granting the License.
|
| 15 |
+
|
| 16 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 17 |
+
other entities that control, are controlled by, or are under common
|
| 18 |
+
control with that entity. For the purposes of this definition,
|
| 19 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 20 |
+
direction or management of such entity, whether by contract or
|
| 21 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 22 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 23 |
+
|
| 24 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 25 |
+
exercising permissions granted by this License.
|
| 26 |
+
|
| 27 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 28 |
+
including but not limited to software source code, documentation
|
| 29 |
+
source, and configuration files.
|
| 30 |
+
|
| 31 |
+
"Object" form shall mean any form resulting from mechanical
|
| 32 |
+
transformation or translation of a Source form, including but
|
| 33 |
+
not limited to compiled object code, generated documentation,
|
| 34 |
+
and conversions to other media types.
|
| 35 |
+
|
| 36 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 37 |
+
Object form, made available under the License, as indicated by a
|
| 38 |
+
copyright notice that is included in or attached to the work
|
| 39 |
+
(an example is provided in the Appendix below).
|
| 40 |
+
|
| 41 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 42 |
+
form, that is based on (or derived from) the Work and for which the
|
| 43 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 44 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 45 |
+
of this License, Derivative Works shall not include works that remain
|
| 46 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 47 |
+
the Work and Derivative Works thereof.
|
| 48 |
+
|
| 49 |
+
"Contribution" shall mean any work of authorship, including
|
| 50 |
+
the original version of the Work and any modifications or additions
|
| 51 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 52 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 53 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 54 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 55 |
+
means any form of electronic, verbal, or written communication sent
|
| 56 |
+
to the Licensor or its representatives, including but not limited to
|
| 57 |
+
communication on electronic mailing lists, source code control systems,
|
| 58 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 59 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 60 |
+
excluding communication that is conspicuously marked or otherwise
|
| 61 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 62 |
+
|
| 63 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 64 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 65 |
+
subsequently incorporated within the Work.
|
| 66 |
+
|
| 67 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 68 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 69 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 70 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 71 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 72 |
+
Work and such Derivative Works in Source or Object form.
|
| 73 |
+
|
| 74 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 75 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 76 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 77 |
+
(except as stated in this section) patent license to make, have made,
|
| 78 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 79 |
+
where such license applies only to those patent claims licensable
|
| 80 |
+
by such Contributor that are necessarily infringed by their
|
| 81 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 82 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 83 |
+
institute patent litigation against any entity (including a
|
| 84 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 85 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 86 |
+
or contributory patent infringement, then any patent licenses
|
| 87 |
+
granted to You under this License for that Work shall terminate
|
| 88 |
+
as of the date such litigation is filed.
|
| 89 |
+
|
| 90 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 91 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 92 |
+
modifications, and in Source or Object form, provided that You
|
| 93 |
+
meet the following conditions:
|
| 94 |
+
|
| 95 |
+
(a) You must give any other recipients of the Work or
|
| 96 |
+
Derivative Works a copy of this License; and
|
| 97 |
+
|
| 98 |
+
(b) You must cause any modified files to carry prominent notices
|
| 99 |
+
stating that You changed the files; and
|
| 100 |
+
|
| 101 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 102 |
+
that You distribute, all copyright, patent, trademark, and
|
| 103 |
+
attribution notices from the Source form of the Work,
|
| 104 |
+
excluding those notices that do not pertain to any part of
|
| 105 |
+
the Derivative Works; and
|
| 106 |
+
|
| 107 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 108 |
+
distribution, then any Derivative Works that You distribute must
|
| 109 |
+
include a readable copy of the attribution notices contained
|
| 110 |
+
within such NOTICE file, excluding those notices that do not
|
| 111 |
+
pertain to any part of the Derivative Works, in at least one
|
| 112 |
+
of the following places: within a NOTICE text file distributed
|
| 113 |
+
as part of the Derivative Works; within the Source form or
|
| 114 |
+
documentation, if provided along with the Derivative Works; or,
|
| 115 |
+
within a display generated by the Derivative Works, if and
|
| 116 |
+
wherever such third-party notices normally appear. The contents
|
| 117 |
+
of the NOTICE file are for informational purposes only and
|
| 118 |
+
do not modify the License. You may add Your own attribution
|
| 119 |
+
notices within Derivative Works that You distribute, alongside
|
| 120 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 121 |
+
that such additional attribution notices cannot be construed
|
| 122 |
+
as modifying the License.
|
| 123 |
+
|
| 124 |
+
You may add Your own copyright statement to Your modifications and
|
| 125 |
+
may provide additional or different license terms and conditions
|
| 126 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 127 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 128 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 129 |
+
the conditions stated in this License.
|
| 130 |
+
|
| 131 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 132 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 133 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 134 |
+
this License, without any additional terms or conditions.
|
| 135 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 136 |
+
the terms of any separate license agreement you may have executed
|
| 137 |
+
with Licensor regarding such Contributions.
|
| 138 |
+
|
| 139 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 140 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 141 |
+
except as required for reasonable and customary use in describing the
|
| 142 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 143 |
+
|
| 144 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 145 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 146 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 147 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 148 |
+
implied, including, without limitation, any warranties or conditions
|
| 149 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 150 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 151 |
+
appropriateness of using or redistributing the Work and assume any
|
| 152 |
+
risks associated with Your exercise of permissions under this License.
|
| 153 |
+
|
| 154 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 155 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 156 |
+
unless required by applicable law (such as deliberate and grossly
|
| 157 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 158 |
+
liable to You for damages, including any direct, indirect, special,
|
| 159 |
+
incidental, or consequential damages of any character arising as a
|
| 160 |
+
result of this License or out of the use or inability to use the
|
| 161 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 162 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 163 |
+
other commercial damages or losses), even if such Contributor
|
| 164 |
+
has been advised of the possibility of such damages.
|
| 165 |
+
|
| 166 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 167 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 168 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 169 |
+
or other liability obligations and/or rights consistent with this
|
| 170 |
+
License. However, in accepting such obligations, You may act only
|
| 171 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 172 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 173 |
+
defend, and hold each Contributor harmless for any liability
|
| 174 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 175 |
+
of your accepting any such warranty or additional liability.
|
| 176 |
+
|
| 177 |
+
END OF TERMS AND CONDITIONS
|
testbed/boto__botocore/MANIFEST.in
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
include README.rst
|
| 2 |
+
include LICENSE.txt
|
| 3 |
+
include requirements.txt
|
| 4 |
+
include requirements-dev.txt
|
| 5 |
+
include botocore/cacert.pem
|
| 6 |
+
include botocore/vendored/requests/cacert.pem
|
| 7 |
+
recursive-include botocore/data *.json
|
| 8 |
+
recursive-include botocore/data *.json.gz
|
| 9 |
+
graft docs
|
| 10 |
+
prune docs/build
|
| 11 |
+
graft tests
|
testbed/boto__botocore/NOTICE
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Botocore
|
| 2 |
+
Copyright 2012-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 3 |
+
|
| 4 |
+
----
|
| 5 |
+
|
| 6 |
+
Botocore includes vendorized parts of the requests python library for backwards compatibility.
|
| 7 |
+
|
| 8 |
+
Requests License
|
| 9 |
+
================
|
| 10 |
+
|
| 11 |
+
Copyright 2013 Kenneth Reitz
|
| 12 |
+
|
| 13 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 14 |
+
you may not use this file except in compliance with the License.
|
| 15 |
+
You may obtain a copy of the License at
|
| 16 |
+
|
| 17 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 18 |
+
|
| 19 |
+
Unless required by applicable law or agreed to in writing, software
|
| 20 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 21 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 22 |
+
See the License for the specific language governing permissions and
|
| 23 |
+
limitations under the License.
|
| 24 |
+
|
| 25 |
+
Botocore includes vendorized parts of the urllib3 library for backwards compatibility.
|
| 26 |
+
|
| 27 |
+
Urllib3 License
|
| 28 |
+
===============
|
| 29 |
+
|
| 30 |
+
This is the MIT license: http://www.opensource.org/licenses/mit-license.php
|
| 31 |
+
|
| 32 |
+
Copyright 2008-2011 Andrey Petrov and contributors (see CONTRIBUTORS.txt),
|
| 33 |
+
Modifications copyright 2012 Kenneth Reitz.
|
| 34 |
+
|
| 35 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
| 36 |
+
software and associated documentation files (the "Software"), to deal in the Software
|
| 37 |
+
without restriction, including without limitation the rights to use, copy, modify, merge,
|
| 38 |
+
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
| 39 |
+
to whom the Software is furnished to do so, subject to the following conditions:
|
| 40 |
+
|
| 41 |
+
The above copyright notice and this permission notice shall be included in all copies or
|
| 42 |
+
substantial portions of the Software.
|
| 43 |
+
|
| 44 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
| 45 |
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
| 46 |
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
| 47 |
+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
| 48 |
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
| 49 |
+
DEALINGS IN THE SOFTWARE.
|
| 50 |
+
|
| 51 |
+
Bundle of CA Root Certificates
|
| 52 |
+
==============================
|
| 53 |
+
|
| 54 |
+
***** BEGIN LICENSE BLOCK *****
|
| 55 |
+
This Source Code Form is subject to the terms of the
|
| 56 |
+
Mozilla Public License, v. 2.0. If a copy of the MPL
|
| 57 |
+
was not distributed with this file, You can obtain
|
| 58 |
+
one at http://mozilla.org/MPL/2.0/.
|
| 59 |
+
|
| 60 |
+
***** END LICENSE BLOCK *****
|
testbed/boto__botocore/README.rst
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
botocore
|
| 2 |
+
========
|
| 3 |
+
|
| 4 |
+
|Version| |Python| |License|
|
| 5 |
+
|
| 6 |
+
A low-level interface to a growing number of Amazon Web Services. The
|
| 7 |
+
botocore package is the foundation for the
|
| 8 |
+
`AWS CLI <https://github.com/aws/aws-cli>`__ as well as
|
| 9 |
+
`boto3 <https://github.com/boto/boto3>`__.
|
| 10 |
+
|
| 11 |
+
Botocore is maintained and published by `Amazon Web Services`_.
|
| 12 |
+
|
| 13 |
+
Notices
|
| 14 |
+
-------
|
| 15 |
+
|
| 16 |
+
On 2023-12-13, support was dropped for Python 3.7. This follows the
|
| 17 |
+
Python Software Foundation `end of support <https://www.python.org/dev/peps/pep-0537/#lifespan>`__
|
| 18 |
+
for the runtime which occurred on 2023-06-27.
|
| 19 |
+
For more information, see this `blog post <https://aws.amazon.com/blogs/developer/python-support-policy-updates-for-aws-sdks-and-tools/>`__.
|
| 20 |
+
|
| 21 |
+
.. _`Amazon Web Services`: https://aws.amazon.com/what-is-aws/
|
| 22 |
+
.. |Python| image:: https://img.shields.io/pypi/pyversions/botocore.svg?style=flat
|
| 23 |
+
:target: https://pypi.python.org/pypi/botocore/
|
| 24 |
+
:alt: Python Versions
|
| 25 |
+
.. |Version| image:: http://img.shields.io/pypi/v/botocore.svg?style=flat
|
| 26 |
+
:target: https://pypi.python.org/pypi/botocore/
|
| 27 |
+
:alt: Package Version
|
| 28 |
+
.. |License| image:: http://img.shields.io/pypi/l/botocore.svg?style=flat
|
| 29 |
+
:target: https://github.com/boto/botocore/blob/develop/LICENSE.txt
|
| 30 |
+
:alt: License
|
| 31 |
+
|
| 32 |
+
Getting Started
|
| 33 |
+
---------------
|
| 34 |
+
Assuming that you have Python and ``virtualenv`` installed, set up your environment and install the required dependencies like this or you can install the library using ``pip``:
|
| 35 |
+
|
| 36 |
+
.. code-block:: sh
|
| 37 |
+
|
| 38 |
+
$ git clone https://github.com/boto/botocore.git
|
| 39 |
+
$ cd botocore
|
| 40 |
+
$ virtualenv venv
|
| 41 |
+
...
|
| 42 |
+
$ . venv/bin/activate
|
| 43 |
+
$ pip install -r requirements.txt
|
| 44 |
+
$ pip install -e .
|
| 45 |
+
|
| 46 |
+
.. code-block:: sh
|
| 47 |
+
|
| 48 |
+
$ pip install botocore
|
| 49 |
+
|
| 50 |
+
Using Botocore
|
| 51 |
+
~~~~~~~~~~~~~~
|
| 52 |
+
After installing botocore
|
| 53 |
+
|
| 54 |
+
Next, set up credentials (in e.g. ``~/.aws/credentials``):
|
| 55 |
+
|
| 56 |
+
.. code-block:: ini
|
| 57 |
+
|
| 58 |
+
[default]
|
| 59 |
+
aws_access_key_id = YOUR_KEY
|
| 60 |
+
aws_secret_access_key = YOUR_SECRET
|
| 61 |
+
|
| 62 |
+
Then, set up a default region (in e.g. ``~/.aws/config``):
|
| 63 |
+
|
| 64 |
+
.. code-block:: ini
|
| 65 |
+
|
| 66 |
+
[default]
|
| 67 |
+
region=us-east-1
|
| 68 |
+
|
| 69 |
+
Other credentials configuration method can be found `here <https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html>`__
|
| 70 |
+
|
| 71 |
+
Then, from a Python interpreter:
|
| 72 |
+
|
| 73 |
+
.. code-block:: python
|
| 74 |
+
|
| 75 |
+
>>> import botocore.session
|
| 76 |
+
>>> session = botocore.session.get_session()
|
| 77 |
+
>>> client = session.create_client('ec2')
|
| 78 |
+
>>> print(client.describe_instances())
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
Getting Help
|
| 82 |
+
------------
|
| 83 |
+
|
| 84 |
+
We use GitHub issues for tracking bugs and feature requests and have limited
|
| 85 |
+
bandwidth to address them. Please use these community resources for getting
|
| 86 |
+
help. Please note many of the same resources available for ``boto3`` are
|
| 87 |
+
applicable for ``botocore``:
|
| 88 |
+
|
| 89 |
+
* Ask a question on `Stack Overflow <https://stackoverflow.com/>`__ and tag it with `boto3 <https://stackoverflow.com/questions/tagged/boto3>`__
|
| 90 |
+
* Open a support ticket with `AWS Support <https://console.aws.amazon.com/support/home#/>`__
|
| 91 |
+
* If it turns out that you may have found a bug, please `open an issue <https://github.com/boto/botocore/issues/new/choose>`__
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
Contributing
|
| 95 |
+
------------
|
| 96 |
+
|
| 97 |
+
We value feedback and contributions from our community. Whether it's a bug report, new feature, correction, or additional documentation, we welcome your issues and pull requests. Please read through this `CONTRIBUTING <https://github.com/boto/botocore/blob/develop/CONTRIBUTING.rst>`__ document before submitting any issues or pull requests to ensure we have all the necessary information to effectively respond to your contribution.
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
Maintenance and Support for SDK Major Versions
|
| 101 |
+
----------------------------------------------
|
| 102 |
+
|
| 103 |
+
Botocore was made generally available on 06/22/2015 and is currently in the full support phase of the availability life cycle.
|
| 104 |
+
|
| 105 |
+
For information about maintenance and support for SDK major versions and their underlying dependencies, see the following in the AWS SDKs and Tools Reference Guide:
|
| 106 |
+
|
| 107 |
+
* `AWS SDKs and Tools Maintenance Policy <https://docs.aws.amazon.com/sdkref/latest/guide/maint-policy.html>`__
|
| 108 |
+
* `AWS SDKs and Tools Version Support Matrix <https://docs.aws.amazon.com/sdkref/latest/guide/version-support-matrix.html>`__
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
More Resources
|
| 112 |
+
--------------
|
| 113 |
+
|
| 114 |
+
* `NOTICE <https://github.com/boto/botocore/blob/develop/NOTICE>`__
|
| 115 |
+
* `Changelog <https://github.com/boto/botocore/blob/develop/CHANGELOG.rst>`__
|
| 116 |
+
* `License <https://github.com/boto/botocore/blob/develop/LICENSE.txt>`__
|
testbed/boto__botocore/pyproject.toml
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[tool.pytest.ini_options]
|
| 2 |
+
markers = [
|
| 3 |
+
"slow: marks tests as slow",
|
| 4 |
+
"validates_models: marks tests as one which validates service models",
|
| 5 |
+
]
|
| 6 |
+
|
| 7 |
+
[tool.isort]
|
| 8 |
+
profile = "black"
|
| 9 |
+
line_length = 79
|
| 10 |
+
honor_noqa = true
|
| 11 |
+
src_paths = ["botocore", "tests"]
|
| 12 |
+
|
| 13 |
+
[tool.ruff]
|
| 14 |
+
exclude = [
|
| 15 |
+
".bzr",
|
| 16 |
+
".direnv",
|
| 17 |
+
".eggs",
|
| 18 |
+
".git",
|
| 19 |
+
".git-rewrite",
|
| 20 |
+
".hg",
|
| 21 |
+
".ipynb_checkpoints",
|
| 22 |
+
".mypy_cache",
|
| 23 |
+
".nox",
|
| 24 |
+
".pants.d",
|
| 25 |
+
".pyenv",
|
| 26 |
+
".pytest_cache",
|
| 27 |
+
".pytype",
|
| 28 |
+
".ruff_cache",
|
| 29 |
+
".svn",
|
| 30 |
+
".tox",
|
| 31 |
+
".venv",
|
| 32 |
+
".vscode",
|
| 33 |
+
"__pypackages__",
|
| 34 |
+
"_build",
|
| 35 |
+
"buck-out",
|
| 36 |
+
"build",
|
| 37 |
+
"dist",
|
| 38 |
+
"node_modules",
|
| 39 |
+
"site-packages",
|
| 40 |
+
"venv",
|
| 41 |
+
]
|
| 42 |
+
|
| 43 |
+
# Format same as Black.
|
| 44 |
+
line-length = 79
|
| 45 |
+
indent-width = 4
|
| 46 |
+
|
| 47 |
+
target-version = "py38"
|
| 48 |
+
|
| 49 |
+
[tool.ruff.lint]
|
| 50 |
+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
|
| 51 |
+
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
|
| 52 |
+
# McCabe complexity (`C901`) by default.
|
| 53 |
+
select = ["E4", "E7", "E9", "F", "UP"]
|
| 54 |
+
ignore = []
|
| 55 |
+
|
| 56 |
+
# Allow fix for all enabled rules (when `--fix`) is provided.
|
| 57 |
+
fixable = ["ALL"]
|
| 58 |
+
unfixable = []
|
| 59 |
+
|
| 60 |
+
# Allow unused variables when underscore-prefixed.
|
| 61 |
+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
| 62 |
+
|
| 63 |
+
[tool.ruff.format]
|
| 64 |
+
# Like Black, use double quotes for strings, spaces for indents
|
| 65 |
+
# and trailing commas.
|
| 66 |
+
quote-style = "preserve"
|
| 67 |
+
indent-style = "space"
|
| 68 |
+
skip-magic-trailing-comma = false
|
| 69 |
+
line-ending = "auto"
|
| 70 |
+
|
| 71 |
+
docstring-code-format = false
|
| 72 |
+
docstring-code-line-length = "dynamic"
|
testbed/boto__botocore/requirements-dev-lock.txt
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is autogenerated by pip-compile with Python 3.8
|
| 3 |
+
# by the following command:
|
| 4 |
+
#
|
| 5 |
+
# pip-compile --allow-unsafe --generate-hashes --output-file=requirements-dev-lock.txt requirements-dev.txt
|
| 6 |
+
#
|
| 7 |
+
atomicwrites==1.4.1 \
|
| 8 |
+
--hash=sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11
|
| 9 |
+
# via -r requirements-dev.txt
|
| 10 |
+
attrs==23.2.0 \
|
| 11 |
+
--hash=sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30 \
|
| 12 |
+
--hash=sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1
|
| 13 |
+
# via
|
| 14 |
+
# jsonschema
|
| 15 |
+
# referencing
|
| 16 |
+
behave==1.2.5 \
|
| 17 |
+
--hash=sha256:07c741f30497b6f9361a9bc74c68418507cd17e70d6f586faa3bff57684a2ec8 \
|
| 18 |
+
--hash=sha256:81b731ac5187e31e4aad2594944fa914943683a9818320846d037c5ebd6d5d0b \
|
| 19 |
+
--hash=sha256:89238a5e4b11ff607e8ebc6b4b1fb1a0b1f3d794fba80e1fb4b6b3652979c927 \
|
| 20 |
+
--hash=sha256:8c182feece4a519c5ffc11e1ab3682d25d5a390dd5f4573bb1296443beb9d7c7
|
| 21 |
+
# via -r requirements-dev.txt
|
| 22 |
+
colorama==0.4.6 \
|
| 23 |
+
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
|
| 24 |
+
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
|
| 25 |
+
# via -r requirements-dev.txt
|
| 26 |
+
coverage[toml]==7.2.7 \
|
| 27 |
+
--hash=sha256:06a9a2be0b5b576c3f18f1a241f0473575c4a26021b52b2a85263a00f034d51f \
|
| 28 |
+
--hash=sha256:06fb182e69f33f6cd1d39a6c597294cff3143554b64b9825d1dc69d18cc2fff2 \
|
| 29 |
+
--hash=sha256:0a5f9e1dbd7fbe30196578ca36f3fba75376fb99888c395c5880b355e2875f8a \
|
| 30 |
+
--hash=sha256:0e1f928eaf5469c11e886fe0885ad2bf1ec606434e79842a879277895a50942a \
|
| 31 |
+
--hash=sha256:171717c7cb6b453aebac9a2ef603699da237f341b38eebfee9be75d27dc38e01 \
|
| 32 |
+
--hash=sha256:1e9d683426464e4a252bf70c3498756055016f99ddaec3774bf368e76bbe02b6 \
|
| 33 |
+
--hash=sha256:201e7389591af40950a6480bd9edfa8ed04346ff80002cec1a66cac4549c1ad7 \
|
| 34 |
+
--hash=sha256:245167dd26180ab4c91d5e1496a30be4cd721a5cf2abf52974f965f10f11419f \
|
| 35 |
+
--hash=sha256:2aee274c46590717f38ae5e4650988d1af340fe06167546cc32fe2f58ed05b02 \
|
| 36 |
+
--hash=sha256:2e07b54284e381531c87f785f613b833569c14ecacdcb85d56b25c4622c16c3c \
|
| 37 |
+
--hash=sha256:31563e97dae5598556600466ad9beea39fb04e0229e61c12eaa206e0aa202063 \
|
| 38 |
+
--hash=sha256:33d6d3ea29d5b3a1a632b3c4e4f4ecae24ef170b0b9ee493883f2df10039959a \
|
| 39 |
+
--hash=sha256:3d376df58cc111dc8e21e3b6e24606b5bb5dee6024f46a5abca99124b2229ef5 \
|
| 40 |
+
--hash=sha256:419bfd2caae268623dd469eff96d510a920c90928b60f2073d79f8fe2bbc5959 \
|
| 41 |
+
--hash=sha256:48c19d2159d433ccc99e729ceae7d5293fbffa0bdb94952d3579983d1c8c9d97 \
|
| 42 |
+
--hash=sha256:49969a9f7ffa086d973d91cec8d2e31080436ef0fb4a359cae927e742abfaaa6 \
|
| 43 |
+
--hash=sha256:52edc1a60c0d34afa421c9c37078817b2e67a392cab17d97283b64c5833f427f \
|
| 44 |
+
--hash=sha256:537891ae8ce59ef63d0123f7ac9e2ae0fc8b72c7ccbe5296fec45fd68967b6c9 \
|
| 45 |
+
--hash=sha256:54b896376ab563bd38453cecb813c295cf347cf5906e8b41d340b0321a5433e5 \
|
| 46 |
+
--hash=sha256:58c2ccc2f00ecb51253cbe5d8d7122a34590fac9646a960d1430d5b15321d95f \
|
| 47 |
+
--hash=sha256:5b7540161790b2f28143191f5f8ec02fb132660ff175b7747b95dcb77ac26562 \
|
| 48 |
+
--hash=sha256:5baa06420f837184130752b7c5ea0808762083bf3487b5038d68b012e5937dbe \
|
| 49 |
+
--hash=sha256:5e330fc79bd7207e46c7d7fd2bb4af2963f5f635703925543a70b99574b0fea9 \
|
| 50 |
+
--hash=sha256:61b9a528fb348373c433e8966535074b802c7a5d7f23c4f421e6c6e2f1697a6f \
|
| 51 |
+
--hash=sha256:63426706118b7f5cf6bb6c895dc215d8a418d5952544042c8a2d9fe87fcf09cb \
|
| 52 |
+
--hash=sha256:6d040ef7c9859bb11dfeb056ff5b3872436e3b5e401817d87a31e1750b9ae2fb \
|
| 53 |
+
--hash=sha256:6f48351d66575f535669306aa7d6d6f71bc43372473b54a832222803eb956fd1 \
|
| 54 |
+
--hash=sha256:7ee7d9d4822c8acc74a5e26c50604dff824710bc8de424904c0982e25c39c6cb \
|
| 55 |
+
--hash=sha256:81c13a1fc7468c40f13420732805a4c38a105d89848b7c10af65a90beff25250 \
|
| 56 |
+
--hash=sha256:8d13c64ee2d33eccf7437961b6ea7ad8673e2be040b4f7fd4fd4d4d28d9ccb1e \
|
| 57 |
+
--hash=sha256:8de8bb0e5ad103888d65abef8bca41ab93721647590a3f740100cd65c3b00511 \
|
| 58 |
+
--hash=sha256:8fa03bce9bfbeeef9f3b160a8bed39a221d82308b4152b27d82d8daa7041fee5 \
|
| 59 |
+
--hash=sha256:924d94291ca674905fe9481f12294eb11f2d3d3fd1adb20314ba89e94f44ed59 \
|
| 60 |
+
--hash=sha256:975d70ab7e3c80a3fe86001d8751f6778905ec723f5b110aed1e450da9d4b7f2 \
|
| 61 |
+
--hash=sha256:976b9c42fb2a43ebf304fa7d4a310e5f16cc99992f33eced91ef6f908bd8f33d \
|
| 62 |
+
--hash=sha256:9e31cb64d7de6b6f09702bb27c02d1904b3aebfca610c12772452c4e6c21a0d3 \
|
| 63 |
+
--hash=sha256:a342242fe22407f3c17f4b499276a02b01e80f861f1682ad1d95b04018e0c0d4 \
|
| 64 |
+
--hash=sha256:a3d33a6b3eae87ceaefa91ffdc130b5e8536182cd6dfdbfc1aa56b46ff8c86de \
|
| 65 |
+
--hash=sha256:a895fcc7b15c3fc72beb43cdcbdf0ddb7d2ebc959edac9cef390b0d14f39f8a9 \
|
| 66 |
+
--hash=sha256:afb17f84d56068a7c29f5fa37bfd38d5aba69e3304af08ee94da8ed5b0865833 \
|
| 67 |
+
--hash=sha256:b1c546aca0ca4d028901d825015dc8e4d56aac4b541877690eb76490f1dc8ed0 \
|
| 68 |
+
--hash=sha256:b29019c76039dc3c0fd815c41392a044ce555d9bcdd38b0fb60fb4cd8e475ba9 \
|
| 69 |
+
--hash=sha256:b46517c02ccd08092f4fa99f24c3b83d8f92f739b4657b0f146246a0ca6a831d \
|
| 70 |
+
--hash=sha256:b7aa5f8a41217360e600da646004f878250a0d6738bcdc11a0a39928d7dc2050 \
|
| 71 |
+
--hash=sha256:b7b4c971f05e6ae490fef852c218b0e79d4e52f79ef0c8475566584a8fb3e01d \
|
| 72 |
+
--hash=sha256:ba90a9563ba44a72fda2e85302c3abc71c5589cea608ca16c22b9804262aaeb6 \
|
| 73 |
+
--hash=sha256:cb017fd1b2603ef59e374ba2063f593abe0fc45f2ad9abdde5b4d83bd922a353 \
|
| 74 |
+
--hash=sha256:d22656368f0e6189e24722214ed8d66b8022db19d182927b9a248a2a8a2f67eb \
|
| 75 |
+
--hash=sha256:d2c2db7fd82e9b72937969bceac4d6ca89660db0a0967614ce2481e81a0b771e \
|
| 76 |
+
--hash=sha256:d39b5b4f2a66ccae8b7263ac3c8170994b65266797fb96cbbfd3fb5b23921db8 \
|
| 77 |
+
--hash=sha256:d62a5c7dad11015c66fbb9d881bc4caa5b12f16292f857842d9d1871595f4495 \
|
| 78 |
+
--hash=sha256:e7d9405291c6928619403db1d10bd07888888ec1abcbd9748fdaa971d7d661b2 \
|
| 79 |
+
--hash=sha256:e84606b74eb7de6ff581a7915e2dab7a28a0517fbe1c9239eb227e1354064dcd \
|
| 80 |
+
--hash=sha256:eb393e5ebc85245347950143969b241d08b52b88a3dc39479822e073a1a8eb27 \
|
| 81 |
+
--hash=sha256:ebba1cd308ef115925421d3e6a586e655ca5a77b5bf41e02eb0e4562a111f2d1 \
|
| 82 |
+
--hash=sha256:ee57190f24fba796e36bb6d3aa8a8783c643d8fa9760c89f7a98ab5455fbf818 \
|
| 83 |
+
--hash=sha256:f2f67fe12b22cd130d34d0ef79206061bfb5eda52feb6ce0dba0644e20a03cf4 \
|
| 84 |
+
--hash=sha256:f6951407391b639504e3b3be51b7ba5f3528adbf1a8ac3302b687ecababf929e \
|
| 85 |
+
--hash=sha256:f75f7168ab25dd93110c8a8117a22450c19976afbc44234cbf71481094c1b850 \
|
| 86 |
+
--hash=sha256:fdec9e8cbf13a5bf63290fc6013d216a4c7232efb51548594ca3631a7f13c3a3
|
| 87 |
+
# via
|
| 88 |
+
# -r requirements-dev.txt
|
| 89 |
+
# pytest-cov
|
| 90 |
+
exceptiongroup==1.2.2 \
|
| 91 |
+
--hash=sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b \
|
| 92 |
+
--hash=sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc
|
| 93 |
+
# via pytest
|
| 94 |
+
execnet==2.1.1 \
|
| 95 |
+
--hash=sha256:26dee51f1b80cebd6d0ca8e74dd8745419761d3bef34163928cbebbdc4749fdc \
|
| 96 |
+
--hash=sha256:5189b52c6121c24feae288166ab41b32549c7e2348652736540b9e6e7d4e72e3
|
| 97 |
+
# via pytest-xdist
|
| 98 |
+
importlib-resources==6.4.0 \
|
| 99 |
+
--hash=sha256:50d10f043df931902d4194ea07ec57960f66a80449ff867bfe782b4c486ba78c \
|
| 100 |
+
--hash=sha256:cdb2b453b8046ca4e3798eb1d84f3cce1446a0e8e7b5ef4efb600f19fc398145
|
| 101 |
+
# via
|
| 102 |
+
# jsonschema
|
| 103 |
+
# jsonschema-specifications
|
| 104 |
+
iniconfig==2.0.0 \
|
| 105 |
+
--hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \
|
| 106 |
+
--hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374
|
| 107 |
+
# via pytest
|
| 108 |
+
jsonschema==4.21.1 \
|
| 109 |
+
--hash=sha256:7996507afae316306f9e2290407761157c6f78002dcf7419acb99822143d1c6f \
|
| 110 |
+
--hash=sha256:85727c00279f5fa6bedbe6238d2aa6403bedd8b4864ab11207d07df3cc1b2ee5
|
| 111 |
+
# via -r requirements-dev.txt
|
| 112 |
+
jsonschema-specifications==2023.12.1 \
|
| 113 |
+
--hash=sha256:48a76787b3e70f5ed53f1160d2b81f586e4ca6d1548c5de7085d1682674764cc \
|
| 114 |
+
--hash=sha256:87e4fdf3a94858b8a2ba2778d9ba57d8a9cafca7c7489c46ba0d30a8bc6a9c3c
|
| 115 |
+
# via jsonschema
|
| 116 |
+
packaging==24.1 \
|
| 117 |
+
--hash=sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002 \
|
| 118 |
+
--hash=sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124
|
| 119 |
+
# via pytest
|
| 120 |
+
parse==1.20.2 \
|
| 121 |
+
--hash=sha256:967095588cb802add9177d0c0b6133b5ba33b1ea9007ca800e526f42a85af558 \
|
| 122 |
+
--hash=sha256:b41d604d16503c79d81af5165155c0b20f6c8d6c559efa66b4b695c3e5a0a0ce
|
| 123 |
+
# via
|
| 124 |
+
# behave
|
| 125 |
+
# parse-type
|
| 126 |
+
parse-type==0.6.2 \
|
| 127 |
+
--hash=sha256:06d39a8b70fde873eb2a131141a0e79bb34a432941fb3d66fad247abafc9766c \
|
| 128 |
+
--hash=sha256:79b1f2497060d0928bc46016793f1fca1057c4aacdf15ef876aa48d75a73a355
|
| 129 |
+
# via behave
|
| 130 |
+
pkgutil-resolve-name==1.3.10 \
|
| 131 |
+
--hash=sha256:357d6c9e6a755653cfd78893817c0853af365dd51ec97f3d358a819373bbd174 \
|
| 132 |
+
--hash=sha256:ca27cc078d25c5ad71a9de0a7a330146c4e014c2462d9af19c6b828280649c5e
|
| 133 |
+
# via jsonschema
|
| 134 |
+
pluggy==1.5.0 \
|
| 135 |
+
--hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \
|
| 136 |
+
--hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669
|
| 137 |
+
# via pytest
|
| 138 |
+
pytest==8.1.1 \
|
| 139 |
+
--hash=sha256:2a8386cfc11fa9d2c50ee7b2a57e7d898ef90470a7a34c4b949ff59662bb78b7 \
|
| 140 |
+
--hash=sha256:ac978141a75948948817d360297b7aae0fcb9d6ff6bc9ec6d514b85d5a65c044
|
| 141 |
+
# via
|
| 142 |
+
# -r requirements-dev.txt
|
| 143 |
+
# pytest-cov
|
| 144 |
+
# pytest-xdist
|
| 145 |
+
pytest-cov==5.0.0 \
|
| 146 |
+
--hash=sha256:4f0764a1219df53214206bf1feea4633c3b558a2925c8b59f144f682861ce652 \
|
| 147 |
+
--hash=sha256:5837b58e9f6ebd335b0f8060eecce69b662415b16dc503883a02f45dfeb14857
|
| 148 |
+
# via -r requirements-dev.txt
|
| 149 |
+
pytest-xdist==3.5.0 \
|
| 150 |
+
--hash=sha256:cbb36f3d67e0c478baa57fa4edc8843887e0f6cfc42d677530a36d7472b32d8a \
|
| 151 |
+
--hash=sha256:d075629c7e00b611df89f490a5063944bee7a4362a5ff11c7cc7824a03dfce24
|
| 152 |
+
# via -r requirements-dev.txt
|
| 153 |
+
referencing==0.35.1 \
|
| 154 |
+
--hash=sha256:25b42124a6c8b632a425174f24087783efb348a6f1e0008e63cd4466fedf703c \
|
| 155 |
+
--hash=sha256:eda6d3234d62814d1c64e305c1331c9a3a6132da475ab6382eaa997b21ee75de
|
| 156 |
+
# via
|
| 157 |
+
# jsonschema
|
| 158 |
+
# jsonschema-specifications
|
| 159 |
+
rpds-py==0.19.1 \
|
| 160 |
+
--hash=sha256:01227f8b3e6c8961490d869aa65c99653df80d2f0a7fde8c64ebddab2b9b02fd \
|
| 161 |
+
--hash=sha256:08ce9c95a0b093b7aec75676b356a27879901488abc27e9d029273d280438505 \
|
| 162 |
+
--hash=sha256:0b02dd77a2de6e49078c8937aadabe933ceac04b41c5dde5eca13a69f3cf144e \
|
| 163 |
+
--hash=sha256:0d4b52811dcbc1aba08fd88d475f75b4f6db0984ba12275d9bed1a04b2cae9b5 \
|
| 164 |
+
--hash=sha256:13e6d4840897d4e4e6b2aa1443e3a8eca92b0402182aafc5f4ca1f5e24f9270a \
|
| 165 |
+
--hash=sha256:1a129c02b42d46758c87faeea21a9f574e1c858b9f358b6dd0bbd71d17713175 \
|
| 166 |
+
--hash=sha256:1a8dfa125b60ec00c7c9baef945bb04abf8ac772d8ebefd79dae2a5f316d7850 \
|
| 167 |
+
--hash=sha256:1c32e41de995f39b6b315d66c27dea3ef7f7c937c06caab4c6a79a5e09e2c415 \
|
| 168 |
+
--hash=sha256:1d494887d40dc4dd0d5a71e9d07324e5c09c4383d93942d391727e7a40ff810b \
|
| 169 |
+
--hash=sha256:1d4af2eb520d759f48f1073ad3caef997d1bfd910dc34e41261a595d3f038a94 \
|
| 170 |
+
--hash=sha256:1fb93d3486f793d54a094e2bfd9cd97031f63fcb5bc18faeb3dd4b49a1c06523 \
|
| 171 |
+
--hash=sha256:24f8ae92c7fae7c28d0fae9b52829235df83f34847aa8160a47eb229d9666c7b \
|
| 172 |
+
--hash=sha256:24fc5a84777cb61692d17988989690d6f34f7f95968ac81398d67c0d0994a897 \
|
| 173 |
+
--hash=sha256:26ab43b6d65d25b1a333c8d1b1c2f8399385ff683a35ab5e274ba7b8bb7dc61c \
|
| 174 |
+
--hash=sha256:271accf41b02687cef26367c775ab220372ee0f4925591c6796e7c148c50cab5 \
|
| 175 |
+
--hash=sha256:2ddd50f18ebc05ec29a0d9271e9dbe93997536da3546677f8ca00b76d477680c \
|
| 176 |
+
--hash=sha256:31dd5794837f00b46f4096aa8ccaa5972f73a938982e32ed817bb520c465e520 \
|
| 177 |
+
--hash=sha256:31e450840f2f27699d014cfc8865cc747184286b26d945bcea6042bb6aa4d26e \
|
| 178 |
+
--hash=sha256:32e0db3d6e4f45601b58e4ac75c6f24afbf99818c647cc2066f3e4b192dabb1f \
|
| 179 |
+
--hash=sha256:346557f5b1d8fd9966059b7a748fd79ac59f5752cd0e9498d6a40e3ac1c1875f \
|
| 180 |
+
--hash=sha256:34bca66e2e3eabc8a19e9afe0d3e77789733c702c7c43cd008e953d5d1463fde \
|
| 181 |
+
--hash=sha256:3511f6baf8438326e351097cecd137eb45c5f019944fe0fd0ae2fea2fd26be39 \
|
| 182 |
+
--hash=sha256:35af5e4d5448fa179fd7fff0bba0fba51f876cd55212f96c8bbcecc5c684ae5c \
|
| 183 |
+
--hash=sha256:3837c63dd6918a24de6c526277910e3766d8c2b1627c500b155f3eecad8fad65 \
|
| 184 |
+
--hash=sha256:39d67896f7235b2c886fb1ee77b1491b77049dcef6fbf0f401e7b4cbed86bbd4 \
|
| 185 |
+
--hash=sha256:3b823be829407393d84ee56dc849dbe3b31b6a326f388e171555b262e8456cc1 \
|
| 186 |
+
--hash=sha256:3c73254c256081704dba0a333457e2fb815364018788f9b501efe7c5e0ada401 \
|
| 187 |
+
--hash=sha256:3ddab996807c6b4227967fe1587febade4e48ac47bb0e2d3e7858bc621b1cace \
|
| 188 |
+
--hash=sha256:3e1dc59a5e7bc7f44bd0c048681f5e05356e479c50be4f2c1a7089103f1621d5 \
|
| 189 |
+
--hash=sha256:4383beb4a29935b8fa28aca8fa84c956bf545cb0c46307b091b8d312a9150e6a \
|
| 190 |
+
--hash=sha256:4cc4bc73e53af8e7a42c8fd7923bbe35babacfa7394ae9240b3430b5dcf16b2a \
|
| 191 |
+
--hash=sha256:4dd02e29c8cbed21a1875330b07246b71121a1c08e29f0ee3db5b4cfe16980c4 \
|
| 192 |
+
--hash=sha256:4f580ae79d0b861dfd912494ab9d477bea535bfb4756a2269130b6607a21802e \
|
| 193 |
+
--hash=sha256:53dbc35808c6faa2ce3e48571f8f74ef70802218554884787b86a30947842a14 \
|
| 194 |
+
--hash=sha256:56313be667a837ff1ea3508cebb1ef6681d418fa2913a0635386cf29cff35165 \
|
| 195 |
+
--hash=sha256:57863d16187995c10fe9cf911b897ed443ac68189179541734502353af33e693 \
|
| 196 |
+
--hash=sha256:5953391af1405f968eb5701ebbb577ebc5ced8d0041406f9052638bafe52209d \
|
| 197 |
+
--hash=sha256:5beffdbe766cfe4fb04f30644d822a1080b5359df7db3a63d30fa928375b2720 \
|
| 198 |
+
--hash=sha256:5e360188b72f8080fefa3adfdcf3618604cc8173651c9754f189fece068d2a45 \
|
| 199 |
+
--hash=sha256:5e58b61dcbb483a442c6239c3836696b79f2cd8e7eec11e12155d3f6f2d886d1 \
|
| 200 |
+
--hash=sha256:69084fd29bfeff14816666c93a466e85414fe6b7d236cfc108a9c11afa6f7301 \
|
| 201 |
+
--hash=sha256:6d1d7539043b2b31307f2c6c72957a97c839a88b2629a348ebabe5aa8b626d6b \
|
| 202 |
+
--hash=sha256:6d8b735c4d162dc7d86a9cf3d717f14b6c73637a1f9cd57fe7e61002d9cb1972 \
|
| 203 |
+
--hash=sha256:6ea961a674172ed2235d990d7edf85d15d8dfa23ab8575e48306371c070cda67 \
|
| 204 |
+
--hash=sha256:71157f9db7f6bc6599a852852f3389343bea34315b4e6f109e5cbc97c1fb2963 \
|
| 205 |
+
--hash=sha256:720f3108fb1bfa32e51db58b832898372eb5891e8472a8093008010911e324c5 \
|
| 206 |
+
--hash=sha256:74129d5ffc4cde992d89d345f7f7d6758320e5d44a369d74d83493429dad2de5 \
|
| 207 |
+
--hash=sha256:747251e428406b05fc86fee3904ee19550c4d2d19258cef274e2151f31ae9d38 \
|
| 208 |
+
--hash=sha256:75130df05aae7a7ac171b3b5b24714cffeabd054ad2ebc18870b3aa4526eba23 \
|
| 209 |
+
--hash=sha256:7b3661e6d4ba63a094138032c1356d557de5b3ea6fd3cca62a195f623e381c76 \
|
| 210 |
+
--hash=sha256:7d5c7e32f3ee42f77d8ff1a10384b5cdcc2d37035e2e3320ded909aa192d32c3 \
|
| 211 |
+
--hash=sha256:8124101e92c56827bebef084ff106e8ea11c743256149a95b9fd860d3a4f331f \
|
| 212 |
+
--hash=sha256:81db2e7282cc0487f500d4db203edc57da81acde9e35f061d69ed983228ffe3b \
|
| 213 |
+
--hash=sha256:840e18c38098221ea6201f091fc5d4de6128961d2930fbbc96806fb43f69aec1 \
|
| 214 |
+
--hash=sha256:89cc8921a4a5028d6dd388c399fcd2eef232e7040345af3d5b16c04b91cf3c7e \
|
| 215 |
+
--hash=sha256:8b32cd4ab6db50c875001ba4f5a6b30c0f42151aa1fbf9c2e7e3674893fb1dc4 \
|
| 216 |
+
--hash=sha256:8df1c283e57c9cb4d271fdc1875f4a58a143a2d1698eb0d6b7c0d7d5f49c53a1 \
|
| 217 |
+
--hash=sha256:902cf4739458852fe917104365ec0efbea7d29a15e4276c96a8d33e6ed8ec137 \
|
| 218 |
+
--hash=sha256:97fbb77eaeb97591efdc654b8b5f3ccc066406ccfb3175b41382f221ecc216e8 \
|
| 219 |
+
--hash=sha256:9c7042488165f7251dc7894cd533a875d2875af6d3b0e09eda9c4b334627ad1c \
|
| 220 |
+
--hash=sha256:9e318e6786b1e750a62f90c6f7fa8b542102bdcf97c7c4de2a48b50b61bd36ec \
|
| 221 |
+
--hash=sha256:a9421b23c85f361a133aa7c5e8ec757668f70343f4ed8fdb5a4a14abd5437244 \
|
| 222 |
+
--hash=sha256:aaf71f95b21f9dc708123335df22e5a2fef6307e3e6f9ed773b2e0938cc4d491 \
|
| 223 |
+
--hash=sha256:afedc35fe4b9e30ab240b208bb9dc8938cb4afe9187589e8d8d085e1aacb8309 \
|
| 224 |
+
--hash=sha256:b5e28e56143750808c1c79c70a16519e9bc0a68b623197b96292b21b62d6055c \
|
| 225 |
+
--hash=sha256:b82c9514c6d74b89a370c4060bdb80d2299bc6857e462e4a215b4ef7aa7b090e \
|
| 226 |
+
--hash=sha256:b8f78398e67a7227aefa95f876481485403eb974b29e9dc38b307bb6eb2315ea \
|
| 227 |
+
--hash=sha256:bbda75f245caecff8faa7e32ee94dfaa8312a3367397975527f29654cd17a6ed \
|
| 228 |
+
--hash=sha256:bca34e913d27401bda2a6f390d0614049f5a95b3b11cd8eff80fe4ec340a1208 \
|
| 229 |
+
--hash=sha256:bd04d8cab16cab5b0a9ffc7d10f0779cf1120ab16c3925404428f74a0a43205a \
|
| 230 |
+
--hash=sha256:c149a652aeac4902ecff2dd93c3b2681c608bd5208c793c4a99404b3e1afc87c \
|
| 231 |
+
--hash=sha256:c2087dbb76a87ec2c619253e021e4fb20d1a72580feeaa6892b0b3d955175a71 \
|
| 232 |
+
--hash=sha256:c34f751bf67cab69638564eee34023909380ba3e0d8ee7f6fe473079bf93f09b \
|
| 233 |
+
--hash=sha256:c6d20c8896c00775e6f62d8373aba32956aa0b850d02b5ec493f486c88e12859 \
|
| 234 |
+
--hash=sha256:c7af6f7b80f687b33a4cdb0a785a5d4de1fb027a44c9a049d8eb67d5bfe8a687 \
|
| 235 |
+
--hash=sha256:c7b07959866a6afb019abb9564d8a55046feb7a84506c74a6f197cbcdf8a208e \
|
| 236 |
+
--hash=sha256:ca0dda0c5715efe2ab35bb83f813f681ebcd2840d8b1b92bfc6fe3ab382fae4a \
|
| 237 |
+
--hash=sha256:cdb7eb3cf3deb3dd9e7b8749323b5d970052711f9e1e9f36364163627f96da58 \
|
| 238 |
+
--hash=sha256:ce757c7c90d35719b38fa3d4ca55654a76a40716ee299b0865f2de21c146801c \
|
| 239 |
+
--hash=sha256:d1fa67ef839bad3815124f5f57e48cd50ff392f4911a9f3cf449d66fa3df62a5 \
|
| 240 |
+
--hash=sha256:d2dbd8f4990d4788cb122f63bf000357533f34860d269c1a8e90ae362090ff3a \
|
| 241 |
+
--hash=sha256:d4ec0046facab83012d821b33cead742a35b54575c4edfb7ed7445f63441835f \
|
| 242 |
+
--hash=sha256:dbceedcf4a9329cc665452db1aaf0845b85c666e4885b92ee0cddb1dbf7e052a \
|
| 243 |
+
--hash=sha256:dc733d35f861f8d78abfaf54035461e10423422999b360966bf1c443cbc42705 \
|
| 244 |
+
--hash=sha256:dd635c2c4043222d80d80ca1ac4530a633102a9f2ad12252183bcf338c1b9474 \
|
| 245 |
+
--hash=sha256:de1f7cd5b6b351e1afd7568bdab94934d656abe273d66cda0ceea43bbc02a0c2 \
|
| 246 |
+
--hash=sha256:df7c841813f6265e636fe548a49664c77af31ddfa0085515326342a751a6ba51 \
|
| 247 |
+
--hash=sha256:e0f9d268b19e8f61bf42a1da48276bcd05f7ab5560311f541d22557f8227b866 \
|
| 248 |
+
--hash=sha256:e2d66eb41ffca6cc3c91d8387509d27ba73ad28371ef90255c50cb51f8953301 \
|
| 249 |
+
--hash=sha256:e429fc517a1c5e2a70d576077231538a98d59a45dfc552d1ac45a132844e6dfb \
|
| 250 |
+
--hash=sha256:e4d2b88efe65544a7d5121b0c3b003ebba92bfede2ea3577ce548b69c5235185 \
|
| 251 |
+
--hash=sha256:e76c902d229a3aa9d5ceb813e1cbcc69bf5bda44c80d574ff1ac1fa3136dea71 \
|
| 252 |
+
--hash=sha256:ef07a0a1d254eeb16455d839cef6e8c2ed127f47f014bbda64a58b5482b6c836 \
|
| 253 |
+
--hash=sha256:f09529d2332264a902688031a83c19de8fda5eb5881e44233286b9c9ec91856d \
|
| 254 |
+
--hash=sha256:f0a6d4a93d2a05daec7cb885157c97bbb0be4da739d6f9dfb02e101eb40921cd \
|
| 255 |
+
--hash=sha256:f0cf2a0dbb5987da4bd92a7ca727eadb225581dd9681365beba9accbe5308f7d \
|
| 256 |
+
--hash=sha256:f2671cb47e50a97f419a02cd1e0c339b31de017b033186358db92f4d8e2e17d8 \
|
| 257 |
+
--hash=sha256:f35b34a5184d5e0cc360b61664c1c06e866aab077b5a7c538a3e20c8fcdbf90b \
|
| 258 |
+
--hash=sha256:f3d73022990ab0c8b172cce57c69fd9a89c24fd473a5e79cbce92df87e3d9c48 \
|
| 259 |
+
--hash=sha256:f5b8353ea1a4d7dfb59a7f45c04df66ecfd363bb5b35f33b11ea579111d4655f \
|
| 260 |
+
--hash=sha256:f809a17cc78bd331e137caa25262b507225854073fd319e987bd216bed911b7c \
|
| 261 |
+
--hash=sha256:f9bc4161bd3b970cd6a6fcda70583ad4afd10f2750609fb1f3ca9505050d4ef3 \
|
| 262 |
+
--hash=sha256:fdf4890cda3b59170009d012fca3294c00140e7f2abe1910e6a730809d0f3f9b
|
| 263 |
+
# via
|
| 264 |
+
# jsonschema
|
| 265 |
+
# referencing
|
| 266 |
+
six==1.16.0 \
|
| 267 |
+
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
|
| 268 |
+
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
|
| 269 |
+
# via
|
| 270 |
+
# behave
|
| 271 |
+
# parse-type
|
| 272 |
+
tomli==2.0.1 \
|
| 273 |
+
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
|
| 274 |
+
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
|
| 275 |
+
# via
|
| 276 |
+
# coverage
|
| 277 |
+
# pytest
|
| 278 |
+
wheel==0.43.0 \
|
| 279 |
+
--hash=sha256:465ef92c69fa5c5da2d1cf8ac40559a8c940886afcef87dcf14b9470862f1d85 \
|
| 280 |
+
--hash=sha256:55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81
|
| 281 |
+
# via -r requirements-dev.txt
|
| 282 |
+
zipp==3.19.2 \
|
| 283 |
+
--hash=sha256:bf1dcf6450f873a13e952a29504887c89e6de7506209e5b1bcc3460135d4de19 \
|
| 284 |
+
--hash=sha256:f091755f667055f2d02b32c53771a7a6c8b47e1fdbc4b72a8b9072b3eef8015c
|
| 285 |
+
# via importlib-resources
|
testbed/boto__botocore/requirements-dev.txt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
wheel==0.43.0
|
| 2 |
+
behave==1.2.5
|
| 3 |
+
jsonschema==4.21.1
|
| 4 |
+
coverage==7.2.7
|
| 5 |
+
setuptools==71.1.0;python_version>="3.12"
|
| 6 |
+
packaging==24.1;python_version>="3.12" # Requirement for setuptools>=71
|
| 7 |
+
|
| 8 |
+
# Pytest specific deps
|
| 9 |
+
pytest==8.1.1
|
| 10 |
+
pytest-cov==5.0.0
|
| 11 |
+
pytest-xdist==3.5.0
|
| 12 |
+
atomicwrites>=1.0 # Windows requirement
|
| 13 |
+
colorama>0.3.0 # Windows requirement
|
testbed/boto__botocore/requirements-docs-lock.txt
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This file is autogenerated by pip-compile with Python 3.8
|
| 3 |
+
# by the following command:
|
| 4 |
+
#
|
| 5 |
+
# pip-compile --allow-unsafe --generate-hashes --output-file=requirements-docs-lock.txt requirements-docs.txt
|
| 6 |
+
#
|
| 7 |
+
alabaster==0.7.13 \
|
| 8 |
+
--hash=sha256:1ee19aca801bbabb5ba3f5f258e4422dfa86f82f3e9cefb0859b283cdd7f62a3 \
|
| 9 |
+
--hash=sha256:a27a4a084d5e690e16e01e03ad2b2e552c61a65469419b907243193de1a84ae2
|
| 10 |
+
# via sphinx
|
| 11 |
+
babel==2.15.0 \
|
| 12 |
+
--hash=sha256:08706bdad8d0a3413266ab61bd6c34d0c28d6e1e7badf40a2cebe67644e2e1fb \
|
| 13 |
+
--hash=sha256:8daf0e265d05768bc6c7a314cf1321e9a123afc328cc635c18622a2f30a04413
|
| 14 |
+
# via sphinx
|
| 15 |
+
beautifulsoup4==4.12.3 \
|
| 16 |
+
--hash=sha256:74e3d1928edc070d21748185c46e3fb33490f22f52a3addee9aee0f4f7781051 \
|
| 17 |
+
--hash=sha256:b80878c9f40111313e55da8ba20bdba06d8fa3969fc68304167741bbf9e082ed
|
| 18 |
+
# via furo
|
| 19 |
+
certifi==2024.7.4 \
|
| 20 |
+
--hash=sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b \
|
| 21 |
+
--hash=sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90
|
| 22 |
+
# via requests
|
| 23 |
+
charset-normalizer==3.3.2 \
|
| 24 |
+
--hash=sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027 \
|
| 25 |
+
--hash=sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087 \
|
| 26 |
+
--hash=sha256:0a55554a2fa0d408816b3b5cedf0045f4b8e1a6065aec45849de2d6f3f8e9786 \
|
| 27 |
+
--hash=sha256:0b2b64d2bb6d3fb9112bafa732def486049e63de9618b5843bcdd081d8144cd8 \
|
| 28 |
+
--hash=sha256:10955842570876604d404661fbccbc9c7e684caf432c09c715ec38fbae45ae09 \
|
| 29 |
+
--hash=sha256:122c7fa62b130ed55f8f285bfd56d5f4b4a5b503609d181f9ad85e55c89f4185 \
|
| 30 |
+
--hash=sha256:1ceae2f17a9c33cb48e3263960dc5fc8005351ee19db217e9b1bb15d28c02574 \
|
| 31 |
+
--hash=sha256:1d3193f4a680c64b4b6a9115943538edb896edc190f0b222e73761716519268e \
|
| 32 |
+
--hash=sha256:1f79682fbe303db92bc2b1136016a38a42e835d932bab5b3b1bfcfbf0640e519 \
|
| 33 |
+
--hash=sha256:2127566c664442652f024c837091890cb1942c30937add288223dc895793f898 \
|
| 34 |
+
--hash=sha256:22afcb9f253dac0696b5a4be4a1c0f8762f8239e21b99680099abd9b2b1b2269 \
|
| 35 |
+
--hash=sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3 \
|
| 36 |
+
--hash=sha256:2e81c7b9c8979ce92ed306c249d46894776a909505d8f5a4ba55b14206e3222f \
|
| 37 |
+
--hash=sha256:3287761bc4ee9e33561a7e058c72ac0938c4f57fe49a09eae428fd88aafe7bb6 \
|
| 38 |
+
--hash=sha256:34d1c8da1e78d2e001f363791c98a272bb734000fcef47a491c1e3b0505657a8 \
|
| 39 |
+
--hash=sha256:37e55c8e51c236f95b033f6fb391d7d7970ba5fe7ff453dad675e88cf303377a \
|
| 40 |
+
--hash=sha256:3d47fa203a7bd9c5b6cee4736ee84ca03b8ef23193c0d1ca99b5089f72645c73 \
|
| 41 |
+
--hash=sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc \
|
| 42 |
+
--hash=sha256:42cb296636fcc8b0644486d15c12376cb9fa75443e00fb25de0b8602e64c1714 \
|
| 43 |
+
--hash=sha256:45485e01ff4d3630ec0d9617310448a8702f70e9c01906b0d0118bdf9d124cf2 \
|
| 44 |
+
--hash=sha256:4a78b2b446bd7c934f5dcedc588903fb2f5eec172f3d29e52a9096a43722adfc \
|
| 45 |
+
--hash=sha256:4ab2fe47fae9e0f9dee8c04187ce5d09f48eabe611be8259444906793ab7cbce \
|
| 46 |
+
--hash=sha256:4d0d1650369165a14e14e1e47b372cfcb31d6ab44e6e33cb2d4e57265290044d \
|
| 47 |
+
--hash=sha256:549a3a73da901d5bc3ce8d24e0600d1fa85524c10287f6004fbab87672bf3e1e \
|
| 48 |
+
--hash=sha256:55086ee1064215781fff39a1af09518bc9255b50d6333f2e4c74ca09fac6a8f6 \
|
| 49 |
+
--hash=sha256:572c3763a264ba47b3cf708a44ce965d98555f618ca42c926a9c1616d8f34269 \
|
| 50 |
+
--hash=sha256:573f6eac48f4769d667c4442081b1794f52919e7edada77495aaed9236d13a96 \
|
| 51 |
+
--hash=sha256:5b4c145409bef602a690e7cfad0a15a55c13320ff7a3ad7ca59c13bb8ba4d45d \
|
| 52 |
+
--hash=sha256:6463effa3186ea09411d50efc7d85360b38d5f09b870c48e4600f63af490e56a \
|
| 53 |
+
--hash=sha256:65f6f63034100ead094b8744b3b97965785388f308a64cf8d7c34f2f2e5be0c4 \
|
| 54 |
+
--hash=sha256:663946639d296df6a2bb2aa51b60a2454ca1cb29835324c640dafb5ff2131a77 \
|
| 55 |
+
--hash=sha256:6897af51655e3691ff853668779c7bad41579facacf5fd7253b0133308cf000d \
|
| 56 |
+
--hash=sha256:68d1f8a9e9e37c1223b656399be5d6b448dea850bed7d0f87a8311f1ff3dabb0 \
|
| 57 |
+
--hash=sha256:6ac7ffc7ad6d040517be39eb591cac5ff87416c2537df6ba3cba3bae290c0fed \
|
| 58 |
+
--hash=sha256:6b3251890fff30ee142c44144871185dbe13b11bab478a88887a639655be1068 \
|
| 59 |
+
--hash=sha256:6c4caeef8fa63d06bd437cd4bdcf3ffefe6738fb1b25951440d80dc7df8c03ac \
|
| 60 |
+
--hash=sha256:6ef1d82a3af9d3eecdba2321dc1b3c238245d890843e040e41e470ffa64c3e25 \
|
| 61 |
+
--hash=sha256:753f10e867343b4511128c6ed8c82f7bec3bd026875576dfd88483c5c73b2fd8 \
|
| 62 |
+
--hash=sha256:7cd13a2e3ddeed6913a65e66e94b51d80a041145a026c27e6bb76c31a853c6ab \
|
| 63 |
+
--hash=sha256:7ed9e526742851e8d5cc9e6cf41427dfc6068d4f5a3bb03659444b4cabf6bc26 \
|
| 64 |
+
--hash=sha256:7f04c839ed0b6b98b1a7501a002144b76c18fb1c1850c8b98d458ac269e26ed2 \
|
| 65 |
+
--hash=sha256:802fe99cca7457642125a8a88a084cef28ff0cf9407060f7b93dca5aa25480db \
|
| 66 |
+
--hash=sha256:80402cd6ee291dcb72644d6eac93785fe2c8b9cb30893c1af5b8fdd753b9d40f \
|
| 67 |
+
--hash=sha256:8465322196c8b4d7ab6d1e049e4c5cb460d0394da4a27d23cc242fbf0034b6b5 \
|
| 68 |
+
--hash=sha256:86216b5cee4b06df986d214f664305142d9c76df9b6512be2738aa72a2048f99 \
|
| 69 |
+
--hash=sha256:87d1351268731db79e0f8e745d92493ee2841c974128ef629dc518b937d9194c \
|
| 70 |
+
--hash=sha256:8bdb58ff7ba23002a4c5808d608e4e6c687175724f54a5dade5fa8c67b604e4d \
|
| 71 |
+
--hash=sha256:8c622a5fe39a48f78944a87d4fb8a53ee07344641b0562c540d840748571b811 \
|
| 72 |
+
--hash=sha256:8d756e44e94489e49571086ef83b2bb8ce311e730092d2c34ca8f7d925cb20aa \
|
| 73 |
+
--hash=sha256:8f4a014bc36d3c57402e2977dada34f9c12300af536839dc38c0beab8878f38a \
|
| 74 |
+
--hash=sha256:9063e24fdb1e498ab71cb7419e24622516c4a04476b17a2dab57e8baa30d6e03 \
|
| 75 |
+
--hash=sha256:90d558489962fd4918143277a773316e56c72da56ec7aa3dc3dbbe20fdfed15b \
|
| 76 |
+
--hash=sha256:923c0c831b7cfcb071580d3f46c4baf50f174be571576556269530f4bbd79d04 \
|
| 77 |
+
--hash=sha256:95f2a5796329323b8f0512e09dbb7a1860c46a39da62ecb2324f116fa8fdc85c \
|
| 78 |
+
--hash=sha256:96b02a3dc4381e5494fad39be677abcb5e6634bf7b4fa83a6dd3112607547001 \
|
| 79 |
+
--hash=sha256:9f96df6923e21816da7e0ad3fd47dd8f94b2a5ce594e00677c0013018b813458 \
|
| 80 |
+
--hash=sha256:a10af20b82360ab00827f916a6058451b723b4e65030c5a18577c8b2de5b3389 \
|
| 81 |
+
--hash=sha256:a50aebfa173e157099939b17f18600f72f84eed3049e743b68ad15bd69b6bf99 \
|
| 82 |
+
--hash=sha256:a981a536974bbc7a512cf44ed14938cf01030a99e9b3a06dd59578882f06f985 \
|
| 83 |
+
--hash=sha256:a9a8e9031d613fd2009c182b69c7b2c1ef8239a0efb1df3f7c8da66d5dd3d537 \
|
| 84 |
+
--hash=sha256:ae5f4161f18c61806f411a13b0310bea87f987c7d2ecdbdaad0e94eb2e404238 \
|
| 85 |
+
--hash=sha256:aed38f6e4fb3f5d6bf81bfa990a07806be9d83cf7bacef998ab1a9bd660a581f \
|
| 86 |
+
--hash=sha256:b01b88d45a6fcb69667cd6d2f7a9aeb4bf53760d7fc536bf679ec94fe9f3ff3d \
|
| 87 |
+
--hash=sha256:b261ccdec7821281dade748d088bb6e9b69e6d15b30652b74cbbac25e280b796 \
|
| 88 |
+
--hash=sha256:b2b0a0c0517616b6869869f8c581d4eb2dd83a4d79e0ebcb7d373ef9956aeb0a \
|
| 89 |
+
--hash=sha256:b4a23f61ce87adf89be746c8a8974fe1c823c891d8f86eb218bb957c924bb143 \
|
| 90 |
+
--hash=sha256:bd8f7df7d12c2db9fab40bdd87a7c09b1530128315d047a086fa3ae3435cb3a8 \
|
| 91 |
+
--hash=sha256:beb58fe5cdb101e3a055192ac291b7a21e3b7ef4f67fa1d74e331a7f2124341c \
|
| 92 |
+
--hash=sha256:c002b4ffc0be611f0d9da932eb0f704fe2602a9a949d1f738e4c34c75b0863d5 \
|
| 93 |
+
--hash=sha256:c083af607d2515612056a31f0a8d9e0fcb5876b7bfc0abad3ecd275bc4ebc2d5 \
|
| 94 |
+
--hash=sha256:c180f51afb394e165eafe4ac2936a14bee3eb10debc9d9e4db8958fe36afe711 \
|
| 95 |
+
--hash=sha256:c235ebd9baae02f1b77bcea61bce332cb4331dc3617d254df3323aa01ab47bd4 \
|
| 96 |
+
--hash=sha256:cd70574b12bb8a4d2aaa0094515df2463cb429d8536cfb6c7ce983246983e5a6 \
|
| 97 |
+
--hash=sha256:d0eccceffcb53201b5bfebb52600a5fb483a20b61da9dbc885f8b103cbe7598c \
|
| 98 |
+
--hash=sha256:d965bba47ddeec8cd560687584e88cf699fd28f192ceb452d1d7ee807c5597b7 \
|
| 99 |
+
--hash=sha256:db364eca23f876da6f9e16c9da0df51aa4f104a972735574842618b8c6d999d4 \
|
| 100 |
+
--hash=sha256:ddbb2551d7e0102e7252db79ba445cdab71b26640817ab1e3e3648dad515003b \
|
| 101 |
+
--hash=sha256:deb6be0ac38ece9ba87dea880e438f25ca3eddfac8b002a2ec3d9183a454e8ae \
|
| 102 |
+
--hash=sha256:e06ed3eb3218bc64786f7db41917d4e686cc4856944f53d5bdf83a6884432e12 \
|
| 103 |
+
--hash=sha256:e27ad930a842b4c5eb8ac0016b0a54f5aebbe679340c26101df33424142c143c \
|
| 104 |
+
--hash=sha256:e537484df0d8f426ce2afb2d0f8e1c3d0b114b83f8850e5f2fbea0e797bd82ae \
|
| 105 |
+
--hash=sha256:eb00ed941194665c332bf8e078baf037d6c35d7c4f3102ea2d4f16ca94a26dc8 \
|
| 106 |
+
--hash=sha256:eb6904c354526e758fda7167b33005998fb68c46fbc10e013ca97f21ca5c8887 \
|
| 107 |
+
--hash=sha256:eb8821e09e916165e160797a6c17edda0679379a4be5c716c260e836e122f54b \
|
| 108 |
+
--hash=sha256:efcb3f6676480691518c177e3b465bcddf57cea040302f9f4e6e191af91174d4 \
|
| 109 |
+
--hash=sha256:f27273b60488abe721a075bcca6d7f3964f9f6f067c8c4c605743023d7d3944f \
|
| 110 |
+
--hash=sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5 \
|
| 111 |
+
--hash=sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33 \
|
| 112 |
+
--hash=sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519 \
|
| 113 |
+
--hash=sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561
|
| 114 |
+
# via requests
|
| 115 |
+
docutils==0.19 \
|
| 116 |
+
--hash=sha256:33995a6753c30b7f577febfc2c50411fec6aac7f7ffeb7c4cfe5991072dcf9e6 \
|
| 117 |
+
--hash=sha256:5e1de4d849fee02c63b040a4a3fd567f4ab104defd8a5511fbbc24a8a017efbc
|
| 118 |
+
# via sphinx
|
| 119 |
+
furo==2022.12.7 \
|
| 120 |
+
--hash=sha256:7cb76c12a25ef65db85ab0743df907573d03027a33631f17d267e598ebb191f7 \
|
| 121 |
+
--hash=sha256:d8008f8efbe7587a97ba533c8b2df1f9c21ee9b3e5cad0d27f61193d38b1a986
|
| 122 |
+
# via -r requirements-docs.txt
|
| 123 |
+
idna==3.7 \
|
| 124 |
+
--hash=sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc \
|
| 125 |
+
--hash=sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0
|
| 126 |
+
# via requests
|
| 127 |
+
imagesize==1.4.1 \
|
| 128 |
+
--hash=sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b \
|
| 129 |
+
--hash=sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a
|
| 130 |
+
# via sphinx
|
| 131 |
+
importlib-metadata==8.0.0 \
|
| 132 |
+
--hash=sha256:15584cf2b1bf449d98ff8a6ff1abef57bf20f3ac6454f431736cd3e660921b2f \
|
| 133 |
+
--hash=sha256:188bd24e4c346d3f0a933f275c2fec67050326a856b9a359881d7c2a697e8812
|
| 134 |
+
# via sphinx
|
| 135 |
+
jinja2==3.1.4 \
|
| 136 |
+
--hash=sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369 \
|
| 137 |
+
--hash=sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d
|
| 138 |
+
# via sphinx
|
| 139 |
+
markupsafe==2.1.5 \
|
| 140 |
+
--hash=sha256:00e046b6dd71aa03a41079792f8473dc494d564611a8f89bbbd7cb93295ebdcf \
|
| 141 |
+
--hash=sha256:075202fa5b72c86ad32dc7d0b56024ebdbcf2048c0ba09f1cde31bfdd57bcfff \
|
| 142 |
+
--hash=sha256:0e397ac966fdf721b2c528cf028494e86172b4feba51d65f81ffd65c63798f3f \
|
| 143 |
+
--hash=sha256:17b950fccb810b3293638215058e432159d2b71005c74371d784862b7e4683f3 \
|
| 144 |
+
--hash=sha256:1f3fbcb7ef1f16e48246f704ab79d79da8a46891e2da03f8783a5b6fa41a9532 \
|
| 145 |
+
--hash=sha256:2174c595a0d73a3080ca3257b40096db99799265e1c27cc5a610743acd86d62f \
|
| 146 |
+
--hash=sha256:2b7c57a4dfc4f16f7142221afe5ba4e093e09e728ca65c51f5620c9aaeb9a617 \
|
| 147 |
+
--hash=sha256:2d2d793e36e230fd32babe143b04cec8a8b3eb8a3122d2aceb4a371e6b09b8df \
|
| 148 |
+
--hash=sha256:30b600cf0a7ac9234b2638fbc0fb6158ba5bdcdf46aeb631ead21248b9affbc4 \
|
| 149 |
+
--hash=sha256:397081c1a0bfb5124355710fe79478cdbeb39626492b15d399526ae53422b906 \
|
| 150 |
+
--hash=sha256:3a57fdd7ce31c7ff06cdfbf31dafa96cc533c21e443d57f5b1ecc6cdc668ec7f \
|
| 151 |
+
--hash=sha256:3c6b973f22eb18a789b1460b4b91bf04ae3f0c4234a0a6aa6b0a92f6f7b951d4 \
|
| 152 |
+
--hash=sha256:3e53af139f8579a6d5f7b76549125f0d94d7e630761a2111bc431fd820e163b8 \
|
| 153 |
+
--hash=sha256:4096e9de5c6fdf43fb4f04c26fb114f61ef0bf2e5604b6ee3019d51b69e8c371 \
|
| 154 |
+
--hash=sha256:4275d846e41ecefa46e2015117a9f491e57a71ddd59bbead77e904dc02b1bed2 \
|
| 155 |
+
--hash=sha256:4c31f53cdae6ecfa91a77820e8b151dba54ab528ba65dfd235c80b086d68a465 \
|
| 156 |
+
--hash=sha256:4f11aa001c540f62c6166c7726f71f7573b52c68c31f014c25cc7901deea0b52 \
|
| 157 |
+
--hash=sha256:5049256f536511ee3f7e1b3f87d1d1209d327e818e6ae1365e8653d7e3abb6a6 \
|
| 158 |
+
--hash=sha256:58c98fee265677f63a4385256a6d7683ab1832f3ddd1e66fe948d5880c21a169 \
|
| 159 |
+
--hash=sha256:598e3276b64aff0e7b3451b72e94fa3c238d452e7ddcd893c3ab324717456bad \
|
| 160 |
+
--hash=sha256:5b7b716f97b52c5a14bffdf688f971b2d5ef4029127f1ad7a513973cfd818df2 \
|
| 161 |
+
--hash=sha256:5dedb4db619ba5a2787a94d877bc8ffc0566f92a01c0ef214865e54ecc9ee5e0 \
|
| 162 |
+
--hash=sha256:619bc166c4f2de5caa5a633b8b7326fbe98e0ccbfacabd87268a2b15ff73a029 \
|
| 163 |
+
--hash=sha256:629ddd2ca402ae6dbedfceeba9c46d5f7b2a61d9749597d4307f943ef198fc1f \
|
| 164 |
+
--hash=sha256:656f7526c69fac7f600bd1f400991cc282b417d17539a1b228617081106feb4a \
|
| 165 |
+
--hash=sha256:6ec585f69cec0aa07d945b20805be741395e28ac1627333b1c5b0105962ffced \
|
| 166 |
+
--hash=sha256:72b6be590cc35924b02c78ef34b467da4ba07e4e0f0454a2c5907f473fc50ce5 \
|
| 167 |
+
--hash=sha256:7502934a33b54030eaf1194c21c692a534196063db72176b0c4028e140f8f32c \
|
| 168 |
+
--hash=sha256:7a68b554d356a91cce1236aa7682dc01df0edba8d043fd1ce607c49dd3c1edcf \
|
| 169 |
+
--hash=sha256:7b2e5a267c855eea6b4283940daa6e88a285f5f2a67f2220203786dfa59b37e9 \
|
| 170 |
+
--hash=sha256:823b65d8706e32ad2df51ed89496147a42a2a6e01c13cfb6ffb8b1e92bc910bb \
|
| 171 |
+
--hash=sha256:8590b4ae07a35970728874632fed7bd57b26b0102df2d2b233b6d9d82f6c62ad \
|
| 172 |
+
--hash=sha256:8dd717634f5a044f860435c1d8c16a270ddf0ef8588d4887037c5028b859b0c3 \
|
| 173 |
+
--hash=sha256:8dec4936e9c3100156f8a2dc89c4b88d5c435175ff03413b443469c7c8c5f4d1 \
|
| 174 |
+
--hash=sha256:97cafb1f3cbcd3fd2b6fbfb99ae11cdb14deea0736fc2b0952ee177f2b813a46 \
|
| 175 |
+
--hash=sha256:a17a92de5231666cfbe003f0e4b9b3a7ae3afb1ec2845aadc2bacc93ff85febc \
|
| 176 |
+
--hash=sha256:a549b9c31bec33820e885335b451286e2969a2d9e24879f83fe904a5ce59d70a \
|
| 177 |
+
--hash=sha256:ac07bad82163452a6884fe8fa0963fb98c2346ba78d779ec06bd7a6262132aee \
|
| 178 |
+
--hash=sha256:ae2ad8ae6ebee9d2d94b17fb62763125f3f374c25618198f40cbb8b525411900 \
|
| 179 |
+
--hash=sha256:b91c037585eba9095565a3556f611e3cbfaa42ca1e865f7b8015fe5c7336d5a5 \
|
| 180 |
+
--hash=sha256:bc1667f8b83f48511b94671e0e441401371dfd0f0a795c7daa4a3cd1dde55bea \
|
| 181 |
+
--hash=sha256:bec0a414d016ac1a18862a519e54b2fd0fc8bbfd6890376898a6c0891dd82e9f \
|
| 182 |
+
--hash=sha256:bf50cd79a75d181c9181df03572cdce0fbb75cc353bc350712073108cba98de5 \
|
| 183 |
+
--hash=sha256:bff1b4290a66b490a2f4719358c0cdcd9bafb6b8f061e45c7a2460866bf50c2e \
|
| 184 |
+
--hash=sha256:c061bb86a71b42465156a3ee7bd58c8c2ceacdbeb95d05a99893e08b8467359a \
|
| 185 |
+
--hash=sha256:c8b29db45f8fe46ad280a7294f5c3ec36dbac9491f2d1c17345be8e69cc5928f \
|
| 186 |
+
--hash=sha256:ce409136744f6521e39fd8e2a24c53fa18ad67aa5bc7c2cf83645cce5b5c4e50 \
|
| 187 |
+
--hash=sha256:d050b3361367a06d752db6ead6e7edeb0009be66bc3bae0ee9d97fb326badc2a \
|
| 188 |
+
--hash=sha256:d283d37a890ba4c1ae73ffadf8046435c76e7bc2247bbb63c00bd1a709c6544b \
|
| 189 |
+
--hash=sha256:d9fad5155d72433c921b782e58892377c44bd6252b5af2f67f16b194987338a4 \
|
| 190 |
+
--hash=sha256:daa4ee5a243f0f20d528d939d06670a298dd39b1ad5f8a72a4275124a7819eff \
|
| 191 |
+
--hash=sha256:db0b55e0f3cc0be60c1f19efdde9a637c32740486004f20d1cff53c3c0ece4d2 \
|
| 192 |
+
--hash=sha256:e61659ba32cf2cf1481e575d0462554625196a1f2fc06a1c777d3f48e8865d46 \
|
| 193 |
+
--hash=sha256:ea3d8a3d18833cf4304cd2fc9cbb1efe188ca9b5efef2bdac7adc20594a0e46b \
|
| 194 |
+
--hash=sha256:ec6a563cff360b50eed26f13adc43e61bc0c04d94b8be985e6fb24b81f6dcfdf \
|
| 195 |
+
--hash=sha256:f5dfb42c4604dddc8e4305050aa6deb084540643ed5804d7455b5df8fe16f5e5 \
|
| 196 |
+
--hash=sha256:fa173ec60341d6bb97a89f5ea19c85c5643c1e7dedebc22f5181eb73573142c5 \
|
| 197 |
+
--hash=sha256:fa9db3f79de01457b03d4f01b34cf91bc0048eb2c3846ff26f66687c2f6d16ab \
|
| 198 |
+
--hash=sha256:fce659a462a1be54d2ffcacea5e3ba2d74daa74f30f5f143fe0c58636e355fdd \
|
| 199 |
+
--hash=sha256:ffee1f21e5ef0d712f9033568f8344d5da8cc2869dbd08d87c84656e6a2d2f68
|
| 200 |
+
# via jinja2
|
| 201 |
+
packaging==24.1 \
|
| 202 |
+
--hash=sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002 \
|
| 203 |
+
--hash=sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124
|
| 204 |
+
# via sphinx
|
| 205 |
+
pygments==2.18.0 \
|
| 206 |
+
--hash=sha256:786ff802f32e91311bff3889f6e9a86e81505fe99f2735bb6d60ae0c5004f199 \
|
| 207 |
+
--hash=sha256:b8e6aca0523f3ab76fee51799c488e38782ac06eafcf95e7ba832985c8e7b13a
|
| 208 |
+
# via
|
| 209 |
+
# furo
|
| 210 |
+
# sphinx
|
| 211 |
+
pytz==2024.1 \
|
| 212 |
+
--hash=sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812 \
|
| 213 |
+
--hash=sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319
|
| 214 |
+
# via babel
|
| 215 |
+
requests==2.32.3 \
|
| 216 |
+
--hash=sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760 \
|
| 217 |
+
--hash=sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6
|
| 218 |
+
# via sphinx
|
| 219 |
+
snowballstemmer==2.2.0 \
|
| 220 |
+
--hash=sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1 \
|
| 221 |
+
--hash=sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a
|
| 222 |
+
# via sphinx
|
| 223 |
+
soupsieve==2.5 \
|
| 224 |
+
--hash=sha256:5663d5a7b3bfaeee0bc4372e7fc48f9cff4940b3eec54a6451cc5299f1097690 \
|
| 225 |
+
--hash=sha256:eaa337ff55a1579b6549dc679565eac1e3d000563bcb1c8ab0d0fefbc0c2cdc7
|
| 226 |
+
# via beautifulsoup4
|
| 227 |
+
sphinx==5.3.0 \
|
| 228 |
+
--hash=sha256:060ca5c9f7ba57a08a1219e547b269fadf125ae25b06b9fa7f66768efb652d6d \
|
| 229 |
+
--hash=sha256:51026de0a9ff9fc13c05d74913ad66047e104f56a129ff73e174eb5c3ee794b5
|
| 230 |
+
# via
|
| 231 |
+
# -r requirements-docs.txt
|
| 232 |
+
# furo
|
| 233 |
+
# sphinx-basic-ng
|
| 234 |
+
# sphinx-copybutton
|
| 235 |
+
# sphinx-remove-toctrees
|
| 236 |
+
sphinx-basic-ng==1.0.0b2 \
|
| 237 |
+
--hash=sha256:9ec55a47c90c8c002b5960c57492ec3021f5193cb26cebc2dc4ea226848651c9 \
|
| 238 |
+
--hash=sha256:eb09aedbabfb650607e9b4b68c9d240b90b1e1be221d6ad71d61c52e29f7932b
|
| 239 |
+
# via furo
|
| 240 |
+
sphinx-copybutton==0.5.1 \
|
| 241 |
+
--hash=sha256:0842851b5955087a7ec7fc870b622cb168618ad408dee42692e9a5c97d071da8 \
|
| 242 |
+
--hash=sha256:366251e28a6f6041514bfb5439425210418d6c750e98d3a695b73e56866a677a
|
| 243 |
+
# via -r requirements-docs.txt
|
| 244 |
+
sphinx-remove-toctrees==0.0.3 \
|
| 245 |
+
--hash=sha256:1077ebc00652f8a896ce27404d31cb5bdde9eeaefc80ada72d95a7a0a7b99a9d \
|
| 246 |
+
--hash=sha256:e4792cc4e5d25ceb1a44dd1490c45d578e6b36f1b1e385ede659e4c324b98cba
|
| 247 |
+
# via -r requirements-docs.txt
|
| 248 |
+
sphinxcontrib-applehelp==1.0.4 \
|
| 249 |
+
--hash=sha256:29d341f67fb0f6f586b23ad80e072c8e6ad0b48417db2bde114a4c9746feb228 \
|
| 250 |
+
--hash=sha256:828f867945bbe39817c210a1abfd1bc4895c8b73fcaade56d45357a348a07d7e
|
| 251 |
+
# via sphinx
|
| 252 |
+
sphinxcontrib-devhelp==1.0.2 \
|
| 253 |
+
--hash=sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e \
|
| 254 |
+
--hash=sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4
|
| 255 |
+
# via sphinx
|
| 256 |
+
sphinxcontrib-htmlhelp==2.0.1 \
|
| 257 |
+
--hash=sha256:0cbdd302815330058422b98a113195c9249825d681e18f11e8b1f78a2f11efff \
|
| 258 |
+
--hash=sha256:c38cb46dccf316c79de6e5515e1770414b797162b23cd3d06e67020e1d2a6903
|
| 259 |
+
# via sphinx
|
| 260 |
+
sphinxcontrib-jsmath==1.0.1 \
|
| 261 |
+
--hash=sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178 \
|
| 262 |
+
--hash=sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8
|
| 263 |
+
# via sphinx
|
| 264 |
+
sphinxcontrib-qthelp==1.0.3 \
|
| 265 |
+
--hash=sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72 \
|
| 266 |
+
--hash=sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6
|
| 267 |
+
# via sphinx
|
| 268 |
+
sphinxcontrib-serializinghtml==1.1.5 \
|
| 269 |
+
--hash=sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd \
|
| 270 |
+
--hash=sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952
|
| 271 |
+
# via sphinx
|
| 272 |
+
urllib3==1.26.19 ; python_version < "3.10" \
|
| 273 |
+
--hash=sha256:37a0344459b199fce0e80b0d3569837ec6b6937435c5244e7fd73fa6006830f3 \
|
| 274 |
+
--hash=sha256:3e3d753a8618b86d7de333b4223005f68720bcd6a7d2bcb9fbd2229ec7c1e429
|
| 275 |
+
# via
|
| 276 |
+
# -r requirements-docs.txt
|
| 277 |
+
# requests
|
| 278 |
+
zipp==3.19.2 \
|
| 279 |
+
--hash=sha256:bf1dcf6450f873a13e952a29504887c89e6de7506209e5b1bcc3460135d4de19 \
|
| 280 |
+
--hash=sha256:f091755f667055f2d02b32c53771a7a6c8b47e1fdbc4b72a8b9072b3eef8015c
|
| 281 |
+
# via importlib-metadata
|
testbed/boto__botocore/requirements-docs.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
sphinx==5.3.0
|
| 2 |
+
furo==2022.12.7
|
| 3 |
+
sphinx_copybutton==0.5.1
|
| 4 |
+
sphinx-remove-toctrees==0.0.3
|
| 5 |
+
# Avoid urllib3 2.x below Python 3.10
|
| 6 |
+
urllib3<2.0 ; python_version < "3.10"
|
testbed/boto__botocore/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
-r requirements-dev.txt
|
testbed/boto__botocore/setup.cfg
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[bdist_wheel]
|
| 2 |
+
universal = 0
|
| 3 |
+
|
| 4 |
+
[metadata]
|
| 5 |
+
requires_dist =
|
| 6 |
+
jmespath>=0.7.1,<2.0.0
|
| 7 |
+
python-dateutil>=2.1,<3.0.0
|
| 8 |
+
urllib3>=1.25.4,<1.27; python_version<"3.10"
|
| 9 |
+
urllib3>=1.25.4,!=2.2.0,<3; python_version>="3.10"
|
| 10 |
+
|
| 11 |
+
[options.extras_require]
|
| 12 |
+
crt = awscrt==0.21.5
|
testbed/boto__botocore/setup.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
import codecs
|
| 3 |
+
import os.path
|
| 4 |
+
import re
|
| 5 |
+
|
| 6 |
+
from setuptools import find_packages, setup
|
| 7 |
+
|
| 8 |
+
here = os.path.abspath(os.path.dirname(__file__))
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def read(*parts):
|
| 12 |
+
return codecs.open(os.path.join(here, *parts), 'r').read()
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def find_version(*file_paths):
|
| 16 |
+
version_file = read(*file_paths)
|
| 17 |
+
version_match = re.search(
|
| 18 |
+
r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M
|
| 19 |
+
)
|
| 20 |
+
if version_match:
|
| 21 |
+
return version_match.group(1)
|
| 22 |
+
raise RuntimeError("Unable to find version string.")
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
requires = [
|
| 26 |
+
'jmespath>=0.7.1,<2.0.0',
|
| 27 |
+
'python-dateutil>=2.1,<3.0.0',
|
| 28 |
+
# Prior to Python 3.10, Python doesn't require openssl 1.1.1
|
| 29 |
+
# but urllib3 2.0+ does. This means all botocore users will be
|
| 30 |
+
# broken by default on Amazon Linux 2 and AWS Lambda without this pin.
|
| 31 |
+
'urllib3>=1.25.4,<1.27 ; python_version < "3.10"',
|
| 32 |
+
'urllib3>=1.25.4,!=2.2.0,<3 ; python_version >= "3.10"',
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
extras_require = {
|
| 36 |
+
'crt': ['awscrt==0.21.5'],
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
setup(
|
| 40 |
+
name='botocore',
|
| 41 |
+
version=find_version("botocore", "__init__.py"),
|
| 42 |
+
description='Low-level, data-driven core of boto 3.',
|
| 43 |
+
long_description=open('README.rst').read(),
|
| 44 |
+
author='Amazon Web Services',
|
| 45 |
+
url='https://github.com/boto/botocore',
|
| 46 |
+
scripts=[],
|
| 47 |
+
packages=find_packages(exclude=['tests*']),
|
| 48 |
+
package_data={
|
| 49 |
+
'botocore': ['cacert.pem', 'data/*.json', 'data/*/*.json'],
|
| 50 |
+
'botocore.vendored.requests': ['*.pem'],
|
| 51 |
+
},
|
| 52 |
+
include_package_data=True,
|
| 53 |
+
install_requires=requires,
|
| 54 |
+
extras_require=extras_require,
|
| 55 |
+
license="Apache License 2.0",
|
| 56 |
+
python_requires=">= 3.8",
|
| 57 |
+
classifiers=[
|
| 58 |
+
'Development Status :: 5 - Production/Stable',
|
| 59 |
+
'Intended Audience :: Developers',
|
| 60 |
+
'Intended Audience :: System Administrators',
|
| 61 |
+
'Natural Language :: English',
|
| 62 |
+
'License :: OSI Approved :: Apache Software License',
|
| 63 |
+
'Programming Language :: Python',
|
| 64 |
+
'Programming Language :: Python :: 3 :: Only',
|
| 65 |
+
'Programming Language :: Python :: 3',
|
| 66 |
+
'Programming Language :: Python :: 3.8',
|
| 67 |
+
'Programming Language :: Python :: 3.9',
|
| 68 |
+
'Programming Language :: Python :: 3.10',
|
| 69 |
+
'Programming Language :: Python :: 3.11',
|
| 70 |
+
'Programming Language :: Python :: 3.12',
|
| 71 |
+
],
|
| 72 |
+
)
|
testbed/boto__botocore/tests/__init__.py
ADDED
|
@@ -0,0 +1,599 @@
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 4 |
+
# may not use this file except in compliance with the License. A copy of
|
| 5 |
+
# the License is located at
|
| 6 |
+
#
|
| 7 |
+
# http://aws.amazon.com/apache2.0/
|
| 8 |
+
#
|
| 9 |
+
# or in the "license" file accompanying this file. This file is
|
| 10 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 11 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 12 |
+
# language governing permissions and limitations under the License.
|
| 13 |
+
|
| 14 |
+
import binascii
|
| 15 |
+
import contextlib
|
| 16 |
+
import datetime
|
| 17 |
+
import os
|
| 18 |
+
import platform
|
| 19 |
+
import random
|
| 20 |
+
import select
|
| 21 |
+
import shutil
|
| 22 |
+
import sys
|
| 23 |
+
import tempfile
|
| 24 |
+
import time
|
| 25 |
+
import unittest
|
| 26 |
+
from contextlib import ContextDecorator
|
| 27 |
+
from io import BytesIO
|
| 28 |
+
from subprocess import PIPE, Popen
|
| 29 |
+
from unittest import mock
|
| 30 |
+
|
| 31 |
+
from dateutil.tz import tzlocal
|
| 32 |
+
|
| 33 |
+
import botocore.loaders
|
| 34 |
+
import botocore.session
|
| 35 |
+
from botocore import credentials, utils
|
| 36 |
+
from botocore.awsrequest import AWSResponse
|
| 37 |
+
from botocore.compat import HAS_CRT, parse_qs, urlparse
|
| 38 |
+
from botocore.stub import Stubber
|
| 39 |
+
|
| 40 |
+
_LOADER = botocore.loaders.Loader()
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def _all_services():
|
| 44 |
+
session = botocore.session.Session()
|
| 45 |
+
service_names = session.get_available_services()
|
| 46 |
+
return [session.get_service_model(name) for name in service_names]
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
# Only compute our service models once
|
| 50 |
+
ALL_SERVICES = _all_services()
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def skip_unless_has_memory_collection(cls):
|
| 54 |
+
"""Class decorator to skip tests that require memory collection.
|
| 55 |
+
|
| 56 |
+
Any test that uses memory collection (such as the resource leak tests)
|
| 57 |
+
can decorate their class with skip_unless_has_memory_collection to
|
| 58 |
+
indicate that if the platform does not support memory collection
|
| 59 |
+
the tests should be skipped.
|
| 60 |
+
"""
|
| 61 |
+
if platform.system() not in ['Darwin', 'Linux']:
|
| 62 |
+
return unittest.skip('Memory tests only supported on mac/linux.')(cls)
|
| 63 |
+
return cls
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def skip_if_windows(reason):
|
| 67 |
+
"""Decorator to skip tests that should not be run on windows.
|
| 68 |
+
Example usage:
|
| 69 |
+
@skip_if_windows("Not valid")
|
| 70 |
+
def test_some_non_windows_stuff(self):
|
| 71 |
+
self.assertEqual(...)
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
+
def decorator(func):
|
| 75 |
+
return unittest.skipIf(
|
| 76 |
+
platform.system() not in ['Darwin', 'Linux'], reason
|
| 77 |
+
)(func)
|
| 78 |
+
|
| 79 |
+
return decorator
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def requires_crt(reason=None):
|
| 83 |
+
if reason is None:
|
| 84 |
+
reason = "Test requires awscrt to be installed"
|
| 85 |
+
|
| 86 |
+
def decorator(func):
|
| 87 |
+
return unittest.skipIf(not HAS_CRT, reason)(func)
|
| 88 |
+
|
| 89 |
+
return decorator
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def random_chars(num_chars):
|
| 93 |
+
"""Returns random hex characters.
|
| 94 |
+
|
| 95 |
+
Useful for creating resources with random names.
|
| 96 |
+
|
| 97 |
+
"""
|
| 98 |
+
return binascii.hexlify(os.urandom(int(num_chars / 2))).decode('ascii')
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
def create_session(**kwargs):
|
| 102 |
+
# Create a Session object. By default,
|
| 103 |
+
# the _LOADER object is used as the loader
|
| 104 |
+
# so that we reused the same models across tests.
|
| 105 |
+
session = botocore.session.Session(**kwargs)
|
| 106 |
+
session.register_component('data_loader', _LOADER)
|
| 107 |
+
session.set_config_variable('credentials_file', 'noexist/foo/botocore')
|
| 108 |
+
return session
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
@contextlib.contextmanager
|
| 112 |
+
def temporary_file(mode):
|
| 113 |
+
"""This is a cross platform temporary file creation.
|
| 114 |
+
|
| 115 |
+
tempfile.NamedTemporary file on windows creates a secure temp file
|
| 116 |
+
that can't be read by other processes and can't be opened a second time.
|
| 117 |
+
|
| 118 |
+
For tests, we generally *want* them to be read multiple times.
|
| 119 |
+
The test fixture writes the temp file contents, the test reads the
|
| 120 |
+
temp file.
|
| 121 |
+
|
| 122 |
+
"""
|
| 123 |
+
temporary_directory = tempfile.mkdtemp()
|
| 124 |
+
basename = f'tmpfile-{int(time.time())}-{random.randint(1, 1000)}'
|
| 125 |
+
full_filename = os.path.join(temporary_directory, basename)
|
| 126 |
+
open(full_filename, 'w').close()
|
| 127 |
+
try:
|
| 128 |
+
with open(full_filename, mode) as f:
|
| 129 |
+
yield f
|
| 130 |
+
finally:
|
| 131 |
+
shutil.rmtree(temporary_directory)
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
class BaseEnvVar(unittest.TestCase):
|
| 135 |
+
def setUp(self):
|
| 136 |
+
# Automatically patches out os.environ for you
|
| 137 |
+
# and gives you a self.environ attribute that simulates
|
| 138 |
+
# the environment. Also will automatically restore state
|
| 139 |
+
# for you in tearDown()
|
| 140 |
+
self.environ = {}
|
| 141 |
+
self.environ_patch = mock.patch('os.environ', self.environ)
|
| 142 |
+
self.environ_patch.start()
|
| 143 |
+
|
| 144 |
+
def tearDown(self):
|
| 145 |
+
self.environ_patch.stop()
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
class BaseSessionTest(BaseEnvVar):
|
| 149 |
+
"""Base class used to provide credentials.
|
| 150 |
+
|
| 151 |
+
This class can be used as a base class that want to use a real
|
| 152 |
+
session class but want to be completely isolated from the
|
| 153 |
+
external environment (including environment variables).
|
| 154 |
+
|
| 155 |
+
This class will also set credential vars so you can make fake
|
| 156 |
+
requests to services.
|
| 157 |
+
|
| 158 |
+
"""
|
| 159 |
+
|
| 160 |
+
def setUp(self, **environ):
|
| 161 |
+
super().setUp()
|
| 162 |
+
self.environ['AWS_ACCESS_KEY_ID'] = 'access_key'
|
| 163 |
+
self.environ['AWS_SECRET_ACCESS_KEY'] = 'secret_key'
|
| 164 |
+
self.environ['AWS_CONFIG_FILE'] = 'no-exist-foo'
|
| 165 |
+
self.environ.update(environ)
|
| 166 |
+
self.session = create_session()
|
| 167 |
+
self.session.config_filename = 'no-exist-foo'
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
@skip_unless_has_memory_collection
|
| 171 |
+
class BaseClientDriverTest(unittest.TestCase):
|
| 172 |
+
INJECT_DUMMY_CREDS = False
|
| 173 |
+
|
| 174 |
+
def setUp(self):
|
| 175 |
+
self.driver = ClientDriver()
|
| 176 |
+
env = None
|
| 177 |
+
if self.INJECT_DUMMY_CREDS:
|
| 178 |
+
env = {'AWS_ACCESS_KEY_ID': 'foo', 'AWS_SECRET_ACCESS_KEY': 'bar'}
|
| 179 |
+
self.driver.start(env=env)
|
| 180 |
+
|
| 181 |
+
def cmd(self, *args):
|
| 182 |
+
self.driver.cmd(*args)
|
| 183 |
+
|
| 184 |
+
def send_cmd(self, *args):
|
| 185 |
+
self.driver.send_cmd(*args)
|
| 186 |
+
|
| 187 |
+
def record_memory(self):
|
| 188 |
+
self.driver.record_memory()
|
| 189 |
+
|
| 190 |
+
@property
|
| 191 |
+
def memory_samples(self):
|
| 192 |
+
return self.driver.memory_samples
|
| 193 |
+
|
| 194 |
+
def tearDown(self):
|
| 195 |
+
self.driver.stop()
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
class ClientDriver:
|
| 199 |
+
CLIENT_SERVER = os.path.join(
|
| 200 |
+
os.path.dirname(os.path.abspath(__file__)), 'cmd-runner'
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
+
def __init__(self):
|
| 204 |
+
self._popen = None
|
| 205 |
+
self.memory_samples = []
|
| 206 |
+
|
| 207 |
+
def _get_memory_with_ps(self, pid):
|
| 208 |
+
# It would be better to eventually switch to psutil,
|
| 209 |
+
# which should allow us to test on windows, but for now
|
| 210 |
+
# we'll just use ps and run on POSIX platforms.
|
| 211 |
+
command_list = ['ps', '-p', str(pid), '-o', 'rss']
|
| 212 |
+
p = Popen(command_list, stdout=PIPE)
|
| 213 |
+
stdout = p.communicate()[0]
|
| 214 |
+
if not p.returncode == 0:
|
| 215 |
+
raise RuntimeError("Could not retrieve memory")
|
| 216 |
+
else:
|
| 217 |
+
# Get the RSS from output that looks like this:
|
| 218 |
+
# RSS
|
| 219 |
+
# 4496
|
| 220 |
+
return int(stdout.splitlines()[1].split()[0]) * 1024
|
| 221 |
+
|
| 222 |
+
def record_memory(self):
|
| 223 |
+
mem = self._get_memory_with_ps(self._popen.pid)
|
| 224 |
+
self.memory_samples.append(mem)
|
| 225 |
+
|
| 226 |
+
def start(self, env=None):
|
| 227 |
+
"""Start up the command runner process."""
|
| 228 |
+
self._popen = Popen(
|
| 229 |
+
[sys.executable, self.CLIENT_SERVER],
|
| 230 |
+
stdout=PIPE,
|
| 231 |
+
stdin=PIPE,
|
| 232 |
+
env=env,
|
| 233 |
+
)
|
| 234 |
+
|
| 235 |
+
def stop(self):
|
| 236 |
+
"""Shutdown the command runner process."""
|
| 237 |
+
self.cmd('exit')
|
| 238 |
+
self._popen.wait()
|
| 239 |
+
|
| 240 |
+
def send_cmd(self, *cmd):
|
| 241 |
+
"""Send a command and return immediately.
|
| 242 |
+
|
| 243 |
+
This is a lower level method than cmd().
|
| 244 |
+
This method will instruct the cmd-runner process
|
| 245 |
+
to execute a command, but this method will
|
| 246 |
+
immediately return. You will need to use
|
| 247 |
+
``is_cmd_finished()`` to check that the command
|
| 248 |
+
is finished.
|
| 249 |
+
|
| 250 |
+
This method is useful if you want to record attributes
|
| 251 |
+
about the process while an operation is occurring. For
|
| 252 |
+
example, if you want to instruct the cmd-runner process
|
| 253 |
+
to upload a 1GB file to S3 and you'd like to record
|
| 254 |
+
the memory during the upload process, you can use
|
| 255 |
+
send_cmd() instead of cmd().
|
| 256 |
+
|
| 257 |
+
"""
|
| 258 |
+
cmd_str = ' '.join(cmd) + '\n'
|
| 259 |
+
cmd_bytes = cmd_str.encode('utf-8')
|
| 260 |
+
self._popen.stdin.write(cmd_bytes)
|
| 261 |
+
self._popen.stdin.flush()
|
| 262 |
+
|
| 263 |
+
def is_cmd_finished(self):
|
| 264 |
+
rlist = [self._popen.stdout.fileno()]
|
| 265 |
+
result = select.select(rlist, [], [], 0.01)
|
| 266 |
+
if result[0]:
|
| 267 |
+
return True
|
| 268 |
+
return False
|
| 269 |
+
|
| 270 |
+
def cmd(self, *cmd):
|
| 271 |
+
"""Send a command and block until it finishes.
|
| 272 |
+
|
| 273 |
+
This method will send a command to the cmd-runner process
|
| 274 |
+
to run. It will block until the cmd-runner process is
|
| 275 |
+
finished executing the command and sends back a status
|
| 276 |
+
response.
|
| 277 |
+
|
| 278 |
+
"""
|
| 279 |
+
self.send_cmd(*cmd)
|
| 280 |
+
result = self._popen.stdout.readline().strip()
|
| 281 |
+
if result != b'OK':
|
| 282 |
+
raise RuntimeError(f"Error from command '{cmd}': {result}")
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
# This is added to this file because it's used in both
|
| 286 |
+
# the functional and unit tests for cred refresh.
|
| 287 |
+
class IntegerRefresher(credentials.RefreshableCredentials):
|
| 288 |
+
"""Refreshable credentials to help with testing.
|
| 289 |
+
|
| 290 |
+
This class makes testing refreshable credentials easier.
|
| 291 |
+
It has the following functionality:
|
| 292 |
+
|
| 293 |
+
* A counter, self.refresh_counter, to indicate how many
|
| 294 |
+
times refresh was called.
|
| 295 |
+
* A way to specify how many seconds to make credentials
|
| 296 |
+
valid.
|
| 297 |
+
* Configurable advisory/mandatory refresh.
|
| 298 |
+
* An easy way to check consistency. Each time creds are
|
| 299 |
+
refreshed, all the cred values are set to the next
|
| 300 |
+
incrementing integer. Frozen credentials should always
|
| 301 |
+
have this value.
|
| 302 |
+
"""
|
| 303 |
+
|
| 304 |
+
_advisory_refresh_timeout = 2
|
| 305 |
+
_mandatory_refresh_timeout = 1
|
| 306 |
+
_credentials_expire = 3
|
| 307 |
+
|
| 308 |
+
def __init__(
|
| 309 |
+
self,
|
| 310 |
+
creds_last_for=_credentials_expire,
|
| 311 |
+
advisory_refresh=_advisory_refresh_timeout,
|
| 312 |
+
mandatory_refresh=_mandatory_refresh_timeout,
|
| 313 |
+
refresh_function=None,
|
| 314 |
+
):
|
| 315 |
+
expires_in = self._current_datetime() + datetime.timedelta(
|
| 316 |
+
seconds=creds_last_for
|
| 317 |
+
)
|
| 318 |
+
if refresh_function is None:
|
| 319 |
+
refresh_function = self._do_refresh
|
| 320 |
+
super().__init__(
|
| 321 |
+
'0', '0', '0', expires_in, refresh_function, 'INTREFRESH'
|
| 322 |
+
)
|
| 323 |
+
self.creds_last_for = creds_last_for
|
| 324 |
+
self.refresh_counter = 0
|
| 325 |
+
self._advisory_refresh_timeout = advisory_refresh
|
| 326 |
+
self._mandatory_refresh_timeout = mandatory_refresh
|
| 327 |
+
|
| 328 |
+
def _do_refresh(self):
|
| 329 |
+
self.refresh_counter += 1
|
| 330 |
+
current = int(self._access_key)
|
| 331 |
+
next_id = str(current + 1)
|
| 332 |
+
|
| 333 |
+
return {
|
| 334 |
+
'access_key': next_id,
|
| 335 |
+
'secret_key': next_id,
|
| 336 |
+
'token': next_id,
|
| 337 |
+
'expiry_time': self._seconds_later(self.creds_last_for),
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
def _seconds_later(self, num_seconds):
|
| 341 |
+
# We need to guarantee at *least* num_seconds.
|
| 342 |
+
# Because this doesn't handle subsecond precision
|
| 343 |
+
# we'll round up to the next second.
|
| 344 |
+
num_seconds += 1
|
| 345 |
+
t = self._current_datetime() + datetime.timedelta(seconds=num_seconds)
|
| 346 |
+
return self._to_timestamp(t)
|
| 347 |
+
|
| 348 |
+
def _to_timestamp(self, datetime_obj):
|
| 349 |
+
obj = utils.parse_to_aware_datetime(datetime_obj)
|
| 350 |
+
return obj.strftime('%Y-%m-%dT%H:%M:%SZ')
|
| 351 |
+
|
| 352 |
+
def _current_timestamp(self):
|
| 353 |
+
return self._to_timestamp(self._current_datetime())
|
| 354 |
+
|
| 355 |
+
def _current_datetime(self):
|
| 356 |
+
return datetime.datetime.now(tzlocal())
|
| 357 |
+
|
| 358 |
+
|
| 359 |
+
def _urlparse(url):
|
| 360 |
+
if isinstance(url, bytes):
|
| 361 |
+
# Not really necessary, but it helps to reduce noise on Python 2.x
|
| 362 |
+
url = url.decode('utf8')
|
| 363 |
+
return urlparse(url)
|
| 364 |
+
|
| 365 |
+
|
| 366 |
+
def assert_url_equal(url1, url2):
|
| 367 |
+
parts1 = _urlparse(url1)
|
| 368 |
+
parts2 = _urlparse(url2)
|
| 369 |
+
|
| 370 |
+
# Because the query string ordering isn't relevant, we have to parse
|
| 371 |
+
# every single part manually and then handle the query string.
|
| 372 |
+
assert parts1.scheme == parts2.scheme
|
| 373 |
+
assert parts1.netloc == parts2.netloc
|
| 374 |
+
assert parts1.path == parts2.path
|
| 375 |
+
assert parts1.params == parts2.params
|
| 376 |
+
assert parts1.fragment == parts2.fragment
|
| 377 |
+
assert parts1.username == parts2.username
|
| 378 |
+
assert parts1.password == parts2.password
|
| 379 |
+
assert parts1.hostname == parts2.hostname
|
| 380 |
+
assert parts1.port == parts2.port
|
| 381 |
+
assert parse_qs(parts1.query) == parse_qs(parts2.query)
|
| 382 |
+
|
| 383 |
+
|
| 384 |
+
class HTTPStubberException(Exception):
|
| 385 |
+
pass
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
class RawResponse(BytesIO):
|
| 389 |
+
# TODO: There's a few objects similar to this in various tests, let's
|
| 390 |
+
# try and consolidate to this one in a future commit.
|
| 391 |
+
def stream(self, **kwargs):
|
| 392 |
+
contents = self.read()
|
| 393 |
+
while contents:
|
| 394 |
+
yield contents
|
| 395 |
+
contents = self.read()
|
| 396 |
+
|
| 397 |
+
|
| 398 |
+
class BaseHTTPStubber:
|
| 399 |
+
def __init__(self, obj_with_event_emitter, strict=True):
|
| 400 |
+
self.reset()
|
| 401 |
+
self._strict = strict
|
| 402 |
+
self._obj_with_event_emitter = obj_with_event_emitter
|
| 403 |
+
|
| 404 |
+
def reset(self):
|
| 405 |
+
self.requests = []
|
| 406 |
+
self.responses = []
|
| 407 |
+
|
| 408 |
+
def add_response(
|
| 409 |
+
self, url='https://example.com', status=200, headers=None, body=b''
|
| 410 |
+
):
|
| 411 |
+
if headers is None:
|
| 412 |
+
headers = {}
|
| 413 |
+
|
| 414 |
+
raw = RawResponse(body)
|
| 415 |
+
response = AWSResponse(url, status, headers, raw)
|
| 416 |
+
self.responses.append(response)
|
| 417 |
+
|
| 418 |
+
@property
|
| 419 |
+
def _events(self):
|
| 420 |
+
raise NotImplementedError('_events')
|
| 421 |
+
|
| 422 |
+
def start(self):
|
| 423 |
+
self._events.register('before-send', self)
|
| 424 |
+
|
| 425 |
+
def stop(self):
|
| 426 |
+
self._events.unregister('before-send', self)
|
| 427 |
+
|
| 428 |
+
def __enter__(self):
|
| 429 |
+
self.start()
|
| 430 |
+
return self
|
| 431 |
+
|
| 432 |
+
def __exit__(self, exc_type, exc_value, traceback):
|
| 433 |
+
self.stop()
|
| 434 |
+
|
| 435 |
+
def __call__(self, request, **kwargs):
|
| 436 |
+
self.requests.append(request)
|
| 437 |
+
if self.responses:
|
| 438 |
+
response = self.responses.pop(0)
|
| 439 |
+
if isinstance(response, Exception):
|
| 440 |
+
raise response
|
| 441 |
+
else:
|
| 442 |
+
return response
|
| 443 |
+
elif self._strict:
|
| 444 |
+
raise HTTPStubberException('Insufficient responses')
|
| 445 |
+
else:
|
| 446 |
+
return None
|
| 447 |
+
|
| 448 |
+
|
| 449 |
+
class ClientHTTPStubber(BaseHTTPStubber):
|
| 450 |
+
@property
|
| 451 |
+
def _events(self):
|
| 452 |
+
return self._obj_with_event_emitter.meta.events
|
| 453 |
+
|
| 454 |
+
|
| 455 |
+
class SessionHTTPStubber(BaseHTTPStubber):
|
| 456 |
+
@property
|
| 457 |
+
def _events(self):
|
| 458 |
+
return self._obj_with_event_emitter.get_component('event_emitter')
|
| 459 |
+
|
| 460 |
+
|
| 461 |
+
class ConsistencyWaiterException(Exception):
|
| 462 |
+
pass
|
| 463 |
+
|
| 464 |
+
|
| 465 |
+
class ConsistencyWaiter:
|
| 466 |
+
"""
|
| 467 |
+
A waiter class for some check to reach a consistent state.
|
| 468 |
+
|
| 469 |
+
:type min_successes: int
|
| 470 |
+
:param min_successes: The minimum number of successful check calls to
|
| 471 |
+
treat the check as stable. Default of 1 success.
|
| 472 |
+
|
| 473 |
+
:type max_attempts: int
|
| 474 |
+
:param min_successes: The maximum number of times to attempt calling
|
| 475 |
+
the check. Default of 20 attempts.
|
| 476 |
+
|
| 477 |
+
:type delay: int
|
| 478 |
+
:param delay: The number of seconds to delay the next API call after a
|
| 479 |
+
failed check call. Default of 5 seconds.
|
| 480 |
+
"""
|
| 481 |
+
|
| 482 |
+
def __init__(
|
| 483 |
+
self,
|
| 484 |
+
min_successes=1,
|
| 485 |
+
max_attempts=20,
|
| 486 |
+
delay=5,
|
| 487 |
+
delay_initial_poll=False,
|
| 488 |
+
):
|
| 489 |
+
self.min_successes = min_successes
|
| 490 |
+
self.max_attempts = max_attempts
|
| 491 |
+
self.delay = delay
|
| 492 |
+
self.delay_initial_poll = delay_initial_poll
|
| 493 |
+
|
| 494 |
+
def wait(self, check, *args, **kwargs):
|
| 495 |
+
"""
|
| 496 |
+
Wait until the check succeeds the configured number of times
|
| 497 |
+
|
| 498 |
+
:type check: callable
|
| 499 |
+
:param check: A callable that returns True or False to indicate
|
| 500 |
+
if the check succeeded or failed.
|
| 501 |
+
|
| 502 |
+
:type args: list
|
| 503 |
+
:param args: Any ordered arguments to be passed to the check.
|
| 504 |
+
|
| 505 |
+
:type kwargs: dict
|
| 506 |
+
:param kwargs: Any keyword arguments to be passed to the check.
|
| 507 |
+
"""
|
| 508 |
+
attempts = 0
|
| 509 |
+
successes = 0
|
| 510 |
+
if self.delay_initial_poll:
|
| 511 |
+
time.sleep(self.delay)
|
| 512 |
+
while attempts < self.max_attempts:
|
| 513 |
+
attempts += 1
|
| 514 |
+
if check(*args, **kwargs):
|
| 515 |
+
successes += 1
|
| 516 |
+
if successes >= self.min_successes:
|
| 517 |
+
return
|
| 518 |
+
else:
|
| 519 |
+
time.sleep(self.delay)
|
| 520 |
+
fail_msg = self._fail_message(attempts, successes)
|
| 521 |
+
raise ConsistencyWaiterException(fail_msg)
|
| 522 |
+
|
| 523 |
+
def _fail_message(self, attempts, successes):
|
| 524 |
+
return (
|
| 525 |
+
f'Failed after {attempts} attempts, only had {successes} successes'
|
| 526 |
+
)
|
| 527 |
+
|
| 528 |
+
|
| 529 |
+
class StubbedSession(botocore.session.Session):
|
| 530 |
+
def __init__(self, *args, **kwargs):
|
| 531 |
+
super().__init__(*args, **kwargs)
|
| 532 |
+
self._cached_clients = {}
|
| 533 |
+
self._client_stubs = {}
|
| 534 |
+
|
| 535 |
+
def create_client(self, service_name, *args, **kwargs):
|
| 536 |
+
if service_name not in self._cached_clients:
|
| 537 |
+
client = self._create_stubbed_client(service_name, *args, **kwargs)
|
| 538 |
+
self._cached_clients[service_name] = client
|
| 539 |
+
return self._cached_clients[service_name]
|
| 540 |
+
|
| 541 |
+
def _create_stubbed_client(self, service_name, *args, **kwargs):
|
| 542 |
+
client = super().create_client(service_name, *args, **kwargs)
|
| 543 |
+
stubber = Stubber(client)
|
| 544 |
+
self._client_stubs[service_name] = stubber
|
| 545 |
+
return client
|
| 546 |
+
|
| 547 |
+
def stub(self, service_name, *args, **kwargs):
|
| 548 |
+
if service_name not in self._client_stubs:
|
| 549 |
+
self.create_client(service_name, *args, **kwargs)
|
| 550 |
+
return self._client_stubs[service_name]
|
| 551 |
+
|
| 552 |
+
def activate_stubs(self):
|
| 553 |
+
for stub in self._client_stubs.values():
|
| 554 |
+
stub.activate()
|
| 555 |
+
|
| 556 |
+
def verify_stubs(self):
|
| 557 |
+
for stub in self._client_stubs.values():
|
| 558 |
+
stub.assert_no_pending_responses()
|
| 559 |
+
|
| 560 |
+
|
| 561 |
+
class FreezeTime(ContextDecorator):
|
| 562 |
+
"""
|
| 563 |
+
Context manager for mocking out datetime in arbitrary modules when creating
|
| 564 |
+
performing actions like signing which require point in time specificity.
|
| 565 |
+
|
| 566 |
+
:type module: module
|
| 567 |
+
:param module: reference to imported module to patch (e.g. botocore.auth.datetime)
|
| 568 |
+
|
| 569 |
+
:type date: datetime.datetime
|
| 570 |
+
:param date: datetime object specifying the output for utcnow()
|
| 571 |
+
"""
|
| 572 |
+
|
| 573 |
+
def __init__(self, module, date=None):
|
| 574 |
+
if date is None:
|
| 575 |
+
date = datetime.datetime.utcnow()
|
| 576 |
+
self.date = date
|
| 577 |
+
self.datetime_patcher = mock.patch.object(
|
| 578 |
+
module, 'datetime', mock.Mock(wraps=datetime.datetime)
|
| 579 |
+
)
|
| 580 |
+
|
| 581 |
+
def __enter__(self, *args, **kwargs):
|
| 582 |
+
mock = self.datetime_patcher.start()
|
| 583 |
+
mock.utcnow.return_value = self.date
|
| 584 |
+
|
| 585 |
+
def __exit__(self, *args, **kwargs):
|
| 586 |
+
self.datetime_patcher.stop()
|
| 587 |
+
|
| 588 |
+
|
| 589 |
+
def patch_load_service_model(
|
| 590 |
+
session, monkeypatch, service_model_json, ruleset_json
|
| 591 |
+
):
|
| 592 |
+
def mock_load_service_model(service_name, type_name, api_version=None):
|
| 593 |
+
if type_name == 'service-2':
|
| 594 |
+
return service_model_json
|
| 595 |
+
if type_name == 'endpoint-rule-set-1':
|
| 596 |
+
return ruleset_json
|
| 597 |
+
|
| 598 |
+
loader = session.get_component('data_loader')
|
| 599 |
+
monkeypatch.setattr(loader, 'load_service_model', mock_load_service_model)
|
testbed/boto__botocore/tests/cmd-runner
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 5 |
+
# may not use this file except in compliance with the License. A copy of
|
| 6 |
+
# the License is located at
|
| 7 |
+
#
|
| 8 |
+
# http://aws.amazon.com/apache2.0/
|
| 9 |
+
#
|
| 10 |
+
# or in the "license" file accompanying this file. This file is
|
| 11 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 12 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 13 |
+
# language governing permissions and limitations under the License.
|
| 14 |
+
"""Driver for client scripts.
|
| 15 |
+
|
| 16 |
+
How it Works
|
| 17 |
+
============
|
| 18 |
+
|
| 19 |
+
This script is part of the infrastructure used for resource leak tests.
|
| 20 |
+
At a high level, we're trying to verify that specific types of operations
|
| 21 |
+
don't leak memory. For example:
|
| 22 |
+
|
| 23 |
+
* Creating 100 clients in a loop doesn't leak memory within reason
|
| 24 |
+
* Making 100 API calls doesn't leak memory
|
| 25 |
+
* Streaming uploads/downloads to/from S3 have O(1) memory usage.
|
| 26 |
+
|
| 27 |
+
In order to do this, these tests are written to utilize two separate
|
| 28 |
+
processes: a driver and a runner. The driver sends commands to the
|
| 29 |
+
runner which performs the actual commands. While the runner is
|
| 30 |
+
running commands the driver can record various attributes about
|
| 31 |
+
the runner process. So far this is just memory usage.
|
| 32 |
+
|
| 33 |
+
There's a BaseClientDriverTest test that implements the driver part
|
| 34 |
+
of the tests. These should read like normal functional/integration tests.
|
| 35 |
+
|
| 36 |
+
This script (cmd-runner) implements the runner. It listens for commands
|
| 37 |
+
from the driver and runs the commands.
|
| 38 |
+
|
| 39 |
+
The driver and runner communicate via a basic text protocol. Commands
|
| 40 |
+
are line separated with arguments separated by spaces. Commands
|
| 41 |
+
are sent to the runner via stdin.
|
| 42 |
+
|
| 43 |
+
On success, the runner response through stdout with "OK".
|
| 44 |
+
|
| 45 |
+
Here's an example::
|
| 46 |
+
|
| 47 |
+
+--------+ +-------+
|
| 48 |
+
| Driver | |Runner |
|
| 49 |
+
+--------+ +-------+
|
| 50 |
+
|
| 51 |
+
create_client s3
|
| 52 |
+
-------------------------------------------->
|
| 53 |
+
OK
|
| 54 |
+
<-------------------------------------------
|
| 55 |
+
|
| 56 |
+
make_aws_request 100 ec2 describe_instances
|
| 57 |
+
-------------------------------------------->
|
| 58 |
+
OK
|
| 59 |
+
<-------------------------------------------
|
| 60 |
+
|
| 61 |
+
stream_s3_upload bucket key /tmp/foo.txt
|
| 62 |
+
-------------------------------------------->
|
| 63 |
+
OK
|
| 64 |
+
<-------------------------------------------
|
| 65 |
+
|
| 66 |
+
exit
|
| 67 |
+
-------------------------------------------->
|
| 68 |
+
OK
|
| 69 |
+
<-------------------------------------------
|
| 70 |
+
|
| 71 |
+
"""
|
| 72 |
+
import botocore.session
|
| 73 |
+
import sys
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
class CommandRunner(object):
|
| 77 |
+
DEFAULT_REGION = 'us-west-2'
|
| 78 |
+
|
| 79 |
+
def __init__(self):
|
| 80 |
+
self._session = botocore.session.get_session()
|
| 81 |
+
self._clients = []
|
| 82 |
+
self._waiters = []
|
| 83 |
+
self._paginators = []
|
| 84 |
+
|
| 85 |
+
def run(self):
|
| 86 |
+
while True:
|
| 87 |
+
line = sys.stdin.readline()
|
| 88 |
+
parts = line.strip().split()
|
| 89 |
+
if not parts:
|
| 90 |
+
break
|
| 91 |
+
elif parts[0] == 'exit':
|
| 92 |
+
sys.stdout.write('OK\n')
|
| 93 |
+
sys.stdout.flush()
|
| 94 |
+
break
|
| 95 |
+
else:
|
| 96 |
+
getattr(self, '_do_%s' % parts[0])(parts[1:])
|
| 97 |
+
sys.stdout.write('OK\n')
|
| 98 |
+
sys.stdout.flush()
|
| 99 |
+
|
| 100 |
+
def _do_create_client(self, args):
|
| 101 |
+
# The args provided by the user map directly to the args
|
| 102 |
+
# passed to create_client. At the least you need
|
| 103 |
+
# to provide the service name.
|
| 104 |
+
self._clients.append(self._session.create_client(*args))
|
| 105 |
+
|
| 106 |
+
def _do_create_multiple_clients(self, args):
|
| 107 |
+
# Args:
|
| 108 |
+
# * num_clients - Number of clients to create in a loop
|
| 109 |
+
# * client_args - Variable number of args to pass to create_client
|
| 110 |
+
num_clients = args[0]
|
| 111 |
+
client_args = args[1:]
|
| 112 |
+
for _ in range(int(num_clients)):
|
| 113 |
+
self._clients.append(self._session.create_client(*client_args))
|
| 114 |
+
|
| 115 |
+
def _do_free_clients(self, args):
|
| 116 |
+
# Frees the memory associated with all clients.
|
| 117 |
+
self._clients = []
|
| 118 |
+
|
| 119 |
+
def _do_create_waiter(self, args):
|
| 120 |
+
# Args:
|
| 121 |
+
# [0] client name used in its instantiation
|
| 122 |
+
# [1] waiter name used in its instantiation
|
| 123 |
+
client = self._create_client(args[0])
|
| 124 |
+
self._waiters.append(client.get_waiter(args[1]))
|
| 125 |
+
|
| 126 |
+
def _do_create_multiple_waiters(self, args):
|
| 127 |
+
# Args:
|
| 128 |
+
# [0] num_waiters - Number of clients to create in a loop
|
| 129 |
+
# [1] client name used in its instantiation
|
| 130 |
+
# [2] waiter name used in its instantiation
|
| 131 |
+
num_waiters = args[0]
|
| 132 |
+
client = self._create_client(args[1])
|
| 133 |
+
for _ in range(int(num_waiters)):
|
| 134 |
+
self._waiters.append(client.get_waiter(args[2]))
|
| 135 |
+
|
| 136 |
+
def _do_free_waiters(self, args):
|
| 137 |
+
# Frees the memory associated with all of the waiters.
|
| 138 |
+
self._waiters = []
|
| 139 |
+
|
| 140 |
+
def _do_create_paginator(self, args):
|
| 141 |
+
# Args:
|
| 142 |
+
# [0] client name used in its instantiation
|
| 143 |
+
# [1] paginator name used in its instantiation
|
| 144 |
+
client = self._create_client(args[0])
|
| 145 |
+
self._paginators.append(client.get_paginator(args[1]))
|
| 146 |
+
|
| 147 |
+
def _do_create_multiple_paginators(self, args):
|
| 148 |
+
# Args:
|
| 149 |
+
# [0] num_paginators - Number of paginators to create in a loop
|
| 150 |
+
# [1] client name used in its instantiation
|
| 151 |
+
# [2] paginator name used in its instantiation
|
| 152 |
+
num_paginators = args[0]
|
| 153 |
+
client = self._create_client(args[1])
|
| 154 |
+
for _ in range(int(num_paginators)):
|
| 155 |
+
self._paginators.append(client.get_paginator(args[2]))
|
| 156 |
+
|
| 157 |
+
def _do_free_paginators(self, args):
|
| 158 |
+
# Frees the memory associated with all of the waiters.
|
| 159 |
+
self._paginators = []
|
| 160 |
+
|
| 161 |
+
def _do_make_aws_request(self, args):
|
| 162 |
+
# Create a client and make a number of AWS requests.
|
| 163 |
+
# Args:
|
| 164 |
+
# * num_requests - The number of requests to create in a loop
|
| 165 |
+
# * service_name - The name of the AWS service
|
| 166 |
+
# * operation_name - The name of the service, snake_cased
|
| 167 |
+
# * oepration_args - Variable args, kwargs to pass to the API call,
|
| 168 |
+
# in the format Kwarg1:Val1 Kwarg2:Val2
|
| 169 |
+
num_requests = int(args[0])
|
| 170 |
+
service_name = args[1]
|
| 171 |
+
operation_name = args[2]
|
| 172 |
+
kwargs = dict([v.split(':', 1) for v in args[3:]])
|
| 173 |
+
client = self._create_client(service_name)
|
| 174 |
+
method = getattr(client, operation_name)
|
| 175 |
+
for _ in range(num_requests):
|
| 176 |
+
method(**kwargs)
|
| 177 |
+
|
| 178 |
+
def _do_stream_s3_upload(self, args):
|
| 179 |
+
# Stream an upload to S3 from a local file.
|
| 180 |
+
# This does *not* create an S3 bucket. You need to create this
|
| 181 |
+
# before running this command. You will also need to create
|
| 182 |
+
# the local file to upload before calling this command.
|
| 183 |
+
# Args:
|
| 184 |
+
# * bucket - The name of the S3 bucket
|
| 185 |
+
# * key - The name of the S3 key
|
| 186 |
+
# * filename - The name of the local filename to upload
|
| 187 |
+
bucket, key, local_filename = args
|
| 188 |
+
client = self._create_client('s3')
|
| 189 |
+
with open(local_filename, 'rb') as f:
|
| 190 |
+
client.put_object(Bucket=bucket, Key=key, Body=f)
|
| 191 |
+
|
| 192 |
+
def _do_stream_s3_download(self, args):
|
| 193 |
+
# Stream a download to S3 from a local file.
|
| 194 |
+
# Before calling this command you'll need to create the S3 bucket
|
| 195 |
+
# as well as the S3 object. Also, the directory where the
|
| 196 |
+
# file will be downloaded must already exist.
|
| 197 |
+
# Args:
|
| 198 |
+
# * bucket - The name of the S3 bucket
|
| 199 |
+
# * key - The name of the S3 key
|
| 200 |
+
# * filename - The local filename where the object will be downloaded
|
| 201 |
+
bucket, key, local_filename = args
|
| 202 |
+
client = self._create_client('s3')
|
| 203 |
+
response = client.get_object(Bucket=bucket, Key=key)
|
| 204 |
+
body_stream = response['Body']
|
| 205 |
+
with open(local_filename, 'wb') as f:
|
| 206 |
+
for chunk in iter(lambda: body_stream.read(64 * 1024), b''):
|
| 207 |
+
f.write(chunk)
|
| 208 |
+
|
| 209 |
+
def _create_client(self, service_name):
|
| 210 |
+
# Create a client using the provided service name.
|
| 211 |
+
# It will also inject a region name of self.DEFAULT_REGION.
|
| 212 |
+
return self._session.create_client(service_name,
|
| 213 |
+
region_name=self.DEFAULT_REGION)
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
def run():
|
| 217 |
+
CommandRunner().run()
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
run()
|
testbed/boto__botocore/tests/unit/__init__.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) 2012-2013 Mitch Garnaat http://garnaat.org/
|
| 2 |
+
# Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 5 |
+
# may not use this file except in compliance with the License. A copy of
|
| 6 |
+
# the License is located at
|
| 7 |
+
#
|
| 8 |
+
# http://aws.amazon.com/apache2.0/
|
| 9 |
+
#
|
| 10 |
+
# or in the "license" file accompanying this file. This file is
|
| 11 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 12 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 13 |
+
# language governing permissions and limitations under the License.
|
| 14 |
+
import copy
|
| 15 |
+
|
| 16 |
+
from tests import unittest
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class BaseResponseTest(unittest.TestCase):
|
| 20 |
+
def assert_response_with_subset_metadata(
|
| 21 |
+
self, actual_response, expected_response
|
| 22 |
+
):
|
| 23 |
+
"""
|
| 24 |
+
Compares two parsed service responses. For ResponseMetadata, it will
|
| 25 |
+
only assert that the expected is a proper subset of the actual. This
|
| 26 |
+
is useful so that when new keys are added to the metadata, tests don't
|
| 27 |
+
break.
|
| 28 |
+
"""
|
| 29 |
+
actual = copy.copy(actual_response)
|
| 30 |
+
expected = copy.copy(expected_response)
|
| 31 |
+
|
| 32 |
+
actual_metadata = actual.pop('ResponseMetadata', {})
|
| 33 |
+
expected_metadata = expected.pop('ResponseMetadata', {})
|
| 34 |
+
|
| 35 |
+
self.assertEqual(actual, expected)
|
| 36 |
+
self.assert_dict_is_proper_subset(actual_metadata, expected_metadata)
|
| 37 |
+
|
| 38 |
+
def assert_dict_is_proper_subset(self, superset, subset):
|
| 39 |
+
"""
|
| 40 |
+
Asserts that a dictionary is a proper subset of another.
|
| 41 |
+
"""
|
| 42 |
+
self.assertTrue(
|
| 43 |
+
all(
|
| 44 |
+
(k in superset and superset[k] == v) for k, v in subset.items()
|
| 45 |
+
)
|
| 46 |
+
)
|
testbed/boto__botocore/tests/unit/put_object_data
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
This is a test of PutObject.
|
testbed/boto__botocore/tests/unit/response_parsing/README.rst
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
======================
|
| 2 |
+
Response Parsing Tests
|
| 3 |
+
======================
|
| 4 |
+
|
| 5 |
+
The purpose of this collection of tests it to determine whether the XML
|
| 6 |
+
responses from the services are being correctly parsed and transformed
|
| 7 |
+
into Python data structures.
|
| 8 |
+
|
| 9 |
+
Within the ``data`` directory you will find pairs of files, an XML file
|
| 10 |
+
and a JSON file using a naming convention of::
|
| 11 |
+
|
| 12 |
+
<service_name>-<operation_name>.[xml|json]
|
| 13 |
+
|
| 14 |
+
Each pair of files represents one test. The XML file contains the
|
| 15 |
+
response sent from the server for that particular request and the JSON
|
| 16 |
+
file contains the expected Python data structure created from the XML
|
| 17 |
+
response.
|
| 18 |
+
|
| 19 |
+
The main test is contained in ``test_response_parser.py`` and is
|
| 20 |
+
implemented as a nose generator. Each time through the loop an XML
|
| 21 |
+
file is read and passed to a ``botocore.response.XmlResponse``
|
| 22 |
+
object. The corresponding JSON file is then parsed and compared to
|
| 23 |
+
the value created by the parser. If the are equal, the test passes. If
|
| 24 |
+
they are not equal, both the expected result and the actual result are
|
| 25 |
+
pretty-printed to stdout and the tests continue.
|
| 26 |
+
|
| 27 |
+
-----------------
|
| 28 |
+
Adding More Tests
|
| 29 |
+
-----------------
|
| 30 |
+
|
| 31 |
+
You can add more tests by simply placing appropriately named XML and JSON
|
| 32 |
+
files into the data directory. Make sure you follow the naming convention
|
| 33 |
+
shown above as that is how the generator determines which service and
|
| 34 |
+
operation to call.
|
testbed/boto__botocore/tests/unit/response_parsing/test_response_parsing.py
ADDED
|
@@ -0,0 +1,195 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 4 |
+
# may not use this file except in compliance with the License. A copy of
|
| 5 |
+
# the License is located at
|
| 6 |
+
#
|
| 7 |
+
# http://aws.amazon.com/apache2.0/
|
| 8 |
+
#
|
| 9 |
+
# or in the "license" file accompanying this file. This file is
|
| 10 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 11 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 12 |
+
# language governing permissions and limitations under the License.
|
| 13 |
+
|
| 14 |
+
import difflib
|
| 15 |
+
import glob
|
| 16 |
+
import json
|
| 17 |
+
import logging
|
| 18 |
+
import os
|
| 19 |
+
import pprint
|
| 20 |
+
|
| 21 |
+
import pytest
|
| 22 |
+
|
| 23 |
+
import botocore.session
|
| 24 |
+
from botocore import parsers, xform_name
|
| 25 |
+
from tests import create_session
|
| 26 |
+
|
| 27 |
+
log = logging.getLogger(__name__)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
SPECIAL_CASES = [
|
| 31 |
+
'iam-get-user-policy.xml', # Needs the JSON decode from handlers.py
|
| 32 |
+
'iam-list-roles.xml', # Needs the JSON decode from handlers.py for the policy
|
| 33 |
+
's3-get-bucket-location.xml', # Confirmed, this will need a special handler
|
| 34 |
+
# 's3-list-multipart-uploads.xml', # Bug in model, missing delimeter
|
| 35 |
+
'cloudformation-get-template.xml', # Need to JSON decode the template body.
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def _get_expected_parsed_result(filename):
|
| 40 |
+
dirname, filename = os.path.split(filename)
|
| 41 |
+
basename = os.path.splitext(filename)[0]
|
| 42 |
+
jsonfile = os.path.join(dirname, basename + '.json')
|
| 43 |
+
with open(jsonfile) as f:
|
| 44 |
+
return json.load(f)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def _get_raw_response_body(xmlfile):
|
| 48 |
+
with open(xmlfile, 'rb') as f:
|
| 49 |
+
return f.read()
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def _get_operation_model(service_model, filename):
|
| 53 |
+
dirname, filename = os.path.split(filename)
|
| 54 |
+
basename = os.path.splitext(filename)[0]
|
| 55 |
+
sn, opname = basename.split('-', 1)
|
| 56 |
+
# In order to have multiple tests for the same
|
| 57 |
+
# operation a '#' char is used to separate
|
| 58 |
+
# operation names from some other suffix so that
|
| 59 |
+
# the tests have a different filename, e.g
|
| 60 |
+
# my-operation#1.xml, my-operation#2.xml.
|
| 61 |
+
opname = opname.split('#')[0]
|
| 62 |
+
operation_names = service_model.operation_names
|
| 63 |
+
for operation_name in operation_names:
|
| 64 |
+
if xform_name(operation_name) == opname.replace('-', '_'):
|
| 65 |
+
return service_model.operation_model(operation_name)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def _test_parsed_response(xmlfile, operation_model, expected):
|
| 69 |
+
response_body = _get_raw_response_body(xmlfile)
|
| 70 |
+
response = {'body': response_body, 'status_code': 200, 'headers': {}}
|
| 71 |
+
for case in SPECIAL_CASES:
|
| 72 |
+
if case in xmlfile:
|
| 73 |
+
print(f"SKIP: {xmlfile}")
|
| 74 |
+
return
|
| 75 |
+
if 'errors' in xmlfile:
|
| 76 |
+
response['status_code'] = 400
|
| 77 |
+
# Handle the special cased __headers__ key if it exists.
|
| 78 |
+
if b'__headers__' in response_body:
|
| 79 |
+
loaded = json.loads(response_body.decode('utf-8'))
|
| 80 |
+
response['headers'] = loaded.pop('__headers__')
|
| 81 |
+
response['body'] = json.dumps(loaded).encode('utf-8')
|
| 82 |
+
|
| 83 |
+
protocol = operation_model.service_model.protocol
|
| 84 |
+
parser_cls = parsers.PROTOCOL_PARSERS[protocol]
|
| 85 |
+
parser = parser_cls(timestamp_parser=lambda x: x)
|
| 86 |
+
parsed = parser.parse(response, operation_model.output_shape)
|
| 87 |
+
parsed = _convert_bytes_to_str(parsed)
|
| 88 |
+
expected['ResponseMetadata']['HTTPStatusCode'] = response['status_code']
|
| 89 |
+
expected['ResponseMetadata']['HTTPHeaders'] = response['headers']
|
| 90 |
+
|
| 91 |
+
d2 = parsed
|
| 92 |
+
d1 = expected
|
| 93 |
+
|
| 94 |
+
if d1 != d2:
|
| 95 |
+
log.debug('-' * 40)
|
| 96 |
+
log.debug("XML FILE:\n" + xmlfile)
|
| 97 |
+
log.debug('-' * 40)
|
| 98 |
+
log.debug("ACTUAL:\n" + pprint.pformat(parsed))
|
| 99 |
+
log.debug('-' * 40)
|
| 100 |
+
log.debug("EXPECTED:\n" + pprint.pformat(expected))
|
| 101 |
+
if not d1 == d2:
|
| 102 |
+
# Borrowed from assertDictEqual, though this doesn't
|
| 103 |
+
# handle the case when unicode literals are used in one
|
| 104 |
+
# dict but not in the other (and we want to consider them
|
| 105 |
+
# as being equal).
|
| 106 |
+
print(d1)
|
| 107 |
+
print()
|
| 108 |
+
print(d2)
|
| 109 |
+
pretty_d1 = pprint.pformat(d1, width=1).splitlines()
|
| 110 |
+
pretty_d2 = pprint.pformat(d2, width=1).splitlines()
|
| 111 |
+
diff = '\n' + '\n'.join(difflib.ndiff(pretty_d1, pretty_d2))
|
| 112 |
+
raise AssertionError(f"Dicts are not equal:\n{diff}")
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def _convert_bytes_to_str(parsed):
|
| 116 |
+
if isinstance(parsed, dict):
|
| 117 |
+
new_dict = {}
|
| 118 |
+
for key, value in parsed.items():
|
| 119 |
+
new_dict[key] = _convert_bytes_to_str(value)
|
| 120 |
+
return new_dict
|
| 121 |
+
elif isinstance(parsed, bytes):
|
| 122 |
+
return parsed.decode('utf-8')
|
| 123 |
+
elif isinstance(parsed, list):
|
| 124 |
+
new_list = []
|
| 125 |
+
for item in parsed:
|
| 126 |
+
new_list.append(_convert_bytes_to_str(item))
|
| 127 |
+
return new_list
|
| 128 |
+
else:
|
| 129 |
+
return parsed
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def _xml_test_cases():
|
| 133 |
+
session = create_session()
|
| 134 |
+
test_cases = []
|
| 135 |
+
for dp in ['responses', 'errors']:
|
| 136 |
+
data_path = os.path.join(os.path.dirname(__file__), 'xml')
|
| 137 |
+
data_path = os.path.join(data_path, dp)
|
| 138 |
+
xml_files = glob.glob(f'{data_path}/*.xml')
|
| 139 |
+
service_names = set()
|
| 140 |
+
for fn in xml_files:
|
| 141 |
+
service_names.add(os.path.split(fn)[1].split('-')[0])
|
| 142 |
+
for service_name in service_names:
|
| 143 |
+
service_model = session.get_service_model(service_name)
|
| 144 |
+
service_xml_files = glob.glob(f'{data_path}/{service_name}-*.xml')
|
| 145 |
+
for xmlfile in service_xml_files:
|
| 146 |
+
expected = _get_expected_parsed_result(xmlfile)
|
| 147 |
+
operation_model = _get_operation_model(service_model, xmlfile)
|
| 148 |
+
test_cases.append((xmlfile, operation_model, expected))
|
| 149 |
+
return sorted(test_cases)
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
@pytest.mark.parametrize(
|
| 153 |
+
"xmlfile, operation_model, expected", _xml_test_cases()
|
| 154 |
+
)
|
| 155 |
+
def test_xml_parsing(xmlfile, operation_model, expected):
|
| 156 |
+
_test_parsed_response(xmlfile, operation_model, expected)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def _json_test_cases():
|
| 160 |
+
# The outputs/ directory has sample output responses
|
| 161 |
+
# For each file in outputs/ there's a corresponding file
|
| 162 |
+
# in expected/ that has the expected parsed response.
|
| 163 |
+
base_dir = os.path.join(os.path.dirname(__file__), 'json')
|
| 164 |
+
json_responses_dir = os.path.join(base_dir, 'errors')
|
| 165 |
+
expected_parsed_dir = os.path.join(base_dir, 'expected')
|
| 166 |
+
session = botocore.session.get_session()
|
| 167 |
+
json_test_cases = []
|
| 168 |
+
for json_response_file in os.listdir(json_responses_dir):
|
| 169 |
+
# Files look like: 'datapipeline-create-pipeline.json'
|
| 170 |
+
service_name, operation_name = os.path.splitext(json_response_file)[
|
| 171 |
+
0
|
| 172 |
+
].split('-', 1)
|
| 173 |
+
expected_parsed_response = os.path.join(
|
| 174 |
+
expected_parsed_dir, json_response_file
|
| 175 |
+
)
|
| 176 |
+
raw_response_file = os.path.join(
|
| 177 |
+
json_responses_dir, json_response_file
|
| 178 |
+
)
|
| 179 |
+
with open(expected_parsed_response) as f:
|
| 180 |
+
expected = json.load(f)
|
| 181 |
+
service_model = session.get_service_model(service_name)
|
| 182 |
+
operation_names = service_model.operation_names
|
| 183 |
+
operation_model = None
|
| 184 |
+
for op_name in operation_names:
|
| 185 |
+
if xform_name(op_name) == operation_name.replace('-', '_'):
|
| 186 |
+
operation_model = service_model.operation_model(op_name)
|
| 187 |
+
json_test_cases.append((raw_response_file, operation_model, expected))
|
| 188 |
+
return sorted(json_test_cases)
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
@pytest.mark.parametrize(
|
| 192 |
+
"raw_response_file, operation_model, expected", _json_test_cases()
|
| 193 |
+
)
|
| 194 |
+
def test_json_errors_parsing(raw_response_file, operation_model, expected):
|
| 195 |
+
_test_parsed_response(raw_response_file, operation_model, expected)
|
testbed/boto__botocore/tests/unit/response_parsing/xml/responses/cloudwatch-describe-alarm-history.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AlarmHistoryItems": [],
|
| 3 |
+
"ResponseMetadata": {
|
| 4 |
+
"RequestId": "ac265b36-9167-11e2-bf7e-91c14e278742"
|
| 5 |
+
}
|
| 6 |
+
}
|
testbed/boto__botocore/tests/unit/response_parsing/xml/responses/cloudwatch-describe-alarm-history.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<DescribeAlarmHistoryResponse xmlns="http://monitoring.amazonaws.com/doc/2010-08-01/">
|
| 2 |
+
<DescribeAlarmHistoryResult>
|
| 3 |
+
<AlarmHistoryItems/>
|
| 4 |
+
</DescribeAlarmHistoryResult>
|
| 5 |
+
<ResponseMetadata>
|
| 6 |
+
<RequestId>ac265b36-9167-11e2-bf7e-91c14e278742</RequestId>
|
| 7 |
+
</ResponseMetadata>
|
| 8 |
+
</DescribeAlarmHistoryResponse>
|
testbed/boto__botocore/tests/unit/response_parsing/xml/responses/cloudwatch-list-metrics.xml
ADDED
|
@@ -0,0 +1,819 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<ListMetricsResponse xmlns="http://monitoring.amazonaws.com/doc/2010-08-01/">
|
| 2 |
+
<ListMetricsResult>
|
| 3 |
+
<Metrics>
|
| 4 |
+
<member>
|
| 5 |
+
<Dimensions>
|
| 6 |
+
<member>
|
| 7 |
+
<Name>VolumeId</Name>
|
| 8 |
+
<Value>vol-267b761f</Value>
|
| 9 |
+
</member>
|
| 10 |
+
</Dimensions>
|
| 11 |
+
<MetricName>VolumeIdleTime</MetricName>
|
| 12 |
+
<Namespace>AWS/EBS</Namespace>
|
| 13 |
+
</member>
|
| 14 |
+
<member>
|
| 15 |
+
<Dimensions>
|
| 16 |
+
<member>
|
| 17 |
+
<Name>VolumeId</Name>
|
| 18 |
+
<Value>vol-04c7c53d</Value>
|
| 19 |
+
</member>
|
| 20 |
+
</Dimensions>
|
| 21 |
+
<MetricName>VolumeReadBytes</MetricName>
|
| 22 |
+
<Namespace>AWS/EBS</Namespace>
|
| 23 |
+
</member>
|
| 24 |
+
<member>
|
| 25 |
+
<Dimensions>
|
| 26 |
+
<member>
|
| 27 |
+
<Name>InstanceId</Name>
|
| 28 |
+
<Value>i-d63c6ce4</Value>
|
| 29 |
+
</member>
|
| 30 |
+
</Dimensions>
|
| 31 |
+
<MetricName>DiskReadBytes</MetricName>
|
| 32 |
+
<Namespace>AWS/EC2</Namespace>
|
| 33 |
+
</member>
|
| 34 |
+
<member>
|
| 35 |
+
<Dimensions>
|
| 36 |
+
<member>
|
| 37 |
+
<Name>QueueName</Name>
|
| 38 |
+
<Value>foobar</Value>
|
| 39 |
+
</member>
|
| 40 |
+
</Dimensions>
|
| 41 |
+
<MetricName>NumberOfEmptyReceives</MetricName>
|
| 42 |
+
<Namespace>AWS/SQS</Namespace>
|
| 43 |
+
</member>
|
| 44 |
+
<member>
|
| 45 |
+
<Dimensions>
|
| 46 |
+
<member>
|
| 47 |
+
<Name>InstanceId</Name>
|
| 48 |
+
<Value>i-78f1b94a</Value>
|
| 49 |
+
</member>
|
| 50 |
+
</Dimensions>
|
| 51 |
+
<MetricName>NetworkOut</MetricName>
|
| 52 |
+
<Namespace>AWS/EC2</Namespace>
|
| 53 |
+
</member>
|
| 54 |
+
<member>
|
| 55 |
+
<Dimensions>
|
| 56 |
+
<member>
|
| 57 |
+
<Name>QueueName</Name>
|
| 58 |
+
<Value>foobar</Value>
|
| 59 |
+
</member>
|
| 60 |
+
</Dimensions>
|
| 61 |
+
<MetricName>ApproximateNumberOfMessagesNotVisible</MetricName>
|
| 62 |
+
<Namespace>AWS/SQS</Namespace>
|
| 63 |
+
</member>
|
| 64 |
+
<member>
|
| 65 |
+
<Dimensions>
|
| 66 |
+
<member>
|
| 67 |
+
<Name>VolumeId</Name>
|
| 68 |
+
<Value>vol-04c7c53d</Value>
|
| 69 |
+
</member>
|
| 70 |
+
</Dimensions>
|
| 71 |
+
<MetricName>VolumeTotalReadTime</MetricName>
|
| 72 |
+
<Namespace>AWS/EBS</Namespace>
|
| 73 |
+
</member>
|
| 74 |
+
<member>
|
| 75 |
+
<Dimensions>
|
| 76 |
+
<member>
|
| 77 |
+
<Name>VolumeId</Name>
|
| 78 |
+
<Value>vol-203b3919</Value>
|
| 79 |
+
</member>
|
| 80 |
+
</Dimensions>
|
| 81 |
+
<MetricName>VolumeWriteOps</MetricName>
|
| 82 |
+
<Namespace>AWS/EBS</Namespace>
|
| 83 |
+
</member>
|
| 84 |
+
<member>
|
| 85 |
+
<Dimensions>
|
| 86 |
+
<member>
|
| 87 |
+
<Name>VolumeId</Name>
|
| 88 |
+
<Value>vol-267b761f</Value>
|
| 89 |
+
</member>
|
| 90 |
+
</Dimensions>
|
| 91 |
+
<MetricName>VolumeWriteOps</MetricName>
|
| 92 |
+
<Namespace>AWS/EBS</Namespace>
|
| 93 |
+
</member>
|
| 94 |
+
<member>
|
| 95 |
+
<Dimensions>
|
| 96 |
+
<member>
|
| 97 |
+
<Name>VolumeId</Name>
|
| 98 |
+
<Value>vol-a8d2e991</Value>
|
| 99 |
+
</member>
|
| 100 |
+
</Dimensions>
|
| 101 |
+
<MetricName>VolumeWriteBytes</MetricName>
|
| 102 |
+
<Namespace>AWS/EBS</Namespace>
|
| 103 |
+
</member>
|
| 104 |
+
<member>
|
| 105 |
+
<Dimensions>
|
| 106 |
+
<member>
|
| 107 |
+
<Name>InstanceId</Name>
|
| 108 |
+
<Value>i-70d08042</Value>
|
| 109 |
+
</member>
|
| 110 |
+
</Dimensions>
|
| 111 |
+
<MetricName>StatusCheckFailed_Instance</MetricName>
|
| 112 |
+
<Namespace>AWS/EC2</Namespace>
|
| 113 |
+
</member>
|
| 114 |
+
<member>
|
| 115 |
+
<Dimensions>
|
| 116 |
+
<member>
|
| 117 |
+
<Name>QueueName</Name>
|
| 118 |
+
<Value>foobar</Value>
|
| 119 |
+
</member>
|
| 120 |
+
</Dimensions>
|
| 121 |
+
<MetricName>ApproximateNumberOfMessagesDelayed</MetricName>
|
| 122 |
+
<Namespace>AWS/SQS</Namespace>
|
| 123 |
+
</member>
|
| 124 |
+
<member>
|
| 125 |
+
<Dimensions>
|
| 126 |
+
<member>
|
| 127 |
+
<Name>VolumeId</Name>
|
| 128 |
+
<Value>vol-04c7c53d</Value>
|
| 129 |
+
</member>
|
| 130 |
+
</Dimensions>
|
| 131 |
+
<MetricName>VolumeReadOps</MetricName>
|
| 132 |
+
<Namespace>AWS/EBS</Namespace>
|
| 133 |
+
</member>
|
| 134 |
+
<member>
|
| 135 |
+
<Dimensions>
|
| 136 |
+
<member>
|
| 137 |
+
<Name>InstanceId</Name>
|
| 138 |
+
<Value>i-d63c6ce4</Value>
|
| 139 |
+
</member>
|
| 140 |
+
</Dimensions>
|
| 141 |
+
<MetricName>CPUUtilization</MetricName>
|
| 142 |
+
<Namespace>AWS/EC2</Namespace>
|
| 143 |
+
</member>
|
| 144 |
+
<member>
|
| 145 |
+
<Dimensions>
|
| 146 |
+
<member>
|
| 147 |
+
<Name>VolumeId</Name>
|
| 148 |
+
<Value>vol-267b761f</Value>
|
| 149 |
+
</member>
|
| 150 |
+
</Dimensions>
|
| 151 |
+
<MetricName>VolumeTotalWriteTime</MetricName>
|
| 152 |
+
<Namespace>AWS/EBS</Namespace>
|
| 153 |
+
</member>
|
| 154 |
+
<member>
|
| 155 |
+
<Dimensions>
|
| 156 |
+
<member>
|
| 157 |
+
<Name>VolumeId</Name>
|
| 158 |
+
<Value>vol-a8d2e991</Value>
|
| 159 |
+
</member>
|
| 160 |
+
</Dimensions>
|
| 161 |
+
<MetricName>VolumeWriteOps</MetricName>
|
| 162 |
+
<Namespace>AWS/EBS</Namespace>
|
| 163 |
+
</member>
|
| 164 |
+
<member>
|
| 165 |
+
<Dimensions>
|
| 166 |
+
<member>
|
| 167 |
+
<Name>InstanceId</Name>
|
| 168 |
+
<Value>i-78f1b94a</Value>
|
| 169 |
+
</member>
|
| 170 |
+
</Dimensions>
|
| 171 |
+
<MetricName>CPUUtilization</MetricName>
|
| 172 |
+
<Namespace>AWS/EC2</Namespace>
|
| 173 |
+
</member>
|
| 174 |
+
<member>
|
| 175 |
+
<Dimensions>
|
| 176 |
+
<member>
|
| 177 |
+
<Name>VolumeId</Name>
|
| 178 |
+
<Value>vol-267b761f</Value>
|
| 179 |
+
</member>
|
| 180 |
+
</Dimensions>
|
| 181 |
+
<MetricName>VolumeQueueLength</MetricName>
|
| 182 |
+
<Namespace>AWS/EBS</Namespace>
|
| 183 |
+
</member>
|
| 184 |
+
<member>
|
| 185 |
+
<Dimensions>
|
| 186 |
+
<member>
|
| 187 |
+
<Name>InstanceId</Name>
|
| 188 |
+
<Value>i-20277712</Value>
|
| 189 |
+
</member>
|
| 190 |
+
</Dimensions>
|
| 191 |
+
<MetricName>DiskWriteBytes</MetricName>
|
| 192 |
+
<Namespace>AWS/EC2</Namespace>
|
| 193 |
+
</member>
|
| 194 |
+
<member>
|
| 195 |
+
<Dimensions>
|
| 196 |
+
<member>
|
| 197 |
+
<Name>VolumeId</Name>
|
| 198 |
+
<Value>vol-267b761f</Value>
|
| 199 |
+
</member>
|
| 200 |
+
</Dimensions>
|
| 201 |
+
<MetricName>VolumeTotalReadTime</MetricName>
|
| 202 |
+
<Namespace>AWS/EBS</Namespace>
|
| 203 |
+
</member>
|
| 204 |
+
<member>
|
| 205 |
+
<Dimensions>
|
| 206 |
+
<member>
|
| 207 |
+
<Name>VolumeId</Name>
|
| 208 |
+
<Value>vol-04c7c53d</Value>
|
| 209 |
+
</member>
|
| 210 |
+
</Dimensions>
|
| 211 |
+
<MetricName>VolumeWriteOps</MetricName>
|
| 212 |
+
<Namespace>AWS/EBS</Namespace>
|
| 213 |
+
</member>
|
| 214 |
+
<member>
|
| 215 |
+
<Dimensions>
|
| 216 |
+
<member>
|
| 217 |
+
<Name>InstanceId</Name>
|
| 218 |
+
<Value>i-70d08042</Value>
|
| 219 |
+
</member>
|
| 220 |
+
</Dimensions>
|
| 221 |
+
<MetricName>CPUUtilization</MetricName>
|
| 222 |
+
<Namespace>AWS/EC2</Namespace>
|
| 223 |
+
</member>
|
| 224 |
+
<member>
|
| 225 |
+
<Dimensions>
|
| 226 |
+
<member>
|
| 227 |
+
<Name>InstanceId</Name>
|
| 228 |
+
<Value>i-20277712</Value>
|
| 229 |
+
</member>
|
| 230 |
+
</Dimensions>
|
| 231 |
+
<MetricName>StatusCheckFailed_Instance</MetricName>
|
| 232 |
+
<Namespace>AWS/EC2</Namespace>
|
| 233 |
+
</member>
|
| 234 |
+
<member>
|
| 235 |
+
<Dimensions>
|
| 236 |
+
<member>
|
| 237 |
+
<Name>InstanceId</Name>
|
| 238 |
+
<Value>i-20277712</Value>
|
| 239 |
+
</member>
|
| 240 |
+
</Dimensions>
|
| 241 |
+
<MetricName>CPUUtilization</MetricName>
|
| 242 |
+
<Namespace>AWS/EC2</Namespace>
|
| 243 |
+
</member>
|
| 244 |
+
<member>
|
| 245 |
+
<Dimensions>
|
| 246 |
+
<member>
|
| 247 |
+
<Name>InstanceId</Name>
|
| 248 |
+
<Value>i-20277712</Value>
|
| 249 |
+
</member>
|
| 250 |
+
</Dimensions>
|
| 251 |
+
<MetricName>DiskReadBytes</MetricName>
|
| 252 |
+
<Namespace>AWS/EC2</Namespace>
|
| 253 |
+
</member>
|
| 254 |
+
<member>
|
| 255 |
+
<Dimensions>
|
| 256 |
+
<member>
|
| 257 |
+
<Name>VolumeId</Name>
|
| 258 |
+
<Value>vol-04c7c53d</Value>
|
| 259 |
+
</member>
|
| 260 |
+
</Dimensions>
|
| 261 |
+
<MetricName>VolumeIdleTime</MetricName>
|
| 262 |
+
<Namespace>AWS/EBS</Namespace>
|
| 263 |
+
</member>
|
| 264 |
+
<member>
|
| 265 |
+
<Dimensions>
|
| 266 |
+
<member>
|
| 267 |
+
<Name>VolumeId</Name>
|
| 268 |
+
<Value>vol-203b3919</Value>
|
| 269 |
+
</member>
|
| 270 |
+
</Dimensions>
|
| 271 |
+
<MetricName>VolumeQueueLength</MetricName>
|
| 272 |
+
<Namespace>AWS/EBS</Namespace>
|
| 273 |
+
</member>
|
| 274 |
+
<member>
|
| 275 |
+
<Dimensions>
|
| 276 |
+
<member>
|
| 277 |
+
<Name>InstanceId</Name>
|
| 278 |
+
<Value>i-d63c6ce4</Value>
|
| 279 |
+
</member>
|
| 280 |
+
</Dimensions>
|
| 281 |
+
<MetricName>DiskReadOps</MetricName>
|
| 282 |
+
<Namespace>AWS/EC2</Namespace>
|
| 283 |
+
</member>
|
| 284 |
+
<member>
|
| 285 |
+
<Dimensions>
|
| 286 |
+
<member>
|
| 287 |
+
<Name>VolumeId</Name>
|
| 288 |
+
<Value>vol-a8d2e991</Value>
|
| 289 |
+
</member>
|
| 290 |
+
</Dimensions>
|
| 291 |
+
<MetricName>VolumeIdleTime</MetricName>
|
| 292 |
+
<Namespace>AWS/EBS</Namespace>
|
| 293 |
+
</member>
|
| 294 |
+
<member>
|
| 295 |
+
<Dimensions>
|
| 296 |
+
<member>
|
| 297 |
+
<Name>VolumeId</Name>
|
| 298 |
+
<Value>vol-267b761f</Value>
|
| 299 |
+
</member>
|
| 300 |
+
</Dimensions>
|
| 301 |
+
<MetricName>VolumeWriteBytes</MetricName>
|
| 302 |
+
<Namespace>AWS/EBS</Namespace>
|
| 303 |
+
</member>
|
| 304 |
+
<member>
|
| 305 |
+
<Dimensions>
|
| 306 |
+
<member>
|
| 307 |
+
<Name>QueueName</Name>
|
| 308 |
+
<Value>foobar</Value>
|
| 309 |
+
</member>
|
| 310 |
+
</Dimensions>
|
| 311 |
+
<MetricName>ApproximateNumberOfMessagesVisible</MetricName>
|
| 312 |
+
<Namespace>AWS/SQS</Namespace>
|
| 313 |
+
</member>
|
| 314 |
+
<member>
|
| 315 |
+
<Dimensions>
|
| 316 |
+
<member>
|
| 317 |
+
<Name>InstanceId</Name>
|
| 318 |
+
<Value>i-70d08042</Value>
|
| 319 |
+
</member>
|
| 320 |
+
</Dimensions>
|
| 321 |
+
<MetricName>DiskReadBytes</MetricName>
|
| 322 |
+
<Namespace>AWS/EC2</Namespace>
|
| 323 |
+
</member>
|
| 324 |
+
<member>
|
| 325 |
+
<Dimensions>
|
| 326 |
+
<member>
|
| 327 |
+
<Name>InstanceId</Name>
|
| 328 |
+
<Value>i-78f1b94a</Value>
|
| 329 |
+
</member>
|
| 330 |
+
</Dimensions>
|
| 331 |
+
<MetricName>StatusCheckFailed_Instance</MetricName>
|
| 332 |
+
<Namespace>AWS/EC2</Namespace>
|
| 333 |
+
</member>
|
| 334 |
+
<member>
|
| 335 |
+
<Dimensions>
|
| 336 |
+
<member>
|
| 337 |
+
<Name>VolumeId</Name>
|
| 338 |
+
<Value>vol-267b761f</Value>
|
| 339 |
+
</member>
|
| 340 |
+
</Dimensions>
|
| 341 |
+
<MetricName>VolumeReadOps</MetricName>
|
| 342 |
+
<Namespace>AWS/EBS</Namespace>
|
| 343 |
+
</member>
|
| 344 |
+
<member>
|
| 345 |
+
<Dimensions>
|
| 346 |
+
<member>
|
| 347 |
+
<Name>InstanceId</Name>
|
| 348 |
+
<Value>i-78f1b94a</Value>
|
| 349 |
+
</member>
|
| 350 |
+
</Dimensions>
|
| 351 |
+
<MetricName>DiskReadOps</MetricName>
|
| 352 |
+
<Namespace>AWS/EC2</Namespace>
|
| 353 |
+
</member>
|
| 354 |
+
<member>
|
| 355 |
+
<Dimensions>
|
| 356 |
+
<member>
|
| 357 |
+
<Name>VolumeId</Name>
|
| 358 |
+
<Value>vol-a8d2e991</Value>
|
| 359 |
+
</member>
|
| 360 |
+
</Dimensions>
|
| 361 |
+
<MetricName>VolumeTotalWriteTime</MetricName>
|
| 362 |
+
<Namespace>AWS/EBS</Namespace>
|
| 363 |
+
</member>
|
| 364 |
+
<member>
|
| 365 |
+
<Dimensions>
|
| 366 |
+
<member>
|
| 367 |
+
<Name>InstanceId</Name>
|
| 368 |
+
<Value>i-d63c6ce4</Value>
|
| 369 |
+
</member>
|
| 370 |
+
</Dimensions>
|
| 371 |
+
<MetricName>StatusCheckFailed_System</MetricName>
|
| 372 |
+
<Namespace>AWS/EC2</Namespace>
|
| 373 |
+
</member>
|
| 374 |
+
<member>
|
| 375 |
+
<Dimensions>
|
| 376 |
+
<member>
|
| 377 |
+
<Name>InstanceId</Name>
|
| 378 |
+
<Value>i-70d08042</Value>
|
| 379 |
+
</member>
|
| 380 |
+
</Dimensions>
|
| 381 |
+
<MetricName>NetworkOut</MetricName>
|
| 382 |
+
<Namespace>AWS/EC2</Namespace>
|
| 383 |
+
</member>
|
| 384 |
+
<member>
|
| 385 |
+
<Dimensions>
|
| 386 |
+
<member>
|
| 387 |
+
<Name>InstanceId</Name>
|
| 388 |
+
<Value>i-d63c6ce4</Value>
|
| 389 |
+
</member>
|
| 390 |
+
</Dimensions>
|
| 391 |
+
<MetricName>StatusCheckFailed</MetricName>
|
| 392 |
+
<Namespace>AWS/EC2</Namespace>
|
| 393 |
+
</member>
|
| 394 |
+
<member>
|
| 395 |
+
<Dimensions>
|
| 396 |
+
<member>
|
| 397 |
+
<Name>VolumeId</Name>
|
| 398 |
+
<Value>vol-a8d2e991</Value>
|
| 399 |
+
</member>
|
| 400 |
+
</Dimensions>
|
| 401 |
+
<MetricName>VolumeReadOps</MetricName>
|
| 402 |
+
<Namespace>AWS/EBS</Namespace>
|
| 403 |
+
</member>
|
| 404 |
+
<member>
|
| 405 |
+
<Dimensions>
|
| 406 |
+
<member>
|
| 407 |
+
<Name>VolumeId</Name>
|
| 408 |
+
<Value>vol-203b3919</Value>
|
| 409 |
+
</member>
|
| 410 |
+
</Dimensions>
|
| 411 |
+
<MetricName>VolumeTotalWriteTime</MetricName>
|
| 412 |
+
<Namespace>AWS/EBS</Namespace>
|
| 413 |
+
</member>
|
| 414 |
+
<member>
|
| 415 |
+
<Dimensions>
|
| 416 |
+
<member>
|
| 417 |
+
<Name>VolumeId</Name>
|
| 418 |
+
<Value>vol-203b3919</Value>
|
| 419 |
+
</member>
|
| 420 |
+
</Dimensions>
|
| 421 |
+
<MetricName>VolumeReadBytes</MetricName>
|
| 422 |
+
<Namespace>AWS/EBS</Namespace>
|
| 423 |
+
</member>
|
| 424 |
+
<member>
|
| 425 |
+
<Dimensions>
|
| 426 |
+
<member>
|
| 427 |
+
<Name>InstanceId</Name>
|
| 428 |
+
<Value>i-d63c6ce4</Value>
|
| 429 |
+
</member>
|
| 430 |
+
</Dimensions>
|
| 431 |
+
<MetricName>DiskWriteOps</MetricName>
|
| 432 |
+
<Namespace>AWS/EC2</Namespace>
|
| 433 |
+
</member>
|
| 434 |
+
<member>
|
| 435 |
+
<Dimensions>
|
| 436 |
+
<member>
|
| 437 |
+
<Name>InstanceId</Name>
|
| 438 |
+
<Value>i-78f1b94a</Value>
|
| 439 |
+
</member>
|
| 440 |
+
</Dimensions>
|
| 441 |
+
<MetricName>DiskWriteOps</MetricName>
|
| 442 |
+
<Namespace>AWS/EC2</Namespace>
|
| 443 |
+
</member>
|
| 444 |
+
<member>
|
| 445 |
+
<Dimensions>
|
| 446 |
+
<member>
|
| 447 |
+
<Name>VolumeId</Name>
|
| 448 |
+
<Value>vol-a8d2e991</Value>
|
| 449 |
+
</member>
|
| 450 |
+
</Dimensions>
|
| 451 |
+
<MetricName>VolumeQueueLength</MetricName>
|
| 452 |
+
<Namespace>AWS/EBS</Namespace>
|
| 453 |
+
</member>
|
| 454 |
+
<member>
|
| 455 |
+
<Dimensions>
|
| 456 |
+
<member>
|
| 457 |
+
<Name>VolumeId</Name>
|
| 458 |
+
<Value>vol-203b3919</Value>
|
| 459 |
+
</member>
|
| 460 |
+
</Dimensions>
|
| 461 |
+
<MetricName>VolumeIdleTime</MetricName>
|
| 462 |
+
<Namespace>AWS/EBS</Namespace>
|
| 463 |
+
</member>
|
| 464 |
+
<member>
|
| 465 |
+
<Dimensions>
|
| 466 |
+
<member>
|
| 467 |
+
<Name>InstanceId</Name>
|
| 468 |
+
<Value>i-78f1b94a</Value>
|
| 469 |
+
</member>
|
| 470 |
+
</Dimensions>
|
| 471 |
+
<MetricName>StatusCheckFailed</MetricName>
|
| 472 |
+
<Namespace>AWS/EC2</Namespace>
|
| 473 |
+
</member>
|
| 474 |
+
<member>
|
| 475 |
+
<Dimensions>
|
| 476 |
+
<member>
|
| 477 |
+
<Name>InstanceId</Name>
|
| 478 |
+
<Value>i-70d08042</Value>
|
| 479 |
+
</member>
|
| 480 |
+
</Dimensions>
|
| 481 |
+
<MetricName>StatusCheckFailed</MetricName>
|
| 482 |
+
<Namespace>AWS/EC2</Namespace>
|
| 483 |
+
</member>
|
| 484 |
+
<member>
|
| 485 |
+
<Dimensions>
|
| 486 |
+
<member>
|
| 487 |
+
<Name>QueueName</Name>
|
| 488 |
+
<Value>foobar</Value>
|
| 489 |
+
</member>
|
| 490 |
+
</Dimensions>
|
| 491 |
+
<MetricName>NumberOfMessagesSent</MetricName>
|
| 492 |
+
<Namespace>AWS/SQS</Namespace>
|
| 493 |
+
</member>
|
| 494 |
+
<member>
|
| 495 |
+
<Dimensions>
|
| 496 |
+
<member>
|
| 497 |
+
<Name>VolumeId</Name>
|
| 498 |
+
<Value>vol-04c7c53d</Value>
|
| 499 |
+
</member>
|
| 500 |
+
</Dimensions>
|
| 501 |
+
<MetricName>VolumeQueueLength</MetricName>
|
| 502 |
+
<Namespace>AWS/EBS</Namespace>
|
| 503 |
+
</member>
|
| 504 |
+
<member>
|
| 505 |
+
<Dimensions>
|
| 506 |
+
<member>
|
| 507 |
+
<Name>VolumeId</Name>
|
| 508 |
+
<Value>vol-267b761f</Value>
|
| 509 |
+
</member>
|
| 510 |
+
</Dimensions>
|
| 511 |
+
<MetricName>VolumeReadBytes</MetricName>
|
| 512 |
+
<Namespace>AWS/EBS</Namespace>
|
| 513 |
+
</member>
|
| 514 |
+
<member>
|
| 515 |
+
<Dimensions>
|
| 516 |
+
<member>
|
| 517 |
+
<Name>TableName</Name>
|
| 518 |
+
<Value>fromcli</Value>
|
| 519 |
+
</member>
|
| 520 |
+
</Dimensions>
|
| 521 |
+
<MetricName>ProvisionedReadCapacityUnits</MetricName>
|
| 522 |
+
<Namespace>AWS/DynamoDB</Namespace>
|
| 523 |
+
</member>
|
| 524 |
+
<member>
|
| 525 |
+
<Dimensions>
|
| 526 |
+
<member>
|
| 527 |
+
<Name>InstanceId</Name>
|
| 528 |
+
<Value>i-70d08042</Value>
|
| 529 |
+
</member>
|
| 530 |
+
</Dimensions>
|
| 531 |
+
<MetricName>StatusCheckFailed_System</MetricName>
|
| 532 |
+
<Namespace>AWS/EC2</Namespace>
|
| 533 |
+
</member>
|
| 534 |
+
<member>
|
| 535 |
+
<Dimensions>
|
| 536 |
+
<member>
|
| 537 |
+
<Name>QueueName</Name>
|
| 538 |
+
<Value>foobar</Value>
|
| 539 |
+
</member>
|
| 540 |
+
</Dimensions>
|
| 541 |
+
<MetricName>NumberOfMessagesDeleted</MetricName>
|
| 542 |
+
<Namespace>AWS/SQS</Namespace>
|
| 543 |
+
</member>
|
| 544 |
+
<member>
|
| 545 |
+
<Dimensions>
|
| 546 |
+
<member>
|
| 547 |
+
<Name>VolumeId</Name>
|
| 548 |
+
<Value>vol-a8d2e991</Value>
|
| 549 |
+
</member>
|
| 550 |
+
</Dimensions>
|
| 551 |
+
<MetricName>VolumeReadBytes</MetricName>
|
| 552 |
+
<Namespace>AWS/EBS</Namespace>
|
| 553 |
+
</member>
|
| 554 |
+
<member>
|
| 555 |
+
<Dimensions>
|
| 556 |
+
<member>
|
| 557 |
+
<Name>InstanceId</Name>
|
| 558 |
+
<Value>i-20277712</Value>
|
| 559 |
+
</member>
|
| 560 |
+
</Dimensions>
|
| 561 |
+
<MetricName>DiskWriteOps</MetricName>
|
| 562 |
+
<Namespace>AWS/EC2</Namespace>
|
| 563 |
+
</member>
|
| 564 |
+
<member>
|
| 565 |
+
<Dimensions>
|
| 566 |
+
<member>
|
| 567 |
+
<Name>InstanceId</Name>
|
| 568 |
+
<Value>i-20277712</Value>
|
| 569 |
+
</member>
|
| 570 |
+
</Dimensions>
|
| 571 |
+
<MetricName>NetworkOut</MetricName>
|
| 572 |
+
<Namespace>AWS/EC2</Namespace>
|
| 573 |
+
</member>
|
| 574 |
+
<member>
|
| 575 |
+
<Dimensions>
|
| 576 |
+
<member>
|
| 577 |
+
<Name>InstanceId</Name>
|
| 578 |
+
<Value>i-20277712</Value>
|
| 579 |
+
</member>
|
| 580 |
+
</Dimensions>
|
| 581 |
+
<MetricName>DiskReadOps</MetricName>
|
| 582 |
+
<Namespace>AWS/EC2</Namespace>
|
| 583 |
+
</member>
|
| 584 |
+
<member>
|
| 585 |
+
<Dimensions>
|
| 586 |
+
<member>
|
| 587 |
+
<Name>InstanceId</Name>
|
| 588 |
+
<Value>i-20277712</Value>
|
| 589 |
+
</member>
|
| 590 |
+
</Dimensions>
|
| 591 |
+
<MetricName>StatusCheckFailed_System</MetricName>
|
| 592 |
+
<Namespace>AWS/EC2</Namespace>
|
| 593 |
+
</member>
|
| 594 |
+
<member>
|
| 595 |
+
<Dimensions>
|
| 596 |
+
<member>
|
| 597 |
+
<Name>InstanceId</Name>
|
| 598 |
+
<Value>i-d63c6ce4</Value>
|
| 599 |
+
</member>
|
| 600 |
+
</Dimensions>
|
| 601 |
+
<MetricName>NetworkOut</MetricName>
|
| 602 |
+
<Namespace>AWS/EC2</Namespace>
|
| 603 |
+
</member>
|
| 604 |
+
<member>
|
| 605 |
+
<Dimensions>
|
| 606 |
+
<member>
|
| 607 |
+
<Name>InstanceId</Name>
|
| 608 |
+
<Value>i-20277712</Value>
|
| 609 |
+
</member>
|
| 610 |
+
</Dimensions>
|
| 611 |
+
<MetricName>NetworkIn</MetricName>
|
| 612 |
+
<Namespace>AWS/EC2</Namespace>
|
| 613 |
+
</member>
|
| 614 |
+
<member>
|
| 615 |
+
<Dimensions>
|
| 616 |
+
<member>
|
| 617 |
+
<Name>VolumeId</Name>
|
| 618 |
+
<Value>vol-203b3919</Value>
|
| 619 |
+
</member>
|
| 620 |
+
</Dimensions>
|
| 621 |
+
<MetricName>VolumeWriteBytes</MetricName>
|
| 622 |
+
<Namespace>AWS/EBS</Namespace>
|
| 623 |
+
</member>
|
| 624 |
+
<member>
|
| 625 |
+
<Dimensions>
|
| 626 |
+
<member>
|
| 627 |
+
<Name>InstanceId</Name>
|
| 628 |
+
<Value>i-70d08042</Value>
|
| 629 |
+
</member>
|
| 630 |
+
</Dimensions>
|
| 631 |
+
<MetricName>DiskWriteBytes</MetricName>
|
| 632 |
+
<Namespace>AWS/EC2</Namespace>
|
| 633 |
+
</member>
|
| 634 |
+
<member>
|
| 635 |
+
<Dimensions>
|
| 636 |
+
<member>
|
| 637 |
+
<Name>QueueName</Name>
|
| 638 |
+
<Value>foobar</Value>
|
| 639 |
+
</member>
|
| 640 |
+
</Dimensions>
|
| 641 |
+
<MetricName>NumberOfMessagesReceived</MetricName>
|
| 642 |
+
<Namespace>AWS/SQS</Namespace>
|
| 643 |
+
</member>
|
| 644 |
+
<member>
|
| 645 |
+
<Dimensions>
|
| 646 |
+
<member>
|
| 647 |
+
<Name>VolumeId</Name>
|
| 648 |
+
<Value>vol-203b3919</Value>
|
| 649 |
+
</member>
|
| 650 |
+
</Dimensions>
|
| 651 |
+
<MetricName>VolumeReadOps</MetricName>
|
| 652 |
+
<Namespace>AWS/EBS</Namespace>
|
| 653 |
+
</member>
|
| 654 |
+
<member>
|
| 655 |
+
<Dimensions>
|
| 656 |
+
<member>
|
| 657 |
+
<Name>VolumeId</Name>
|
| 658 |
+
<Value>vol-203b3919</Value>
|
| 659 |
+
</member>
|
| 660 |
+
</Dimensions>
|
| 661 |
+
<MetricName>VolumeTotalReadTime</MetricName>
|
| 662 |
+
<Namespace>AWS/EBS</Namespace>
|
| 663 |
+
</member>
|
| 664 |
+
<member>
|
| 665 |
+
<Dimensions>
|
| 666 |
+
<member>
|
| 667 |
+
<Name>InstanceId</Name>
|
| 668 |
+
<Value>i-70d08042</Value>
|
| 669 |
+
</member>
|
| 670 |
+
</Dimensions>
|
| 671 |
+
<MetricName>DiskWriteOps</MetricName>
|
| 672 |
+
<Namespace>AWS/EC2</Namespace>
|
| 673 |
+
</member>
|
| 674 |
+
<member>
|
| 675 |
+
<Dimensions>
|
| 676 |
+
<member>
|
| 677 |
+
<Name>TableName</Name>
|
| 678 |
+
<Value>fromcli</Value>
|
| 679 |
+
</member>
|
| 680 |
+
</Dimensions>
|
| 681 |
+
<MetricName>ProvisionedWriteCapacityUnits</MetricName>
|
| 682 |
+
<Namespace>AWS/DynamoDB</Namespace>
|
| 683 |
+
</member>
|
| 684 |
+
<member>
|
| 685 |
+
<Dimensions>
|
| 686 |
+
<member>
|
| 687 |
+
<Name>VolumeId</Name>
|
| 688 |
+
<Value>vol-04c7c53d</Value>
|
| 689 |
+
</member>
|
| 690 |
+
</Dimensions>
|
| 691 |
+
<MetricName>VolumeTotalWriteTime</MetricName>
|
| 692 |
+
<Namespace>AWS/EBS</Namespace>
|
| 693 |
+
</member>
|
| 694 |
+
<member>
|
| 695 |
+
<Dimensions>
|
| 696 |
+
<member>
|
| 697 |
+
<Name>VolumeId</Name>
|
| 698 |
+
<Value>vol-a8d2e991</Value>
|
| 699 |
+
</member>
|
| 700 |
+
</Dimensions>
|
| 701 |
+
<MetricName>VolumeTotalReadTime</MetricName>
|
| 702 |
+
<Namespace>AWS/EBS</Namespace>
|
| 703 |
+
</member>
|
| 704 |
+
<member>
|
| 705 |
+
<Dimensions>
|
| 706 |
+
<member>
|
| 707 |
+
<Name>VolumeId</Name>
|
| 708 |
+
<Value>vol-04c7c53d</Value>
|
| 709 |
+
</member>
|
| 710 |
+
</Dimensions>
|
| 711 |
+
<MetricName>VolumeWriteBytes</MetricName>
|
| 712 |
+
<Namespace>AWS/EBS</Namespace>
|
| 713 |
+
</member>
|
| 714 |
+
<member>
|
| 715 |
+
<Dimensions>
|
| 716 |
+
<member>
|
| 717 |
+
<Name>InstanceId</Name>
|
| 718 |
+
<Value>i-78f1b94a</Value>
|
| 719 |
+
</member>
|
| 720 |
+
</Dimensions>
|
| 721 |
+
<MetricName>DiskReadBytes</MetricName>
|
| 722 |
+
<Namespace>AWS/EC2</Namespace>
|
| 723 |
+
</member>
|
| 724 |
+
<member>
|
| 725 |
+
<Dimensions>
|
| 726 |
+
<member>
|
| 727 |
+
<Name>InstanceId</Name>
|
| 728 |
+
<Value>i-d63c6ce4</Value>
|
| 729 |
+
</member>
|
| 730 |
+
</Dimensions>
|
| 731 |
+
<MetricName>DiskWriteBytes</MetricName>
|
| 732 |
+
<Namespace>AWS/EC2</Namespace>
|
| 733 |
+
</member>
|
| 734 |
+
<member>
|
| 735 |
+
<Dimensions>
|
| 736 |
+
<member>
|
| 737 |
+
<Name>InstanceId</Name>
|
| 738 |
+
<Value>i-20277712</Value>
|
| 739 |
+
</member>
|
| 740 |
+
</Dimensions>
|
| 741 |
+
<MetricName>StatusCheckFailed</MetricName>
|
| 742 |
+
<Namespace>AWS/EC2</Namespace>
|
| 743 |
+
</member>
|
| 744 |
+
<member>
|
| 745 |
+
<Dimensions>
|
| 746 |
+
<member>
|
| 747 |
+
<Name>InstanceId</Name>
|
| 748 |
+
<Value>i-d63c6ce4</Value>
|
| 749 |
+
</member>
|
| 750 |
+
</Dimensions>
|
| 751 |
+
<MetricName>StatusCheckFailed_Instance</MetricName>
|
| 752 |
+
<Namespace>AWS/EC2</Namespace>
|
| 753 |
+
</member>
|
| 754 |
+
<member>
|
| 755 |
+
<Dimensions>
|
| 756 |
+
<member>
|
| 757 |
+
<Name>InstanceId</Name>
|
| 758 |
+
<Value>i-70d08042</Value>
|
| 759 |
+
</member>
|
| 760 |
+
</Dimensions>
|
| 761 |
+
<MetricName>NetworkIn</MetricName>
|
| 762 |
+
<Namespace>AWS/EC2</Namespace>
|
| 763 |
+
</member>
|
| 764 |
+
<member>
|
| 765 |
+
<Dimensions>
|
| 766 |
+
<member>
|
| 767 |
+
<Name>InstanceId</Name>
|
| 768 |
+
<Value>i-78f1b94a</Value>
|
| 769 |
+
</member>
|
| 770 |
+
</Dimensions>
|
| 771 |
+
<MetricName>NetworkIn</MetricName>
|
| 772 |
+
<Namespace>AWS/EC2</Namespace>
|
| 773 |
+
</member>
|
| 774 |
+
<member>
|
| 775 |
+
<Dimensions>
|
| 776 |
+
<member>
|
| 777 |
+
<Name>InstanceId</Name>
|
| 778 |
+
<Value>i-70d08042</Value>
|
| 779 |
+
</member>
|
| 780 |
+
</Dimensions>
|
| 781 |
+
<MetricName>DiskReadOps</MetricName>
|
| 782 |
+
<Namespace>AWS/EC2</Namespace>
|
| 783 |
+
</member>
|
| 784 |
+
<member>
|
| 785 |
+
<Dimensions>
|
| 786 |
+
<member>
|
| 787 |
+
<Name>InstanceId</Name>
|
| 788 |
+
<Value>i-d63c6ce4</Value>
|
| 789 |
+
</member>
|
| 790 |
+
</Dimensions>
|
| 791 |
+
<MetricName>NetworkIn</MetricName>
|
| 792 |
+
<Namespace>AWS/EC2</Namespace>
|
| 793 |
+
</member>
|
| 794 |
+
<member>
|
| 795 |
+
<Dimensions>
|
| 796 |
+
<member>
|
| 797 |
+
<Name>InstanceId</Name>
|
| 798 |
+
<Value>i-78f1b94a</Value>
|
| 799 |
+
</member>
|
| 800 |
+
</Dimensions>
|
| 801 |
+
<MetricName>StatusCheckFailed_System</MetricName>
|
| 802 |
+
<Namespace>AWS/EC2</Namespace>
|
| 803 |
+
</member>
|
| 804 |
+
<member>
|
| 805 |
+
<Dimensions>
|
| 806 |
+
<member>
|
| 807 |
+
<Name>InstanceId</Name>
|
| 808 |
+
<Value>i-78f1b94a</Value>
|
| 809 |
+
</member>
|
| 810 |
+
</Dimensions>
|
| 811 |
+
<MetricName>DiskWriteBytes</MetricName>
|
| 812 |
+
<Namespace>AWS/EC2</Namespace>
|
| 813 |
+
</member>
|
| 814 |
+
</Metrics>
|
| 815 |
+
</ListMetricsResult>
|
| 816 |
+
<ResponseMetadata>
|
| 817 |
+
<RequestId>abea8add-9167-11e2-91d1-9b4c7751b290</RequestId>
|
| 818 |
+
</ResponseMetadata>
|
| 819 |
+
</ListMetricsResponse>
|
testbed/boto__botocore/tests/unit/response_parsing/xml/responses/sqs-change-message-visibility-batch.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"Successful": [
|
| 3 |
+
{
|
| 4 |
+
"Id": "change_visibility_msg_2"
|
| 5 |
+
},
|
| 6 |
+
{
|
| 7 |
+
"Id": "change_visibility_msg_3"
|
| 8 |
+
}
|
| 9 |
+
],
|
| 10 |
+
"ResponseMetadata": {
|
| 11 |
+
"RequestId": "ca9668f7-ab1b-4f7a-8859-f15747ab17a7"
|
| 12 |
+
}
|
| 13 |
+
}
|
testbed/boto__botocore/tests/unit/response_parsing/xml/responses/sqs-list-queues.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"QueueUrls": [
|
| 3 |
+
"https://us-west-2.queue.amazonaws.com/123456789012/foobar",
|
| 4 |
+
"https://us-west-2.queue.amazonaws.com/123456789012/fiebaz"
|
| 5 |
+
],
|
| 6 |
+
"ResponseMetadata": {
|
| 7 |
+
"RequestId": "517c6371-751f-5711-9ebc-2ab2b1a92268"
|
| 8 |
+
}
|
| 9 |
+
}
|
testbed/boto__botocore/tests/unit/response_parsing/xml/responses/sts-get-session-token.xml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<GetSessionTokenResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
|
| 2 |
+
<GetSessionTokenResult>
|
| 3 |
+
<Credentials>
|
| 4 |
+
<SessionToken>AQoEXAMPLEH4aoAH0gNCAPyJxz4BlCFFxWNE1OPTgk5TthT+FvwqnKwRcOIfrRh3c/L
|
| 5 |
+
To6UDdyJwOOvEVPvLXCrrrUtdnniCEXAMPLE/IvU1dYUg2RVAJBanLiHb4IgRmpRV3z
|
| 6 |
+
rkuWJOgQs8IZZaIv2BXIa2R4OlgkBN9bkUDNCJiBeb/AXlzBBko7b15fjrBs2+cTQtp
|
| 7 |
+
Z3CYWFXG8C5zqx37wnOE49mRl/+OtkIKGO7fAE</SessionToken>
|
| 8 |
+
<SecretAccessKey>wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY</SecretAccessKey>
|
| 9 |
+
<Expiration>2011-07-11T19:55:29.611Z</Expiration>
|
| 10 |
+
<AccessKeyId>AKIAIOSFODNN7EXAMPLE</AccessKeyId>
|
| 11 |
+
</Credentials>
|
| 12 |
+
</GetSessionTokenResult>
|
| 13 |
+
<ResponseMetadata>
|
| 14 |
+
<RequestId>58c5dbae-abef-11e0-8cfe-09039844ac7d</RequestId>
|
| 15 |
+
</ResponseMetadata>
|
| 16 |
+
</GetSessionTokenResponse>
|
testbed/boto__botocore/tests/unit/retries/__init__.py
ADDED
|
File without changes
|
testbed/boto__botocore/tests/unit/retries/test_adaptive.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from botocore.retries import adaptive, bucket, standard, throttling
|
| 2 |
+
from tests import mock, unittest
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class FakeClock(bucket.Clock):
|
| 6 |
+
def __init__(self, timestamp_sequences):
|
| 7 |
+
self.timestamp_sequences = timestamp_sequences
|
| 8 |
+
self.sleep_call_amounts = []
|
| 9 |
+
|
| 10 |
+
def sleep(self, amount):
|
| 11 |
+
self.sleep_call_amounts.append(amount)
|
| 12 |
+
|
| 13 |
+
def current_time(self):
|
| 14 |
+
return self.timestamp_sequences.pop(0)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class TestCanCreateRetryHandler(unittest.TestCase):
|
| 18 |
+
def test_can_register_retry_handler(self):
|
| 19 |
+
client = mock.Mock()
|
| 20 |
+
limiter = adaptive.register_retry_handler(client)
|
| 21 |
+
self.assertEqual(
|
| 22 |
+
client.meta.events.register.call_args_list,
|
| 23 |
+
[
|
| 24 |
+
mock.call('before-send', limiter.on_sending_request),
|
| 25 |
+
mock.call('needs-retry', limiter.on_receiving_response),
|
| 26 |
+
],
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class TestClientRateLimiter(unittest.TestCase):
|
| 31 |
+
def setUp(self):
|
| 32 |
+
self.timestamp_sequences = [0]
|
| 33 |
+
self.clock = FakeClock(self.timestamp_sequences)
|
| 34 |
+
self.token_bucket = mock.Mock(spec=bucket.TokenBucket)
|
| 35 |
+
self.rate_adjustor = mock.Mock(spec=throttling.CubicCalculator)
|
| 36 |
+
self.rate_clocker = mock.Mock(spec=adaptive.RateClocker)
|
| 37 |
+
self.throttling_detector = mock.Mock(
|
| 38 |
+
spec=standard.ThrottlingErrorDetector
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
def create_client_limiter(self):
|
| 42 |
+
rate_limiter = adaptive.ClientRateLimiter(
|
| 43 |
+
rate_adjustor=self.rate_adjustor,
|
| 44 |
+
rate_clocker=self.rate_clocker,
|
| 45 |
+
token_bucket=self.token_bucket,
|
| 46 |
+
throttling_detector=self.throttling_detector,
|
| 47 |
+
clock=self.clock,
|
| 48 |
+
)
|
| 49 |
+
return rate_limiter
|
| 50 |
+
|
| 51 |
+
def test_bucket_bucket_acquisition_only_if_enabled(self):
|
| 52 |
+
rate_limiter = self.create_client_limiter()
|
| 53 |
+
rate_limiter.on_sending_request(request=mock.sentinel.request)
|
| 54 |
+
self.assertFalse(self.token_bucket.acquire.called)
|
| 55 |
+
|
| 56 |
+
def test_token_bucket_enabled_on_throttling_error(self):
|
| 57 |
+
rate_limiter = self.create_client_limiter()
|
| 58 |
+
self.throttling_detector.is_throttling_error.return_value = True
|
| 59 |
+
self.rate_clocker.record.return_value = 21
|
| 60 |
+
self.rate_adjustor.error_received.return_value = 17
|
| 61 |
+
rate_limiter.on_receiving_response()
|
| 62 |
+
# Now if we call on_receiving_response we should try to acquire
|
| 63 |
+
# token.
|
| 64 |
+
self.timestamp_sequences.append(1)
|
| 65 |
+
rate_limiter.on_sending_request(request=mock.sentinel.request)
|
| 66 |
+
self.assertTrue(self.token_bucket.acquire.called)
|
| 67 |
+
|
| 68 |
+
def test_max_rate_updated_on_success_response(self):
|
| 69 |
+
rate_limiter = self.create_client_limiter()
|
| 70 |
+
self.throttling_detector.is_throttling_error.return_value = False
|
| 71 |
+
self.rate_adjustor.success_received.return_value = 20
|
| 72 |
+
self.rate_clocker.record.return_value = 21
|
| 73 |
+
rate_limiter.on_receiving_response()
|
| 74 |
+
self.assertEqual(self.token_bucket.max_rate, 20)
|
| 75 |
+
|
| 76 |
+
def test_max_rate_cant_exceed_20_percent_max(self):
|
| 77 |
+
rate_limiter = self.create_client_limiter()
|
| 78 |
+
self.throttling_detector.is_throttling_error.return_value = False
|
| 79 |
+
# So if our actual measured sending rate is 20 TPS
|
| 80 |
+
self.rate_clocker.record.return_value = 20
|
| 81 |
+
# But the rate adjustor is telling us to go up to 100 TPS
|
| 82 |
+
self.rate_adjustor.success_received.return_value = 100
|
| 83 |
+
|
| 84 |
+
# The most we should go up is 2.0 * 20
|
| 85 |
+
rate_limiter.on_receiving_response()
|
| 86 |
+
self.assertEqual(self.token_bucket.max_rate, 2.0 * 20)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
class TestRateClocker(unittest.TestCase):
|
| 90 |
+
def setUp(self):
|
| 91 |
+
self.timestamp_sequences = [0]
|
| 92 |
+
self.clock = FakeClock(self.timestamp_sequences)
|
| 93 |
+
self.rate_measure = adaptive.RateClocker(self.clock)
|
| 94 |
+
self.smoothing = 0.8
|
| 95 |
+
|
| 96 |
+
def test_initial_rate_is_0(self):
|
| 97 |
+
self.assertEqual(self.rate_measure.measured_rate, 0)
|
| 98 |
+
|
| 99 |
+
def test_time_updates_if_after_bucket_range(self):
|
| 100 |
+
self.timestamp_sequences.append(1)
|
| 101 |
+
# This should be 1 * 0.8 + 0 * 0.2, or just 0.8
|
| 102 |
+
self.assertEqual(self.rate_measure.record(), 0.8)
|
| 103 |
+
|
| 104 |
+
def test_can_measure_constant_rate(self):
|
| 105 |
+
# Timestamps of 1 every second indicate a rate of 1 TPS.
|
| 106 |
+
self.timestamp_sequences.extend(range(1, 21))
|
| 107 |
+
for _ in range(20):
|
| 108 |
+
self.rate_measure.record()
|
| 109 |
+
self.assertAlmostEqual(self.rate_measure.measured_rate, 1)
|
| 110 |
+
|
| 111 |
+
def test_uses_smoothing_to_favor_recent_weights(self):
|
| 112 |
+
self.timestamp_sequences.extend(
|
| 113 |
+
[
|
| 114 |
+
1,
|
| 115 |
+
1.5,
|
| 116 |
+
2,
|
| 117 |
+
2.5,
|
| 118 |
+
3,
|
| 119 |
+
3.5,
|
| 120 |
+
4,
|
| 121 |
+
# If we now wait 10 seconds (.1 TPS),
|
| 122 |
+
# our rate is somewhere between 2 TPS and .1 TPS.
|
| 123 |
+
14,
|
| 124 |
+
]
|
| 125 |
+
)
|
| 126 |
+
for _ in range(7):
|
| 127 |
+
self.rate_measure.record()
|
| 128 |
+
# We should almost be at 2.0 but not quite.
|
| 129 |
+
self.assertGreaterEqual(self.rate_measure.measured_rate, 1.99)
|
| 130 |
+
self.assertLessEqual(self.rate_measure.measured_rate, 2.0)
|
| 131 |
+
# With our last recording we now drop down between 0.1 and 2
|
| 132 |
+
# depending on our smoothing factor.
|
| 133 |
+
self.rate_measure.record()
|
| 134 |
+
self.assertGreaterEqual(self.rate_measure.measured_rate, 0.1)
|
| 135 |
+
self.assertLessEqual(self.rate_measure.measured_rate, 2.0)
|
| 136 |
+
|
| 137 |
+
def test_noop_when_delta_t_is_0(self):
|
| 138 |
+
self.timestamp_sequences.extend([1, 1, 1, 2, 3])
|
| 139 |
+
for _ in range(5):
|
| 140 |
+
self.rate_measure.record()
|
| 141 |
+
self.assertGreaterEqual(self.rate_measure.measured_rate, 1.0)
|
| 142 |
+
|
| 143 |
+
def test_times_are_grouped_per_time_bucket(self):
|
| 144 |
+
# Using our default of 0.5 time buckets, we have:
|
| 145 |
+
self.timestamp_sequences.extend(
|
| 146 |
+
[
|
| 147 |
+
0.1,
|
| 148 |
+
0.2,
|
| 149 |
+
0.3,
|
| 150 |
+
0.4,
|
| 151 |
+
0.49,
|
| 152 |
+
]
|
| 153 |
+
)
|
| 154 |
+
for _ in range(len(self.timestamp_sequences)):
|
| 155 |
+
self.rate_measure.record()
|
| 156 |
+
# This is showing the tradeoff we're making with measuring rates.
|
| 157 |
+
# we're currently in the window from 0 <= x < 0.5, which means
|
| 158 |
+
# we use the rate from the previous bucket, which is 0:
|
| 159 |
+
self.assertEqual(self.rate_measure.measured_rate, 0)
|
| 160 |
+
# However if we now add a new measurement that's in the next
|
| 161 |
+
# time bucket 0.5 <= x < 1.0
|
| 162 |
+
# we'll use the range from the previous bucket:
|
| 163 |
+
self.timestamp_sequences.append(0.5)
|
| 164 |
+
self.rate_measure.record()
|
| 165 |
+
# And our previous bucket will be:
|
| 166 |
+
# 12 * 0.8 + 0.2 * 0
|
| 167 |
+
self.assertEqual(self.rate_measure.measured_rate, 12 * 0.8)
|
testbed/boto__botocore/tests/unit/retries/test_special.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from botocore.awsrequest import AWSResponse
|
| 2 |
+
from botocore.retries import special, standard
|
| 3 |
+
from tests import mock, unittest
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def create_fake_op_model(service_name):
|
| 7 |
+
model = mock.Mock()
|
| 8 |
+
model.service_model.service_name = service_name
|
| 9 |
+
return model
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class TestRetryIDPCommunicationError(unittest.TestCase):
|
| 13 |
+
def setUp(self):
|
| 14 |
+
self.checker = special.RetryIDPCommunicationError()
|
| 15 |
+
|
| 16 |
+
def test_only_retries_error_for_sts(self):
|
| 17 |
+
context = standard.RetryContext(
|
| 18 |
+
attempt_number=1,
|
| 19 |
+
operation_model=create_fake_op_model('s3'),
|
| 20 |
+
parsed_response={
|
| 21 |
+
'Error': {
|
| 22 |
+
'Code': 'IDPCommunicationError',
|
| 23 |
+
'Message': 'message',
|
| 24 |
+
}
|
| 25 |
+
},
|
| 26 |
+
http_response=AWSResponse(
|
| 27 |
+
status_code=400, raw=None, headers={}, url='https://foo'
|
| 28 |
+
),
|
| 29 |
+
caught_exception=None,
|
| 30 |
+
)
|
| 31 |
+
self.assertFalse(self.checker.is_retryable(context))
|
| 32 |
+
|
| 33 |
+
def test_can_retry_idp_communication_error(self):
|
| 34 |
+
context = standard.RetryContext(
|
| 35 |
+
attempt_number=1,
|
| 36 |
+
operation_model=create_fake_op_model('sts'),
|
| 37 |
+
parsed_response={
|
| 38 |
+
'Error': {
|
| 39 |
+
'Code': 'IDPCommunicationError',
|
| 40 |
+
'Message': 'message',
|
| 41 |
+
}
|
| 42 |
+
},
|
| 43 |
+
http_response=AWSResponse(
|
| 44 |
+
status_code=400, raw=None, headers={}, url='https://foo'
|
| 45 |
+
),
|
| 46 |
+
caught_exception=None,
|
| 47 |
+
)
|
| 48 |
+
self.assertTrue(self.checker.is_retryable(context))
|
| 49 |
+
|
| 50 |
+
def test_not_idp_communication_error(self):
|
| 51 |
+
context = standard.RetryContext(
|
| 52 |
+
attempt_number=1,
|
| 53 |
+
operation_model=create_fake_op_model('sts'),
|
| 54 |
+
parsed_response={
|
| 55 |
+
'Error': {
|
| 56 |
+
'Code': 'NotIDPCommunicationError',
|
| 57 |
+
'Message': 'message',
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
http_response=AWSResponse(
|
| 61 |
+
status_code=400, raw=None, headers={}, url='https://foo'
|
| 62 |
+
),
|
| 63 |
+
caught_exception=None,
|
| 64 |
+
)
|
| 65 |
+
self.assertFalse(self.checker.is_retryable(context))
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
class TestRetryDDBChecksumError(unittest.TestCase):
|
| 69 |
+
def setUp(self):
|
| 70 |
+
self.checker = special.RetryDDBChecksumError()
|
| 71 |
+
|
| 72 |
+
def raw_stream(self, contents):
|
| 73 |
+
raw = mock.Mock()
|
| 74 |
+
raw.stream.return_value = [contents]
|
| 75 |
+
return raw
|
| 76 |
+
|
| 77 |
+
def test_checksum_not_in_header(self):
|
| 78 |
+
context = standard.RetryContext(
|
| 79 |
+
attempt_number=1,
|
| 80 |
+
operation_model=create_fake_op_model('dynamodb'),
|
| 81 |
+
parsed_response={
|
| 82 |
+
'Anything': ["foo"],
|
| 83 |
+
},
|
| 84 |
+
http_response=AWSResponse(
|
| 85 |
+
status_code=200,
|
| 86 |
+
raw=self.raw_stream(b'foo'),
|
| 87 |
+
headers={},
|
| 88 |
+
url='https://foo',
|
| 89 |
+
),
|
| 90 |
+
caught_exception=None,
|
| 91 |
+
)
|
| 92 |
+
self.assertFalse(self.checker.is_retryable(context))
|
| 93 |
+
|
| 94 |
+
def test_checksum_matches(self):
|
| 95 |
+
context = standard.RetryContext(
|
| 96 |
+
attempt_number=1,
|
| 97 |
+
operation_model=create_fake_op_model('dynamodb'),
|
| 98 |
+
parsed_response={
|
| 99 |
+
'Anything': ["foo"],
|
| 100 |
+
},
|
| 101 |
+
http_response=AWSResponse(
|
| 102 |
+
status_code=200,
|
| 103 |
+
raw=self.raw_stream(b'foo'),
|
| 104 |
+
headers={'x-amz-crc32': '2356372769'},
|
| 105 |
+
url='https://foo',
|
| 106 |
+
),
|
| 107 |
+
caught_exception=None,
|
| 108 |
+
)
|
| 109 |
+
self.assertFalse(self.checker.is_retryable(context))
|
| 110 |
+
|
| 111 |
+
def test_checksum_not_matches(self):
|
| 112 |
+
context = standard.RetryContext(
|
| 113 |
+
attempt_number=1,
|
| 114 |
+
operation_model=create_fake_op_model('dynamodb'),
|
| 115 |
+
parsed_response={
|
| 116 |
+
'Anything': ["foo"],
|
| 117 |
+
},
|
| 118 |
+
http_response=AWSResponse(
|
| 119 |
+
status_code=200,
|
| 120 |
+
raw=self.raw_stream(b'foo'),
|
| 121 |
+
headers={'x-amz-crc32': '2356372768'},
|
| 122 |
+
url='https://foo',
|
| 123 |
+
),
|
| 124 |
+
caught_exception=None,
|
| 125 |
+
)
|
| 126 |
+
self.assertTrue(self.checker.is_retryable(context))
|
| 127 |
+
|
| 128 |
+
def test_checksum_check_only_for_dynamodb(self):
|
| 129 |
+
context = standard.RetryContext(
|
| 130 |
+
attempt_number=1,
|
| 131 |
+
operation_model=create_fake_op_model('s3'),
|
| 132 |
+
parsed_response={
|
| 133 |
+
'Anything': ["foo"],
|
| 134 |
+
},
|
| 135 |
+
http_response=AWSResponse(
|
| 136 |
+
status_code=200,
|
| 137 |
+
raw=self.raw_stream(b'foo'),
|
| 138 |
+
headers={'x-amz-crc32': '2356372768'},
|
| 139 |
+
url='https://foo',
|
| 140 |
+
),
|
| 141 |
+
caught_exception=None,
|
| 142 |
+
)
|
| 143 |
+
self.assertFalse(self.checker.is_retryable(context))
|
testbed/boto__botocore/tests/unit/test_args.py
ADDED
|
@@ -0,0 +1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.com, Inc. or its affiliates. All Rights Reserved.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 5 |
+
# may not use this file except in compliance with the License. A copy of
|
| 6 |
+
# the License is located at
|
| 7 |
+
#
|
| 8 |
+
# http://aws.amazon.com/apache2.0/
|
| 9 |
+
#
|
| 10 |
+
# or in the "license" file accompanying this file. This file is
|
| 11 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 12 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 13 |
+
# language governing permissions and limitations under the License.
|
| 14 |
+
import socket
|
| 15 |
+
|
| 16 |
+
from botocore import args, exceptions
|
| 17 |
+
from botocore.client import ClientEndpointBridge
|
| 18 |
+
from botocore.config import Config
|
| 19 |
+
from botocore.configprovider import ConfigValueStore
|
| 20 |
+
from botocore.hooks import HierarchicalEmitter
|
| 21 |
+
from botocore.model import ServiceModel
|
| 22 |
+
from botocore.useragent import UserAgentString
|
| 23 |
+
from tests import mock, unittest
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class TestCreateClientArgs(unittest.TestCase):
|
| 27 |
+
def setUp(self):
|
| 28 |
+
self.event_emitter = mock.Mock(HierarchicalEmitter)
|
| 29 |
+
self.config_store = ConfigValueStore()
|
| 30 |
+
user_agent_creator = UserAgentString(
|
| 31 |
+
platform_name=None,
|
| 32 |
+
platform_version=None,
|
| 33 |
+
platform_machine=None,
|
| 34 |
+
python_version=None,
|
| 35 |
+
python_implementation=None,
|
| 36 |
+
execution_env=None,
|
| 37 |
+
crt_version=None,
|
| 38 |
+
)
|
| 39 |
+
self.args_create = args.ClientArgsCreator(
|
| 40 |
+
event_emitter=self.event_emitter,
|
| 41 |
+
user_agent=None,
|
| 42 |
+
response_parser_factory=None,
|
| 43 |
+
loader=None,
|
| 44 |
+
exceptions_factory=None,
|
| 45 |
+
config_store=self.config_store,
|
| 46 |
+
user_agent_creator=user_agent_creator,
|
| 47 |
+
)
|
| 48 |
+
self.service_name = 'ec2'
|
| 49 |
+
self.region = 'us-west-2'
|
| 50 |
+
self.endpoint_url = 'https://ec2/'
|
| 51 |
+
self.service_model = self._get_service_model()
|
| 52 |
+
self.bridge = mock.Mock(ClientEndpointBridge)
|
| 53 |
+
self._set_endpoint_bridge_resolve()
|
| 54 |
+
self._set_resolver_uses_builtin()
|
| 55 |
+
self.default_socket_options = [
|
| 56 |
+
(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
| 57 |
+
]
|
| 58 |
+
|
| 59 |
+
def _get_service_model(self, service_name=None):
|
| 60 |
+
if service_name is None:
|
| 61 |
+
service_name = self.service_name
|
| 62 |
+
service_model = mock.Mock(ServiceModel)
|
| 63 |
+
service_model.service_name = service_name
|
| 64 |
+
service_model.endpoint_prefix = service_name
|
| 65 |
+
service_model.metadata = {
|
| 66 |
+
'serviceFullName': 'MyService',
|
| 67 |
+
'protocol': 'query',
|
| 68 |
+
}
|
| 69 |
+
service_model.operation_names = []
|
| 70 |
+
return service_model
|
| 71 |
+
|
| 72 |
+
def _set_endpoint_bridge_resolve(self, **override_kwargs):
|
| 73 |
+
ret_val = {
|
| 74 |
+
'region_name': self.region,
|
| 75 |
+
'signature_version': 'v4',
|
| 76 |
+
'endpoint_url': self.endpoint_url,
|
| 77 |
+
'signing_name': self.service_name,
|
| 78 |
+
'signing_region': self.region,
|
| 79 |
+
'metadata': {},
|
| 80 |
+
}
|
| 81 |
+
ret_val.update(**override_kwargs)
|
| 82 |
+
self.bridge.resolve.return_value = ret_val
|
| 83 |
+
|
| 84 |
+
def _set_resolver_uses_builtin(self, uses_builtin=True):
|
| 85 |
+
self.bridge.resolver_uses_builtin_data.return_value = uses_builtin
|
| 86 |
+
|
| 87 |
+
def call_get_client_args(self, **override_kwargs):
|
| 88 |
+
call_kwargs = {
|
| 89 |
+
'service_model': self.service_model,
|
| 90 |
+
'region_name': self.region,
|
| 91 |
+
'is_secure': True,
|
| 92 |
+
'endpoint_url': self.endpoint_url,
|
| 93 |
+
'verify': True,
|
| 94 |
+
'credentials': None,
|
| 95 |
+
'scoped_config': {},
|
| 96 |
+
'client_config': None,
|
| 97 |
+
'endpoint_bridge': self.bridge,
|
| 98 |
+
'endpoints_ruleset_data': {
|
| 99 |
+
'version': '1.0',
|
| 100 |
+
'parameters': {},
|
| 101 |
+
'rules': [],
|
| 102 |
+
},
|
| 103 |
+
'partition_data': {},
|
| 104 |
+
}
|
| 105 |
+
call_kwargs.update(**override_kwargs)
|
| 106 |
+
return self.args_create.get_client_args(**call_kwargs)
|
| 107 |
+
|
| 108 |
+
def assert_create_endpoint_call(self, mock_endpoint, **override_kwargs):
|
| 109 |
+
call_kwargs = {
|
| 110 |
+
'endpoint_url': self.endpoint_url,
|
| 111 |
+
'region_name': self.region,
|
| 112 |
+
'response_parser_factory': None,
|
| 113 |
+
'timeout': (60, 60),
|
| 114 |
+
'verify': True,
|
| 115 |
+
'max_pool_connections': 10,
|
| 116 |
+
'proxies': None,
|
| 117 |
+
'proxies_config': None,
|
| 118 |
+
'socket_options': self.default_socket_options,
|
| 119 |
+
'client_cert': None,
|
| 120 |
+
}
|
| 121 |
+
call_kwargs.update(**override_kwargs)
|
| 122 |
+
mock_endpoint.return_value.create_endpoint.assert_called_with(
|
| 123 |
+
self.service_model, **call_kwargs
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
def test_compute_s3_configuration(self):
|
| 127 |
+
self.assertIsNone(self.args_create.compute_s3_config(None))
|
| 128 |
+
|
| 129 |
+
def test_compute_s3_config_only_config_store(self):
|
| 130 |
+
self.config_store.set_config_variable(
|
| 131 |
+
's3', {'use_accelerate_endpoint': True}
|
| 132 |
+
)
|
| 133 |
+
self.assertEqual(
|
| 134 |
+
self.args_create.compute_s3_config(None),
|
| 135 |
+
{'use_accelerate_endpoint': True},
|
| 136 |
+
)
|
| 137 |
+
|
| 138 |
+
def test_client_s3_accelerate_from_client_config(self):
|
| 139 |
+
self.assertEqual(
|
| 140 |
+
self.args_create.compute_s3_config(
|
| 141 |
+
client_config=Config(s3={'use_accelerate_endpoint': True})
|
| 142 |
+
),
|
| 143 |
+
{'use_accelerate_endpoint': True},
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
def test_client_s3_accelerate_client_config_overrides_config_store(self):
|
| 147 |
+
self.config_store.set_config_variable(
|
| 148 |
+
's3', {'use_accelerate_endpoint': False}
|
| 149 |
+
)
|
| 150 |
+
self.assertEqual(
|
| 151 |
+
self.args_create.compute_s3_config(
|
| 152 |
+
client_config=Config(s3={'use_accelerate_endpoint': True})
|
| 153 |
+
),
|
| 154 |
+
# client_config beats scoped_config
|
| 155 |
+
{'use_accelerate_endpoint': True},
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
def test_max_pool_from_client_config_forwarded_to_endpoint_creator(self):
|
| 159 |
+
config = Config(max_pool_connections=20)
|
| 160 |
+
with mock.patch('botocore.args.EndpointCreator') as m:
|
| 161 |
+
self.call_get_client_args(client_config=config)
|
| 162 |
+
self.assert_create_endpoint_call(m, max_pool_connections=20)
|
| 163 |
+
|
| 164 |
+
def test_proxies_from_client_config_forwarded_to_endpoint_creator(self):
|
| 165 |
+
proxies = {
|
| 166 |
+
'http': 'http://foo.bar:1234',
|
| 167 |
+
'https': 'https://foo.bar:4321',
|
| 168 |
+
}
|
| 169 |
+
config = Config(proxies=proxies)
|
| 170 |
+
with mock.patch('botocore.args.EndpointCreator') as m:
|
| 171 |
+
self.call_get_client_args(client_config=config)
|
| 172 |
+
self.assert_create_endpoint_call(m, proxies=proxies)
|
| 173 |
+
|
| 174 |
+
def test_s3_with_endpoint_url_still_resolves_region(self):
|
| 175 |
+
self.service_model.endpoint_prefix = 's3'
|
| 176 |
+
self.service_model.metadata = {'protocol': 'rest-xml'}
|
| 177 |
+
self.bridge.resolve.side_effect = [
|
| 178 |
+
{
|
| 179 |
+
'region_name': None,
|
| 180 |
+
'signature_version': 's3v4',
|
| 181 |
+
'endpoint_url': 'http://other.com/',
|
| 182 |
+
'signing_name': 's3',
|
| 183 |
+
'signing_region': None,
|
| 184 |
+
'metadata': {},
|
| 185 |
+
},
|
| 186 |
+
{
|
| 187 |
+
'region_name': 'us-west-2',
|
| 188 |
+
'signature_version': 's3v4',
|
| 189 |
+
'endpoint_url': 'https://s3-us-west-2.amazonaws.com',
|
| 190 |
+
'signing_name': 's3',
|
| 191 |
+
'signing_region': 'us-west-2',
|
| 192 |
+
'metadata': {},
|
| 193 |
+
},
|
| 194 |
+
]
|
| 195 |
+
client_args = self.call_get_client_args(
|
| 196 |
+
endpoint_url='http://other.com/'
|
| 197 |
+
)
|
| 198 |
+
self.assertEqual(client_args['client_config'].region_name, 'us-west-2')
|
| 199 |
+
|
| 200 |
+
def test_region_does_not_resolve_if_not_s3_and_endpoint_url_provided(self):
|
| 201 |
+
self.service_model.endpoint_prefix = 'ec2'
|
| 202 |
+
self.service_model.metadata = {'protocol': 'query'}
|
| 203 |
+
self.bridge.resolve.side_effect = [
|
| 204 |
+
{
|
| 205 |
+
'region_name': None,
|
| 206 |
+
'signature_version': 'v4',
|
| 207 |
+
'endpoint_url': 'http://other.com/',
|
| 208 |
+
'signing_name': 'ec2',
|
| 209 |
+
'signing_region': None,
|
| 210 |
+
'metadata': {},
|
| 211 |
+
}
|
| 212 |
+
]
|
| 213 |
+
client_args = self.call_get_client_args(
|
| 214 |
+
endpoint_url='http://other.com/'
|
| 215 |
+
)
|
| 216 |
+
self.assertEqual(client_args['client_config'].region_name, None)
|
| 217 |
+
|
| 218 |
+
def test_tcp_keepalive_enabled_scoped_config(self):
|
| 219 |
+
scoped_config = {'tcp_keepalive': 'true'}
|
| 220 |
+
with mock.patch('botocore.args.EndpointCreator') as m:
|
| 221 |
+
self.call_get_client_args(scoped_config=scoped_config)
|
| 222 |
+
self.assert_create_endpoint_call(
|
| 223 |
+
m,
|
| 224 |
+
socket_options=self.default_socket_options
|
| 225 |
+
+ [(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)],
|
| 226 |
+
)
|
| 227 |
+
|
| 228 |
+
def test_tcp_keepalive_not_specified(self):
|
| 229 |
+
with mock.patch('botocore.args.EndpointCreator') as m:
|
| 230 |
+
self.call_get_client_args(scoped_config={}, client_config=None)
|
| 231 |
+
self.assert_create_endpoint_call(
|
| 232 |
+
m, socket_options=self.default_socket_options
|
| 233 |
+
)
|
| 234 |
+
self.call_get_client_args(
|
| 235 |
+
scoped_config=None, client_config=Config()
|
| 236 |
+
)
|
| 237 |
+
self.assert_create_endpoint_call(
|
| 238 |
+
m, socket_options=self.default_socket_options
|
| 239 |
+
)
|
| 240 |
+
|
| 241 |
+
def test_tcp_keepalive_enabled_if_set_anywhere(self):
|
| 242 |
+
with mock.patch('botocore.args.EndpointCreator') as m:
|
| 243 |
+
self.call_get_client_args(
|
| 244 |
+
scoped_config={'tcp_keepalive': 'true'},
|
| 245 |
+
client_config=Config(tcp_keepalive=False),
|
| 246 |
+
)
|
| 247 |
+
self.assert_create_endpoint_call(
|
| 248 |
+
m,
|
| 249 |
+
socket_options=self.default_socket_options
|
| 250 |
+
+ [(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)],
|
| 251 |
+
)
|
| 252 |
+
self.call_get_client_args(
|
| 253 |
+
scoped_config={'tcp_keepalive': 'false'},
|
| 254 |
+
client_config=Config(tcp_keepalive=True),
|
| 255 |
+
)
|
| 256 |
+
self.assert_create_endpoint_call(
|
| 257 |
+
m,
|
| 258 |
+
socket_options=self.default_socket_options
|
| 259 |
+
+ [(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)],
|
| 260 |
+
)
|
| 261 |
+
|
| 262 |
+
def test_tcp_keepalive_explicitly_disabled(self):
|
| 263 |
+
scoped_config = {'tcp_keepalive': 'false'}
|
| 264 |
+
with mock.patch('botocore.args.EndpointCreator') as m:
|
| 265 |
+
self.call_get_client_args(scoped_config=scoped_config)
|
| 266 |
+
self.assert_create_endpoint_call(
|
| 267 |
+
m, socket_options=self.default_socket_options
|
| 268 |
+
)
|
| 269 |
+
|
| 270 |
+
def test_tcp_keepalive_enabled_case_insensitive(self):
|
| 271 |
+
scoped_config = {'tcp_keepalive': 'True'}
|
| 272 |
+
with mock.patch('botocore.args.EndpointCreator') as m:
|
| 273 |
+
self.call_get_client_args(scoped_config=scoped_config)
|
| 274 |
+
self.assert_create_endpoint_call(
|
| 275 |
+
m,
|
| 276 |
+
socket_options=self.default_socket_options
|
| 277 |
+
+ [(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)],
|
| 278 |
+
)
|
| 279 |
+
|
| 280 |
+
def test_client_config_has_use_dualstack_endpoint_flag(self):
|
| 281 |
+
self._set_endpoint_bridge_resolve(metadata={'tags': ['dualstack']})
|
| 282 |
+
client_args = self.call_get_client_args(
|
| 283 |
+
service_model=self._get_service_model('ec2'),
|
| 284 |
+
)
|
| 285 |
+
self.assertTrue(client_args['client_config'].use_dualstack_endpoint)
|
| 286 |
+
|
| 287 |
+
def test_client_config_has_use_fips_endpoint_flag(self):
|
| 288 |
+
self._set_endpoint_bridge_resolve(metadata={'tags': ['fips']})
|
| 289 |
+
client_args = self.call_get_client_args(
|
| 290 |
+
service_model=self._get_service_model('ec2'),
|
| 291 |
+
)
|
| 292 |
+
self.assertTrue(client_args['client_config'].use_fips_endpoint)
|
| 293 |
+
|
| 294 |
+
def test_client_config_has_both_use_fips_and_use_dualstack__endpoint_flags(
|
| 295 |
+
self,
|
| 296 |
+
):
|
| 297 |
+
self._set_endpoint_bridge_resolve(
|
| 298 |
+
metadata={'tags': ['fips', 'dualstack']}
|
| 299 |
+
)
|
| 300 |
+
client_args = self.call_get_client_args(
|
| 301 |
+
service_model=self._get_service_model('ec2'),
|
| 302 |
+
)
|
| 303 |
+
self.assertTrue(client_args['client_config'].use_fips_endpoint)
|
| 304 |
+
self.assertTrue(client_args['client_config'].use_dualstack_endpoint)
|
| 305 |
+
|
| 306 |
+
def test_s3_override_use_dualstack_endpoint_flag(self):
|
| 307 |
+
self._set_endpoint_bridge_resolve(metadata={'tags': ['dualstack']})
|
| 308 |
+
client_args = self.call_get_client_args(
|
| 309 |
+
service_model=self._get_service_model('s3'),
|
| 310 |
+
)
|
| 311 |
+
self.assertTrue(
|
| 312 |
+
client_args['client_config'].s3['use_dualstack_endpoint']
|
| 313 |
+
)
|
| 314 |
+
|
| 315 |
+
def test_sts_override_resolved_endpoint_for_legacy_region(self):
|
| 316 |
+
self.config_store.set_config_variable(
|
| 317 |
+
'sts_regional_endpoints', 'legacy'
|
| 318 |
+
)
|
| 319 |
+
client_args = self.call_get_client_args(
|
| 320 |
+
service_model=self._get_service_model('sts'),
|
| 321 |
+
region_name='us-west-2',
|
| 322 |
+
endpoint_url=None,
|
| 323 |
+
)
|
| 324 |
+
self.assertEqual(
|
| 325 |
+
client_args['endpoint'].host, 'https://sts.amazonaws.com'
|
| 326 |
+
)
|
| 327 |
+
self.assertEqual(
|
| 328 |
+
client_args['request_signer'].region_name, 'us-east-1'
|
| 329 |
+
)
|
| 330 |
+
|
| 331 |
+
def test_sts_use_resolved_endpoint_for_nonlegacy_region(self):
|
| 332 |
+
resolved_endpoint = 'https://resolved-endpoint'
|
| 333 |
+
resolved_region = 'resolved-region'
|
| 334 |
+
self._set_endpoint_bridge_resolve(
|
| 335 |
+
endpoint_url=resolved_endpoint, signing_region=resolved_region
|
| 336 |
+
)
|
| 337 |
+
self.config_store.set_config_variable(
|
| 338 |
+
'sts_regional_endpoints', 'legacy'
|
| 339 |
+
)
|
| 340 |
+
client_args = self.call_get_client_args(
|
| 341 |
+
service_model=self._get_service_model('sts'),
|
| 342 |
+
region_name='ap-east-1',
|
| 343 |
+
endpoint_url=None,
|
| 344 |
+
)
|
| 345 |
+
self.assertEqual(client_args['endpoint'].host, resolved_endpoint)
|
| 346 |
+
self.assertEqual(
|
| 347 |
+
client_args['request_signer'].region_name, resolved_region
|
| 348 |
+
)
|
| 349 |
+
|
| 350 |
+
def test_sts_use_resolved_endpoint_for_regional_configuration(self):
|
| 351 |
+
resolved_endpoint = 'https://resolved-endpoint'
|
| 352 |
+
resolved_region = 'resolved-region'
|
| 353 |
+
self._set_endpoint_bridge_resolve(
|
| 354 |
+
endpoint_url=resolved_endpoint, signing_region=resolved_region
|
| 355 |
+
)
|
| 356 |
+
self.config_store.set_config_variable(
|
| 357 |
+
'sts_regional_endpoints', 'regional'
|
| 358 |
+
)
|
| 359 |
+
client_args = self.call_get_client_args(
|
| 360 |
+
service_model=self._get_service_model('sts'),
|
| 361 |
+
region_name='us-west-2',
|
| 362 |
+
endpoint_url=None,
|
| 363 |
+
)
|
| 364 |
+
self.assertEqual(client_args['endpoint'].host, resolved_endpoint)
|
| 365 |
+
self.assertEqual(
|
| 366 |
+
client_args['request_signer'].region_name, resolved_region
|
| 367 |
+
)
|
| 368 |
+
|
| 369 |
+
def test_sts_with_endpoint_override_and_legacy_configured(self):
|
| 370 |
+
override_endpoint = 'https://override-endpoint'
|
| 371 |
+
self._set_endpoint_bridge_resolve(endpoint_url=override_endpoint)
|
| 372 |
+
self.config_store.set_config_variable(
|
| 373 |
+
'sts_regional_endpoints', 'legacy'
|
| 374 |
+
)
|
| 375 |
+
client_args = self.call_get_client_args(
|
| 376 |
+
service_model=self._get_service_model('sts'),
|
| 377 |
+
region_name='us-west-2',
|
| 378 |
+
endpoint_url=override_endpoint,
|
| 379 |
+
)
|
| 380 |
+
self.assertEqual(client_args['endpoint'].host, override_endpoint)
|
| 381 |
+
|
| 382 |
+
def test_sts_http_scheme_for_override_endpoint(self):
|
| 383 |
+
self.config_store.set_config_variable(
|
| 384 |
+
'sts_regional_endpoints', 'legacy'
|
| 385 |
+
)
|
| 386 |
+
client_args = self.call_get_client_args(
|
| 387 |
+
service_model=self._get_service_model('sts'),
|
| 388 |
+
region_name='us-west-2',
|
| 389 |
+
endpoint_url=None,
|
| 390 |
+
is_secure=False,
|
| 391 |
+
)
|
| 392 |
+
self.assertEqual(
|
| 393 |
+
client_args['endpoint'].host, 'http://sts.amazonaws.com'
|
| 394 |
+
)
|
| 395 |
+
|
| 396 |
+
def test_sts_regional_endpoints_defaults_to_legacy_if_not_set(self):
|
| 397 |
+
self.config_store.set_config_variable('sts_regional_endpoints', None)
|
| 398 |
+
client_args = self.call_get_client_args(
|
| 399 |
+
service_model=self._get_service_model('sts'),
|
| 400 |
+
region_name='us-west-2',
|
| 401 |
+
endpoint_url=None,
|
| 402 |
+
)
|
| 403 |
+
self.assertEqual(
|
| 404 |
+
client_args['endpoint'].host, 'https://sts.amazonaws.com'
|
| 405 |
+
)
|
| 406 |
+
self.assertEqual(
|
| 407 |
+
client_args['request_signer'].region_name, 'us-east-1'
|
| 408 |
+
)
|
| 409 |
+
|
| 410 |
+
def test_invalid_sts_regional_endpoints(self):
|
| 411 |
+
self.config_store.set_config_variable(
|
| 412 |
+
'sts_regional_endpoints', 'invalid'
|
| 413 |
+
)
|
| 414 |
+
with self.assertRaises(
|
| 415 |
+
exceptions.InvalidSTSRegionalEndpointsConfigError
|
| 416 |
+
):
|
| 417 |
+
self.call_get_client_args(
|
| 418 |
+
service_model=self._get_service_model('sts'),
|
| 419 |
+
region_name='us-west-2',
|
| 420 |
+
endpoint_url=None,
|
| 421 |
+
)
|
| 422 |
+
|
| 423 |
+
def test_provides_total_max_attempts(self):
|
| 424 |
+
config = Config(retries={'total_max_attempts': 10})
|
| 425 |
+
client_args = self.call_get_client_args(client_config=config)
|
| 426 |
+
self.assertEqual(
|
| 427 |
+
client_args['client_config'].retries['total_max_attempts'], 10
|
| 428 |
+
)
|
| 429 |
+
|
| 430 |
+
def test_provides_total_max_attempts_has_precedence(self):
|
| 431 |
+
config = Config(retries={'total_max_attempts': 10, 'max_attempts': 5})
|
| 432 |
+
client_args = self.call_get_client_args(client_config=config)
|
| 433 |
+
self.assertEqual(
|
| 434 |
+
client_args['client_config'].retries['total_max_attempts'], 10
|
| 435 |
+
)
|
| 436 |
+
self.assertNotIn('max_attempts', client_args['client_config'].retries)
|
| 437 |
+
|
| 438 |
+
def test_provide_retry_config_maps_total_max_attempts(self):
|
| 439 |
+
config = Config(retries={'max_attempts': 10})
|
| 440 |
+
client_args = self.call_get_client_args(client_config=config)
|
| 441 |
+
self.assertEqual(
|
| 442 |
+
client_args['client_config'].retries['total_max_attempts'], 11
|
| 443 |
+
)
|
| 444 |
+
self.assertNotIn('max_attempts', client_args['client_config'].retries)
|
| 445 |
+
|
| 446 |
+
def test_can_merge_max_attempts(self):
|
| 447 |
+
self.config_store.set_config_variable('max_attempts', 4)
|
| 448 |
+
config = self.call_get_client_args()['client_config']
|
| 449 |
+
self.assertEqual(config.retries['total_max_attempts'], 4)
|
| 450 |
+
|
| 451 |
+
def test_uses_config_value_if_present_for_max_attempts(self):
|
| 452 |
+
config = self.call_get_client_args(
|
| 453 |
+
client_config=Config(retries={'max_attempts': 2})
|
| 454 |
+
)['client_config']
|
| 455 |
+
self.assertEqual(config.retries['total_max_attempts'], 3)
|
| 456 |
+
|
| 457 |
+
def test_uses_client_config_over_config_store_max_attempts(self):
|
| 458 |
+
self.config_store.set_config_variable('max_attempts', 4)
|
| 459 |
+
config = self.call_get_client_args(
|
| 460 |
+
client_config=Config(retries={'max_attempts': 2})
|
| 461 |
+
)['client_config']
|
| 462 |
+
self.assertEqual(config.retries['total_max_attempts'], 3)
|
| 463 |
+
|
| 464 |
+
def test_uses_client_config_total_over_config_store_max_attempts(self):
|
| 465 |
+
self.config_store.set_config_variable('max_attempts', 4)
|
| 466 |
+
config = self.call_get_client_args(
|
| 467 |
+
client_config=Config(retries={'total_max_attempts': 2})
|
| 468 |
+
)['client_config']
|
| 469 |
+
self.assertEqual(config.retries['total_max_attempts'], 2)
|
| 470 |
+
|
| 471 |
+
def test_max_attempts_unset_if_retries_is_none(self):
|
| 472 |
+
config = self.call_get_client_args(client_config=Config(retries=None))[
|
| 473 |
+
'client_config'
|
| 474 |
+
]
|
| 475 |
+
self.assertEqual(config.retries, {'mode': 'legacy'})
|
| 476 |
+
|
| 477 |
+
def test_retry_mode_set_on_config_store(self):
|
| 478 |
+
self.config_store.set_config_variable('retry_mode', 'standard')
|
| 479 |
+
config = self.call_get_client_args()['client_config']
|
| 480 |
+
self.assertEqual(config.retries['mode'], 'standard')
|
| 481 |
+
|
| 482 |
+
def test_retry_mode_set_on_client_config(self):
|
| 483 |
+
config = self.call_get_client_args(
|
| 484 |
+
client_config=Config(retries={'mode': 'standard'})
|
| 485 |
+
)['client_config']
|
| 486 |
+
self.assertEqual(config.retries['mode'], 'standard')
|
| 487 |
+
|
| 488 |
+
def test_connect_timeout_set_on_config_store(self):
|
| 489 |
+
self.config_store.set_config_variable('connect_timeout', 10)
|
| 490 |
+
config = self.call_get_client_args(
|
| 491 |
+
client_config=Config(defaults_mode='standard')
|
| 492 |
+
)['client_config']
|
| 493 |
+
self.assertEqual(config.connect_timeout, 10)
|
| 494 |
+
|
| 495 |
+
def test_connnect_timeout_set_on_client_config(self):
|
| 496 |
+
config = self.call_get_client_args(
|
| 497 |
+
client_config=Config(connect_timeout=10)
|
| 498 |
+
)['client_config']
|
| 499 |
+
self.assertEqual(config.connect_timeout, 10)
|
| 500 |
+
|
| 501 |
+
def test_connnect_timeout_set_to_client_config_default(self):
|
| 502 |
+
config = self.call_get_client_args()['client_config']
|
| 503 |
+
self.assertEqual(config.connect_timeout, 60)
|
| 504 |
+
|
| 505 |
+
def test_client_config_beats_config_store(self):
|
| 506 |
+
self.config_store.set_config_variable('retry_mode', 'adaptive')
|
| 507 |
+
config = self.call_get_client_args(
|
| 508 |
+
client_config=Config(retries={'mode': 'standard'})
|
| 509 |
+
)['client_config']
|
| 510 |
+
self.assertEqual(config.retries['mode'], 'standard')
|
| 511 |
+
|
| 512 |
+
def test_creates_ruleset_resolver_if_given_data(self):
|
| 513 |
+
with mock.patch('botocore.args.EndpointRulesetResolver') as m:
|
| 514 |
+
self.call_get_client_args(
|
| 515 |
+
service_model=self._get_service_model('s3'),
|
| 516 |
+
endpoints_ruleset_data={
|
| 517 |
+
'version': '1.0',
|
| 518 |
+
'parameters': {},
|
| 519 |
+
'rules': [],
|
| 520 |
+
},
|
| 521 |
+
)
|
| 522 |
+
m.assert_called_once()
|
| 523 |
+
|
| 524 |
+
def test_doesnt_create_ruleset_resolver_if_not_given_data(self):
|
| 525 |
+
with mock.patch('botocore.args.EndpointRulesetResolver') as m:
|
| 526 |
+
self.call_get_client_args(
|
| 527 |
+
service_model=self._get_service_model('s3'),
|
| 528 |
+
endpoints_ruleset_data=None,
|
| 529 |
+
)
|
| 530 |
+
m.assert_not_called()
|
| 531 |
+
|
| 532 |
+
def test_request_compression_client_config(self):
|
| 533 |
+
input_config = Config(
|
| 534 |
+
disable_request_compression=True,
|
| 535 |
+
request_min_compression_size_bytes=100,
|
| 536 |
+
)
|
| 537 |
+
client_args = self.call_get_client_args(client_config=input_config)
|
| 538 |
+
config = client_args['client_config']
|
| 539 |
+
self.assertEqual(config.request_min_compression_size_bytes, 100)
|
| 540 |
+
self.assertTrue(config.disable_request_compression)
|
| 541 |
+
|
| 542 |
+
def test_request_compression_config_store(self):
|
| 543 |
+
self.config_store.set_config_variable(
|
| 544 |
+
'request_min_compression_size_bytes', 100
|
| 545 |
+
)
|
| 546 |
+
self.config_store.set_config_variable(
|
| 547 |
+
'disable_request_compression', True
|
| 548 |
+
)
|
| 549 |
+
config = self.call_get_client_args()['client_config']
|
| 550 |
+
self.assertEqual(config.request_min_compression_size_bytes, 100)
|
| 551 |
+
self.assertTrue(config.disable_request_compression)
|
| 552 |
+
|
| 553 |
+
def test_request_compression_client_config_overrides_config_store(self):
|
| 554 |
+
self.config_store.set_config_variable(
|
| 555 |
+
'request_min_compression_size_bytes', 100
|
| 556 |
+
)
|
| 557 |
+
self.config_store.set_config_variable(
|
| 558 |
+
'disable_request_compression', True
|
| 559 |
+
)
|
| 560 |
+
input_config = Config(
|
| 561 |
+
disable_request_compression=False,
|
| 562 |
+
request_min_compression_size_bytes=1,
|
| 563 |
+
)
|
| 564 |
+
client_args = self.call_get_client_args(client_config=input_config)
|
| 565 |
+
config = client_args['client_config']
|
| 566 |
+
self.assertEqual(config.request_min_compression_size_bytes, 1)
|
| 567 |
+
self.assertFalse(config.disable_request_compression)
|
| 568 |
+
|
| 569 |
+
def test_coercible_value_request_min_compression_size_bytes(self):
|
| 570 |
+
config = Config(request_min_compression_size_bytes='100')
|
| 571 |
+
client_args = self.call_get_client_args(client_config=config)
|
| 572 |
+
config = client_args['client_config']
|
| 573 |
+
self.assertEqual(config.request_min_compression_size_bytes, 100)
|
| 574 |
+
|
| 575 |
+
def test_coercible_value_disable_request_compression(self):
|
| 576 |
+
config = Config(disable_request_compression='true')
|
| 577 |
+
client_args = self.call_get_client_args(client_config=config)
|
| 578 |
+
config = client_args['client_config']
|
| 579 |
+
self.assertTrue(config.disable_request_compression)
|
| 580 |
+
|
| 581 |
+
def test_bad_type_request_min_compression_size_bytes(self):
|
| 582 |
+
with self.assertRaises(exceptions.InvalidConfigError):
|
| 583 |
+
config = Config(request_min_compression_size_bytes='foo')
|
| 584 |
+
self.call_get_client_args(client_config=config)
|
| 585 |
+
self.config_store.set_config_variable(
|
| 586 |
+
'request_min_compression_size_bytes', 'foo'
|
| 587 |
+
)
|
| 588 |
+
with self.assertRaises(exceptions.InvalidConfigError):
|
| 589 |
+
self.call_get_client_args()
|
| 590 |
+
|
| 591 |
+
def test_low_min_request_min_compression_size_bytes(self):
|
| 592 |
+
with self.assertRaises(exceptions.InvalidConfigError):
|
| 593 |
+
config = Config(request_min_compression_size_bytes=0)
|
| 594 |
+
self.call_get_client_args(client_config=config)
|
| 595 |
+
self.config_store.set_config_variable(
|
| 596 |
+
'request_min_compression_size_bytes', 0
|
| 597 |
+
)
|
| 598 |
+
with self.assertRaises(exceptions.InvalidConfigError):
|
| 599 |
+
self.call_get_client_args()
|
| 600 |
+
|
| 601 |
+
def test_high_max_request_min_compression_size_bytes(self):
|
| 602 |
+
with self.assertRaises(exceptions.InvalidConfigError):
|
| 603 |
+
config = Config(request_min_compression_size_bytes=9999999)
|
| 604 |
+
self.call_get_client_args(client_config=config)
|
| 605 |
+
self.config_store.set_config_variable(
|
| 606 |
+
'request_min_compression_size_bytes', 9999999
|
| 607 |
+
)
|
| 608 |
+
with self.assertRaises(exceptions.InvalidConfigError):
|
| 609 |
+
self.call_get_client_args()
|
| 610 |
+
|
| 611 |
+
def test_bad_value_disable_request_compression(self):
|
| 612 |
+
input_config = Config(disable_request_compression='foo')
|
| 613 |
+
client_args = self.call_get_client_args(client_config=input_config)
|
| 614 |
+
config = client_args['client_config']
|
| 615 |
+
self.assertFalse(config.disable_request_compression)
|
| 616 |
+
|
| 617 |
+
|
| 618 |
+
class TestEndpointResolverBuiltins(unittest.TestCase):
|
| 619 |
+
def setUp(self):
|
| 620 |
+
event_emitter = mock.Mock(HierarchicalEmitter)
|
| 621 |
+
self.config_store = ConfigValueStore()
|
| 622 |
+
user_agent_creator = UserAgentString(
|
| 623 |
+
platform_name=None,
|
| 624 |
+
platform_version=None,
|
| 625 |
+
platform_machine=None,
|
| 626 |
+
python_version=None,
|
| 627 |
+
python_implementation=None,
|
| 628 |
+
execution_env=None,
|
| 629 |
+
crt_version=None,
|
| 630 |
+
)
|
| 631 |
+
self.args_create = args.ClientArgsCreator(
|
| 632 |
+
event_emitter=event_emitter,
|
| 633 |
+
user_agent=None,
|
| 634 |
+
response_parser_factory=None,
|
| 635 |
+
loader=None,
|
| 636 |
+
exceptions_factory=None,
|
| 637 |
+
config_store=self.config_store,
|
| 638 |
+
user_agent_creator=user_agent_creator,
|
| 639 |
+
)
|
| 640 |
+
self.bridge = ClientEndpointBridge(
|
| 641 |
+
endpoint_resolver=mock.Mock(),
|
| 642 |
+
scoped_config=None,
|
| 643 |
+
client_config=Config(),
|
| 644 |
+
default_endpoint=None,
|
| 645 |
+
service_signing_name=None,
|
| 646 |
+
config_store=self.config_store,
|
| 647 |
+
)
|
| 648 |
+
# assume a legacy endpoint resolver that uses the builtin
|
| 649 |
+
# endpoints.json file
|
| 650 |
+
self.bridge.endpoint_resolver.uses_builtin_data = True
|
| 651 |
+
|
| 652 |
+
def call_compute_endpoint_resolver_builtin_defaults(self, **overrides):
|
| 653 |
+
defaults = {
|
| 654 |
+
'region_name': 'ca-central-1',
|
| 655 |
+
'service_name': 'fooservice',
|
| 656 |
+
's3_config': {},
|
| 657 |
+
'endpoint_bridge': self.bridge,
|
| 658 |
+
'client_endpoint_url': None,
|
| 659 |
+
'legacy_endpoint_url': 'https://my.legacy.endpoint.com',
|
| 660 |
+
}
|
| 661 |
+
kwargs = {**defaults, **overrides}
|
| 662 |
+
return self.args_create.compute_endpoint_resolver_builtin_defaults(
|
| 663 |
+
**kwargs
|
| 664 |
+
)
|
| 665 |
+
|
| 666 |
+
def test_builtins_defaults(self):
|
| 667 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults()
|
| 668 |
+
|
| 669 |
+
self.assertEqual(bins['AWS::Region'], 'ca-central-1')
|
| 670 |
+
self.assertEqual(bins['AWS::UseFIPS'], False)
|
| 671 |
+
self.assertEqual(bins['AWS::UseDualStack'], False)
|
| 672 |
+
self.assertEqual(bins['AWS::STS::UseGlobalEndpoint'], True)
|
| 673 |
+
self.assertEqual(bins['AWS::S3::UseGlobalEndpoint'], False)
|
| 674 |
+
self.assertEqual(bins['AWS::S3::Accelerate'], False)
|
| 675 |
+
self.assertEqual(bins['AWS::S3::ForcePathStyle'], False)
|
| 676 |
+
self.assertEqual(bins['AWS::S3::UseArnRegion'], True)
|
| 677 |
+
self.assertEqual(bins['AWS::S3Control::UseArnRegion'], False)
|
| 678 |
+
self.assertEqual(
|
| 679 |
+
bins['AWS::S3::DisableMultiRegionAccessPoints'], False
|
| 680 |
+
)
|
| 681 |
+
self.assertEqual(bins['SDK::Endpoint'], None)
|
| 682 |
+
|
| 683 |
+
def test_aws_region(self):
|
| 684 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 685 |
+
region_name='my-region-1',
|
| 686 |
+
)
|
| 687 |
+
self.assertEqual(bins['AWS::Region'], 'my-region-1')
|
| 688 |
+
|
| 689 |
+
def test_aws_use_fips_when_config_is_set_true(self):
|
| 690 |
+
self.config_store.set_config_variable('use_fips_endpoint', True)
|
| 691 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults()
|
| 692 |
+
self.assertEqual(bins['AWS::UseFIPS'], True)
|
| 693 |
+
|
| 694 |
+
def test_aws_use_fips_when_config_is_set_false(self):
|
| 695 |
+
self.config_store.set_config_variable('use_fips_endpoint', False)
|
| 696 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults()
|
| 697 |
+
self.assertEqual(bins['AWS::UseFIPS'], False)
|
| 698 |
+
|
| 699 |
+
def test_aws_use_dualstack_when_config_is_set_true(self):
|
| 700 |
+
self.bridge.client_config = Config(s3={'use_dualstack_endpoint': True})
|
| 701 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 702 |
+
service_name='s3-control'
|
| 703 |
+
)
|
| 704 |
+
self.assertEqual(bins['AWS::UseDualStack'], True)
|
| 705 |
+
|
| 706 |
+
def test_aws_use_dualstack_when_config_is_set_false(self):
|
| 707 |
+
self.bridge.client_config = Config(
|
| 708 |
+
s3={'use_dualstack_endpoint': False}
|
| 709 |
+
)
|
| 710 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 711 |
+
service_name='s3-control'
|
| 712 |
+
)
|
| 713 |
+
self.assertEqual(bins['AWS::UseDualStack'], False)
|
| 714 |
+
|
| 715 |
+
def test_aws_use_dualstack_when_non_dualstack_service(self):
|
| 716 |
+
self.bridge.client_config = Config(s3={'use_dualstack_endpoint': True})
|
| 717 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 718 |
+
service_name='other-service'
|
| 719 |
+
)
|
| 720 |
+
self.assertEqual(bins['AWS::UseDualStack'], False)
|
| 721 |
+
|
| 722 |
+
def test_aws_sts_global_endpoint_with_default_and_legacy_region(self):
|
| 723 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 724 |
+
region_name='us-west-2',
|
| 725 |
+
)
|
| 726 |
+
self.assertEqual(bins['AWS::STS::UseGlobalEndpoint'], True)
|
| 727 |
+
|
| 728 |
+
def test_aws_sts_global_endpoint_with_default_and_nonlegacy_region(self):
|
| 729 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 730 |
+
region_name='eu-south-1',
|
| 731 |
+
)
|
| 732 |
+
self.assertEqual(bins['AWS::STS::UseGlobalEndpoint'], False)
|
| 733 |
+
|
| 734 |
+
def test_aws_sts_global_endpoint_with_nondefault_config(self):
|
| 735 |
+
self.config_store.set_config_variable(
|
| 736 |
+
'sts_regional_endpoints', 'regional'
|
| 737 |
+
)
|
| 738 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 739 |
+
region_name='us-west-2',
|
| 740 |
+
)
|
| 741 |
+
self.assertEqual(bins['AWS::STS::UseGlobalEndpoint'], False)
|
| 742 |
+
|
| 743 |
+
def test_s3_global_endpoint(self):
|
| 744 |
+
# The only reason for this builtin to not have the default value
|
| 745 |
+
# (False) is that the ``_should_force_s3_global`` method
|
| 746 |
+
# returns True.
|
| 747 |
+
self.args_create._should_force_s3_global = mock.Mock(return_value=True)
|
| 748 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults()
|
| 749 |
+
self.assertTrue(bins['AWS::S3::UseGlobalEndpoint'])
|
| 750 |
+
self.args_create._should_force_s3_global.assert_called_once()
|
| 751 |
+
|
| 752 |
+
def test_s3_accelerate_with_config_set_true(self):
|
| 753 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 754 |
+
s3_config={'use_accelerate_endpoint': True},
|
| 755 |
+
)
|
| 756 |
+
self.assertEqual(bins['AWS::S3::Accelerate'], True)
|
| 757 |
+
|
| 758 |
+
def test_s3_accelerate_with_config_set_false(self):
|
| 759 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 760 |
+
s3_config={'use_accelerate_endpoint': False},
|
| 761 |
+
)
|
| 762 |
+
self.assertEqual(bins['AWS::S3::Accelerate'], False)
|
| 763 |
+
|
| 764 |
+
def test_force_path_style_with_config_set_to_path(self):
|
| 765 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 766 |
+
s3_config={'addressing_style': 'path'},
|
| 767 |
+
)
|
| 768 |
+
self.assertEqual(bins['AWS::S3::ForcePathStyle'], True)
|
| 769 |
+
|
| 770 |
+
def test_force_path_style_with_config_set_to_auto(self):
|
| 771 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 772 |
+
s3_config={'addressing_style': 'auto'},
|
| 773 |
+
)
|
| 774 |
+
self.assertEqual(bins['AWS::S3::ForcePathStyle'], False)
|
| 775 |
+
|
| 776 |
+
def test_force_path_style_with_config_set_to_virtual(self):
|
| 777 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 778 |
+
s3_config={'addressing_style': 'virtual'},
|
| 779 |
+
)
|
| 780 |
+
self.assertEqual(bins['AWS::S3::ForcePathStyle'], False)
|
| 781 |
+
|
| 782 |
+
def test_use_arn_region_with_config_set_false(self):
|
| 783 |
+
# These two builtins both take their value from the ``use_arn_region``
|
| 784 |
+
# in the S3 configuration, but have different default values.
|
| 785 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 786 |
+
s3_config={'use_arn_region': False},
|
| 787 |
+
)
|
| 788 |
+
self.assertEqual(bins['AWS::S3::UseArnRegion'], False)
|
| 789 |
+
self.assertEqual(bins['AWS::S3Control::UseArnRegion'], False)
|
| 790 |
+
|
| 791 |
+
def test_use_arn_region_with_config_set_true(self):
|
| 792 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 793 |
+
s3_config={'use_arn_region': True},
|
| 794 |
+
)
|
| 795 |
+
self.assertEqual(bins['AWS::S3::UseArnRegion'], True)
|
| 796 |
+
self.assertEqual(bins['AWS::S3Control::UseArnRegion'], True)
|
| 797 |
+
|
| 798 |
+
def test_disable_mrap_with_config_set_true(self):
|
| 799 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 800 |
+
s3_config={'s3_disable_multiregion_access_points': True},
|
| 801 |
+
)
|
| 802 |
+
self.assertEqual(bins['AWS::S3::DisableMultiRegionAccessPoints'], True)
|
| 803 |
+
|
| 804 |
+
def test_disable_mrap_with_config_set_false(self):
|
| 805 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 806 |
+
s3_config={'s3_disable_multiregion_access_points': False},
|
| 807 |
+
)
|
| 808 |
+
self.assertEqual(
|
| 809 |
+
bins['AWS::S3::DisableMultiRegionAccessPoints'], False
|
| 810 |
+
)
|
| 811 |
+
|
| 812 |
+
def test_sdk_endpoint_both_inputs_set(self):
|
| 813 |
+
# assume a legacy endpoint resolver that uses a customized
|
| 814 |
+
# endpoints.json file
|
| 815 |
+
self.bridge.endpoint_resolver.uses_builtin_data = False
|
| 816 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 817 |
+
client_endpoint_url='https://my.client.endpoint.com',
|
| 818 |
+
legacy_endpoint_url='https://my.legacy.endpoint.com',
|
| 819 |
+
)
|
| 820 |
+
self.assertEqual(
|
| 821 |
+
bins['SDK::Endpoint'], 'https://my.client.endpoint.com'
|
| 822 |
+
)
|
| 823 |
+
|
| 824 |
+
def test_sdk_endpoint_legacy_set_with_builtin_data(self):
|
| 825 |
+
# assume a legacy endpoint resolver that uses a customized
|
| 826 |
+
# endpoints.json file
|
| 827 |
+
self.bridge.endpoint_resolver.uses_builtin_data = False
|
| 828 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 829 |
+
client_endpoint_url=None,
|
| 830 |
+
legacy_endpoint_url='https://my.legacy.endpoint.com',
|
| 831 |
+
)
|
| 832 |
+
self.assertEqual(
|
| 833 |
+
bins['SDK::Endpoint'], 'https://my.legacy.endpoint.com'
|
| 834 |
+
)
|
| 835 |
+
|
| 836 |
+
def test_sdk_endpoint_legacy_set_without_builtin_data(self):
|
| 837 |
+
# assume a legacy endpoint resolver that uses the builtin
|
| 838 |
+
# endpoints.json file
|
| 839 |
+
self.bridge.endpoint_resolver.uses_builtin_data = True
|
| 840 |
+
bins = self.call_compute_endpoint_resolver_builtin_defaults(
|
| 841 |
+
client_endpoint_url=None,
|
| 842 |
+
legacy_endpoint_url='https://my.legacy.endpoint.com',
|
| 843 |
+
)
|
| 844 |
+
self.assertEqual(bins['SDK::Endpoint'], None)
|
testbed/boto__botocore/tests/unit/test_auth_bearer.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 4 |
+
# may not use this file except in compliance with the License. A copy of
|
| 5 |
+
# the License is located at
|
| 6 |
+
#
|
| 7 |
+
# http://aws.amazon.com/apache2.0/
|
| 8 |
+
#
|
| 9 |
+
# or in the "license" file accompanying this file. This file is
|
| 10 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 11 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 12 |
+
# language governing permissions and limitations under the License.
|
| 13 |
+
import pytest
|
| 14 |
+
|
| 15 |
+
from botocore.auth import BearerAuth
|
| 16 |
+
from botocore.awsrequest import AWSRequest
|
| 17 |
+
from botocore.exceptions import NoAuthTokenError
|
| 18 |
+
from botocore.tokens import FrozenAuthToken
|
| 19 |
+
|
| 20 |
+
cases = [
|
| 21 |
+
{
|
| 22 |
+
"documentation": "Minimal bearer auth case",
|
| 23 |
+
"headers": {},
|
| 24 |
+
"token": "mF_9.B5f-4.1JqM",
|
| 25 |
+
"expectedHeaders": {"Authorization": "Bearer mF_9.B5f-4.1JqM"},
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"documentation": "Longer token case",
|
| 29 |
+
"headers": {},
|
| 30 |
+
"token": "eW91J3JlIG5vdCBzdXBwb3NlZCB0byBkZWNvZGUgdGhpcyE=",
|
| 31 |
+
"expectedHeaders": {
|
| 32 |
+
"Authorization": "Bearer eW91J3JlIG5vdCBzdXBwb3NlZCB0byBkZWNvZGUgdGhpcyE="
|
| 33 |
+
},
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"documentation": "Signer should override existing header",
|
| 37 |
+
"headers": {"Authorization": "Bearer foo"},
|
| 38 |
+
"token": "mF_9.B5f-4.1JqM",
|
| 39 |
+
"expectedHeaders": {"Authorization": "Bearer mF_9.B5f-4.1JqM"},
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"documentation": "Signer requires a token",
|
| 43 |
+
"headers": {},
|
| 44 |
+
"token": None,
|
| 45 |
+
"expectedException": NoAuthTokenError,
|
| 46 |
+
},
|
| 47 |
+
]
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
@pytest.mark.parametrize("test_case", cases)
|
| 51 |
+
def test_bearer_auth(test_case):
|
| 52 |
+
url = "https://example.com"
|
| 53 |
+
headers = test_case.get("headers", {})
|
| 54 |
+
request = AWSRequest(method="GET", url=url, headers=headers)
|
| 55 |
+
|
| 56 |
+
auth_token = None
|
| 57 |
+
raw_token = test_case["token"]
|
| 58 |
+
if raw_token:
|
| 59 |
+
auth_token = FrozenAuthToken(test_case["token"], expiration=None)
|
| 60 |
+
|
| 61 |
+
bearer_auth = BearerAuth(auth_token)
|
| 62 |
+
expected_headers = test_case.get("expectedHeaders")
|
| 63 |
+
expected_exception = test_case.get("expectedException")
|
| 64 |
+
if expected_headers:
|
| 65 |
+
bearer_auth.add_auth(request)
|
| 66 |
+
for name in expected_headers:
|
| 67 |
+
actual_header = request.headers[name]
|
| 68 |
+
expected_header = expected_headers[name]
|
| 69 |
+
assert actual_header == expected_header
|
| 70 |
+
elif expected_exception:
|
| 71 |
+
with pytest.raises(expected_exception):
|
| 72 |
+
bearer_auth.add_auth(request)
|
testbed/boto__botocore/tests/unit/test_auth_sigv4.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 4 |
+
# may not use this file except in compliance with the License. A copy of
|
| 5 |
+
# the License is located at
|
| 6 |
+
#
|
| 7 |
+
# http://aws.amazon.com/apache2.0/
|
| 8 |
+
#
|
| 9 |
+
# or in the "license" file accompanying this file. This file is
|
| 10 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 11 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 12 |
+
# language governing permissions and limitations under the License.
|
| 13 |
+
from botocore.auth import SigV4Auth
|
| 14 |
+
from botocore.awsrequest import AWSRequest
|
| 15 |
+
from botocore.credentials import Credentials
|
| 16 |
+
from tests import unittest
|
| 17 |
+
|
| 18 |
+
SECRET_KEY = "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"
|
| 19 |
+
ACCESS_KEY = 'AKIDEXAMPLE'
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class TestSigV4Auth(unittest.TestCase):
|
| 23 |
+
def setUp(self):
|
| 24 |
+
self.credentials = Credentials(ACCESS_KEY, SECRET_KEY)
|
| 25 |
+
self.sigv4 = SigV4Auth(self.credentials, 'host', 'us-weast-1')
|
| 26 |
+
|
| 27 |
+
def test_signed_host_is_lowercase(self):
|
| 28 |
+
endpoint = 'https://S5.Us-WeAsT-2.AmAZonAwS.com'
|
| 29 |
+
expected_host = 's5.us-weast-2.amazonaws.com'
|
| 30 |
+
request = AWSRequest(method='GET', url=endpoint)
|
| 31 |
+
headers_to_sign = self.sigv4.headers_to_sign(request)
|
| 32 |
+
self.assertEqual(expected_host, headers_to_sign.get('host'))
|
| 33 |
+
|
| 34 |
+
def test_signed_host_is_ipv6_without_port(self):
|
| 35 |
+
endpoint = 'http://[::1]'
|
| 36 |
+
expected_host = '[::1]'
|
| 37 |
+
request = AWSRequest(method='GET', url=endpoint)
|
| 38 |
+
headers_to_sign = self.sigv4.headers_to_sign(request)
|
| 39 |
+
self.assertEqual(expected_host, headers_to_sign.get('host'))
|
| 40 |
+
|
| 41 |
+
def test_signed_host_is_ipv6_with_default_port(self):
|
| 42 |
+
endpoint = 'http://[::1]:80'
|
| 43 |
+
expected_host = '[::1]'
|
| 44 |
+
request = AWSRequest(method='GET', url=endpoint)
|
| 45 |
+
headers_to_sign = self.sigv4.headers_to_sign(request)
|
| 46 |
+
self.assertEqual(expected_host, headers_to_sign.get('host'))
|
| 47 |
+
|
| 48 |
+
def test_signed_host_is_ipv6_with_explicit_port(self):
|
| 49 |
+
endpoint = 'http://[::1]:6789'
|
| 50 |
+
expected_host = '[::1]:6789'
|
| 51 |
+
request = AWSRequest(method='GET', url=endpoint)
|
| 52 |
+
headers_to_sign = self.sigv4.headers_to_sign(request)
|
| 53 |
+
self.assertEqual(expected_host, headers_to_sign.get('host'))
|
testbed/boto__botocore/tests/unit/test_awsrequest.py
ADDED
|
@@ -0,0 +1,802 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 5 |
+
# may not use this file except in compliance with the License. A copy of
|
| 6 |
+
# the License is located at
|
| 7 |
+
#
|
| 8 |
+
# http://aws.amazon.com/apache2.0/
|
| 9 |
+
#
|
| 10 |
+
# or in the "license" file accompanying this file. This file is
|
| 11 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 12 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 13 |
+
# language governing permissions and limitations under the License.
|
| 14 |
+
|
| 15 |
+
import io
|
| 16 |
+
import os
|
| 17 |
+
import shutil
|
| 18 |
+
import socket
|
| 19 |
+
import tempfile
|
| 20 |
+
|
| 21 |
+
import pytest
|
| 22 |
+
from urllib3.connectionpool import HTTPConnectionPool, HTTPSConnectionPool
|
| 23 |
+
|
| 24 |
+
from botocore.awsrequest import (
|
| 25 |
+
AWSHTTPConnection,
|
| 26 |
+
AWSHTTPSConnection,
|
| 27 |
+
AWSRequest,
|
| 28 |
+
AWSResponse,
|
| 29 |
+
HeadersDict,
|
| 30 |
+
create_request_object,
|
| 31 |
+
prepare_request_dict,
|
| 32 |
+
)
|
| 33 |
+
from botocore.compat import file_type
|
| 34 |
+
from botocore.exceptions import UnseekableStreamError
|
| 35 |
+
from tests import mock, unittest
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class IgnoreCloseBytesIO(io.BytesIO):
|
| 39 |
+
def close(self):
|
| 40 |
+
pass
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class FakeSocket:
|
| 44 |
+
def __init__(self, read_data, fileclass=IgnoreCloseBytesIO):
|
| 45 |
+
self.sent_data = b''
|
| 46 |
+
self.read_data = read_data
|
| 47 |
+
self.fileclass = fileclass
|
| 48 |
+
self._fp_object = None
|
| 49 |
+
|
| 50 |
+
def sendall(self, data):
|
| 51 |
+
self.sent_data += data
|
| 52 |
+
|
| 53 |
+
def makefile(self, mode, bufsize=None):
|
| 54 |
+
if self._fp_object is None:
|
| 55 |
+
self._fp_object = self.fileclass(self.read_data)
|
| 56 |
+
return self._fp_object
|
| 57 |
+
|
| 58 |
+
def close(self):
|
| 59 |
+
pass
|
| 60 |
+
|
| 61 |
+
def settimeout(self, value):
|
| 62 |
+
pass
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
class BytesIOWithLen(io.BytesIO):
|
| 66 |
+
def __len__(self):
|
| 67 |
+
return len(self.getvalue())
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
class Unseekable(file_type):
|
| 71 |
+
def __init__(self, stream):
|
| 72 |
+
self._stream = stream
|
| 73 |
+
|
| 74 |
+
def read(self):
|
| 75 |
+
return self._stream.read()
|
| 76 |
+
|
| 77 |
+
def seek(self, offset, whence):
|
| 78 |
+
# This is a case where seek() exists as part of the object's interface,
|
| 79 |
+
# but it doesn't actually work (for example socket.makefile(), which
|
| 80 |
+
# will raise an io.* error on python3).
|
| 81 |
+
raise ValueError("Underlying stream does not support seeking.")
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
class Seekable:
|
| 85 |
+
"""This class represents a bare-bones,seekable file-like object
|
| 86 |
+
|
| 87 |
+
Note it does not include some of the other attributes of other
|
| 88 |
+
file-like objects such as StringIO's getvalue() and file object's fileno
|
| 89 |
+
property. If the file-like object does not have either of these attributes
|
| 90 |
+
requests will not calculate the content length even though it is still
|
| 91 |
+
possible to calculate it.
|
| 92 |
+
"""
|
| 93 |
+
|
| 94 |
+
def __init__(self, stream):
|
| 95 |
+
self._stream = stream
|
| 96 |
+
|
| 97 |
+
def __iter__(self):
|
| 98 |
+
return iter(self._stream)
|
| 99 |
+
|
| 100 |
+
def read(self):
|
| 101 |
+
return self._stream.read()
|
| 102 |
+
|
| 103 |
+
def seek(self, offset, whence=0):
|
| 104 |
+
self._stream.seek(offset, whence)
|
| 105 |
+
|
| 106 |
+
def tell(self):
|
| 107 |
+
return self._stream.tell()
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
class TestAWSRequest(unittest.TestCase):
|
| 111 |
+
def setUp(self):
|
| 112 |
+
self.tempdir = tempfile.mkdtemp()
|
| 113 |
+
self.filename = os.path.join(self.tempdir, 'foo')
|
| 114 |
+
self.request = AWSRequest(method='GET', url='http://example.com')
|
| 115 |
+
self.prepared_request = self.request.prepare()
|
| 116 |
+
|
| 117 |
+
def tearDown(self):
|
| 118 |
+
shutil.rmtree(self.tempdir)
|
| 119 |
+
|
| 120 |
+
def test_prepared_request_repr(self):
|
| 121 |
+
expected_repr = (
|
| 122 |
+
'<AWSPreparedRequest stream_output=False, method=GET, '
|
| 123 |
+
'url=http://example.com, headers={}>'
|
| 124 |
+
)
|
| 125 |
+
request_repr = repr(self.prepared_request)
|
| 126 |
+
self.assertEqual(request_repr, expected_repr)
|
| 127 |
+
|
| 128 |
+
def test_can_prepare_url_params(self):
|
| 129 |
+
request = AWSRequest(url='http://example.com/', params={'foo': 'bar'})
|
| 130 |
+
prepared_request = request.prepare()
|
| 131 |
+
self.assertEqual(prepared_request.url, 'http://example.com/?foo=bar')
|
| 132 |
+
|
| 133 |
+
def test_can_prepare_url_params_with_existing_query(self):
|
| 134 |
+
request = AWSRequest(
|
| 135 |
+
url='http://example.com/?bar=foo', params={'foo': 'bar'}
|
| 136 |
+
)
|
| 137 |
+
prepared_request = request.prepare()
|
| 138 |
+
self.assertEqual(
|
| 139 |
+
prepared_request.url, 'http://example.com/?bar=foo&foo=bar'
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
def test_can_prepare_dict_body(self):
|
| 143 |
+
body = {'dead': 'beef'}
|
| 144 |
+
request = AWSRequest(url='http://example.com/', data=body)
|
| 145 |
+
prepared_request = request.prepare()
|
| 146 |
+
self.assertEqual(prepared_request.body, 'dead=beef')
|
| 147 |
+
|
| 148 |
+
def test_can_prepare_dict_body_unicode_values(self):
|
| 149 |
+
body = {'Text': '\u30c6\u30b9\u30c8 string'}
|
| 150 |
+
expected_body = 'Text=%E3%83%86%E3%82%B9%E3%83%88+string'
|
| 151 |
+
request = AWSRequest(url='http://example.com/', data=body)
|
| 152 |
+
prepared_request = request.prepare()
|
| 153 |
+
self.assertEqual(prepared_request.body, expected_body)
|
| 154 |
+
|
| 155 |
+
def test_can_prepare_dict_body_unicode_keys(self):
|
| 156 |
+
body = {'\u30c6\u30b9\u30c8': 'string'}
|
| 157 |
+
expected_body = '%E3%83%86%E3%82%B9%E3%83%88=string'
|
| 158 |
+
request = AWSRequest(url='http://example.com/', data=body)
|
| 159 |
+
prepared_request = request.prepare()
|
| 160 |
+
self.assertEqual(prepared_request.body, expected_body)
|
| 161 |
+
|
| 162 |
+
def test_can_prepare_empty_body(self):
|
| 163 |
+
request = AWSRequest(url='http://example.com/', data=b'')
|
| 164 |
+
prepared_request = request.prepare()
|
| 165 |
+
self.assertEqual(prepared_request.body, None)
|
| 166 |
+
content_length = prepared_request.headers.get('content-length')
|
| 167 |
+
self.assertEqual(content_length, '0')
|
| 168 |
+
|
| 169 |
+
def test_request_body_is_prepared(self):
|
| 170 |
+
request = AWSRequest(url='http://example.com/', data='body')
|
| 171 |
+
self.assertEqual(request.body, b'body')
|
| 172 |
+
|
| 173 |
+
def test_prepare_body_content_adds_content_length(self):
|
| 174 |
+
content = b'foobarbaz'
|
| 175 |
+
expected_len = str(len(content))
|
| 176 |
+
with open(self.filename, 'wb') as f:
|
| 177 |
+
f.write(content)
|
| 178 |
+
with open(self.filename, 'rb') as f:
|
| 179 |
+
data = Seekable(f)
|
| 180 |
+
self.request.data = data
|
| 181 |
+
self.request.method = 'POST'
|
| 182 |
+
prepared_request = self.request.prepare()
|
| 183 |
+
calculated_len = prepared_request.headers['Content-Length']
|
| 184 |
+
self.assertEqual(calculated_len, expected_len)
|
| 185 |
+
|
| 186 |
+
def test_prepare_body_doesnt_override_content_length(self):
|
| 187 |
+
self.request.method = 'PUT'
|
| 188 |
+
self.request.headers['Content-Length'] = '20'
|
| 189 |
+
self.request.data = b'asdf'
|
| 190 |
+
prepared_request = self.request.prepare()
|
| 191 |
+
self.assertEqual(prepared_request.headers['Content-Length'], '20')
|
| 192 |
+
|
| 193 |
+
def test_prepare_body_doesnt_set_content_length_head(self):
|
| 194 |
+
self.request.method = 'HEAD'
|
| 195 |
+
self.request.data = b'thisshouldntbehere'
|
| 196 |
+
prepared_request = self.request.prepare()
|
| 197 |
+
self.assertEqual(prepared_request.headers.get('Content-Length'), None)
|
| 198 |
+
|
| 199 |
+
def test_prepare_body_doesnt_set_content_length_get(self):
|
| 200 |
+
self.request.method = 'GET'
|
| 201 |
+
self.request.data = b'thisshouldntbehere'
|
| 202 |
+
prepared_request = self.request.prepare()
|
| 203 |
+
self.assertEqual(prepared_request.headers.get('Content-Length'), None)
|
| 204 |
+
|
| 205 |
+
def test_prepare_body_doesnt_set_content_length_options(self):
|
| 206 |
+
self.request.method = 'OPTIONS'
|
| 207 |
+
self.request.data = b'thisshouldntbehere'
|
| 208 |
+
prepared_request = self.request.prepare()
|
| 209 |
+
self.assertEqual(prepared_request.headers.get('Content-Length'), None)
|
| 210 |
+
|
| 211 |
+
def test_can_reset_stream_handles_binary(self):
|
| 212 |
+
contents = b'notastream'
|
| 213 |
+
self.prepared_request.body = contents
|
| 214 |
+
self.prepared_request.reset_stream()
|
| 215 |
+
# assert the request body doesn't change after reset_stream is called
|
| 216 |
+
self.assertEqual(self.prepared_request.body, contents)
|
| 217 |
+
|
| 218 |
+
def test_can_reset_stream_handles_bytearray(self):
|
| 219 |
+
contents = bytearray(b'notastream')
|
| 220 |
+
self.prepared_request.body = contents
|
| 221 |
+
self.prepared_request.reset_stream()
|
| 222 |
+
# assert the request body doesn't change after reset_stream is called
|
| 223 |
+
self.assertEqual(self.prepared_request.body, contents)
|
| 224 |
+
|
| 225 |
+
def test_can_reset_stream(self):
|
| 226 |
+
contents = b'foobarbaz'
|
| 227 |
+
with open(self.filename, 'wb') as f:
|
| 228 |
+
f.write(contents)
|
| 229 |
+
with open(self.filename, 'rb') as body:
|
| 230 |
+
self.prepared_request.body = body
|
| 231 |
+
# pretend the request body was partially sent
|
| 232 |
+
body.read()
|
| 233 |
+
self.assertNotEqual(body.tell(), 0)
|
| 234 |
+
# have the prepared request reset its stream
|
| 235 |
+
self.prepared_request.reset_stream()
|
| 236 |
+
# the stream should be reset
|
| 237 |
+
self.assertEqual(body.tell(), 0)
|
| 238 |
+
|
| 239 |
+
def test_cannot_reset_stream_raises_error(self):
|
| 240 |
+
contents = b'foobarbaz'
|
| 241 |
+
with open(self.filename, 'wb') as f:
|
| 242 |
+
f.write(contents)
|
| 243 |
+
with open(self.filename, 'rb') as body:
|
| 244 |
+
self.prepared_request.body = Unseekable(body)
|
| 245 |
+
# pretend the request body was partially sent
|
| 246 |
+
body.read()
|
| 247 |
+
self.assertNotEqual(body.tell(), 0)
|
| 248 |
+
# reset stream should fail
|
| 249 |
+
with self.assertRaises(UnseekableStreamError):
|
| 250 |
+
self.prepared_request.reset_stream()
|
| 251 |
+
|
| 252 |
+
def test_duck_type_for_file_check(self):
|
| 253 |
+
# As part of determining whether or not we can rewind a stream
|
| 254 |
+
# we first need to determine if the thing is a file like object.
|
| 255 |
+
# We should not be using an isinstance check. Instead, we should
|
| 256 |
+
# be using duck type checks.
|
| 257 |
+
|
| 258 |
+
class LooksLikeFile:
|
| 259 |
+
def __init__(self):
|
| 260 |
+
self.seek_called = False
|
| 261 |
+
|
| 262 |
+
def read(self, amount=None):
|
| 263 |
+
pass
|
| 264 |
+
|
| 265 |
+
def seek(self, where):
|
| 266 |
+
self.seek_called = True
|
| 267 |
+
|
| 268 |
+
looks_like_file = LooksLikeFile()
|
| 269 |
+
self.prepared_request.body = looks_like_file
|
| 270 |
+
self.prepared_request.reset_stream()
|
| 271 |
+
# The stream should now be reset.
|
| 272 |
+
self.assertTrue(looks_like_file.seek_called)
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
@pytest.mark.parametrize(
|
| 276 |
+
"test_input,expected_output",
|
| 277 |
+
[
|
| 278 |
+
([('foo', None)], 'http://example.com/?foo=None'),
|
| 279 |
+
([(None, None)], 'http://example.com/?None=None'),
|
| 280 |
+
(
|
| 281 |
+
[('foo', 'bar'), ('foo', 'baz'), ('fizz', 'buzz')],
|
| 282 |
+
'http://example.com/?foo=bar&foo=baz&fizz=buzz',
|
| 283 |
+
),
|
| 284 |
+
(
|
| 285 |
+
[('foo', 'bar'), ('foo', None)],
|
| 286 |
+
'http://example.com/?foo=bar&foo=None',
|
| 287 |
+
),
|
| 288 |
+
([('foo', 'bar')], 'http://example.com/?foo=bar'),
|
| 289 |
+
(
|
| 290 |
+
[('foo', 'bar'), ('foo', 'bar'), ('fizz', 'buzz')],
|
| 291 |
+
'http://example.com/?foo=bar&foo=bar&fizz=buzz',
|
| 292 |
+
),
|
| 293 |
+
([('', 'bar')], 'http://example.com/?=bar'),
|
| 294 |
+
([(1, 'bar')], 'http://example.com/?1=bar'),
|
| 295 |
+
],
|
| 296 |
+
)
|
| 297 |
+
def test_can_use_list_tuples_for_params(test_input, expected_output):
|
| 298 |
+
request = AWSRequest(url='http://example.com/', params=test_input)
|
| 299 |
+
prepared_request = request.prepare()
|
| 300 |
+
assert prepared_request.url == expected_output
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
def test_empty_list_tuples_value_error_for_params():
|
| 304 |
+
request = AWSRequest(url='http://example.com/', params=[()])
|
| 305 |
+
with pytest.raises(ValueError):
|
| 306 |
+
request.prepare()
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
class TestAWSResponse(unittest.TestCase):
|
| 310 |
+
def setUp(self):
|
| 311 |
+
self.response = AWSResponse('http://url.com', 200, HeadersDict(), None)
|
| 312 |
+
self.response.raw = mock.Mock()
|
| 313 |
+
|
| 314 |
+
def set_raw_stream(self, blobs):
|
| 315 |
+
def stream(*args, **kwargs):
|
| 316 |
+
yield from blobs
|
| 317 |
+
|
| 318 |
+
self.response.raw.stream.return_value = stream()
|
| 319 |
+
|
| 320 |
+
def test_content_property(self):
|
| 321 |
+
self.set_raw_stream([b'some', b'data'])
|
| 322 |
+
self.assertEqual(self.response.content, b'somedata')
|
| 323 |
+
self.assertEqual(self.response.content, b'somedata')
|
| 324 |
+
# assert that stream was not called more than once
|
| 325 |
+
self.assertEqual(self.response.raw.stream.call_count, 1)
|
| 326 |
+
|
| 327 |
+
def test_text_property(self):
|
| 328 |
+
self.set_raw_stream([b'\xe3\x82\xb8\xe3\x83\xa7\xe3\x82\xb0'])
|
| 329 |
+
self.response.headers['content-type'] = 'text/plain; charset=utf-8'
|
| 330 |
+
self.assertEqual(self.response.text, '\u30b8\u30e7\u30b0')
|
| 331 |
+
|
| 332 |
+
def test_text_property_defaults_utf8(self):
|
| 333 |
+
self.set_raw_stream([b'\xe3\x82\xb8\xe3\x83\xa7\xe3\x82\xb0'])
|
| 334 |
+
self.assertEqual(self.response.text, '\u30b8\u30e7\u30b0')
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
class TestAWSHTTPConnection(unittest.TestCase):
|
| 338 |
+
def create_tunneled_connection(self, url, port, response):
|
| 339 |
+
s = FakeSocket(response)
|
| 340 |
+
conn = AWSHTTPConnection(url, port)
|
| 341 |
+
conn.sock = s
|
| 342 |
+
conn._tunnel_host = url
|
| 343 |
+
conn._tunnel_port = port
|
| 344 |
+
conn._tunnel_headers = {'key': 'value'}
|
| 345 |
+
|
| 346 |
+
# Create a mock response.
|
| 347 |
+
self.mock_response = mock.Mock()
|
| 348 |
+
self.mock_response.fp = mock.Mock()
|
| 349 |
+
|
| 350 |
+
# Imitate readline function by creating a list to be sent as
|
| 351 |
+
# a side effect of the mocked readline to be able to track how the
|
| 352 |
+
# response is processed in ``_tunnel()``.
|
| 353 |
+
delimeter = b'\r\n'
|
| 354 |
+
side_effect = []
|
| 355 |
+
response_components = response.split(delimeter)
|
| 356 |
+
for i in range(len(response_components)):
|
| 357 |
+
new_component = response_components[i]
|
| 358 |
+
# Only add the delimeter on if it is not the last component
|
| 359 |
+
# which should be an empty string.
|
| 360 |
+
if i != len(response_components) - 1:
|
| 361 |
+
new_component += delimeter
|
| 362 |
+
side_effect.append(new_component)
|
| 363 |
+
|
| 364 |
+
self.mock_response.fp.readline.side_effect = side_effect
|
| 365 |
+
|
| 366 |
+
response_components = response.split(b' ')
|
| 367 |
+
self.mock_response._read_status.return_value = (
|
| 368 |
+
response_components[0],
|
| 369 |
+
int(response_components[1]),
|
| 370 |
+
response_components[2],
|
| 371 |
+
)
|
| 372 |
+
conn.response_class = mock.Mock()
|
| 373 |
+
conn.response_class.return_value = self.mock_response
|
| 374 |
+
return conn
|
| 375 |
+
|
| 376 |
+
def test_expect_100_continue_returned(self):
|
| 377 |
+
with mock.patch('urllib3.util.wait_for_read') as wait_mock:
|
| 378 |
+
# Shows the server first sending a 100 continue response
|
| 379 |
+
# then a 200 ok response.
|
| 380 |
+
s = FakeSocket(b'HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK\r\n')
|
| 381 |
+
conn = AWSHTTPConnection('s3.amazonaws.com', 443)
|
| 382 |
+
conn.sock = s
|
| 383 |
+
wait_mock.return_value = True
|
| 384 |
+
conn.request(
|
| 385 |
+
'GET', '/bucket/foo', b'body', {'Expect': b'100-continue'}
|
| 386 |
+
)
|
| 387 |
+
response = conn.getresponse()
|
| 388 |
+
# Assert that we waited for the 100-continue response
|
| 389 |
+
self.assertEqual(wait_mock.call_count, 1)
|
| 390 |
+
# Now we should verify that our final response is the 200 OK
|
| 391 |
+
self.assertEqual(response.status, 200)
|
| 392 |
+
|
| 393 |
+
def test_handles_expect_100_with_different_reason_phrase(self):
|
| 394 |
+
with mock.patch('urllib3.util.wait_for_read') as wait_mock:
|
| 395 |
+
# Shows the server first sending a 100 continue response
|
| 396 |
+
# then a 200 ok response.
|
| 397 |
+
s = FakeSocket(
|
| 398 |
+
b'HTTP/1.1 100 (Continue)\r\n\r\nHTTP/1.1 200 OK\r\n'
|
| 399 |
+
)
|
| 400 |
+
conn = AWSHTTPConnection('s3.amazonaws.com', 443)
|
| 401 |
+
conn.sock = s
|
| 402 |
+
wait_mock.return_value = True
|
| 403 |
+
conn.request(
|
| 404 |
+
'GET',
|
| 405 |
+
'/bucket/foo',
|
| 406 |
+
io.BytesIO(b'body'),
|
| 407 |
+
{'Expect': b'100-continue', 'Content-Length': b'4'},
|
| 408 |
+
)
|
| 409 |
+
response = conn.getresponse()
|
| 410 |
+
# Now we should verify that our final response is the 200 OK.
|
| 411 |
+
self.assertEqual(response.status, 200)
|
| 412 |
+
# Assert that we waited for the 100-continue response
|
| 413 |
+
self.assertEqual(wait_mock.call_count, 1)
|
| 414 |
+
# Verify that we went the request body because we got a 100
|
| 415 |
+
# continue.
|
| 416 |
+
self.assertIn(b'body', s.sent_data)
|
| 417 |
+
|
| 418 |
+
def test_expect_100_sends_connection_header(self):
|
| 419 |
+
# When using squid as an HTTP proxy, it will also send
|
| 420 |
+
# a Connection: keep-alive header back with the 100 continue
|
| 421 |
+
# response. We need to ensure we handle this case.
|
| 422 |
+
with mock.patch('urllib3.util.wait_for_read') as wait_mock:
|
| 423 |
+
# Shows the server first sending a 100 continue response
|
| 424 |
+
# then a 500 response. We're picking 500 to confirm we
|
| 425 |
+
# actually parse the response instead of getting the
|
| 426 |
+
# default status of 200 which happens when we can't parse
|
| 427 |
+
# the response.
|
| 428 |
+
s = FakeSocket(
|
| 429 |
+
b'HTTP/1.1 100 Continue\r\n'
|
| 430 |
+
b'Connection: keep-alive\r\n'
|
| 431 |
+
b'\r\n'
|
| 432 |
+
b'HTTP/1.1 500 Internal Service Error\r\n'
|
| 433 |
+
)
|
| 434 |
+
conn = AWSHTTPConnection('s3.amazonaws.com', 443)
|
| 435 |
+
conn.sock = s
|
| 436 |
+
wait_mock.return_value = True
|
| 437 |
+
conn.request(
|
| 438 |
+
'GET', '/bucket/foo', b'body', {'Expect': b'100-continue'}
|
| 439 |
+
)
|
| 440 |
+
# Assert that we waited for the 100-continue response
|
| 441 |
+
self.assertEqual(wait_mock.call_count, 1)
|
| 442 |
+
response = conn.getresponse()
|
| 443 |
+
self.assertEqual(response.status, 500)
|
| 444 |
+
|
| 445 |
+
def test_expect_100_continue_sends_307(self):
|
| 446 |
+
# This is the case where we send a 100 continue and the server
|
| 447 |
+
# immediately sends a 307
|
| 448 |
+
with mock.patch('urllib3.util.wait_for_read') as wait_mock:
|
| 449 |
+
# Shows the server first sending a 100 continue response
|
| 450 |
+
# then a 200 ok response.
|
| 451 |
+
s = FakeSocket(
|
| 452 |
+
b'HTTP/1.1 307 Temporary Redirect\r\n'
|
| 453 |
+
b'Location: http://example.org\r\n'
|
| 454 |
+
)
|
| 455 |
+
conn = AWSHTTPConnection('s3.amazonaws.com', 443)
|
| 456 |
+
conn.sock = s
|
| 457 |
+
wait_mock.return_value = True
|
| 458 |
+
conn.request(
|
| 459 |
+
'GET', '/bucket/foo', b'body', {'Expect': b'100-continue'}
|
| 460 |
+
)
|
| 461 |
+
# Assert that we waited for the 100-continue response
|
| 462 |
+
self.assertEqual(wait_mock.call_count, 1)
|
| 463 |
+
response = conn.getresponse()
|
| 464 |
+
# Now we should verify that our final response is the 307.
|
| 465 |
+
self.assertEqual(response.status, 307)
|
| 466 |
+
|
| 467 |
+
def test_expect_100_continue_no_response_from_server(self):
|
| 468 |
+
with mock.patch('urllib3.util.wait_for_read') as wait_mock:
|
| 469 |
+
# Shows the server first sending a 100 continue response
|
| 470 |
+
# then a 200 ok response.
|
| 471 |
+
s = FakeSocket(
|
| 472 |
+
b'HTTP/1.1 307 Temporary Redirect\r\n'
|
| 473 |
+
b'Location: http://example.org\r\n'
|
| 474 |
+
)
|
| 475 |
+
conn = AWSHTTPConnection('s3.amazonaws.com', 443)
|
| 476 |
+
conn.sock = s
|
| 477 |
+
# By settings wait_mock to return False, this indicates
|
| 478 |
+
# that the server did not send any response. In this situation
|
| 479 |
+
# we should just send the request anyways.
|
| 480 |
+
wait_mock.return_value = False
|
| 481 |
+
conn.request(
|
| 482 |
+
'GET', '/bucket/foo', b'body', {'Expect': b'100-continue'}
|
| 483 |
+
)
|
| 484 |
+
# Assert that we waited for the 100-continue response
|
| 485 |
+
self.assertEqual(wait_mock.call_count, 1)
|
| 486 |
+
response = conn.getresponse()
|
| 487 |
+
self.assertEqual(response.status, 307)
|
| 488 |
+
|
| 489 |
+
def test_message_body_is_file_like_object(self):
|
| 490 |
+
# Shows the server first sending a 100 continue response
|
| 491 |
+
# then a 200 ok response.
|
| 492 |
+
body = BytesIOWithLen(b'body contents')
|
| 493 |
+
s = FakeSocket(b'HTTP/1.1 200 OK\r\n')
|
| 494 |
+
conn = AWSHTTPConnection('s3.amazonaws.com', 443)
|
| 495 |
+
conn.sock = s
|
| 496 |
+
conn.request('GET', '/bucket/foo', body)
|
| 497 |
+
response = conn.getresponse()
|
| 498 |
+
self.assertEqual(response.status, 200)
|
| 499 |
+
|
| 500 |
+
def test_no_expect_header_set(self):
|
| 501 |
+
# Shows the server first sending a 100 continue response
|
| 502 |
+
# then a 200 ok response.
|
| 503 |
+
s = FakeSocket(b'HTTP/1.1 200 OK\r\n')
|
| 504 |
+
conn = AWSHTTPConnection('s3.amazonaws.com', 443)
|
| 505 |
+
conn.sock = s
|
| 506 |
+
conn.request('GET', '/bucket/foo', b'body')
|
| 507 |
+
response = conn.getresponse()
|
| 508 |
+
self.assertEqual(response.status, 200)
|
| 509 |
+
|
| 510 |
+
def test_tunnel_readline_none_bugfix(self):
|
| 511 |
+
# Tests whether ``_tunnel`` function is able to work around the
|
| 512 |
+
# py26 bug of avoiding infinite while loop if nothing is returned.
|
| 513 |
+
conn = self.create_tunneled_connection(
|
| 514 |
+
url='s3.amazonaws.com',
|
| 515 |
+
port=443,
|
| 516 |
+
response=b'HTTP/1.1 200 OK\r\n',
|
| 517 |
+
)
|
| 518 |
+
conn._tunnel()
|
| 519 |
+
# Ensure proper amount of readline calls were made.
|
| 520 |
+
self.assertEqual(self.mock_response.fp.readline.call_count, 2)
|
| 521 |
+
|
| 522 |
+
def test_tunnel_readline_normal(self):
|
| 523 |
+
# Tests that ``_tunnel`` function behaves normally when it comes
|
| 524 |
+
# across the usual http ending.
|
| 525 |
+
conn = self.create_tunneled_connection(
|
| 526 |
+
url='s3.amazonaws.com',
|
| 527 |
+
port=443,
|
| 528 |
+
response=b'HTTP/1.1 200 OK\r\n\r\n',
|
| 529 |
+
)
|
| 530 |
+
conn._tunnel()
|
| 531 |
+
# Ensure proper amount of readline calls were made.
|
| 532 |
+
self.assertEqual(self.mock_response.fp.readline.call_count, 2)
|
| 533 |
+
|
| 534 |
+
def test_tunnel_raises_socket_error(self):
|
| 535 |
+
# Tests that ``_tunnel`` function throws appropriate error when
|
| 536 |
+
# not 200 status.
|
| 537 |
+
conn = self.create_tunneled_connection(
|
| 538 |
+
url='s3.amazonaws.com',
|
| 539 |
+
port=443,
|
| 540 |
+
response=b'HTTP/1.1 404 Not Found\r\n\r\n',
|
| 541 |
+
)
|
| 542 |
+
with self.assertRaises(socket.error):
|
| 543 |
+
conn._tunnel()
|
| 544 |
+
|
| 545 |
+
def test_tunnel_uses_std_lib(self):
|
| 546 |
+
s = FakeSocket(b'HTTP/1.1 200 OK\r\n')
|
| 547 |
+
conn = AWSHTTPConnection('s3.amazonaws.com', 443)
|
| 548 |
+
conn.sock = s
|
| 549 |
+
# Test that the standard library method was used by patching out
|
| 550 |
+
# the ``_tunnel`` method and seeing if the std lib method was called.
|
| 551 |
+
with mock.patch(
|
| 552 |
+
'urllib3.connection.HTTPConnection._tunnel'
|
| 553 |
+
) as mock_tunnel:
|
| 554 |
+
conn._tunnel()
|
| 555 |
+
self.assertTrue(mock_tunnel.called)
|
| 556 |
+
|
| 557 |
+
def test_encodes_unicode_method_line(self):
|
| 558 |
+
s = FakeSocket(b'HTTP/1.1 200 OK\r\n')
|
| 559 |
+
conn = AWSHTTPConnection('s3.amazonaws.com', 443)
|
| 560 |
+
conn.sock = s
|
| 561 |
+
# Note the combination of unicode 'GET' and
|
| 562 |
+
# bytes 'Utf8-Header' value.
|
| 563 |
+
conn.request(
|
| 564 |
+
'GET',
|
| 565 |
+
'/bucket/foo',
|
| 566 |
+
b'body',
|
| 567 |
+
headers={"Utf8-Header": b"\xe5\xb0\x8f"},
|
| 568 |
+
)
|
| 569 |
+
response = conn.getresponse()
|
| 570 |
+
self.assertEqual(response.status, 200)
|
| 571 |
+
|
| 572 |
+
def test_state_reset_on_connection_close(self):
|
| 573 |
+
# This simulates what urllib3 does with connections
|
| 574 |
+
# in its connection pool logic.
|
| 575 |
+
with mock.patch('urllib3.util.wait_for_read') as wait_mock:
|
| 576 |
+
# First fast fail with a 500 response when we first
|
| 577 |
+
# send the expect header.
|
| 578 |
+
s = FakeSocket(b'HTTP/1.1 500 Internal Server Error\r\n')
|
| 579 |
+
conn = AWSHTTPConnection('s3.amazonaws.com', 443)
|
| 580 |
+
conn.sock = s
|
| 581 |
+
wait_mock.return_value = True
|
| 582 |
+
|
| 583 |
+
conn.request(
|
| 584 |
+
'GET', '/bucket/foo', b'body', {'Expect': b'100-continue'}
|
| 585 |
+
)
|
| 586 |
+
self.assertEqual(wait_mock.call_count, 1)
|
| 587 |
+
response = conn.getresponse()
|
| 588 |
+
self.assertEqual(response.status, 500)
|
| 589 |
+
|
| 590 |
+
# Now what happens in urllib3 is that when the next
|
| 591 |
+
# request comes along and this conection gets checked
|
| 592 |
+
# out. We see that the connection needs to be
|
| 593 |
+
# reset. So first the connection is closed.
|
| 594 |
+
conn.close()
|
| 595 |
+
|
| 596 |
+
# And then a new connection is established.
|
| 597 |
+
new_conn = FakeSocket(
|
| 598 |
+
b'HTTP/1.1 100 (Continue)\r\n\r\nHTTP/1.1 200 OK\r\n'
|
| 599 |
+
)
|
| 600 |
+
conn.sock = new_conn
|
| 601 |
+
|
| 602 |
+
# And we make a request, we should see the 200 response
|
| 603 |
+
# that was sent back.
|
| 604 |
+
wait_mock.return_value = True
|
| 605 |
+
|
| 606 |
+
conn.request(
|
| 607 |
+
'GET', '/bucket/foo', b'body', {'Expect': b'100-continue'}
|
| 608 |
+
)
|
| 609 |
+
# Assert that we waited for the 100-continue response
|
| 610 |
+
self.assertEqual(wait_mock.call_count, 2)
|
| 611 |
+
response = conn.getresponse()
|
| 612 |
+
# This should be 200. If it's a 500 then
|
| 613 |
+
# the prior response was leaking into our
|
| 614 |
+
# current response.,
|
| 615 |
+
self.assertEqual(response.status, 200)
|
| 616 |
+
|
| 617 |
+
|
| 618 |
+
class TestAWSHTTPConnectionPool(unittest.TestCase):
|
| 619 |
+
def test_global_urllib3_pool_is_unchanged(self):
|
| 620 |
+
http_connection_class = HTTPConnectionPool.ConnectionCls
|
| 621 |
+
self.assertIsNot(http_connection_class, AWSHTTPConnection)
|
| 622 |
+
https_connection_class = HTTPSConnectionPool.ConnectionCls
|
| 623 |
+
self.assertIsNot(https_connection_class, AWSHTTPSConnection)
|
| 624 |
+
|
| 625 |
+
|
| 626 |
+
class TestPrepareRequestDict(unittest.TestCase):
|
| 627 |
+
def setUp(self):
|
| 628 |
+
self.user_agent = 'botocore/1.0'
|
| 629 |
+
self.endpoint_url = 'https://s3.amazonaws.com'
|
| 630 |
+
self.base_request_dict = {
|
| 631 |
+
'body': '',
|
| 632 |
+
'headers': {},
|
| 633 |
+
'method': 'GET',
|
| 634 |
+
'query_string': '',
|
| 635 |
+
'url_path': '/',
|
| 636 |
+
'context': {},
|
| 637 |
+
}
|
| 638 |
+
|
| 639 |
+
def prepare_base_request_dict(
|
| 640 |
+
self, request_dict, endpoint_url=None, user_agent=None, context=None
|
| 641 |
+
):
|
| 642 |
+
self.base_request_dict.update(request_dict)
|
| 643 |
+
context = context or {}
|
| 644 |
+
if user_agent is None:
|
| 645 |
+
user_agent = self.user_agent
|
| 646 |
+
if endpoint_url is None:
|
| 647 |
+
endpoint_url = self.endpoint_url
|
| 648 |
+
prepare_request_dict(
|
| 649 |
+
self.base_request_dict,
|
| 650 |
+
endpoint_url=endpoint_url,
|
| 651 |
+
user_agent=user_agent,
|
| 652 |
+
context=context,
|
| 653 |
+
)
|
| 654 |
+
|
| 655 |
+
def test_prepare_request_dict_for_get(self):
|
| 656 |
+
request_dict = {'method': 'GET', 'url_path': '/'}
|
| 657 |
+
self.prepare_base_request_dict(
|
| 658 |
+
request_dict, endpoint_url='https://s3.amazonaws.com'
|
| 659 |
+
)
|
| 660 |
+
self.assertEqual(self.base_request_dict['method'], 'GET')
|
| 661 |
+
self.assertEqual(
|
| 662 |
+
self.base_request_dict['url'], 'https://s3.amazonaws.com/'
|
| 663 |
+
)
|
| 664 |
+
self.assertEqual(
|
| 665 |
+
self.base_request_dict['headers']['User-Agent'], self.user_agent
|
| 666 |
+
)
|
| 667 |
+
|
| 668 |
+
def test_prepare_request_dict_for_get_no_user_agent(self):
|
| 669 |
+
self.user_agent = None
|
| 670 |
+
request_dict = {'method': 'GET', 'url_path': '/'}
|
| 671 |
+
self.prepare_base_request_dict(
|
| 672 |
+
request_dict, endpoint_url='https://s3.amazonaws.com'
|
| 673 |
+
)
|
| 674 |
+
self.assertNotIn('User-Agent', self.base_request_dict['headers'])
|
| 675 |
+
|
| 676 |
+
def test_prepare_request_dict_with_context(self):
|
| 677 |
+
context = {'foo': 'bar'}
|
| 678 |
+
self.prepare_base_request_dict({}, context=context)
|
| 679 |
+
self.assertEqual(self.base_request_dict['context'], context)
|
| 680 |
+
|
| 681 |
+
def test_query_string_serialized_to_url(self):
|
| 682 |
+
request_dict = {
|
| 683 |
+
'method': 'GET',
|
| 684 |
+
'query_string': {'prefix': 'foo'},
|
| 685 |
+
'url_path': '/mybucket',
|
| 686 |
+
}
|
| 687 |
+
self.prepare_base_request_dict(request_dict)
|
| 688 |
+
self.assertEqual(
|
| 689 |
+
self.base_request_dict['url'],
|
| 690 |
+
'https://s3.amazonaws.com/mybucket?prefix=foo',
|
| 691 |
+
)
|
| 692 |
+
|
| 693 |
+
def test_url_path_combined_with_endpoint_url(self):
|
| 694 |
+
# This checks the case where a user specifies and
|
| 695 |
+
# endpoint_url that has a path component, and the
|
| 696 |
+
# serializer gives us a request_dict that has a url
|
| 697 |
+
# component as well (say from a rest-* service).
|
| 698 |
+
request_dict = {
|
| 699 |
+
'query_string': {'prefix': 'foo'},
|
| 700 |
+
'url_path': '/mybucket',
|
| 701 |
+
}
|
| 702 |
+
endpoint_url = 'https://custom.endpoint/foo/bar'
|
| 703 |
+
self.prepare_base_request_dict(request_dict, endpoint_url)
|
| 704 |
+
self.assertEqual(
|
| 705 |
+
self.base_request_dict['url'],
|
| 706 |
+
'https://custom.endpoint/foo/bar/mybucket?prefix=foo',
|
| 707 |
+
)
|
| 708 |
+
|
| 709 |
+
def test_url_path_with_trailing_slash(self):
|
| 710 |
+
self.prepare_base_request_dict(
|
| 711 |
+
{'url_path': '/mybucket'},
|
| 712 |
+
endpoint_url='https://custom.endpoint/foo/bar/',
|
| 713 |
+
)
|
| 714 |
+
|
| 715 |
+
self.assertEqual(
|
| 716 |
+
self.base_request_dict['url'],
|
| 717 |
+
'https://custom.endpoint/foo/bar/mybucket',
|
| 718 |
+
)
|
| 719 |
+
|
| 720 |
+
def test_url_path_is_slash(self):
|
| 721 |
+
self.prepare_base_request_dict(
|
| 722 |
+
{'url_path': '/'}, endpoint_url='https://custom.endpoint/foo/bar/'
|
| 723 |
+
)
|
| 724 |
+
|
| 725 |
+
self.assertEqual(
|
| 726 |
+
self.base_request_dict['url'], 'https://custom.endpoint/foo/bar/'
|
| 727 |
+
)
|
| 728 |
+
|
| 729 |
+
def test_url_path_is_slash_with_endpoint_url_no_slash(self):
|
| 730 |
+
self.prepare_base_request_dict(
|
| 731 |
+
{'url_path': '/'}, endpoint_url='https://custom.endpoint/foo/bar'
|
| 732 |
+
)
|
| 733 |
+
|
| 734 |
+
self.assertEqual(
|
| 735 |
+
self.base_request_dict['url'], 'https://custom.endpoint/foo/bar'
|
| 736 |
+
)
|
| 737 |
+
|
| 738 |
+
def test_custom_endpoint_with_query_string(self):
|
| 739 |
+
self.prepare_base_request_dict(
|
| 740 |
+
{'url_path': '/baz', 'query_string': {'x': 'y'}},
|
| 741 |
+
endpoint_url='https://custom.endpoint/foo/bar?foo=bar',
|
| 742 |
+
)
|
| 743 |
+
|
| 744 |
+
self.assertEqual(
|
| 745 |
+
self.base_request_dict['url'],
|
| 746 |
+
'https://custom.endpoint/foo/bar/baz?foo=bar&x=y',
|
| 747 |
+
)
|
| 748 |
+
|
| 749 |
+
|
| 750 |
+
class TestCreateRequestObject(unittest.TestCase):
|
| 751 |
+
def setUp(self):
|
| 752 |
+
self.request_dict = {
|
| 753 |
+
'method': 'GET',
|
| 754 |
+
'query_string': {'prefix': 'foo'},
|
| 755 |
+
'url_path': '/mybucket',
|
| 756 |
+
'headers': {'User-Agent': 'my-agent'},
|
| 757 |
+
'body': 'my body',
|
| 758 |
+
'url': 'https://s3.amazonaws.com/mybucket?prefix=foo',
|
| 759 |
+
'context': {'signing': {'region': 'us-west-2'}},
|
| 760 |
+
}
|
| 761 |
+
|
| 762 |
+
def test_create_request_object(self):
|
| 763 |
+
request = create_request_object(self.request_dict)
|
| 764 |
+
self.assertEqual(request.method, self.request_dict['method'])
|
| 765 |
+
self.assertEqual(request.url, self.request_dict['url'])
|
| 766 |
+
self.assertEqual(request.data, self.request_dict['body'])
|
| 767 |
+
self.assertEqual(request.context, self.request_dict['context'])
|
| 768 |
+
self.assertIn('User-Agent', request.headers)
|
| 769 |
+
|
| 770 |
+
|
| 771 |
+
class TestHeadersDict(unittest.TestCase):
|
| 772 |
+
def setUp(self):
|
| 773 |
+
self.headers = HeadersDict()
|
| 774 |
+
|
| 775 |
+
def test_get_insensitive(self):
|
| 776 |
+
self.headers['foo'] = 'bar'
|
| 777 |
+
self.assertEqual(self.headers['FOO'], 'bar')
|
| 778 |
+
|
| 779 |
+
def test_set_insensitive(self):
|
| 780 |
+
self.headers['foo'] = 'bar'
|
| 781 |
+
self.headers['FOO'] = 'baz'
|
| 782 |
+
self.assertEqual(self.headers['foo'], 'baz')
|
| 783 |
+
|
| 784 |
+
def test_del_insensitive(self):
|
| 785 |
+
self.headers['foo'] = 'bar'
|
| 786 |
+
self.assertEqual(self.headers['FOO'], 'bar')
|
| 787 |
+
del self.headers['FoO']
|
| 788 |
+
with self.assertRaises(KeyError):
|
| 789 |
+
self.headers['foo']
|
| 790 |
+
|
| 791 |
+
def test_iteration(self):
|
| 792 |
+
self.headers['FOO'] = 'bar'
|
| 793 |
+
self.headers['dead'] = 'beef'
|
| 794 |
+
self.assertIn('FOO', list(self.headers))
|
| 795 |
+
self.assertIn('dead', list(self.headers))
|
| 796 |
+
headers_items = list(self.headers.items())
|
| 797 |
+
self.assertIn(('FOO', 'bar'), headers_items)
|
| 798 |
+
self.assertIn(('dead', 'beef'), headers_items)
|
| 799 |
+
|
| 800 |
+
|
| 801 |
+
if __name__ == "__main__":
|
| 802 |
+
unittest.main()
|
testbed/boto__botocore/tests/unit/test_client.py
ADDED
|
@@ -0,0 +1,2368 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 4 |
+
# may not use this file except in compliance with the License. A copy of
|
| 5 |
+
# the License is located at
|
| 6 |
+
#
|
| 7 |
+
# http://aws.amazon.com/apache2.0/
|
| 8 |
+
#
|
| 9 |
+
# or in the "license" file accompanying this file. This file is
|
| 10 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 11 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 12 |
+
# language governing permissions and limitations under the License.
|
| 13 |
+
import io
|
| 14 |
+
from contextlib import closing
|
| 15 |
+
|
| 16 |
+
import botocore
|
| 17 |
+
import botocore.config
|
| 18 |
+
from botocore import client, exceptions, hooks
|
| 19 |
+
from botocore.auth import AUTH_TYPE_MAPS, BaseSigner
|
| 20 |
+
from botocore.client import ClientEndpointBridge
|
| 21 |
+
from botocore.configprovider import (
|
| 22 |
+
ChainProvider,
|
| 23 |
+
ConfigValueStore,
|
| 24 |
+
EnvironmentProvider,
|
| 25 |
+
)
|
| 26 |
+
from botocore.credentials import Credentials
|
| 27 |
+
from botocore.endpoint import DEFAULT_TIMEOUT
|
| 28 |
+
from botocore.errorfactory import ClientExceptionsFactory
|
| 29 |
+
from botocore.exceptions import (
|
| 30 |
+
InvalidMaxRetryAttemptsError,
|
| 31 |
+
InvalidRetryConfigurationError,
|
| 32 |
+
InvalidRetryModeError,
|
| 33 |
+
InvalidS3AddressingStyleError,
|
| 34 |
+
ParamValidationError,
|
| 35 |
+
UnknownSignatureVersionError,
|
| 36 |
+
)
|
| 37 |
+
from botocore.stub import Stubber
|
| 38 |
+
from botocore.useragent import UserAgentString
|
| 39 |
+
from tests import mock, unittest
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class TestAutoGeneratedClient(unittest.TestCase):
|
| 43 |
+
def setUp(self):
|
| 44 |
+
self.service_description = {
|
| 45 |
+
'metadata': {
|
| 46 |
+
'serviceFullName': 'AWS MyService',
|
| 47 |
+
'apiVersion': '2014-01-01',
|
| 48 |
+
'endpointPrefix': 'myservice',
|
| 49 |
+
'signatureVersion': 'v4',
|
| 50 |
+
'protocol': 'query',
|
| 51 |
+
'serviceId': 'MyService',
|
| 52 |
+
},
|
| 53 |
+
'operations': {
|
| 54 |
+
'TestOperation': {
|
| 55 |
+
'name': 'TestOperation',
|
| 56 |
+
'http': {
|
| 57 |
+
'method': 'POST',
|
| 58 |
+
'requestUri': '/',
|
| 59 |
+
},
|
| 60 |
+
'input': {'shape': 'TestOperationRequest'},
|
| 61 |
+
'errors': [{'shape': 'TestOperationException'}],
|
| 62 |
+
'documentation': 'Documents TestOperation',
|
| 63 |
+
}
|
| 64 |
+
},
|
| 65 |
+
'shapes': {
|
| 66 |
+
'TestOperationRequest': {
|
| 67 |
+
'type': 'structure',
|
| 68 |
+
'required': ['Foo'],
|
| 69 |
+
'members': {
|
| 70 |
+
'Foo': {
|
| 71 |
+
'shape': 'StringType',
|
| 72 |
+
'documentation': 'Documents Foo',
|
| 73 |
+
},
|
| 74 |
+
'Bar': {
|
| 75 |
+
'shape': 'StringType',
|
| 76 |
+
'documentation': 'Documents Bar',
|
| 77 |
+
},
|
| 78 |
+
},
|
| 79 |
+
},
|
| 80 |
+
"TestOperationException": {
|
| 81 |
+
'type': 'structure',
|
| 82 |
+
'exception': True,
|
| 83 |
+
'error': {'code': 'TestOperationErrorCode'},
|
| 84 |
+
},
|
| 85 |
+
'StringType': {'type': 'string'},
|
| 86 |
+
},
|
| 87 |
+
}
|
| 88 |
+
self.endpoint_ruleset = {
|
| 89 |
+
"version": "1.0",
|
| 90 |
+
"parameters": {},
|
| 91 |
+
"rules": [
|
| 92 |
+
{
|
| 93 |
+
"conditions": [],
|
| 94 |
+
"type": "endpoint",
|
| 95 |
+
"endpoint": {
|
| 96 |
+
"url": "https://foo.bar",
|
| 97 |
+
"properties": {},
|
| 98 |
+
"headers": {},
|
| 99 |
+
},
|
| 100 |
+
}
|
| 101 |
+
],
|
| 102 |
+
}
|
| 103 |
+
self.retry_config = {
|
| 104 |
+
"retry": {
|
| 105 |
+
"__default__": {
|
| 106 |
+
"max_attempts": 5,
|
| 107 |
+
"delay": {
|
| 108 |
+
"type": "exponential",
|
| 109 |
+
"base": "rand",
|
| 110 |
+
"growth_factor": 2,
|
| 111 |
+
},
|
| 112 |
+
"policies": {},
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
def load_service_mock(*args, **kwargs):
|
| 118 |
+
if args[1] == "service-2":
|
| 119 |
+
return self.service_description
|
| 120 |
+
|
| 121 |
+
self.loader = mock.Mock()
|
| 122 |
+
self.loader.load_service_model.side_effect = load_service_mock
|
| 123 |
+
self.loader.load_data.return_value = self.retry_config
|
| 124 |
+
|
| 125 |
+
self.credentials = Credentials('access-key', 'secret-key')
|
| 126 |
+
|
| 127 |
+
self.endpoint_creator_patch = mock.patch(
|
| 128 |
+
'botocore.args.EndpointCreator'
|
| 129 |
+
)
|
| 130 |
+
self.endpoint_creator_cls = self.endpoint_creator_patch.start()
|
| 131 |
+
self.endpoint_creator = self.endpoint_creator_cls.return_value
|
| 132 |
+
|
| 133 |
+
self.endpoint = mock.Mock()
|
| 134 |
+
self.endpoint.host = 'https://myservice.amazonaws.com'
|
| 135 |
+
self.endpoint.make_request.return_value = (
|
| 136 |
+
mock.Mock(status_code=200),
|
| 137 |
+
{},
|
| 138 |
+
)
|
| 139 |
+
self.endpoint_creator.create_endpoint.return_value = self.endpoint
|
| 140 |
+
|
| 141 |
+
self.resolver = mock.Mock()
|
| 142 |
+
self.endpoint_data = {
|
| 143 |
+
'partition': 'aws',
|
| 144 |
+
'hostname': 'foo',
|
| 145 |
+
'endpointName': 'us-west-2',
|
| 146 |
+
'signatureVersions': ['v4'],
|
| 147 |
+
}
|
| 148 |
+
self.resolver.construct_endpoint.return_value = self.endpoint_data
|
| 149 |
+
self.resolver.get_available_endpoints.return_value = ['us-west-2']
|
| 150 |
+
self.config_store = ConfigValueStore()
|
| 151 |
+
|
| 152 |
+
def tearDown(self):
|
| 153 |
+
self.endpoint_creator_patch.stop()
|
| 154 |
+
|
| 155 |
+
def create_mock_emitter(self, responses=None):
|
| 156 |
+
if responses is None:
|
| 157 |
+
responses = []
|
| 158 |
+
|
| 159 |
+
emitter = mock.Mock()
|
| 160 |
+
emitter.emit.return_value = responses
|
| 161 |
+
return emitter
|
| 162 |
+
|
| 163 |
+
def create_client_creator(
|
| 164 |
+
self,
|
| 165 |
+
endpoint_creator=None,
|
| 166 |
+
event_emitter=None,
|
| 167 |
+
retry_handler_factory=None,
|
| 168 |
+
retry_config_translator=None,
|
| 169 |
+
response_parser_factory=None,
|
| 170 |
+
endpoint_prefix=None,
|
| 171 |
+
exceptions_factory=None,
|
| 172 |
+
config_store=None,
|
| 173 |
+
user_agent_creator=None,
|
| 174 |
+
):
|
| 175 |
+
if event_emitter is None:
|
| 176 |
+
event_emitter = hooks.HierarchicalEmitter()
|
| 177 |
+
if retry_handler_factory is None:
|
| 178 |
+
retry_handler_factory = botocore.retryhandler
|
| 179 |
+
if retry_config_translator is None:
|
| 180 |
+
retry_config_translator = botocore.translate
|
| 181 |
+
if endpoint_prefix is not None:
|
| 182 |
+
self.service_description['metadata']['endpointPrefix'] = (
|
| 183 |
+
endpoint_prefix
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
if endpoint_creator is not None:
|
| 187 |
+
self.endpoint_creator_cls.return_value = endpoint_creator
|
| 188 |
+
if exceptions_factory is None:
|
| 189 |
+
exceptions_factory = ClientExceptionsFactory()
|
| 190 |
+
if config_store is None:
|
| 191 |
+
config_store = self.config_store
|
| 192 |
+
if user_agent_creator is None:
|
| 193 |
+
user_agent_creator = (
|
| 194 |
+
UserAgentString.from_environment().set_session_config(
|
| 195 |
+
session_user_agent_name='MyUserAgent',
|
| 196 |
+
session_user_agent_version='1.2.3-rc5',
|
| 197 |
+
session_user_agent_extra=None,
|
| 198 |
+
)
|
| 199 |
+
)
|
| 200 |
+
creator = client.ClientCreator(
|
| 201 |
+
self.loader,
|
| 202 |
+
self.resolver,
|
| 203 |
+
'user-agent',
|
| 204 |
+
event_emitter,
|
| 205 |
+
retry_handler_factory,
|
| 206 |
+
retry_config_translator,
|
| 207 |
+
response_parser_factory,
|
| 208 |
+
exceptions_factory,
|
| 209 |
+
config_store,
|
| 210 |
+
user_agent_creator,
|
| 211 |
+
)
|
| 212 |
+
return creator
|
| 213 |
+
|
| 214 |
+
def assert_no_param_error_raised(self, client):
|
| 215 |
+
try:
|
| 216 |
+
self.make_api_call_with_missing_param(client)
|
| 217 |
+
except ParamValidationError:
|
| 218 |
+
self.fail(
|
| 219 |
+
"ParamValidationError shouldn't be raised "
|
| 220 |
+
"with validation disabled"
|
| 221 |
+
)
|
| 222 |
+
|
| 223 |
+
def make_api_call_with_missing_param(self, service_client):
|
| 224 |
+
# Missing required 'Foo' param.
|
| 225 |
+
service_client.test_operation(Bar='two')
|
| 226 |
+
|
| 227 |
+
def test_client_name(self):
|
| 228 |
+
creator = self.create_client_creator()
|
| 229 |
+
service_client = creator.create_client(
|
| 230 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 231 |
+
)
|
| 232 |
+
self.assertTrue(service_client.__class__.__name__, 'MyService')
|
| 233 |
+
|
| 234 |
+
def test_client_name_with_amazon(self):
|
| 235 |
+
self.service_description['metadata']['serviceFullName'] = (
|
| 236 |
+
'Amazon MyService'
|
| 237 |
+
)
|
| 238 |
+
creator = self.create_client_creator()
|
| 239 |
+
service_client = creator.create_client(
|
| 240 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 241 |
+
)
|
| 242 |
+
self.assertTrue(service_client.__class__.__name__, 'MyService')
|
| 243 |
+
|
| 244 |
+
def test_client_name_using_abreviation(self):
|
| 245 |
+
self.service_description['metadata']['serviceAbbreviation'] = (
|
| 246 |
+
'Abbreviation'
|
| 247 |
+
)
|
| 248 |
+
creator = self.create_client_creator()
|
| 249 |
+
service_client = creator.create_client(
|
| 250 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 251 |
+
)
|
| 252 |
+
self.assertTrue(service_client.__class__.__name__, 'Abbreviation')
|
| 253 |
+
|
| 254 |
+
def test_client_name_with_non_alphabet_characters(self):
|
| 255 |
+
self.service_description['metadata']['serviceFullName'] = (
|
| 256 |
+
'Amazon My-Service'
|
| 257 |
+
)
|
| 258 |
+
creator = self.create_client_creator()
|
| 259 |
+
service_client = creator.create_client(
|
| 260 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 261 |
+
)
|
| 262 |
+
self.assertTrue(service_client.__class__.__name__, 'MyService')
|
| 263 |
+
|
| 264 |
+
def test_client_name_with_no_full_name_or_abbreviation(self):
|
| 265 |
+
del self.service_description['metadata']['serviceFullName']
|
| 266 |
+
creator = self.create_client_creator()
|
| 267 |
+
service_client = creator.create_client(
|
| 268 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 269 |
+
)
|
| 270 |
+
self.assertTrue(service_client.__class__.__name__, 'myservice')
|
| 271 |
+
|
| 272 |
+
def test_client_generated_from_model(self):
|
| 273 |
+
creator = self.create_client_creator()
|
| 274 |
+
service_client = creator.create_client(
|
| 275 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 276 |
+
)
|
| 277 |
+
self.assertTrue(hasattr(service_client, 'test_operation'))
|
| 278 |
+
|
| 279 |
+
def test_client_with_nonstandard_signature_version(self):
|
| 280 |
+
self.service_description['metadata']['signatureVersion'] = 'foo'
|
| 281 |
+
creator = self.create_client_creator()
|
| 282 |
+
foo_signer = mock.Mock(spec=BaseSigner)
|
| 283 |
+
|
| 284 |
+
auth_types = AUTH_TYPE_MAPS.copy()
|
| 285 |
+
auth_types['foo'] = foo_signer
|
| 286 |
+
|
| 287 |
+
with mock.patch('botocore.client.AUTH_TYPE_MAPS', auth_types):
|
| 288 |
+
service_client = creator.create_client(
|
| 289 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 290 |
+
)
|
| 291 |
+
assert service_client.meta.config.signature_version == 'foo'
|
| 292 |
+
|
| 293 |
+
def test_client_method_docstring(self):
|
| 294 |
+
creator = self.create_client_creator()
|
| 295 |
+
service_client = creator.create_client(
|
| 296 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 297 |
+
)
|
| 298 |
+
method_docstring = str(service_client.test_operation.__doc__)
|
| 299 |
+
ref_docstring_lines = [
|
| 300 |
+
'Documents TestOperation',
|
| 301 |
+
'**Request Syntax**',
|
| 302 |
+
' response = client.test_operation(',
|
| 303 |
+
' Bar=\'string\'',
|
| 304 |
+
' Foo=\'string\'',
|
| 305 |
+
' )',
|
| 306 |
+
':type Bar: string',
|
| 307 |
+
':param Bar: Documents Bar',
|
| 308 |
+
':type Foo: string',
|
| 309 |
+
':param Foo: **[REQUIRED]** Documents Foo',
|
| 310 |
+
]
|
| 311 |
+
for line in ref_docstring_lines:
|
| 312 |
+
self.assertIn(line, method_docstring)
|
| 313 |
+
|
| 314 |
+
def test_client_method_help(self):
|
| 315 |
+
creator = self.create_client_creator()
|
| 316 |
+
service_client = creator.create_client(
|
| 317 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 318 |
+
)
|
| 319 |
+
with mock.patch('sys.stdout', io.StringIO()) as mock_stdout:
|
| 320 |
+
help(service_client.test_operation)
|
| 321 |
+
method_docstring = mock_stdout.getvalue()
|
| 322 |
+
ref_docstring_lines = [
|
| 323 |
+
'Documents TestOperation',
|
| 324 |
+
'**Request Syntax**',
|
| 325 |
+
' response = client.test_operation(',
|
| 326 |
+
' Bar=\'string\'',
|
| 327 |
+
' Foo=\'string\'',
|
| 328 |
+
' )',
|
| 329 |
+
':type Bar: string',
|
| 330 |
+
':param Bar: Documents Bar',
|
| 331 |
+
':type Foo: string',
|
| 332 |
+
':param Foo: **[REQUIRED]** Documents Foo',
|
| 333 |
+
]
|
| 334 |
+
for line in ref_docstring_lines:
|
| 335 |
+
self.assertIn(line, method_docstring)
|
| 336 |
+
|
| 337 |
+
def test_client_create_unicode(self):
|
| 338 |
+
creator = self.create_client_creator()
|
| 339 |
+
service_client = creator.create_client(
|
| 340 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 341 |
+
)
|
| 342 |
+
self.assertTrue(hasattr(service_client, 'test_operation'))
|
| 343 |
+
|
| 344 |
+
def test_client_has_region_name_on_meta(self):
|
| 345 |
+
creator = self.create_client_creator()
|
| 346 |
+
region_name = 'us-west-2'
|
| 347 |
+
self.endpoint.region_name = region_name
|
| 348 |
+
service_client = creator.create_client(
|
| 349 |
+
'myservice', region_name, credentials=self.credentials
|
| 350 |
+
)
|
| 351 |
+
self.assertEqual(service_client.meta.region_name, region_name)
|
| 352 |
+
|
| 353 |
+
def test_client_has_endpoint_url_on_meta(self):
|
| 354 |
+
creator = self.create_client_creator()
|
| 355 |
+
self.endpoint.host = 'https://foo.bar'
|
| 356 |
+
service_client = creator.create_client(
|
| 357 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 358 |
+
)
|
| 359 |
+
self.assertEqual(service_client.meta.endpoint_url, 'https://foo.bar')
|
| 360 |
+
|
| 361 |
+
def test_client_has_standard_partition_on_meta(self):
|
| 362 |
+
creator = self.create_client_creator()
|
| 363 |
+
service_client = creator.create_client(
|
| 364 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 365 |
+
)
|
| 366 |
+
self.assertEqual(service_client.meta.partition, 'aws')
|
| 367 |
+
|
| 368 |
+
def test_client_has_non_standard_partition_on_meta(self):
|
| 369 |
+
creator = self.create_client_creator()
|
| 370 |
+
self.resolver.construct_endpoint.return_value = {
|
| 371 |
+
'partition': 'aws-cn',
|
| 372 |
+
'hostname': 'foo',
|
| 373 |
+
'endpointName': 'cn-north-1',
|
| 374 |
+
'signatureVersions': ['v4'],
|
| 375 |
+
}
|
| 376 |
+
service_client = creator.create_client(
|
| 377 |
+
'myservice', 'cn-north-1', credentials=self.credentials
|
| 378 |
+
)
|
| 379 |
+
self.assertEqual(service_client.meta.partition, 'aws-cn')
|
| 380 |
+
|
| 381 |
+
def test_client_has_exceptions_attribute(self):
|
| 382 |
+
creator = self.create_client_creator()
|
| 383 |
+
service_client = creator.create_client(
|
| 384 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 385 |
+
)
|
| 386 |
+
self.assertTrue(hasattr(service_client, 'exceptions'))
|
| 387 |
+
|
| 388 |
+
def test_client_has_modeled_exceptions(self):
|
| 389 |
+
creator = self.create_client_creator()
|
| 390 |
+
service_client = creator.create_client(
|
| 391 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 392 |
+
)
|
| 393 |
+
self.assertTrue(
|
| 394 |
+
issubclass(
|
| 395 |
+
service_client.exceptions.TestOperationException,
|
| 396 |
+
client.ClientError,
|
| 397 |
+
)
|
| 398 |
+
)
|
| 399 |
+
|
| 400 |
+
def test_client_fips_region_transformation(self):
|
| 401 |
+
creator = self.create_client_creator()
|
| 402 |
+
with self.assertLogs('botocore.client', level='WARNING') as log:
|
| 403 |
+
creator.create_client(
|
| 404 |
+
'myservice', 'fips-us-west-2', credentials=self.credentials
|
| 405 |
+
)
|
| 406 |
+
self.assertIn('fips-us-west-2 to us-west-2', log.output[0])
|
| 407 |
+
|
| 408 |
+
def test_api_version_is_passed_to_loader_if_provided(self):
|
| 409 |
+
creator = self.create_client_creator()
|
| 410 |
+
self.endpoint.host = 'https://foo.bar'
|
| 411 |
+
specific_api_version = '2014-03-01'
|
| 412 |
+
creator.create_client(
|
| 413 |
+
'myservice',
|
| 414 |
+
'us-west-2',
|
| 415 |
+
credentials=self.credentials,
|
| 416 |
+
api_version=specific_api_version,
|
| 417 |
+
)
|
| 418 |
+
calls = [
|
| 419 |
+
mock.call(
|
| 420 |
+
'myservice', 'service-2', api_version=specific_api_version
|
| 421 |
+
),
|
| 422 |
+
mock.call(
|
| 423 |
+
'myservice',
|
| 424 |
+
'endpoint-rule-set-1',
|
| 425 |
+
api_version=specific_api_version,
|
| 426 |
+
),
|
| 427 |
+
]
|
| 428 |
+
self.loader.load_service_model.assert_has_calls(calls)
|
| 429 |
+
|
| 430 |
+
def test_create_client_class_creates_class(self):
|
| 431 |
+
creator = self.create_client_creator()
|
| 432 |
+
client_class = creator.create_client_class('myservice')
|
| 433 |
+
self.assertTrue(hasattr(client_class, 'test_operation'))
|
| 434 |
+
|
| 435 |
+
def test_create_client_class_forwards_api_version(self):
|
| 436 |
+
creator = self.create_client_creator()
|
| 437 |
+
specific_api_version = '2014-03-01'
|
| 438 |
+
creator.create_client_class(
|
| 439 |
+
'myservice', api_version=specific_api_version
|
| 440 |
+
)
|
| 441 |
+
self.loader.load_service_model.assert_called_with(
|
| 442 |
+
'myservice', 'service-2', api_version=specific_api_version
|
| 443 |
+
)
|
| 444 |
+
|
| 445 |
+
def test_signing_region_does_not_change_client_region(self):
|
| 446 |
+
with mock.patch('botocore.args.RequestSigner') as mock_signer:
|
| 447 |
+
credential_scope_region = 'us-east-1'
|
| 448 |
+
self.resolver.construct_endpoint.return_value = {
|
| 449 |
+
'partition': 'aws',
|
| 450 |
+
'hostname': 'endpoint.url',
|
| 451 |
+
'endpointName': 'us-west-2',
|
| 452 |
+
'signatureVersions': ['v4'],
|
| 453 |
+
'credentialScope': {'region': credential_scope_region},
|
| 454 |
+
}
|
| 455 |
+
creator = self.create_client_creator()
|
| 456 |
+
service_client = creator.create_client(
|
| 457 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 458 |
+
)
|
| 459 |
+
self.assertEqual(service_client.meta.region_name, 'us-west-2')
|
| 460 |
+
call_args = mock_signer.call_args
|
| 461 |
+
self.assertEqual(credential_scope_region, call_args[0][1])
|
| 462 |
+
|
| 463 |
+
def test_client_uses_signing_region_from_credential_scope(self):
|
| 464 |
+
with mock.patch('botocore.args.RequestSigner') as mock_signer:
|
| 465 |
+
credential_scope_region = 'us-east-1'
|
| 466 |
+
self.resolver.construct_endpoint.return_value = {
|
| 467 |
+
'partition': 'aws',
|
| 468 |
+
'endpointName': 'us-west-2',
|
| 469 |
+
'hostname': 'endpoint.url',
|
| 470 |
+
'signatureVersions': ['v4'],
|
| 471 |
+
'credentialScope': {'region': credential_scope_region},
|
| 472 |
+
}
|
| 473 |
+
creator = self.create_client_creator()
|
| 474 |
+
service_client = creator.create_client(
|
| 475 |
+
service_name='myservice',
|
| 476 |
+
region_name='us-west-2',
|
| 477 |
+
credentials=self.credentials,
|
| 478 |
+
)
|
| 479 |
+
# Use the resolved region as the region value.
|
| 480 |
+
self.assertEqual(service_client.meta.region_name, 'us-west-2')
|
| 481 |
+
# Ensure that we use the credential scope region for signing,
|
| 482 |
+
# and not the resolved region name.
|
| 483 |
+
call_args = mock_signer.call_args
|
| 484 |
+
self.assertEqual(credential_scope_region, call_args[0][1])
|
| 485 |
+
|
| 486 |
+
def test_client_uses_signing_name_from_credential_scope(self):
|
| 487 |
+
with mock.patch('botocore.args.RequestSigner') as mock_signer:
|
| 488 |
+
self.resolver.construct_endpoint.return_value = {
|
| 489 |
+
'partition': 'aws',
|
| 490 |
+
'endpointName': 'us-west-2',
|
| 491 |
+
'hostname': 'endpoint.url',
|
| 492 |
+
'signatureVersions': ['v4'],
|
| 493 |
+
'credentialScope': {'service': 'override'},
|
| 494 |
+
}
|
| 495 |
+
creator = self.create_client_creator()
|
| 496 |
+
creator.create_client(
|
| 497 |
+
service_name='myservice',
|
| 498 |
+
region_name='us-west-2',
|
| 499 |
+
credentials=self.credentials,
|
| 500 |
+
)
|
| 501 |
+
call_args = mock_signer.call_args
|
| 502 |
+
self.assertEqual('MyService', call_args[0][0])
|
| 503 |
+
self.assertEqual('override', call_args[0][2])
|
| 504 |
+
|
| 505 |
+
def test_client_uses_given_region_name_and_endpoint_url_when_present(self):
|
| 506 |
+
with mock.patch('botocore.args.RequestSigner') as mock_signer:
|
| 507 |
+
credential_scope_region = 'us-east-1'
|
| 508 |
+
self.resolver.construct_endpoint.return_value = {
|
| 509 |
+
'partition': 'aws',
|
| 510 |
+
'endpointName': 'us-west-2',
|
| 511 |
+
'hostname': 'endpoint.url',
|
| 512 |
+
'signatureVersions': ['v4'],
|
| 513 |
+
'credentialScope': {'region': credential_scope_region},
|
| 514 |
+
}
|
| 515 |
+
creator = self.create_client_creator()
|
| 516 |
+
service_client = creator.create_client(
|
| 517 |
+
service_name='myservice',
|
| 518 |
+
region_name='us-west-2',
|
| 519 |
+
credentials=self.credentials,
|
| 520 |
+
endpoint_url='https://foo',
|
| 521 |
+
)
|
| 522 |
+
self.assertEqual(service_client.meta.region_name, 'us-west-2')
|
| 523 |
+
call_args = mock_signer.call_args
|
| 524 |
+
self.assertEqual('us-west-2', call_args[0][1])
|
| 525 |
+
|
| 526 |
+
def test_client_uses_signing_name_from_model_if_present_if_resolved(self):
|
| 527 |
+
self.service_description['metadata']['signingName'] = 'otherName'
|
| 528 |
+
with mock.patch('botocore.args.RequestSigner') as mock_signer:
|
| 529 |
+
self.resolver.construct_endpoint.return_value = {
|
| 530 |
+
'partition': 'aws',
|
| 531 |
+
'endpointName': 'us-west-2',
|
| 532 |
+
'hostname': 'endpoint.url',
|
| 533 |
+
'signatureVersions': ['v4'],
|
| 534 |
+
}
|
| 535 |
+
creator = self.create_client_creator()
|
| 536 |
+
service_client = creator.create_client(
|
| 537 |
+
service_name='myservice',
|
| 538 |
+
region_name='us-west-2',
|
| 539 |
+
credentials=self.credentials,
|
| 540 |
+
endpoint_url='https://foo',
|
| 541 |
+
)
|
| 542 |
+
self.assertEqual(service_client.meta.region_name, 'us-west-2')
|
| 543 |
+
call_args = mock_signer.call_args[0]
|
| 544 |
+
self.assertEqual('otherName', call_args[2])
|
| 545 |
+
|
| 546 |
+
def test_client_uses_signing_name_even_with_no_resolve(self):
|
| 547 |
+
self.service_description['metadata']['signingName'] = 'otherName'
|
| 548 |
+
with mock.patch('botocore.args.RequestSigner') as mock_signer:
|
| 549 |
+
self.resolver.construct_endpoint.return_value = {}
|
| 550 |
+
creator = self.create_client_creator()
|
| 551 |
+
service_client = creator.create_client(
|
| 552 |
+
service_name='myservice',
|
| 553 |
+
region_name='us-west-2',
|
| 554 |
+
credentials=self.credentials,
|
| 555 |
+
endpoint_url='https://foo',
|
| 556 |
+
)
|
| 557 |
+
self.assertEqual(service_client.meta.region_name, 'us-west-2')
|
| 558 |
+
call_args = mock_signer.call_args[0]
|
| 559 |
+
self.assertEqual('otherName', call_args[2])
|
| 560 |
+
|
| 561 |
+
@mock.patch('botocore.args.RequestSigner')
|
| 562 |
+
def test_client_signature_no_override(self, request_signer):
|
| 563 |
+
creator = self.create_client_creator()
|
| 564 |
+
creator.create_client(
|
| 565 |
+
'myservice',
|
| 566 |
+
'us-west-2',
|
| 567 |
+
credentials=self.credentials,
|
| 568 |
+
scoped_config={},
|
| 569 |
+
)
|
| 570 |
+
request_signer.assert_called_with(
|
| 571 |
+
mock.ANY,
|
| 572 |
+
mock.ANY,
|
| 573 |
+
mock.ANY,
|
| 574 |
+
'v4',
|
| 575 |
+
mock.ANY,
|
| 576 |
+
mock.ANY,
|
| 577 |
+
mock.ANY,
|
| 578 |
+
)
|
| 579 |
+
|
| 580 |
+
@mock.patch('botocore.args.RequestSigner')
|
| 581 |
+
def test_client_signature_override_config_file(self, request_signer):
|
| 582 |
+
creator = self.create_client_creator()
|
| 583 |
+
config = {'myservice': {'signature_version': 'foo'}}
|
| 584 |
+
creator.create_client(
|
| 585 |
+
'myservice',
|
| 586 |
+
'us-west-2',
|
| 587 |
+
credentials=self.credentials,
|
| 588 |
+
scoped_config=config,
|
| 589 |
+
)
|
| 590 |
+
request_signer.assert_called_with(
|
| 591 |
+
mock.ANY,
|
| 592 |
+
mock.ANY,
|
| 593 |
+
mock.ANY,
|
| 594 |
+
'foo',
|
| 595 |
+
mock.ANY,
|
| 596 |
+
mock.ANY,
|
| 597 |
+
mock.ANY,
|
| 598 |
+
)
|
| 599 |
+
|
| 600 |
+
@mock.patch('botocore.args.RequestSigner')
|
| 601 |
+
def test_client_signature_override_arg(self, request_signer):
|
| 602 |
+
creator = self.create_client_creator()
|
| 603 |
+
config = botocore.config.Config(signature_version='foo')
|
| 604 |
+
creator.create_client(
|
| 605 |
+
'myservice',
|
| 606 |
+
'us-west-2',
|
| 607 |
+
credentials=self.credentials,
|
| 608 |
+
client_config=config,
|
| 609 |
+
)
|
| 610 |
+
request_signer.assert_called_with(
|
| 611 |
+
mock.ANY,
|
| 612 |
+
mock.ANY,
|
| 613 |
+
mock.ANY,
|
| 614 |
+
'foo',
|
| 615 |
+
mock.ANY,
|
| 616 |
+
mock.ANY,
|
| 617 |
+
mock.ANY,
|
| 618 |
+
)
|
| 619 |
+
|
| 620 |
+
def test_client_method_to_api_mapping(self):
|
| 621 |
+
creator = self.create_client_creator()
|
| 622 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 623 |
+
self.assertEqual(
|
| 624 |
+
service_client.meta.method_to_api_mapping,
|
| 625 |
+
{'test_operation': 'TestOperation'},
|
| 626 |
+
)
|
| 627 |
+
|
| 628 |
+
def test_anonymous_client_request(self):
|
| 629 |
+
creator = self.create_client_creator()
|
| 630 |
+
config = botocore.config.Config(signature_version=botocore.UNSIGNED)
|
| 631 |
+
service_client = creator.create_client(
|
| 632 |
+
'myservice', 'us-west-2', client_config=config
|
| 633 |
+
)
|
| 634 |
+
|
| 635 |
+
service_client.test_operation(Foo='one')
|
| 636 |
+
|
| 637 |
+
# Make sure a request has been attempted
|
| 638 |
+
self.assertTrue(self.endpoint.make_request.called)
|
| 639 |
+
|
| 640 |
+
# Make sure the request parameters do NOT include auth
|
| 641 |
+
# information. The service defined above for these tests
|
| 642 |
+
# uses sigv4 by default (which we disable).
|
| 643 |
+
params = {
|
| 644 |
+
k.lower(): v
|
| 645 |
+
for k, v in self.endpoint.make_request.call_args[0][1].items()
|
| 646 |
+
}
|
| 647 |
+
self.assertNotIn('authorization', params)
|
| 648 |
+
self.assertNotIn('x-amz-signature', params)
|
| 649 |
+
|
| 650 |
+
def test_client_user_agent_in_request(self):
|
| 651 |
+
creator = self.create_client_creator()
|
| 652 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 653 |
+
|
| 654 |
+
service_client.test_operation(Foo='one')
|
| 655 |
+
|
| 656 |
+
self.assertTrue(self.endpoint.make_request.called)
|
| 657 |
+
params = {
|
| 658 |
+
k.lower(): v
|
| 659 |
+
for k, v in self.endpoint.make_request.call_args[0][1].items()
|
| 660 |
+
}
|
| 661 |
+
self.assertIn('MyUserAgent/1.2.3', params['headers']['User-Agent'])
|
| 662 |
+
|
| 663 |
+
def test_client_custom_user_agent_in_request(self):
|
| 664 |
+
creator = self.create_client_creator()
|
| 665 |
+
config = botocore.config.Config(user_agent='baz')
|
| 666 |
+
service_client = creator.create_client(
|
| 667 |
+
'myservice', 'us-west-2', client_config=config
|
| 668 |
+
)
|
| 669 |
+
|
| 670 |
+
service_client.test_operation(Foo='one')
|
| 671 |
+
|
| 672 |
+
self.assertTrue(self.endpoint.make_request.called)
|
| 673 |
+
params = {
|
| 674 |
+
k.lower(): v
|
| 675 |
+
for k, v in self.endpoint.make_request.call_args[0][1].items()
|
| 676 |
+
}
|
| 677 |
+
self.assertEqual(params['headers']['User-Agent'], 'baz')
|
| 678 |
+
|
| 679 |
+
def test_client_custom_user_agent_extra_in_request(self):
|
| 680 |
+
creator = self.create_client_creator()
|
| 681 |
+
config = botocore.config.Config(user_agent_extra='extrastuff')
|
| 682 |
+
service_client = creator.create_client(
|
| 683 |
+
'myservice', 'us-west-2', client_config=config
|
| 684 |
+
)
|
| 685 |
+
service_client.test_operation(Foo='one')
|
| 686 |
+
headers = self.endpoint.make_request.call_args[0][1]['headers']
|
| 687 |
+
self.assertTrue(headers['User-Agent'].endswith('extrastuff'))
|
| 688 |
+
|
| 689 |
+
def test_client_registers_request_created_handler(self):
|
| 690 |
+
event_emitter = self.create_mock_emitter()
|
| 691 |
+
creator = self.create_client_creator(event_emitter=event_emitter)
|
| 692 |
+
creator.create_client(
|
| 693 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 694 |
+
)
|
| 695 |
+
self.assertIn(
|
| 696 |
+
mock.call('request-created.myservice', mock.ANY),
|
| 697 |
+
event_emitter.register.call_args_list,
|
| 698 |
+
)
|
| 699 |
+
|
| 700 |
+
def test_client_makes_call(self):
|
| 701 |
+
creator = self.create_client_creator()
|
| 702 |
+
service_client = creator.create_client(
|
| 703 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 704 |
+
)
|
| 705 |
+
|
| 706 |
+
self.assertTrue(self.endpoint_creator.create_endpoint.called)
|
| 707 |
+
|
| 708 |
+
response = service_client.test_operation(Foo='one', Bar='two')
|
| 709 |
+
self.assertEqual(response, {})
|
| 710 |
+
|
| 711 |
+
def test_client_error_message_for_positional_args(self):
|
| 712 |
+
creator = self.create_client_creator()
|
| 713 |
+
service_client = creator.create_client(
|
| 714 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 715 |
+
)
|
| 716 |
+
with self.assertRaisesRegex(
|
| 717 |
+
TypeError, 'only accepts keyword arguments'
|
| 718 |
+
):
|
| 719 |
+
service_client.test_operation('foo')
|
| 720 |
+
|
| 721 |
+
@mock.patch('botocore.args.RequestSigner.sign')
|
| 722 |
+
def test_client_signs_call(self, signer_mock):
|
| 723 |
+
creator = self.create_client_creator()
|
| 724 |
+
service_client = creator.create_client(
|
| 725 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 726 |
+
)
|
| 727 |
+
request = mock.Mock()
|
| 728 |
+
|
| 729 |
+
# Emit the request created event to see if it would be signed.
|
| 730 |
+
# We tested above to ensure this event is registered when
|
| 731 |
+
# a client is created. This prevents testing the entire client
|
| 732 |
+
# call logic.
|
| 733 |
+
service_client.meta.events.emit(
|
| 734 |
+
'request-created.myservice.test_operation',
|
| 735 |
+
request=request,
|
| 736 |
+
operation_name='test_operation',
|
| 737 |
+
)
|
| 738 |
+
|
| 739 |
+
signer_mock.assert_called_with('test_operation', request)
|
| 740 |
+
|
| 741 |
+
def test_client_validates_params_by_default(self):
|
| 742 |
+
creator = self.create_client_creator()
|
| 743 |
+
|
| 744 |
+
service_client = creator.create_client(
|
| 745 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 746 |
+
)
|
| 747 |
+
with self.assertRaises(ParamValidationError):
|
| 748 |
+
self.make_api_call_with_missing_param(service_client)
|
| 749 |
+
|
| 750 |
+
def test_client_doesnt_validate_params_when_validation_disabled(self):
|
| 751 |
+
creator = self.create_client_creator()
|
| 752 |
+
|
| 753 |
+
client_config = botocore.config.Config()
|
| 754 |
+
client_config.parameter_validation = False
|
| 755 |
+
service_client = creator.create_client(
|
| 756 |
+
'myservice',
|
| 757 |
+
'us-west-2',
|
| 758 |
+
credentials=self.credentials,
|
| 759 |
+
client_config=client_config,
|
| 760 |
+
)
|
| 761 |
+
|
| 762 |
+
self.assert_no_param_error_raised(service_client)
|
| 763 |
+
|
| 764 |
+
def test_can_disable_param_validation_from_scoped_config(self):
|
| 765 |
+
creator = self.create_client_creator()
|
| 766 |
+
service_client = creator.create_client(
|
| 767 |
+
'myservice',
|
| 768 |
+
'us-west-2',
|
| 769 |
+
credentials=self.credentials,
|
| 770 |
+
scoped_config={'parameter_validation': False},
|
| 771 |
+
)
|
| 772 |
+
self.assert_no_param_error_raised(service_client)
|
| 773 |
+
|
| 774 |
+
def test_client_config_trumps_scoped_config(self):
|
| 775 |
+
creator = self.create_client_creator()
|
| 776 |
+
scoped_config = {'parameter_validation': True}
|
| 777 |
+
client_config = botocore.config.Config(parameter_validation=False)
|
| 778 |
+
# Client config should win and param validation is disabled.
|
| 779 |
+
service_client = creator.create_client(
|
| 780 |
+
'myservice',
|
| 781 |
+
'us-west-2',
|
| 782 |
+
credentials=self.credentials,
|
| 783 |
+
scoped_config=scoped_config,
|
| 784 |
+
client_config=client_config,
|
| 785 |
+
)
|
| 786 |
+
self.assert_no_param_error_raised(service_client)
|
| 787 |
+
|
| 788 |
+
def test_client_with_custom_both_timeout(self):
|
| 789 |
+
self.create_client_creator().create_client(
|
| 790 |
+
'myservice',
|
| 791 |
+
'us-west-2',
|
| 792 |
+
client_config=botocore.config.Config(
|
| 793 |
+
connect_timeout=123, read_timeout=234
|
| 794 |
+
),
|
| 795 |
+
)
|
| 796 |
+
call_kwargs = self.endpoint_creator.create_endpoint.call_args[1]
|
| 797 |
+
self.assertEqual(call_kwargs['timeout'], (123, 234))
|
| 798 |
+
|
| 799 |
+
def test_client_with_custom_connect_timeout(self):
|
| 800 |
+
self.create_client_creator().create_client(
|
| 801 |
+
'myservice',
|
| 802 |
+
'us-west-2',
|
| 803 |
+
client_config=botocore.config.Config(connect_timeout=123),
|
| 804 |
+
)
|
| 805 |
+
call_kwargs = self.endpoint_creator.create_endpoint.call_args[1]
|
| 806 |
+
self.assertEqual(call_kwargs['timeout'], (123, DEFAULT_TIMEOUT))
|
| 807 |
+
|
| 808 |
+
def test_client_with_custom_read_timeout(self):
|
| 809 |
+
self.create_client_creator().create_client(
|
| 810 |
+
'myservice',
|
| 811 |
+
'us-west-2',
|
| 812 |
+
client_config=botocore.config.Config(read_timeout=234),
|
| 813 |
+
)
|
| 814 |
+
call_kwargs = self.endpoint_creator.create_endpoint.call_args[1]
|
| 815 |
+
self.assertEqual(call_kwargs['timeout'], (DEFAULT_TIMEOUT, 234))
|
| 816 |
+
|
| 817 |
+
def test_client_with_custom_neither_timeout(self):
|
| 818 |
+
self.create_client_creator().create_client('myservice', 'us-west-2')
|
| 819 |
+
call_kwargs = self.endpoint_creator.create_endpoint.call_args[1]
|
| 820 |
+
self.assertEqual(
|
| 821 |
+
call_kwargs['timeout'], (DEFAULT_TIMEOUT, DEFAULT_TIMEOUT)
|
| 822 |
+
)
|
| 823 |
+
|
| 824 |
+
def test_client_with_custom_params(self):
|
| 825 |
+
creator = self.create_client_creator()
|
| 826 |
+
creator.create_client(
|
| 827 |
+
'myservice', 'us-west-2', is_secure=False, verify=False
|
| 828 |
+
)
|
| 829 |
+
call_kwargs = self.endpoint_creator.create_endpoint.call_args[1]
|
| 830 |
+
self.assertFalse(call_kwargs['verify'])
|
| 831 |
+
self.assertNotIn('is_secure', call_kwargs)
|
| 832 |
+
|
| 833 |
+
def test_client_with_custom_proxy_config(self):
|
| 834 |
+
proxies_config = {
|
| 835 |
+
'proxy_ca_bundle': 'foo_ca_bundle',
|
| 836 |
+
'proxy_client_cert': 'foo_cert',
|
| 837 |
+
'proxy_use_forwarding_for_https': False,
|
| 838 |
+
}
|
| 839 |
+
self.create_client_creator().create_client(
|
| 840 |
+
'myservice',
|
| 841 |
+
'us-west-2',
|
| 842 |
+
client_config=botocore.config.Config(
|
| 843 |
+
proxies_config=proxies_config
|
| 844 |
+
),
|
| 845 |
+
)
|
| 846 |
+
call_kwargs = self.endpoint_creator.create_endpoint.call_args[1]
|
| 847 |
+
self.assertEqual(call_kwargs['proxies_config'], proxies_config)
|
| 848 |
+
|
| 849 |
+
def test_client_with_endpoint_url(self):
|
| 850 |
+
creator = self.create_client_creator()
|
| 851 |
+
creator.create_client(
|
| 852 |
+
'myservice', 'us-west-2', endpoint_url='http://custom.foo'
|
| 853 |
+
)
|
| 854 |
+
call_kwargs = self.endpoint_creator.create_endpoint.call_args[1]
|
| 855 |
+
self.assertEqual(call_kwargs['endpoint_url'], 'http://custom.foo')
|
| 856 |
+
|
| 857 |
+
def test_client_can_use_guessed_endpoints(self):
|
| 858 |
+
# Ensure the resolver returns None (meaning a guess is made)
|
| 859 |
+
self.resolver.construct_endpoint.return_value = None
|
| 860 |
+
creator = self.create_client_creator()
|
| 861 |
+
client = creator.create_client('myservice', region_name='invalid')
|
| 862 |
+
self.assertEqual('invalid', client.meta.region_name)
|
| 863 |
+
|
| 864 |
+
def test_client_with_response_parser_factory(self):
|
| 865 |
+
factory = mock.Mock()
|
| 866 |
+
creator = self.create_client_creator(response_parser_factory=factory)
|
| 867 |
+
creator.create_client('myservice', 'us-west-2')
|
| 868 |
+
call_kwargs = self.endpoint_creator.create_endpoint.call_args[1]
|
| 869 |
+
self.assertEqual(call_kwargs['response_parser_factory'], factory)
|
| 870 |
+
|
| 871 |
+
def test_operation_cannot_paginate(self):
|
| 872 |
+
pagination_config = {
|
| 873 |
+
'pagination': {
|
| 874 |
+
# Note that there's no pagination config for
|
| 875 |
+
# 'TestOperation', indicating that TestOperation
|
| 876 |
+
# is not pageable.
|
| 877 |
+
'SomeOtherOperation': {
|
| 878 |
+
"input_token": "Marker",
|
| 879 |
+
"output_token": "Marker",
|
| 880 |
+
"more_results": "IsTruncated",
|
| 881 |
+
"limit_key": "MaxItems",
|
| 882 |
+
"result_key": "Users",
|
| 883 |
+
}
|
| 884 |
+
}
|
| 885 |
+
}
|
| 886 |
+
self.loader.load_service_model.side_effect = [
|
| 887 |
+
self.service_description,
|
| 888 |
+
self.endpoint_ruleset,
|
| 889 |
+
pagination_config,
|
| 890 |
+
]
|
| 891 |
+
creator = self.create_client_creator()
|
| 892 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 893 |
+
self.assertFalse(service_client.can_paginate('test_operation'))
|
| 894 |
+
|
| 895 |
+
def test_operation_can_paginate(self):
|
| 896 |
+
pagination_config = {
|
| 897 |
+
'pagination': {
|
| 898 |
+
'TestOperation': {
|
| 899 |
+
"input_token": "Marker",
|
| 900 |
+
"output_token": "Marker",
|
| 901 |
+
"more_results": "IsTruncated",
|
| 902 |
+
"limit_key": "MaxItems",
|
| 903 |
+
"result_key": "Users",
|
| 904 |
+
}
|
| 905 |
+
}
|
| 906 |
+
}
|
| 907 |
+
self.loader.load_service_model.side_effect = [
|
| 908 |
+
self.service_description,
|
| 909 |
+
self.endpoint_ruleset,
|
| 910 |
+
pagination_config,
|
| 911 |
+
]
|
| 912 |
+
creator = self.create_client_creator()
|
| 913 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 914 |
+
self.assertTrue(service_client.can_paginate('test_operation'))
|
| 915 |
+
# Also, the config is cached, but we want to make sure we get
|
| 916 |
+
# the same answer when we ask again.
|
| 917 |
+
self.assertTrue(service_client.can_paginate('test_operation'))
|
| 918 |
+
|
| 919 |
+
def test_service_has_no_pagination_configs(self):
|
| 920 |
+
# This is the case where there is an actual *.paginator.json, file,
|
| 921 |
+
# but the specific operation itself is not actually pageable.
|
| 922 |
+
# If the loader cannot load pagination configs, it communicates
|
| 923 |
+
# this by raising a DataNotFoundError.
|
| 924 |
+
self.loader.load_service_model.side_effect = [
|
| 925 |
+
self.service_description,
|
| 926 |
+
self.endpoint_ruleset,
|
| 927 |
+
exceptions.DataNotFoundError(data_path='/foo'),
|
| 928 |
+
]
|
| 929 |
+
creator = self.create_client_creator()
|
| 930 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 931 |
+
self.assertFalse(service_client.can_paginate('test_operation'))
|
| 932 |
+
|
| 933 |
+
def test_waiter_config_uses_service_name_not_endpoint_prefix(self):
|
| 934 |
+
waiter_config = {'version': 2, 'waiters': {}}
|
| 935 |
+
self.loader.load_service_model.side_effect = [
|
| 936 |
+
self.service_description,
|
| 937 |
+
self.endpoint_ruleset,
|
| 938 |
+
waiter_config,
|
| 939 |
+
]
|
| 940 |
+
creator = self.create_client_creator()
|
| 941 |
+
# We're going to verify that the loader loads a service called
|
| 942 |
+
# 'other-service-name', and even though the endpointPrefix is
|
| 943 |
+
# 'myservice', we use 'other-service-name' for waiters/paginators, etc.
|
| 944 |
+
service_client = creator.create_client(
|
| 945 |
+
'other-service-name', 'us-west-2'
|
| 946 |
+
)
|
| 947 |
+
self.assertEqual(service_client.waiter_names, [])
|
| 948 |
+
# Note we're using other-service-name, not
|
| 949 |
+
# 'myservice', which is the endpointPrefix.
|
| 950 |
+
self.loader.load_service_model.assert_called_with(
|
| 951 |
+
'other-service-name', 'waiters-2', '2014-01-01'
|
| 952 |
+
)
|
| 953 |
+
|
| 954 |
+
def test_service_has_waiter_configs(self):
|
| 955 |
+
waiter_config = {
|
| 956 |
+
'version': 2,
|
| 957 |
+
'waiters': {
|
| 958 |
+
"Waiter1": {
|
| 959 |
+
'operation': 'TestOperation',
|
| 960 |
+
'delay': 5,
|
| 961 |
+
'maxAttempts': 20,
|
| 962 |
+
'acceptors': [],
|
| 963 |
+
},
|
| 964 |
+
"Waiter2": {
|
| 965 |
+
'operation': 'TestOperation',
|
| 966 |
+
'delay': 5,
|
| 967 |
+
'maxAttempts': 20,
|
| 968 |
+
'acceptors': [],
|
| 969 |
+
},
|
| 970 |
+
},
|
| 971 |
+
}
|
| 972 |
+
self.loader.load_service_model.side_effect = [
|
| 973 |
+
self.service_description,
|
| 974 |
+
self.endpoint_ruleset,
|
| 975 |
+
waiter_config,
|
| 976 |
+
]
|
| 977 |
+
creator = self.create_client_creator()
|
| 978 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 979 |
+
self.assertEqual(
|
| 980 |
+
sorted(service_client.waiter_names), sorted(['waiter1', 'waiter2'])
|
| 981 |
+
)
|
| 982 |
+
self.assertTrue(hasattr(service_client.get_waiter('waiter1'), 'wait'))
|
| 983 |
+
|
| 984 |
+
def test_service_has_no_waiter_configs(self):
|
| 985 |
+
self.loader.load_service_model.side_effect = [
|
| 986 |
+
self.service_description,
|
| 987 |
+
self.endpoint_ruleset,
|
| 988 |
+
exceptions.DataNotFoundError(data_path='/foo'),
|
| 989 |
+
]
|
| 990 |
+
creator = self.create_client_creator()
|
| 991 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 992 |
+
self.assertEqual(service_client.waiter_names, [])
|
| 993 |
+
with self.assertRaises(ValueError):
|
| 994 |
+
service_client.get_waiter("unknown_waiter")
|
| 995 |
+
|
| 996 |
+
def test_service_has_retry_event(self):
|
| 997 |
+
# A retry event should be registered for the service.
|
| 998 |
+
event_emitter = self.create_mock_emitter()
|
| 999 |
+
creator = self.create_client_creator(event_emitter=event_emitter)
|
| 1000 |
+
creator.create_client('myservice', 'us-west-2')
|
| 1001 |
+
|
| 1002 |
+
event_emitter.register.assert_any_call(
|
| 1003 |
+
'needs-retry.myservice',
|
| 1004 |
+
mock.ANY,
|
| 1005 |
+
unique_id='retry-config-myservice',
|
| 1006 |
+
)
|
| 1007 |
+
|
| 1008 |
+
def test_service_creates_retryhandler(self):
|
| 1009 |
+
# A retry handler with the expected configuration should be
|
| 1010 |
+
# created when instantiating a client.
|
| 1011 |
+
retry_handler_factory = mock.Mock()
|
| 1012 |
+
creator = self.create_client_creator(
|
| 1013 |
+
retry_handler_factory=retry_handler_factory
|
| 1014 |
+
)
|
| 1015 |
+
creator.create_client('myservice', 'us-west-2')
|
| 1016 |
+
|
| 1017 |
+
retry_handler_factory.create_retry_handler.assert_called_with(
|
| 1018 |
+
{
|
| 1019 |
+
'__default__': {
|
| 1020 |
+
'delay': {
|
| 1021 |
+
'growth_factor': 2,
|
| 1022 |
+
'base': 'rand',
|
| 1023 |
+
'type': 'exponential',
|
| 1024 |
+
},
|
| 1025 |
+
'policies': {},
|
| 1026 |
+
'max_attempts': 5,
|
| 1027 |
+
}
|
| 1028 |
+
},
|
| 1029 |
+
'myservice',
|
| 1030 |
+
)
|
| 1031 |
+
|
| 1032 |
+
def test_service_registers_retry_handler(self):
|
| 1033 |
+
# The retry handler returned from ``create_retry_handler``
|
| 1034 |
+
# that was tested above needs to be set as the handler for
|
| 1035 |
+
# the event emitter.
|
| 1036 |
+
retry_handler_factory = mock.Mock()
|
| 1037 |
+
handler = mock.Mock()
|
| 1038 |
+
event_emitter = self.create_mock_emitter()
|
| 1039 |
+
retry_handler_factory.create_retry_handler.return_value = handler
|
| 1040 |
+
|
| 1041 |
+
creator = self.create_client_creator(
|
| 1042 |
+
event_emitter=event_emitter,
|
| 1043 |
+
retry_handler_factory=retry_handler_factory,
|
| 1044 |
+
)
|
| 1045 |
+
creator.create_client('myservice', 'us-west-2')
|
| 1046 |
+
|
| 1047 |
+
event_emitter.register.assert_any_call(
|
| 1048 |
+
mock.ANY, handler, unique_id=mock.ANY
|
| 1049 |
+
)
|
| 1050 |
+
|
| 1051 |
+
def test_service_retry_missing_config(self):
|
| 1052 |
+
# No config means we should never see any retry events registered.
|
| 1053 |
+
self.loader.load_data.return_value = {}
|
| 1054 |
+
|
| 1055 |
+
event_emitter = self.create_mock_emitter()
|
| 1056 |
+
creator = self.create_client_creator(event_emitter=event_emitter)
|
| 1057 |
+
creator.create_client('myservice', 'us-west-2')
|
| 1058 |
+
|
| 1059 |
+
for call in event_emitter.register.call_args_list:
|
| 1060 |
+
self.assertNotIn('needs-retry', call[0][0])
|
| 1061 |
+
|
| 1062 |
+
def test_emits_after_call_error(self):
|
| 1063 |
+
event_emitter = hooks.HierarchicalEmitter()
|
| 1064 |
+
|
| 1065 |
+
recorded_kwargs = []
|
| 1066 |
+
|
| 1067 |
+
def record(event_name, **kwargs):
|
| 1068 |
+
recorded_kwargs.append(kwargs)
|
| 1069 |
+
|
| 1070 |
+
event_emitter.register(
|
| 1071 |
+
'after-call-error.myservice.TestOperation', record
|
| 1072 |
+
)
|
| 1073 |
+
|
| 1074 |
+
raised_error = RuntimeError('Unexpected error')
|
| 1075 |
+
self.endpoint.make_request.side_effect = raised_error
|
| 1076 |
+
creator = self.create_client_creator(event_emitter=event_emitter)
|
| 1077 |
+
client = creator.create_client('myservice', 'us-west-2')
|
| 1078 |
+
with self.assertRaises(RuntimeError):
|
| 1079 |
+
client.test_operation(Foo='one', Bar='two')
|
| 1080 |
+
self.assertEqual(
|
| 1081 |
+
recorded_kwargs, [{'exception': raised_error, 'context': mock.ANY}]
|
| 1082 |
+
)
|
| 1083 |
+
|
| 1084 |
+
def test_can_override_max_attempts(self):
|
| 1085 |
+
retry_handler_factory = mock.Mock(botocore.retryhandler)
|
| 1086 |
+
creator = self.create_client_creator(
|
| 1087 |
+
retry_handler_factory=retry_handler_factory
|
| 1088 |
+
)
|
| 1089 |
+
creator.create_client(
|
| 1090 |
+
'myservice',
|
| 1091 |
+
'us-west-2',
|
| 1092 |
+
client_config=botocore.config.Config(
|
| 1093 |
+
retries={'max_attempts': 9, 'mode': 'legacy'}
|
| 1094 |
+
),
|
| 1095 |
+
)
|
| 1096 |
+
|
| 1097 |
+
retry_handler_factory.create_retry_handler.assert_called_with(
|
| 1098 |
+
{
|
| 1099 |
+
'__default__': {
|
| 1100 |
+
'delay': {
|
| 1101 |
+
'growth_factor': 2,
|
| 1102 |
+
'base': 'rand',
|
| 1103 |
+
'type': 'exponential',
|
| 1104 |
+
},
|
| 1105 |
+
'policies': {},
|
| 1106 |
+
'max_attempts': 10,
|
| 1107 |
+
}
|
| 1108 |
+
},
|
| 1109 |
+
'myservice',
|
| 1110 |
+
)
|
| 1111 |
+
|
| 1112 |
+
def test_can_register_standard_retry_mode(self):
|
| 1113 |
+
with mock.patch('botocore.client.standard') as standard:
|
| 1114 |
+
creator = self.create_client_creator()
|
| 1115 |
+
creator.create_client(
|
| 1116 |
+
'myservice',
|
| 1117 |
+
'us-west-2',
|
| 1118 |
+
client_config=botocore.config.Config(
|
| 1119 |
+
retries={'mode': 'standard'}
|
| 1120 |
+
),
|
| 1121 |
+
)
|
| 1122 |
+
self.assertTrue(standard.register_retry_handler.called)
|
| 1123 |
+
|
| 1124 |
+
def test_can_register_standard_retry_mode_from_config_store(self):
|
| 1125 |
+
fake_env = {'AWS_RETRY_MODE': 'standard'}
|
| 1126 |
+
config_store = ConfigValueStore(
|
| 1127 |
+
mapping={
|
| 1128 |
+
'retry_mode': ChainProvider(
|
| 1129 |
+
[
|
| 1130 |
+
EnvironmentProvider('AWS_RETRY_MODE', fake_env),
|
| 1131 |
+
]
|
| 1132 |
+
)
|
| 1133 |
+
}
|
| 1134 |
+
)
|
| 1135 |
+
creator = self.create_client_creator(config_store=config_store)
|
| 1136 |
+
with mock.patch('botocore.client.standard') as standard:
|
| 1137 |
+
creator.create_client('myservice', 'us-west-2')
|
| 1138 |
+
self.assertTrue(standard.register_retry_handler.called)
|
| 1139 |
+
|
| 1140 |
+
def test_try_to_paginate_non_paginated(self):
|
| 1141 |
+
self.loader.load_service_model.side_effect = [
|
| 1142 |
+
self.service_description,
|
| 1143 |
+
self.endpoint_ruleset,
|
| 1144 |
+
exceptions.DataNotFoundError(data_path='/foo'),
|
| 1145 |
+
]
|
| 1146 |
+
creator = self.create_client_creator()
|
| 1147 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 1148 |
+
with self.assertRaises(exceptions.OperationNotPageableError):
|
| 1149 |
+
service_client.get_paginator('test_operation')
|
| 1150 |
+
|
| 1151 |
+
def test_successful_pagination_object_created(self):
|
| 1152 |
+
pagination_config = {
|
| 1153 |
+
'pagination': {
|
| 1154 |
+
'TestOperation': {
|
| 1155 |
+
"input_token": "Marker",
|
| 1156 |
+
"output_token": "Marker",
|
| 1157 |
+
"more_results": "IsTruncated",
|
| 1158 |
+
"limit_key": "MaxItems",
|
| 1159 |
+
"result_key": "Users",
|
| 1160 |
+
}
|
| 1161 |
+
}
|
| 1162 |
+
}
|
| 1163 |
+
self.loader.load_service_model.side_effect = [
|
| 1164 |
+
self.service_description,
|
| 1165 |
+
self.endpoint_ruleset,
|
| 1166 |
+
pagination_config,
|
| 1167 |
+
]
|
| 1168 |
+
creator = self.create_client_creator()
|
| 1169 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 1170 |
+
paginator = service_client.get_paginator('test_operation')
|
| 1171 |
+
# The pagination logic itself is tested elsewhere (test_paginate.py),
|
| 1172 |
+
# but we can at least make sure it looks like a paginator.
|
| 1173 |
+
self.assertTrue(hasattr(paginator, 'paginate'))
|
| 1174 |
+
|
| 1175 |
+
def test_paginator_class_name_from_client(self):
|
| 1176 |
+
pagination_config = {
|
| 1177 |
+
'pagination': {
|
| 1178 |
+
'TestOperation': {
|
| 1179 |
+
"input_token": "Marker",
|
| 1180 |
+
"output_token": "Marker",
|
| 1181 |
+
"more_results": "IsTruncated",
|
| 1182 |
+
"limit_key": "MaxItems",
|
| 1183 |
+
"result_key": "Users",
|
| 1184 |
+
}
|
| 1185 |
+
}
|
| 1186 |
+
}
|
| 1187 |
+
self.loader.load_service_model.side_effect = [
|
| 1188 |
+
self.service_description,
|
| 1189 |
+
self.endpoint_ruleset,
|
| 1190 |
+
pagination_config,
|
| 1191 |
+
]
|
| 1192 |
+
creator = self.create_client_creator()
|
| 1193 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 1194 |
+
paginator = service_client.get_paginator('test_operation')
|
| 1195 |
+
self.assertEqual(
|
| 1196 |
+
paginator.__class__.__name__, 'MyService.Paginator.TestOperation'
|
| 1197 |
+
)
|
| 1198 |
+
|
| 1199 |
+
def test_paginator_help_from_client(self):
|
| 1200 |
+
pagination_config = {
|
| 1201 |
+
'pagination': {
|
| 1202 |
+
'TestOperation': {
|
| 1203 |
+
"input_token": "Marker",
|
| 1204 |
+
"output_token": "Marker",
|
| 1205 |
+
"more_results": "IsTruncated",
|
| 1206 |
+
"limit_key": "MaxItems",
|
| 1207 |
+
"result_key": "Users",
|
| 1208 |
+
}
|
| 1209 |
+
}
|
| 1210 |
+
}
|
| 1211 |
+
self.loader.load_service_model.side_effect = [
|
| 1212 |
+
self.service_description,
|
| 1213 |
+
self.endpoint_ruleset,
|
| 1214 |
+
pagination_config,
|
| 1215 |
+
]
|
| 1216 |
+
creator = self.create_client_creator()
|
| 1217 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 1218 |
+
paginator = service_client.get_paginator('test_operation')
|
| 1219 |
+
with mock.patch('sys.stdout', io.StringIO()) as mock_stdout:
|
| 1220 |
+
help(paginator.paginate)
|
| 1221 |
+
contents = mock_stdout.getvalue()
|
| 1222 |
+
lines = [
|
| 1223 |
+
(
|
| 1224 |
+
' Creates an iterator that will paginate through responses '
|
| 1225 |
+
'from :py:meth:`MyService.Client.test_operation`.'
|
| 1226 |
+
),
|
| 1227 |
+
' **Request Syntax**',
|
| 1228 |
+
' ::',
|
| 1229 |
+
' response_iterator = paginator.paginate(',
|
| 1230 |
+
" Foo='string',",
|
| 1231 |
+
" Bar='string',",
|
| 1232 |
+
' PaginationConfig={',
|
| 1233 |
+
" 'MaxItems': 123,",
|
| 1234 |
+
" 'PageSize': 123,",
|
| 1235 |
+
" 'StartingToken': 'string'",
|
| 1236 |
+
' }',
|
| 1237 |
+
' )',
|
| 1238 |
+
' :type Foo: string',
|
| 1239 |
+
' :param Foo: **[REQUIRED]** Documents Foo',
|
| 1240 |
+
' :type Bar: string',
|
| 1241 |
+
' :param Bar: Documents Bar',
|
| 1242 |
+
' :type PaginationConfig: dict',
|
| 1243 |
+
' :param PaginationConfig:',
|
| 1244 |
+
(
|
| 1245 |
+
' A dictionary that provides parameters to control '
|
| 1246 |
+
'pagination.'
|
| 1247 |
+
),
|
| 1248 |
+
' - **MaxItems** *(integer) --*',
|
| 1249 |
+
(
|
| 1250 |
+
' The total number of items to return. If the total '
|
| 1251 |
+
'number of items available is more than the value specified '
|
| 1252 |
+
'in max-items then a ``NextToken`` will be provided in the '
|
| 1253 |
+
'output that you can use to resume pagination.'
|
| 1254 |
+
),
|
| 1255 |
+
' - **PageSize** *(integer) --*',
|
| 1256 |
+
' The size of each page.',
|
| 1257 |
+
' - **StartingToken** *(string) --*',
|
| 1258 |
+
(
|
| 1259 |
+
' A token to specify where to start paginating. This is '
|
| 1260 |
+
'the ``NextToken`` from a previous response.'
|
| 1261 |
+
),
|
| 1262 |
+
' :returns: None',
|
| 1263 |
+
]
|
| 1264 |
+
for line in lines:
|
| 1265 |
+
self.assertIn(line, contents)
|
| 1266 |
+
|
| 1267 |
+
def test_can_set_credentials_in_client_init(self):
|
| 1268 |
+
creator = self.create_client_creator()
|
| 1269 |
+
credentials = Credentials(
|
| 1270 |
+
access_key='access_key',
|
| 1271 |
+
secret_key='secret_key',
|
| 1272 |
+
token='session_token',
|
| 1273 |
+
)
|
| 1274 |
+
client = creator.create_client(
|
| 1275 |
+
'myservice', 'us-west-2', credentials=credentials
|
| 1276 |
+
)
|
| 1277 |
+
|
| 1278 |
+
# Verify that we create an endpoint with a credentials object
|
| 1279 |
+
# matching our creds arguments.
|
| 1280 |
+
self.assertEqual(client._request_signer._credentials, credentials)
|
| 1281 |
+
|
| 1282 |
+
def test_event_emitted_when_invoked(self):
|
| 1283 |
+
event_emitter = hooks.HierarchicalEmitter()
|
| 1284 |
+
creator = self.create_client_creator(event_emitter=event_emitter)
|
| 1285 |
+
|
| 1286 |
+
calls = []
|
| 1287 |
+
|
| 1288 |
+
def handler(**kwargs):
|
| 1289 |
+
return calls.append(kwargs)
|
| 1290 |
+
|
| 1291 |
+
event_emitter.register('before-call', handler)
|
| 1292 |
+
|
| 1293 |
+
service_client = creator.create_client(
|
| 1294 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1295 |
+
)
|
| 1296 |
+
service_client.test_operation(Foo='one', Bar='two')
|
| 1297 |
+
self.assertEqual(len(calls), 1)
|
| 1298 |
+
|
| 1299 |
+
def test_events_are_per_client(self):
|
| 1300 |
+
event_emitter = hooks.HierarchicalEmitter()
|
| 1301 |
+
creator = self.create_client_creator(event_emitter=event_emitter)
|
| 1302 |
+
|
| 1303 |
+
first_calls = []
|
| 1304 |
+
|
| 1305 |
+
def first_handler(**kwargs):
|
| 1306 |
+
return first_calls.append(kwargs)
|
| 1307 |
+
|
| 1308 |
+
second_calls = []
|
| 1309 |
+
|
| 1310 |
+
def second_handler(**kwargs):
|
| 1311 |
+
return second_calls.append(kwargs)
|
| 1312 |
+
|
| 1313 |
+
first_client = creator.create_client(
|
| 1314 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1315 |
+
)
|
| 1316 |
+
second_client = creator.create_client(
|
| 1317 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1318 |
+
)
|
| 1319 |
+
|
| 1320 |
+
first_client.meta.events.register('before-call', first_handler)
|
| 1321 |
+
second_client.meta.events.register('before-call', second_handler)
|
| 1322 |
+
|
| 1323 |
+
# Now, if we invoke an operation from either client, only
|
| 1324 |
+
# the handlers registered with the specific client will be invoked.
|
| 1325 |
+
# So if we invoke the first client.
|
| 1326 |
+
first_client.test_operation(Foo='one', Bar='two')
|
| 1327 |
+
# Only first_calls is populated, not second_calls.
|
| 1328 |
+
self.assertEqual(len(first_calls), 1)
|
| 1329 |
+
self.assertEqual(len(second_calls), 0)
|
| 1330 |
+
|
| 1331 |
+
# If we invoke an operation from the second client,
|
| 1332 |
+
# only second_calls will be populated, not first_calls.
|
| 1333 |
+
second_client.test_operation(Foo='one', Bar='two')
|
| 1334 |
+
# first_calls == 1 from the previous first_client.test_operation()
|
| 1335 |
+
# call.
|
| 1336 |
+
self.assertEqual(len(first_calls), 1)
|
| 1337 |
+
self.assertEqual(len(second_calls), 1)
|
| 1338 |
+
|
| 1339 |
+
def test_clients_inherit_handlers_from_session(self):
|
| 1340 |
+
# Even though clients get their own event emitters, they still
|
| 1341 |
+
# inherit any handlers that were registered on the event emitter
|
| 1342 |
+
# at the time the client was created.
|
| 1343 |
+
event_emitter = hooks.HierarchicalEmitter()
|
| 1344 |
+
creator = self.create_client_creator(event_emitter=event_emitter)
|
| 1345 |
+
|
| 1346 |
+
# So if an event handler is registered before any clients are created:
|
| 1347 |
+
|
| 1348 |
+
base_calls = []
|
| 1349 |
+
|
| 1350 |
+
def base_handler(**kwargs):
|
| 1351 |
+
return base_calls.append(kwargs)
|
| 1352 |
+
|
| 1353 |
+
event_emitter.register('before-call', base_handler)
|
| 1354 |
+
|
| 1355 |
+
# Then any client created from this point forward from the
|
| 1356 |
+
# event_emitter passed into the ClientCreator will have this
|
| 1357 |
+
# handler.
|
| 1358 |
+
first_client = creator.create_client(
|
| 1359 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1360 |
+
)
|
| 1361 |
+
first_client.test_operation(Foo='one', Bar='two')
|
| 1362 |
+
self.assertEqual(len(base_calls), 1)
|
| 1363 |
+
|
| 1364 |
+
# Same thing if we create another client.
|
| 1365 |
+
second_client = creator.create_client(
|
| 1366 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1367 |
+
)
|
| 1368 |
+
second_client.test_operation(Foo='one', Bar='two')
|
| 1369 |
+
self.assertEqual(len(base_calls), 2)
|
| 1370 |
+
|
| 1371 |
+
def test_clients_inherit_only_at_create_time(self):
|
| 1372 |
+
# If event handlers are added to the copied event emitter
|
| 1373 |
+
# _after_ a client is created, we don't pick those up.
|
| 1374 |
+
event_emitter = hooks.HierarchicalEmitter()
|
| 1375 |
+
creator = self.create_client_creator(event_emitter=event_emitter)
|
| 1376 |
+
|
| 1377 |
+
# 1. Create a client.
|
| 1378 |
+
first_client = creator.create_client(
|
| 1379 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1380 |
+
)
|
| 1381 |
+
|
| 1382 |
+
# 2. Now register an event handler from the originating event emitter.
|
| 1383 |
+
base_calls = []
|
| 1384 |
+
|
| 1385 |
+
def base_handler(**kwargs):
|
| 1386 |
+
return base_calls.append(kwargs)
|
| 1387 |
+
|
| 1388 |
+
event_emitter.register('before-call', base_handler)
|
| 1389 |
+
|
| 1390 |
+
# 3. The client will _not_ see this because it already has its
|
| 1391 |
+
# own copy of the event handlers.
|
| 1392 |
+
first_client.test_operation(Foo='one', Bar='two')
|
| 1393 |
+
self.assertEqual(len(base_calls), 0)
|
| 1394 |
+
|
| 1395 |
+
def test_clients_have_meta_object(self):
|
| 1396 |
+
creator = self.create_client_creator()
|
| 1397 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 1398 |
+
self.assertTrue(hasattr(service_client, 'meta'))
|
| 1399 |
+
self.assertTrue(hasattr(service_client.meta, 'events'))
|
| 1400 |
+
# Sanity check the event emitter has an .emit() method.
|
| 1401 |
+
self.assertTrue(hasattr(service_client.meta.events, 'emit'))
|
| 1402 |
+
|
| 1403 |
+
def test_client_register_seperate_unique_id_event(self):
|
| 1404 |
+
event_emitter = hooks.HierarchicalEmitter()
|
| 1405 |
+
creator = self.create_client_creator(event_emitter=event_emitter)
|
| 1406 |
+
|
| 1407 |
+
client1 = creator.create_client('myservice', 'us-west-2')
|
| 1408 |
+
client2 = creator.create_client('myservice', 'us-west-2')
|
| 1409 |
+
|
| 1410 |
+
def ping(**kwargs):
|
| 1411 |
+
return 'foo'
|
| 1412 |
+
|
| 1413 |
+
client1.meta.events.register('some-event', ping, 'my-unique-id')
|
| 1414 |
+
client2.meta.events.register('some-event', ping, 'my-unique-id')
|
| 1415 |
+
|
| 1416 |
+
# Ensure both clients can register a function with an unique id
|
| 1417 |
+
client1_responses = client1.meta.events.emit('some-event')
|
| 1418 |
+
self.assertEqual(len(client1_responses), 1)
|
| 1419 |
+
self.assertEqual(client1_responses[0][1], 'foo')
|
| 1420 |
+
|
| 1421 |
+
client2_responses = client2.meta.events.emit('some-event')
|
| 1422 |
+
self.assertEqual(len(client2_responses), 1)
|
| 1423 |
+
self.assertEqual(client2_responses[0][1], 'foo')
|
| 1424 |
+
|
| 1425 |
+
# Ensure when a client is unregistered the other client has
|
| 1426 |
+
# the unique-id event still registered.
|
| 1427 |
+
client1.meta.events.unregister('some-event', ping, 'my-unique-id')
|
| 1428 |
+
client1_responses = client1.meta.events.emit('some-event')
|
| 1429 |
+
self.assertEqual(len(client1_responses), 0)
|
| 1430 |
+
|
| 1431 |
+
client2_responses = client2.meta.events.emit('some-event')
|
| 1432 |
+
self.assertEqual(len(client2_responses), 1)
|
| 1433 |
+
self.assertEqual(client2_responses[0][1], 'foo')
|
| 1434 |
+
|
| 1435 |
+
# Ensure that the other client can unregister the event
|
| 1436 |
+
client2.meta.events.unregister('some-event', ping, 'my-unique-id')
|
| 1437 |
+
client2_responses = client2.meta.events.emit('some-event')
|
| 1438 |
+
self.assertEqual(len(client2_responses), 0)
|
| 1439 |
+
|
| 1440 |
+
def test_client_created_emits_events(self):
|
| 1441 |
+
called = []
|
| 1442 |
+
|
| 1443 |
+
def on_client_create(class_attributes, **kwargs):
|
| 1444 |
+
called.append(class_attributes)
|
| 1445 |
+
|
| 1446 |
+
event_emitter = hooks.HierarchicalEmitter()
|
| 1447 |
+
event_emitter.register('creating-client-class', on_client_create)
|
| 1448 |
+
|
| 1449 |
+
creator = self.create_client_creator(event_emitter=event_emitter)
|
| 1450 |
+
creator.create_client(
|
| 1451 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1452 |
+
)
|
| 1453 |
+
|
| 1454 |
+
self.assertEqual(len(called), 1)
|
| 1455 |
+
self.assertIn('test_operation', called[0])
|
| 1456 |
+
|
| 1457 |
+
def test_client_method_called_event(self):
|
| 1458 |
+
event_emitter = hooks.HierarchicalEmitter()
|
| 1459 |
+
|
| 1460 |
+
def inject_params(params, **kwargs):
|
| 1461 |
+
new_params = params.copy()
|
| 1462 |
+
new_params['Foo'] = 'zero'
|
| 1463 |
+
return new_params
|
| 1464 |
+
|
| 1465 |
+
event_emitter.register(
|
| 1466 |
+
'provide-client-params.myservice.TestOperation', inject_params
|
| 1467 |
+
)
|
| 1468 |
+
|
| 1469 |
+
wrapped_emitter = mock.Mock(wraps=event_emitter)
|
| 1470 |
+
creator = self.create_client_creator(event_emitter=wrapped_emitter)
|
| 1471 |
+
service_client = creator.create_client(
|
| 1472 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1473 |
+
)
|
| 1474 |
+
|
| 1475 |
+
params = {'Foo': 'one', 'Bar': 'two'}
|
| 1476 |
+
service_client.test_operation(**params)
|
| 1477 |
+
|
| 1478 |
+
# Ensure that the initial params were not modified in the handler
|
| 1479 |
+
self.assertEqual(params, {'Foo': 'one', 'Bar': 'two'})
|
| 1480 |
+
|
| 1481 |
+
# Ensure the handler passed on the correct param values.
|
| 1482 |
+
body = self.endpoint.make_request.call_args[0][1]['body']
|
| 1483 |
+
self.assertEqual(body['Foo'], 'zero')
|
| 1484 |
+
|
| 1485 |
+
def test_client_default_for_s3_addressing_style(self):
|
| 1486 |
+
creator = self.create_client_creator()
|
| 1487 |
+
client = creator.create_client('myservice', 'us-west-2')
|
| 1488 |
+
self.assertEqual(client.meta.config.s3, None)
|
| 1489 |
+
|
| 1490 |
+
def test_client_s3_addressing_style_with_config(self):
|
| 1491 |
+
creator = self.create_client_creator()
|
| 1492 |
+
my_client = creator.create_client(
|
| 1493 |
+
'myservice',
|
| 1494 |
+
'us-west-2',
|
| 1495 |
+
client_config=botocore.config.Config(
|
| 1496 |
+
s3={'addressing_style': 'auto'}
|
| 1497 |
+
),
|
| 1498 |
+
)
|
| 1499 |
+
self.assertEqual(my_client.meta.config.s3['addressing_style'], 'auto')
|
| 1500 |
+
|
| 1501 |
+
def test_client_s3_addressing_style_with_bad_value(self):
|
| 1502 |
+
creator = self.create_client_creator()
|
| 1503 |
+
client = creator.create_client(
|
| 1504 |
+
'myservice',
|
| 1505 |
+
'us-west-2',
|
| 1506 |
+
scoped_config={'s3': ''},
|
| 1507 |
+
)
|
| 1508 |
+
self.assertIsNone(client.meta.config.s3)
|
| 1509 |
+
|
| 1510 |
+
def test_client_s3_addressing_style_with_config_store(self):
|
| 1511 |
+
self.config_store.set_config_variable(
|
| 1512 |
+
's3', {'addressing_style': 'virtual'}
|
| 1513 |
+
)
|
| 1514 |
+
creator = self.create_client_creator()
|
| 1515 |
+
client = creator.create_client('myservice', 'us-west-2')
|
| 1516 |
+
self.assertEqual(client.meta.config.s3['addressing_style'], 'virtual')
|
| 1517 |
+
|
| 1518 |
+
def test_client_s3_addressing_style_with_incorrect_style(self):
|
| 1519 |
+
with self.assertRaises(InvalidS3AddressingStyleError):
|
| 1520 |
+
botocore.config.Config(s3={'addressing_style': 'foo'})
|
| 1521 |
+
|
| 1522 |
+
def test_client_s3_addressing_style_config_overrides_config_store(self):
|
| 1523 |
+
self.config_store.set_config_variable(
|
| 1524 |
+
's3', {'addressing_style': 'virtual'}
|
| 1525 |
+
)
|
| 1526 |
+
creator = self.create_client_creator()
|
| 1527 |
+
my_client = creator.create_client(
|
| 1528 |
+
'myservice',
|
| 1529 |
+
'us-west-2',
|
| 1530 |
+
client_config=botocore.config.Config(
|
| 1531 |
+
s3={'addressing_style': 'auto'}
|
| 1532 |
+
),
|
| 1533 |
+
)
|
| 1534 |
+
self.assertEqual(my_client.meta.config.s3['addressing_style'], 'auto')
|
| 1535 |
+
|
| 1536 |
+
def test_client_payload_signing_from_config_store(self):
|
| 1537 |
+
self.config_store.set_config_variable(
|
| 1538 |
+
's3', {'payload_signing_enabled': True}
|
| 1539 |
+
)
|
| 1540 |
+
creator = self.create_client_creator()
|
| 1541 |
+
my_client = creator.create_client('myservice', 'us-west-2')
|
| 1542 |
+
self.assertEqual(
|
| 1543 |
+
my_client.meta.config.s3['payload_signing_enabled'], True
|
| 1544 |
+
)
|
| 1545 |
+
|
| 1546 |
+
def test_client_payload_signing_from_client_config(self):
|
| 1547 |
+
creator = self.create_client_creator()
|
| 1548 |
+
my_client = creator.create_client(
|
| 1549 |
+
'myservice',
|
| 1550 |
+
'us-west-2',
|
| 1551 |
+
client_config=client.Config(s3={'payload_signing_enabled': True}),
|
| 1552 |
+
)
|
| 1553 |
+
self.assertEqual(
|
| 1554 |
+
my_client.meta.config.s3['payload_signing_enabled'], True
|
| 1555 |
+
)
|
| 1556 |
+
|
| 1557 |
+
def test_client_payload_signing_client_config_overrides_scoped(self):
|
| 1558 |
+
creator = self.create_client_creator()
|
| 1559 |
+
my_client = creator.create_client(
|
| 1560 |
+
'myservice',
|
| 1561 |
+
'us-west-2',
|
| 1562 |
+
scoped_config={'s3': {'payload_signing_enabled': False}},
|
| 1563 |
+
client_config=client.Config(s3={'payload_signing_enabled': True}),
|
| 1564 |
+
)
|
| 1565 |
+
self.assertEqual(
|
| 1566 |
+
my_client.meta.config.s3['payload_signing_enabled'], True
|
| 1567 |
+
)
|
| 1568 |
+
|
| 1569 |
+
def test_client_s3_accelerate_from_config_store(self):
|
| 1570 |
+
self.config_store.set_config_variable(
|
| 1571 |
+
's3', {'use_accelerate_endpoint': True}
|
| 1572 |
+
)
|
| 1573 |
+
creator = self.create_client_creator()
|
| 1574 |
+
my_client = creator.create_client('myservice', 'us-west-2')
|
| 1575 |
+
self.assertEqual(
|
| 1576 |
+
my_client.meta.config.s3['use_accelerate_endpoint'], True
|
| 1577 |
+
)
|
| 1578 |
+
|
| 1579 |
+
def test_client_s3_accelerate_from_client_config(self):
|
| 1580 |
+
creator = self.create_client_creator()
|
| 1581 |
+
my_client = creator.create_client(
|
| 1582 |
+
'myservice',
|
| 1583 |
+
'us-west-2',
|
| 1584 |
+
client_config=client.Config(s3={'use_accelerate_endpoint': True}),
|
| 1585 |
+
)
|
| 1586 |
+
self.assertEqual(
|
| 1587 |
+
my_client.meta.config.s3['use_accelerate_endpoint'], True
|
| 1588 |
+
)
|
| 1589 |
+
|
| 1590 |
+
def test_client_s3_accelerate_client_config_overrides_config_store(self):
|
| 1591 |
+
self.config_store.set_config_variable(
|
| 1592 |
+
's3', {'use_accelerate_endpoint': False}
|
| 1593 |
+
)
|
| 1594 |
+
creator = self.create_client_creator()
|
| 1595 |
+
my_client = creator.create_client(
|
| 1596 |
+
'myservice',
|
| 1597 |
+
'us-west-2',
|
| 1598 |
+
client_config=client.Config(s3={'use_accelerate_endpoint': True}),
|
| 1599 |
+
)
|
| 1600 |
+
self.assertEqual(
|
| 1601 |
+
my_client.meta.config.s3['use_accelerate_endpoint'], True
|
| 1602 |
+
)
|
| 1603 |
+
|
| 1604 |
+
def test_before_call_short_circuits_request(self):
|
| 1605 |
+
def return_mock_tuple(**kwargs):
|
| 1606 |
+
http_mock = mock.Mock()
|
| 1607 |
+
http_mock.status_code = 200
|
| 1608 |
+
return http_mock, mock.Mock()
|
| 1609 |
+
|
| 1610 |
+
emitter = hooks.HierarchicalEmitter()
|
| 1611 |
+
emitter.register_last('before-call.*.*', return_mock_tuple)
|
| 1612 |
+
creator = self.create_client_creator(event_emitter=emitter)
|
| 1613 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 1614 |
+
|
| 1615 |
+
service_client.test_operation(Foo='one')
|
| 1616 |
+
self.assertFalse(self.endpoint.make_request.called)
|
| 1617 |
+
|
| 1618 |
+
def test_getattr_emits_event(self):
|
| 1619 |
+
emitter = self.create_mock_emitter()
|
| 1620 |
+
emitter.emit_until_response.return_value = (None, None)
|
| 1621 |
+
|
| 1622 |
+
creator = self.create_client_creator(event_emitter=emitter)
|
| 1623 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 1624 |
+
|
| 1625 |
+
# Assert that the event hasn't fired yet
|
| 1626 |
+
emitter.emit_until_response.assert_not_called()
|
| 1627 |
+
|
| 1628 |
+
with self.assertRaises(AttributeError):
|
| 1629 |
+
service_client.attribute_that_does_not_exist
|
| 1630 |
+
|
| 1631 |
+
emitter.emit_until_response.assert_called_once_with(
|
| 1632 |
+
'getattr.myservice.attribute_that_does_not_exist',
|
| 1633 |
+
client=service_client,
|
| 1634 |
+
)
|
| 1635 |
+
|
| 1636 |
+
def test_getattr_event_returns_response(self):
|
| 1637 |
+
emitter = self.create_mock_emitter()
|
| 1638 |
+
emitter.emit_until_response.return_value = (None, 'success')
|
| 1639 |
+
|
| 1640 |
+
creator = self.create_client_creator(event_emitter=emitter)
|
| 1641 |
+
service_client = creator.create_client('myservice', 'us-west-2')
|
| 1642 |
+
|
| 1643 |
+
value = service_client.attribute_that_does_not_exist
|
| 1644 |
+
|
| 1645 |
+
self.assertEqual(value, 'success')
|
| 1646 |
+
|
| 1647 |
+
def _create_hostname_binding_client(self, *args, **kwargs):
|
| 1648 |
+
test_operation = self.service_description['operations'][
|
| 1649 |
+
'TestOperation'
|
| 1650 |
+
]
|
| 1651 |
+
test_operation['endpoint'] = {'hostPrefix': '{Foo}.'}
|
| 1652 |
+
test_shape = self.service_description['shapes']['TestOperationRequest']
|
| 1653 |
+
test_shape['members']['Foo']['hostLabel'] = True
|
| 1654 |
+
|
| 1655 |
+
creator = self.create_client_creator()
|
| 1656 |
+
return creator.create_client('myservice', *args, **kwargs)
|
| 1657 |
+
|
| 1658 |
+
def test_client_operation_hostname_binding(self):
|
| 1659 |
+
client = self._create_hostname_binding_client('us-west-2')
|
| 1660 |
+
client.test_operation(Foo='bound')
|
| 1661 |
+
|
| 1662 |
+
expected_url = 'https://bound.myservice.amazonaws.com/'
|
| 1663 |
+
self.assertTrue(self.endpoint.make_request.called)
|
| 1664 |
+
request_dict = self.endpoint.make_request.call_args[0][1]
|
| 1665 |
+
self.assertEqual(request_dict['url'], expected_url)
|
| 1666 |
+
|
| 1667 |
+
def test_client_operation_hostname_binding_validation(self):
|
| 1668 |
+
client = self._create_hostname_binding_client('us-west-2')
|
| 1669 |
+
with self.assertRaises(ParamValidationError):
|
| 1670 |
+
client.test_operation(Foo='')
|
| 1671 |
+
|
| 1672 |
+
def test_client_operation_hostname_binding_configuration(self):
|
| 1673 |
+
config = botocore.config.Config(inject_host_prefix=False)
|
| 1674 |
+
client = self._create_hostname_binding_client(
|
| 1675 |
+
'us-west-2',
|
| 1676 |
+
client_config=config,
|
| 1677 |
+
)
|
| 1678 |
+
|
| 1679 |
+
client.test_operation(Foo='baz')
|
| 1680 |
+
expected_url = 'https://myservice.amazonaws.com/'
|
| 1681 |
+
self.assertTrue(self.endpoint.make_request.called)
|
| 1682 |
+
request_dict = self.endpoint.make_request.call_args[0][1]
|
| 1683 |
+
self.assertEqual(request_dict['url'], expected_url)
|
| 1684 |
+
|
| 1685 |
+
def test_client_close(self):
|
| 1686 |
+
creator = self.create_client_creator()
|
| 1687 |
+
service_client = creator.create_client(
|
| 1688 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1689 |
+
)
|
| 1690 |
+
|
| 1691 |
+
service_client.close()
|
| 1692 |
+
self.endpoint.close.assert_called_once_with()
|
| 1693 |
+
|
| 1694 |
+
def test_client_close_context_manager(self):
|
| 1695 |
+
creator = self.create_client_creator()
|
| 1696 |
+
with closing(
|
| 1697 |
+
creator.create_client(
|
| 1698 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1699 |
+
)
|
| 1700 |
+
) as service_client:
|
| 1701 |
+
service_client.test_operation(Foo='baz')
|
| 1702 |
+
|
| 1703 |
+
self.endpoint.close.assert_called_once_with()
|
| 1704 |
+
|
| 1705 |
+
def test_client_internal_credential_shim(self):
|
| 1706 |
+
"""This test exercises the internal credential shim exposed on clients.
|
| 1707 |
+
It's here to ensure we don't unintentionally regress behavior used with
|
| 1708 |
+
our upload/download operations in s3transfer with the CRT.
|
| 1709 |
+
"""
|
| 1710 |
+
creator = self.create_client_creator()
|
| 1711 |
+
service_client = creator.create_client(
|
| 1712 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1713 |
+
)
|
| 1714 |
+
self.assertEqual(service_client._get_credentials(), self.credentials)
|
| 1715 |
+
|
| 1716 |
+
|
| 1717 |
+
class TestClientErrors(TestAutoGeneratedClient):
|
| 1718 |
+
def add_error_response(self, error_response):
|
| 1719 |
+
self.endpoint.make_request.return_value = (
|
| 1720 |
+
mock.Mock(status_code=400),
|
| 1721 |
+
error_response,
|
| 1722 |
+
)
|
| 1723 |
+
|
| 1724 |
+
def test_client_makes_call_with_error(self):
|
| 1725 |
+
creator = self.create_client_creator()
|
| 1726 |
+
client = creator.create_client(
|
| 1727 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1728 |
+
)
|
| 1729 |
+
|
| 1730 |
+
with Stubber(client) as stub:
|
| 1731 |
+
stub.add_client_error(
|
| 1732 |
+
'test_operation', 'TestOperationErrorCode', 'error occurred'
|
| 1733 |
+
)
|
| 1734 |
+
with self.assertRaises(client.exceptions.TestOperationException):
|
| 1735 |
+
client.test_operation(Foo='one', Bar='two')
|
| 1736 |
+
|
| 1737 |
+
def test_error_with_no_wire_code(self):
|
| 1738 |
+
creator = self.create_client_creator()
|
| 1739 |
+
client = creator.create_client(
|
| 1740 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1741 |
+
)
|
| 1742 |
+
|
| 1743 |
+
with Stubber(client) as stub:
|
| 1744 |
+
stub.add_client_error('test_operation', '404', 'Not Found')
|
| 1745 |
+
try:
|
| 1746 |
+
client.test_operation(Foo='one', Bar='two')
|
| 1747 |
+
except client.exceptions.ClientError as e:
|
| 1748 |
+
# This is needed becasue the error could be a subclass of
|
| 1749 |
+
# ClientError.
|
| 1750 |
+
# We explicitly want it to be a generic ClientError though
|
| 1751 |
+
self.assertEqual(e.__class__, exceptions.ClientError)
|
| 1752 |
+
|
| 1753 |
+
def test_error_with_dot_separated_code(self):
|
| 1754 |
+
creator = self.create_client_creator()
|
| 1755 |
+
client = creator.create_client(
|
| 1756 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1757 |
+
)
|
| 1758 |
+
|
| 1759 |
+
with Stubber(client) as stub:
|
| 1760 |
+
stub.add_client_error(
|
| 1761 |
+
'test_operation', 'InvalidAddress.NotFound', 'Not Found'
|
| 1762 |
+
)
|
| 1763 |
+
try:
|
| 1764 |
+
client.test_operation(Foo='one', Bar='two')
|
| 1765 |
+
except client.exceptions.ClientError as e:
|
| 1766 |
+
# This is needed becasue the error could be a subclass of
|
| 1767 |
+
# ClientError.
|
| 1768 |
+
# We explicitly want it to be a generic ClientError though
|
| 1769 |
+
self.assertEqual(e.__class__, exceptions.ClientError)
|
| 1770 |
+
|
| 1771 |
+
def test_error_with_empty_message(self):
|
| 1772 |
+
creator = self.create_client_creator()
|
| 1773 |
+
client = creator.create_client(
|
| 1774 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1775 |
+
)
|
| 1776 |
+
|
| 1777 |
+
with Stubber(client) as stub:
|
| 1778 |
+
stub.add_client_error('test_operation', 'TestOperationErrorCode')
|
| 1779 |
+
with self.assertRaises(client.exceptions.TestOperationException):
|
| 1780 |
+
client.test_operation(Foo='one', Bar='two')
|
| 1781 |
+
|
| 1782 |
+
def test_error_with_empty_code(self):
|
| 1783 |
+
creator = self.create_client_creator()
|
| 1784 |
+
client = creator.create_client(
|
| 1785 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1786 |
+
)
|
| 1787 |
+
|
| 1788 |
+
with Stubber(client) as stub:
|
| 1789 |
+
stub.add_client_error('test_operation')
|
| 1790 |
+
try:
|
| 1791 |
+
client.test_operation(Foo='one', Bar='two')
|
| 1792 |
+
except client.exceptions.ClientError as e:
|
| 1793 |
+
# This is needed becasue the error could be a subclass of
|
| 1794 |
+
# ClientError.
|
| 1795 |
+
# We explicitly want it to be a generic ClientError though
|
| 1796 |
+
self.assertEqual(e.__class__, exceptions.ClientError)
|
| 1797 |
+
|
| 1798 |
+
def test_error_with_missing_code(self):
|
| 1799 |
+
error_response = {'Error': {'Message': 'error occurred'}}
|
| 1800 |
+
# The stubber is not being used because it will always populate the
|
| 1801 |
+
# the message and code.
|
| 1802 |
+
self.endpoint.make_request.return_value = (
|
| 1803 |
+
mock.Mock(status_code=400),
|
| 1804 |
+
error_response,
|
| 1805 |
+
)
|
| 1806 |
+
|
| 1807 |
+
creator = self.create_client_creator()
|
| 1808 |
+
client = creator.create_client(
|
| 1809 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1810 |
+
)
|
| 1811 |
+
|
| 1812 |
+
try:
|
| 1813 |
+
client.test_operation(Foo='one', Bar='two')
|
| 1814 |
+
except client.exceptions.ClientError as e:
|
| 1815 |
+
# This is needed becasue the error could be a subclass of
|
| 1816 |
+
# ClientError.
|
| 1817 |
+
# We explicitly want it to be a generic ClientError though
|
| 1818 |
+
self.assertEqual(e.__class__, exceptions.ClientError)
|
| 1819 |
+
|
| 1820 |
+
def test_error_with_empty_contents(self):
|
| 1821 |
+
error_response = {'Error': {}}
|
| 1822 |
+
# The stubber is not being used because it will always populate the
|
| 1823 |
+
# the message and code.
|
| 1824 |
+
self.endpoint.make_request.return_value = (
|
| 1825 |
+
mock.Mock(status_code=400),
|
| 1826 |
+
error_response,
|
| 1827 |
+
)
|
| 1828 |
+
|
| 1829 |
+
creator = self.create_client_creator()
|
| 1830 |
+
client = creator.create_client(
|
| 1831 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1832 |
+
)
|
| 1833 |
+
|
| 1834 |
+
try:
|
| 1835 |
+
client.test_operation(Foo='one', Bar='two')
|
| 1836 |
+
except client.exceptions.ClientError as e:
|
| 1837 |
+
# This is needed becasue the error could be a subclass of
|
| 1838 |
+
# ClientError.
|
| 1839 |
+
# We explicitly want it to be a generic ClientError though
|
| 1840 |
+
self.assertEqual(e.__class__, exceptions.ClientError)
|
| 1841 |
+
|
| 1842 |
+
def test_exception_classes_across_clients_are_the_same(self):
|
| 1843 |
+
creator = self.create_client_creator(
|
| 1844 |
+
exceptions_factory=ClientExceptionsFactory()
|
| 1845 |
+
)
|
| 1846 |
+
client = creator.create_client(
|
| 1847 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1848 |
+
)
|
| 1849 |
+
client2 = creator.create_client(
|
| 1850 |
+
'myservice', 'us-west-2', credentials=self.credentials
|
| 1851 |
+
)
|
| 1852 |
+
|
| 1853 |
+
with Stubber(client) as stub:
|
| 1854 |
+
stub.add_client_error(
|
| 1855 |
+
'test_operation', 'TestOperationErrorCode', 'error occurred'
|
| 1856 |
+
)
|
| 1857 |
+
try:
|
| 1858 |
+
client.test_operation(Foo='one', Bar='two')
|
| 1859 |
+
except client2.exceptions.TestOperationException as e:
|
| 1860 |
+
# Caught exception should as well be an instance of the
|
| 1861 |
+
# other client's TestOperationException
|
| 1862 |
+
self.assertIsInstance(
|
| 1863 |
+
e, client.exceptions.TestOperationException
|
| 1864 |
+
)
|
| 1865 |
+
|
| 1866 |
+
|
| 1867 |
+
class TestConfig(unittest.TestCase):
|
| 1868 |
+
def test_can_use_args_to_construct(self):
|
| 1869 |
+
config = botocore.config.Config(
|
| 1870 |
+
*botocore.config.Config.OPTION_DEFAULTS.values()
|
| 1871 |
+
)
|
| 1872 |
+
for (
|
| 1873 |
+
option,
|
| 1874 |
+
default_value,
|
| 1875 |
+
) in botocore.config.Config.OPTION_DEFAULTS.items():
|
| 1876 |
+
self.assertTrue(hasattr(config, option))
|
| 1877 |
+
self.assertEqual(getattr(config, option), default_value)
|
| 1878 |
+
|
| 1879 |
+
def test_can_use_kwargs_to_construct(self):
|
| 1880 |
+
config = botocore.config.Config(
|
| 1881 |
+
**botocore.config.Config.OPTION_DEFAULTS
|
| 1882 |
+
)
|
| 1883 |
+
for (
|
| 1884 |
+
option,
|
| 1885 |
+
default_value,
|
| 1886 |
+
) in botocore.config.Config.OPTION_DEFAULTS.items():
|
| 1887 |
+
self.assertTrue(hasattr(config, option))
|
| 1888 |
+
self.assertEqual(getattr(config, option), default_value)
|
| 1889 |
+
|
| 1890 |
+
def test_can_use_mix_of_args_and_kwargs(self):
|
| 1891 |
+
config = botocore.config.Config('us-east-1', read_timeout=50)
|
| 1892 |
+
self.assertEqual(config.region_name, 'us-east-1')
|
| 1893 |
+
self.assertEqual(config.read_timeout, 50)
|
| 1894 |
+
|
| 1895 |
+
def test_invalid_kwargs(self):
|
| 1896 |
+
with self.assertRaisesRegex(TypeError, 'Got unexpected keyword'):
|
| 1897 |
+
botocore.config.Config(foo='foo')
|
| 1898 |
+
|
| 1899 |
+
def test_pass_invalid_length_of_args(self):
|
| 1900 |
+
with self.assertRaisesRegex(TypeError, 'Takes at most'):
|
| 1901 |
+
botocore.config.Config(
|
| 1902 |
+
'foo', *botocore.config.Config.OPTION_DEFAULTS.values()
|
| 1903 |
+
)
|
| 1904 |
+
|
| 1905 |
+
def test_create_with_multiple_kwargs(self):
|
| 1906 |
+
with self.assertRaisesRegex(TypeError, 'Got multiple values'):
|
| 1907 |
+
botocore.config.Config('us-east-1', region_name='us-east-1')
|
| 1908 |
+
|
| 1909 |
+
def test_merge_returns_new_config_object(self):
|
| 1910 |
+
config = botocore.config.Config()
|
| 1911 |
+
other_config = botocore.config.Config()
|
| 1912 |
+
new_config = config.merge(other_config)
|
| 1913 |
+
# Check the type is correct
|
| 1914 |
+
self.assertIsInstance(new_config, botocore.config.Config)
|
| 1915 |
+
# Make sure the new config is a brand new config object
|
| 1916 |
+
self.assertIsNot(new_config, config)
|
| 1917 |
+
self.assertIsNot(new_config, other_config)
|
| 1918 |
+
|
| 1919 |
+
def test_general_merge_keeps_default_values(self):
|
| 1920 |
+
config = botocore.config.Config()
|
| 1921 |
+
other_config = botocore.config.Config()
|
| 1922 |
+
config_properties = vars(config)
|
| 1923 |
+
new_config = config.merge(other_config)
|
| 1924 |
+
# Ensure that the values all stayed the same in the new config
|
| 1925 |
+
self.assertEqual(config_properties, vars(new_config))
|
| 1926 |
+
|
| 1927 |
+
def test_merge_overrides_values(self):
|
| 1928 |
+
config = botocore.config.Config(region_name='us-east-1')
|
| 1929 |
+
other_config = botocore.config.Config(region_name='us-west-2')
|
| 1930 |
+
new_config = config.merge(other_config)
|
| 1931 |
+
self.assertEqual(new_config.region_name, 'us-west-2')
|
| 1932 |
+
|
| 1933 |
+
def test_merge_overrides_values_even_when_using_default(self):
|
| 1934 |
+
config = botocore.config.Config(region_name='us-east-1')
|
| 1935 |
+
other_config = botocore.config.Config(region_name=None)
|
| 1936 |
+
new_config = config.merge(other_config)
|
| 1937 |
+
self.assertEqual(new_config.region_name, None)
|
| 1938 |
+
|
| 1939 |
+
def test_merge_overrides_values_even_when_using_default_timeout(self):
|
| 1940 |
+
config = botocore.config.Config(read_timeout=30)
|
| 1941 |
+
other_config = botocore.config.Config(read_timeout=DEFAULT_TIMEOUT)
|
| 1942 |
+
new_config = config.merge(other_config)
|
| 1943 |
+
self.assertEqual(new_config.read_timeout, DEFAULT_TIMEOUT)
|
| 1944 |
+
|
| 1945 |
+
def test_merge_overrides_only_when_user_provided_values(self):
|
| 1946 |
+
config = botocore.config.Config(
|
| 1947 |
+
region_name='us-east-1', signature_version='s3v4'
|
| 1948 |
+
)
|
| 1949 |
+
other_config = botocore.config.Config(region_name='us-west-2')
|
| 1950 |
+
new_config = config.merge(other_config)
|
| 1951 |
+
self.assertEqual(new_config.region_name, 'us-west-2')
|
| 1952 |
+
self.assertEqual(new_config.signature_version, 's3v4')
|
| 1953 |
+
|
| 1954 |
+
def test_can_set_retry_max_attempts(self):
|
| 1955 |
+
config = botocore.config.Config(retries={'max_attempts': 15})
|
| 1956 |
+
self.assertEqual(config.retries['max_attempts'], 15)
|
| 1957 |
+
|
| 1958 |
+
def test_validates_retry_config(self):
|
| 1959 |
+
with self.assertRaisesRegex(
|
| 1960 |
+
InvalidRetryConfigurationError,
|
| 1961 |
+
'Cannot provide retry configuration for "not-allowed"',
|
| 1962 |
+
):
|
| 1963 |
+
botocore.config.Config(retries={'not-allowed': True})
|
| 1964 |
+
|
| 1965 |
+
def test_validates_max_retry_attempts(self):
|
| 1966 |
+
with self.assertRaises(InvalidMaxRetryAttemptsError):
|
| 1967 |
+
botocore.config.Config(retries={'max_attempts': -1})
|
| 1968 |
+
|
| 1969 |
+
def test_validates_total_max_attempts(self):
|
| 1970 |
+
with self.assertRaises(InvalidMaxRetryAttemptsError):
|
| 1971 |
+
botocore.config.Config(retries={'total_max_attempts': 0})
|
| 1972 |
+
|
| 1973 |
+
def test_validaties_retry_mode(self):
|
| 1974 |
+
with self.assertRaises(InvalidRetryModeError):
|
| 1975 |
+
botocore.config.Config(retries={'mode': 'turbo-mode'})
|
| 1976 |
+
|
| 1977 |
+
|
| 1978 |
+
class TestClientEndpointBridge(unittest.TestCase):
|
| 1979 |
+
def setUp(self):
|
| 1980 |
+
self.resolver = mock.Mock()
|
| 1981 |
+
self.boilerplate_response = {
|
| 1982 |
+
'endpointName': 'us-east-1',
|
| 1983 |
+
'hostname': 's3.amazonaws.com',
|
| 1984 |
+
'partition': 'aws',
|
| 1985 |
+
'protocols': ['http', 'https'],
|
| 1986 |
+
'dnsSuffix': 'amazonaws.com',
|
| 1987 |
+
'signatureVersions': ['s3', 's3v4'],
|
| 1988 |
+
}
|
| 1989 |
+
self.resolver.construct_endpoint.return_value = (
|
| 1990 |
+
self.boilerplate_response
|
| 1991 |
+
)
|
| 1992 |
+
|
| 1993 |
+
def test_guesses_endpoint_as_last_resort(self):
|
| 1994 |
+
resolver = mock.Mock()
|
| 1995 |
+
resolver.construct_endpoint.return_value = None
|
| 1996 |
+
bridge = ClientEndpointBridge(resolver)
|
| 1997 |
+
resolved = bridge.resolve('myservice', region_name='guess')
|
| 1998 |
+
self.assertEqual('guess', resolved['region_name'])
|
| 1999 |
+
self.assertEqual('guess', resolved['signing_region'])
|
| 2000 |
+
self.assertEqual('myservice', resolved['signing_name'])
|
| 2001 |
+
self.assertEqual('myservice', resolved['service_name'])
|
| 2002 |
+
self.assertEqual('v4', resolved['signature_version'])
|
| 2003 |
+
self.assertEqual(
|
| 2004 |
+
'https://myservice.guess.amazonaws.com', resolved['endpoint_url']
|
| 2005 |
+
)
|
| 2006 |
+
|
| 2007 |
+
def test_uses_us_east_1_by_default_for_s3(self):
|
| 2008 |
+
resolver = mock.Mock()
|
| 2009 |
+
resolver.construct_endpoint.return_value = {
|
| 2010 |
+
'partition': 'aws',
|
| 2011 |
+
'hostname': 's3.amazonaws.com',
|
| 2012 |
+
'endpointName': 'us-east-1',
|
| 2013 |
+
'signatureVersions': ['s3', 's3v4'],
|
| 2014 |
+
'protocols': ['https'],
|
| 2015 |
+
}
|
| 2016 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2017 |
+
resolved = bridge.resolve('s3')
|
| 2018 |
+
self.assertEqual('us-east-1', resolved['region_name'])
|
| 2019 |
+
self.assertEqual('us-east-1', resolved['signing_region'])
|
| 2020 |
+
self.assertEqual('https://s3.amazonaws.com', resolved['endpoint_url'])
|
| 2021 |
+
|
| 2022 |
+
def test_uses_region_from_client_config_if_available(self):
|
| 2023 |
+
resolver = mock.Mock()
|
| 2024 |
+
resolver.construct_endpoint.return_value = None
|
| 2025 |
+
client_config = mock.Mock()
|
| 2026 |
+
client_config.region_name = 'us-foo-bar'
|
| 2027 |
+
bridge = ClientEndpointBridge(resolver, client_config=client_config)
|
| 2028 |
+
resolved = bridge.resolve('test')
|
| 2029 |
+
self.assertEqual('us-foo-bar', resolved['region_name'])
|
| 2030 |
+
self.assertEqual('us-foo-bar', resolved['signing_region'])
|
| 2031 |
+
self.assertEqual(
|
| 2032 |
+
'https://test.us-foo-bar.amazonaws.com', resolved['endpoint_url']
|
| 2033 |
+
)
|
| 2034 |
+
|
| 2035 |
+
def test_can_guess_endpoint_and_use_given_endpoint_url(self):
|
| 2036 |
+
resolver = mock.Mock()
|
| 2037 |
+
resolver.construct_endpoint.return_value = None
|
| 2038 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2039 |
+
resolved = bridge.resolve(
|
| 2040 |
+
'test', 'guess', endpoint_url='http://test.com'
|
| 2041 |
+
)
|
| 2042 |
+
self.assertEqual('guess', resolved['region_name'])
|
| 2043 |
+
self.assertEqual('guess', resolved['signing_region'])
|
| 2044 |
+
self.assertEqual('http://test.com', resolved['endpoint_url'])
|
| 2045 |
+
|
| 2046 |
+
def test_can_use_endpoint_url_with_resolved_endpoint(self):
|
| 2047 |
+
resolver = mock.Mock()
|
| 2048 |
+
resolver.construct_endpoint.return_value = {
|
| 2049 |
+
'partition': 'aws',
|
| 2050 |
+
'hostname': 'do-not-use-this',
|
| 2051 |
+
'endpointName': 'us-west-2',
|
| 2052 |
+
'signatureVersions': ['v2'],
|
| 2053 |
+
}
|
| 2054 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2055 |
+
resolved = bridge.resolve(
|
| 2056 |
+
'ec2', 'us-west-2', endpoint_url='https://foo'
|
| 2057 |
+
)
|
| 2058 |
+
self.assertEqual('us-west-2', resolved['region_name'])
|
| 2059 |
+
self.assertEqual('us-west-2', resolved['signing_region'])
|
| 2060 |
+
self.assertEqual('https://foo', resolved['endpoint_url'])
|
| 2061 |
+
self.assertEqual('v2', resolved['signature_version'])
|
| 2062 |
+
|
| 2063 |
+
def test_can_create_http_urls(self):
|
| 2064 |
+
resolver = mock.Mock()
|
| 2065 |
+
resolver.construct_endpoint.return_value = {
|
| 2066 |
+
'partition': 'aws',
|
| 2067 |
+
'hostname': 'host.com',
|
| 2068 |
+
'signatureVersions': ['v4'],
|
| 2069 |
+
'endpointName': 'us-foo-baz',
|
| 2070 |
+
}
|
| 2071 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2072 |
+
resolved = bridge.resolve('myservice', 'us-foo-baz', is_secure=False)
|
| 2073 |
+
self.assertEqual('http://host.com', resolved['endpoint_url'])
|
| 2074 |
+
|
| 2075 |
+
def test_credential_scope_overrides_signing_region(self):
|
| 2076 |
+
resolver = mock.Mock()
|
| 2077 |
+
resolver.construct_endpoint.return_value = {
|
| 2078 |
+
'partition': 'aws',
|
| 2079 |
+
'hostname': 'host.com',
|
| 2080 |
+
'endpointName': 'us-foo-baz',
|
| 2081 |
+
'signatureVersions': ['v4'],
|
| 2082 |
+
'credentialScope': {'region': 'override'},
|
| 2083 |
+
}
|
| 2084 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2085 |
+
resolved = bridge.resolve('myservice', 'us-foo-baz')
|
| 2086 |
+
self.assertEqual('us-foo-baz', resolved['region_name'])
|
| 2087 |
+
self.assertEqual('override', resolved['signing_region'])
|
| 2088 |
+
|
| 2089 |
+
def test_cred_scope_does_not_override_signing_region_if_endpoint_url(self):
|
| 2090 |
+
resolver = mock.Mock()
|
| 2091 |
+
resolver.construct_endpoint.return_value = {
|
| 2092 |
+
'partition': 'aws',
|
| 2093 |
+
'hostname': 'will-not-use.com',
|
| 2094 |
+
'endpointName': 'us-foo-baz',
|
| 2095 |
+
'signatureVersions': ['v4'],
|
| 2096 |
+
'credentialScope': {'region': 'override'},
|
| 2097 |
+
}
|
| 2098 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2099 |
+
resolved = bridge.resolve(
|
| 2100 |
+
'myservice', 'us-foo-baz', endpoint_url='https://override.com'
|
| 2101 |
+
)
|
| 2102 |
+
self.assertEqual('us-foo-baz', resolved['region_name'])
|
| 2103 |
+
self.assertEqual('us-foo-baz', resolved['signing_region'])
|
| 2104 |
+
self.assertEqual('https://override.com', resolved['endpoint_url'])
|
| 2105 |
+
|
| 2106 |
+
def test_resolved_region_overrides_region_when_no_endpoint_url(self):
|
| 2107 |
+
resolver = mock.Mock()
|
| 2108 |
+
resolver.construct_endpoint.return_value = {
|
| 2109 |
+
'partition': 'aws',
|
| 2110 |
+
'hostname': 'host.com',
|
| 2111 |
+
'signatureVersions': ['v4'],
|
| 2112 |
+
'endpointName': 'override',
|
| 2113 |
+
'protocols': ['https'],
|
| 2114 |
+
}
|
| 2115 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2116 |
+
resolved = bridge.resolve('myservice', 'will-not-be-there')
|
| 2117 |
+
self.assertEqual('override', resolved['region_name'])
|
| 2118 |
+
self.assertEqual('override', resolved['signing_region'])
|
| 2119 |
+
self.assertEqual('https://host.com', resolved['endpoint_url'])
|
| 2120 |
+
|
| 2121 |
+
def test_does_not_use_https_if_not_available(self):
|
| 2122 |
+
resolver = mock.Mock()
|
| 2123 |
+
resolver.construct_endpoint.return_value = {
|
| 2124 |
+
'partition': 'aws',
|
| 2125 |
+
'hostname': 'host.com',
|
| 2126 |
+
'signatureVersions': ['v4'],
|
| 2127 |
+
'endpointName': 'foo',
|
| 2128 |
+
# Note: http, not https
|
| 2129 |
+
'protocols': ['http'],
|
| 2130 |
+
}
|
| 2131 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2132 |
+
resolved = bridge.resolve('myservice')
|
| 2133 |
+
# We should resolve to http://, not https://
|
| 2134 |
+
self.assertEqual('http://host.com', resolved['endpoint_url'])
|
| 2135 |
+
|
| 2136 |
+
def test_uses_signature_version_from_client_config(self):
|
| 2137 |
+
resolver = mock.Mock()
|
| 2138 |
+
resolver.construct_endpoint.return_value = {
|
| 2139 |
+
'partition': 'aws',
|
| 2140 |
+
'hostname': 'test.com',
|
| 2141 |
+
'endpointName': 'us-west-2',
|
| 2142 |
+
'signatureVersions': ['v2'],
|
| 2143 |
+
}
|
| 2144 |
+
client_config = mock.Mock()
|
| 2145 |
+
client_config.signature_version = 's3'
|
| 2146 |
+
bridge = ClientEndpointBridge(resolver, client_config=client_config)
|
| 2147 |
+
resolved = bridge.resolve('test', 'us-west-2')
|
| 2148 |
+
self.assertEqual('s3', resolved['signature_version'])
|
| 2149 |
+
|
| 2150 |
+
def test_uses_signature_version_from_client_config_when_guessing(self):
|
| 2151 |
+
resolver = mock.Mock()
|
| 2152 |
+
resolver.construct_endpoint.return_value = None
|
| 2153 |
+
client_config = mock.Mock()
|
| 2154 |
+
client_config.signature_version = 's3v4'
|
| 2155 |
+
bridge = ClientEndpointBridge(resolver, client_config=client_config)
|
| 2156 |
+
resolved = bridge.resolve('test', 'us-west-2')
|
| 2157 |
+
self.assertEqual('s3v4', resolved['signature_version'])
|
| 2158 |
+
|
| 2159 |
+
def test_uses_signature_version_from_scoped_config(self):
|
| 2160 |
+
resolver = mock.Mock()
|
| 2161 |
+
resolver.construct_endpoint.return_value = {
|
| 2162 |
+
'partition': 'aws',
|
| 2163 |
+
'hostname': 'test.com',
|
| 2164 |
+
'endpointName': 'us-west-2',
|
| 2165 |
+
'signatureVersions': ['v2'],
|
| 2166 |
+
}
|
| 2167 |
+
scoped_config = mock.Mock()
|
| 2168 |
+
scoped_config.get.return_value = {'signature_version': 's3'}
|
| 2169 |
+
bridge = ClientEndpointBridge(resolver, scoped_config)
|
| 2170 |
+
resolved = bridge.resolve('test', 'us-west-2')
|
| 2171 |
+
self.assertEqual('s3', resolved['signature_version'])
|
| 2172 |
+
|
| 2173 |
+
def test_uses_s3v4_over_s3_for_s3(self):
|
| 2174 |
+
resolver = mock.Mock()
|
| 2175 |
+
resolver.construct_endpoint.return_value = {
|
| 2176 |
+
'partition': 'aws',
|
| 2177 |
+
'hostname': 'test.com',
|
| 2178 |
+
'endpointName': 'us-west-2',
|
| 2179 |
+
'signatureVersions': ['s3v4', 's3'],
|
| 2180 |
+
}
|
| 2181 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2182 |
+
resolved = bridge.resolve('s3', 'us-west-2')
|
| 2183 |
+
self.assertEqual('s3v4', resolved['signature_version'])
|
| 2184 |
+
|
| 2185 |
+
def test_uses_s3v4_over_others_for_s3(self):
|
| 2186 |
+
resolver = mock.Mock()
|
| 2187 |
+
resolver.construct_endpoint.return_value = {
|
| 2188 |
+
'partition': 'aws',
|
| 2189 |
+
'hostname': 'test.com',
|
| 2190 |
+
'endpointName': 'us-west-2',
|
| 2191 |
+
'signatureVersions': ['s3v4', 'v4'],
|
| 2192 |
+
}
|
| 2193 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2194 |
+
resolved = bridge.resolve('s3', 'us-west-2')
|
| 2195 |
+
self.assertEqual('s3v4', resolved['signature_version'])
|
| 2196 |
+
|
| 2197 |
+
def test_uses_v4_over_other_signers(self):
|
| 2198 |
+
resolver = mock.Mock()
|
| 2199 |
+
resolver.construct_endpoint.return_value = {
|
| 2200 |
+
'partition': 'aws',
|
| 2201 |
+
'hostname': 'test',
|
| 2202 |
+
'signatureVersions': ['v2', 'v4'],
|
| 2203 |
+
'endpointName': 'us-west-2',
|
| 2204 |
+
}
|
| 2205 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2206 |
+
resolved = bridge.resolve('test', 'us-west-2')
|
| 2207 |
+
self.assertEqual('v4', resolved['signature_version'])
|
| 2208 |
+
|
| 2209 |
+
def test_uses_known_signers_from_list_of_signature_versions(self):
|
| 2210 |
+
resolver = mock.Mock()
|
| 2211 |
+
resolver.construct_endpoint.return_value = {
|
| 2212 |
+
'partition': 'aws',
|
| 2213 |
+
'hostname': 'test',
|
| 2214 |
+
'signatureVersions': ['foo', 'baz', 'v3https'],
|
| 2215 |
+
'endpointName': 'us-west-2',
|
| 2216 |
+
}
|
| 2217 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2218 |
+
resolved = bridge.resolve('test', 'us-west-2')
|
| 2219 |
+
self.assertEqual('v3https', resolved['signature_version'])
|
| 2220 |
+
|
| 2221 |
+
def test_raises_when_signature_version_is_unknown(self):
|
| 2222 |
+
resolver = mock.Mock()
|
| 2223 |
+
resolver.construct_endpoint.return_value = {
|
| 2224 |
+
'partition': 'aws',
|
| 2225 |
+
'hostname': 'test',
|
| 2226 |
+
'endpointName': 'us-west-2',
|
| 2227 |
+
'signatureVersions': ['foo'],
|
| 2228 |
+
}
|
| 2229 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2230 |
+
with self.assertRaises(UnknownSignatureVersionError):
|
| 2231 |
+
bridge.resolve('test', 'us-west-2')
|
| 2232 |
+
|
| 2233 |
+
def test_uses_first_known_signature_version(self):
|
| 2234 |
+
resolver = mock.Mock()
|
| 2235 |
+
resolver.construct_endpoint.return_value = {
|
| 2236 |
+
'partition': 'aws',
|
| 2237 |
+
'hostname': 'test',
|
| 2238 |
+
'endpointName': 'us-west-2',
|
| 2239 |
+
'signatureVersions': ['foo', 'bar', 'baz', 's3v4', 'v2'],
|
| 2240 |
+
}
|
| 2241 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2242 |
+
resolved = bridge.resolve('test', 'us-west-2')
|
| 2243 |
+
self.assertEqual('s3v4', resolved['signature_version'])
|
| 2244 |
+
|
| 2245 |
+
def test_raises_when_signature_version_is_not_found(self):
|
| 2246 |
+
resolver = mock.Mock()
|
| 2247 |
+
resolver.construct_endpoint.return_value = {
|
| 2248 |
+
'partition': 'aws',
|
| 2249 |
+
'hostname': 'test',
|
| 2250 |
+
'endpointName': 'us-west-2',
|
| 2251 |
+
}
|
| 2252 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2253 |
+
with self.assertRaises(UnknownSignatureVersionError):
|
| 2254 |
+
bridge.resolve('test', 'us-west-2')
|
| 2255 |
+
|
| 2256 |
+
def test_uses_service_name_as_signing_name(self):
|
| 2257 |
+
resolver = mock.Mock()
|
| 2258 |
+
resolver.construct_endpoint.return_value = {
|
| 2259 |
+
'partition': 'aws',
|
| 2260 |
+
'hostname': 'test',
|
| 2261 |
+
'signatureVersions': ['v4'],
|
| 2262 |
+
'endpointName': 'us-west-2',
|
| 2263 |
+
}
|
| 2264 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2265 |
+
resolved = bridge.resolve('test', 'us-west-2')
|
| 2266 |
+
self.assertEqual('test', resolved['signing_name'])
|
| 2267 |
+
|
| 2268 |
+
def test_uses_credential_scope_signing_name(self):
|
| 2269 |
+
resolver = mock.Mock()
|
| 2270 |
+
resolver.construct_endpoint.return_value = {
|
| 2271 |
+
'partition': 'aws',
|
| 2272 |
+
'hostname': 'test',
|
| 2273 |
+
'endpointName': 'us-west-2',
|
| 2274 |
+
'signatureVersions': ['v4'],
|
| 2275 |
+
'credentialScope': {'service': 'override'},
|
| 2276 |
+
}
|
| 2277 |
+
bridge = ClientEndpointBridge(resolver)
|
| 2278 |
+
resolved = bridge.resolve('test', 'us-west-2')
|
| 2279 |
+
self.assertEqual('override', resolved['signing_name'])
|
| 2280 |
+
|
| 2281 |
+
def test_uses_service_signing_name_when_present_and_no_cred_scope(self):
|
| 2282 |
+
resolver = mock.Mock()
|
| 2283 |
+
resolver.construct_endpoint.return_value = {
|
| 2284 |
+
'partition': 'aws',
|
| 2285 |
+
'hostname': 'test',
|
| 2286 |
+
'signatureVersions': ['v4'],
|
| 2287 |
+
'endpointName': 'us-west-2',
|
| 2288 |
+
}
|
| 2289 |
+
bridge = ClientEndpointBridge(resolver, service_signing_name='foo')
|
| 2290 |
+
resolved = bridge.resolve('test', 'us-west-2')
|
| 2291 |
+
self.assertEqual('foo', resolved['signing_name'])
|
| 2292 |
+
|
| 2293 |
+
def test_disable_dualstack_explicitly(self):
|
| 2294 |
+
scoped_config = {'s3': {'use_dualstack_endpoint': True}}
|
| 2295 |
+
config = botocore.config.Config(s3={'use_dualstack_endpoint': False})
|
| 2296 |
+
bridge = ClientEndpointBridge(
|
| 2297 |
+
self.resolver, scoped_config, client_config=config
|
| 2298 |
+
)
|
| 2299 |
+
resolved = bridge.resolve('s3', 'us-east-1')
|
| 2300 |
+
self.assertEqual(resolved['endpoint_url'], 'https://s3.amazonaws.com')
|
| 2301 |
+
|
| 2302 |
+
def test_use_dualstack_endpoint(self):
|
| 2303 |
+
config = botocore.config.Config(use_dualstack_endpoint=True)
|
| 2304 |
+
bridge = ClientEndpointBridge(self.resolver, client_config=config)
|
| 2305 |
+
bridge.resolve('ec2', 'us-west-2')
|
| 2306 |
+
self.resolver.construct_endpoint.assert_called_with(
|
| 2307 |
+
'ec2',
|
| 2308 |
+
'us-west-2',
|
| 2309 |
+
use_dualstack_endpoint=True,
|
| 2310 |
+
use_fips_endpoint=False,
|
| 2311 |
+
)
|
| 2312 |
+
|
| 2313 |
+
def test_use_fips_endpoint(self):
|
| 2314 |
+
config = botocore.config.Config(use_fips_endpoint=True)
|
| 2315 |
+
bridge = ClientEndpointBridge(self.resolver, client_config=config)
|
| 2316 |
+
bridge.resolve('ec2', 'us-west-2')
|
| 2317 |
+
self.resolver.construct_endpoint.assert_called_with(
|
| 2318 |
+
'ec2',
|
| 2319 |
+
'us-west-2',
|
| 2320 |
+
use_dualstack_endpoint=False,
|
| 2321 |
+
use_fips_endpoint=True,
|
| 2322 |
+
)
|
| 2323 |
+
|
| 2324 |
+
def test_use_dualstack_endpoint_omits_s3(self):
|
| 2325 |
+
config = botocore.config.Config(
|
| 2326 |
+
use_dualstack_endpoint=True, s3={'use_dualstack_endpoint': False}
|
| 2327 |
+
)
|
| 2328 |
+
bridge = ClientEndpointBridge(self.resolver, client_config=config)
|
| 2329 |
+
bridge.resolve('s3', 'us-west-2')
|
| 2330 |
+
self.resolver.construct_endpoint.assert_called_with(
|
| 2331 |
+
's3',
|
| 2332 |
+
'us-west-2',
|
| 2333 |
+
use_dualstack_endpoint=False,
|
| 2334 |
+
use_fips_endpoint=False,
|
| 2335 |
+
)
|
| 2336 |
+
|
| 2337 |
+
def test_modeled_endpoint_variants_client_config_trumps_scoped_config(
|
| 2338 |
+
self,
|
| 2339 |
+
):
|
| 2340 |
+
scoped_config = {
|
| 2341 |
+
'use_dualstack_endpoint': True,
|
| 2342 |
+
'use_fips_endpoint': True,
|
| 2343 |
+
}
|
| 2344 |
+
config = botocore.config.Config(
|
| 2345 |
+
use_dualstack_endpoint=False, use_fips_endpoint=False
|
| 2346 |
+
)
|
| 2347 |
+
bridge = ClientEndpointBridge(
|
| 2348 |
+
self.resolver, scoped_config, client_config=config
|
| 2349 |
+
)
|
| 2350 |
+
bridge.resolve('ec2', 'us-west-2')
|
| 2351 |
+
self.resolver.construct_endpoint.assert_called_with(
|
| 2352 |
+
'ec2',
|
| 2353 |
+
'us-west-2',
|
| 2354 |
+
use_dualstack_endpoint=False,
|
| 2355 |
+
use_fips_endpoint=False,
|
| 2356 |
+
)
|
| 2357 |
+
|
| 2358 |
+
def test_modeled_endpoint_variants_tags_using_config_store(self):
|
| 2359 |
+
config_store = mock.Mock()
|
| 2360 |
+
config_store.get_config_variable.return_value = True
|
| 2361 |
+
bridge = ClientEndpointBridge(self.resolver, config_store=config_store)
|
| 2362 |
+
bridge.resolve('ec2', 'us-west-2')
|
| 2363 |
+
self.resolver.construct_endpoint.assert_called_with(
|
| 2364 |
+
'ec2',
|
| 2365 |
+
'us-west-2',
|
| 2366 |
+
use_dualstack_endpoint=True,
|
| 2367 |
+
use_fips_endpoint=True,
|
| 2368 |
+
)
|
testbed/boto__botocore/tests/unit/test_compress.py
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 4 |
+
# may not use this file except in compliance with the License. A copy of
|
| 5 |
+
# the License is located at
|
| 6 |
+
#
|
| 7 |
+
# http://aws.amazon.com/apache2.0/
|
| 8 |
+
#
|
| 9 |
+
# or in the "license" file accompanying this file. This file is
|
| 10 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 11 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 12 |
+
# language governing permissions and limitations under the License.
|
| 13 |
+
import gzip
|
| 14 |
+
import io
|
| 15 |
+
import sys
|
| 16 |
+
|
| 17 |
+
import pytest
|
| 18 |
+
|
| 19 |
+
import botocore
|
| 20 |
+
from botocore.compress import COMPRESSION_MAPPING, maybe_compress_request
|
| 21 |
+
from botocore.config import Config
|
| 22 |
+
from tests import mock
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def _make_op(
|
| 26 |
+
request_compression=None,
|
| 27 |
+
has_streaming_input=False,
|
| 28 |
+
streaming_metadata=None,
|
| 29 |
+
):
|
| 30 |
+
op = mock.Mock()
|
| 31 |
+
op.request_compression = request_compression
|
| 32 |
+
op.has_streaming_input = has_streaming_input
|
| 33 |
+
if streaming_metadata is not None:
|
| 34 |
+
streaming_shape = mock.Mock()
|
| 35 |
+
streaming_shape.metadata = streaming_metadata
|
| 36 |
+
op.get_streaming_input.return_value = streaming_shape
|
| 37 |
+
return op
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
OP_NO_COMPRESSION = _make_op()
|
| 41 |
+
OP_WITH_COMPRESSION = _make_op({'encodings': ['gzip']})
|
| 42 |
+
OP_UNKNOWN_COMPRESSION = _make_op({'encodings': ['foo']})
|
| 43 |
+
OP_MULTIPLE_COMPRESSIONS = _make_op({'encodings': ['gzip', 'foo']})
|
| 44 |
+
STREAMING_OP_WITH_COMPRESSION = _make_op(
|
| 45 |
+
{'encodings': ['gzip']},
|
| 46 |
+
True,
|
| 47 |
+
{},
|
| 48 |
+
)
|
| 49 |
+
STREAMING_OP_WITH_COMPRESSION_REQUIRES_LENGTH = _make_op(
|
| 50 |
+
{'encodings': ['gzip']},
|
| 51 |
+
True,
|
| 52 |
+
{'requiresLength': True},
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
REQUEST_BODY = (
|
| 57 |
+
b'Action=PutMetricData&Version=2010-08-01&Namespace=Namespace'
|
| 58 |
+
b'&MetricData.member.1.MetricName=metric&MetricData.member.1.Unit=Bytes'
|
| 59 |
+
b'&MetricData.member.1.Value=128'
|
| 60 |
+
)
|
| 61 |
+
REQUEST_BODY_COMPRESSED = (
|
| 62 |
+
b'\x1f\x8b\x08\x00\x01\x00\x00\x00\x02\xffsL.\xc9\xcc\xcf\xb3\r(-\xf1M-)'
|
| 63 |
+
b'\xcaLvI,IT\x0bK-*\x06\x89\x1a\x19\x18\x1a\xe8\x1aX\xe8\x1a\x18\xaa\xf9%'
|
| 64 |
+
b'\xe6\xa6\x16\x17$&\xa7\xda\xc2Yj\x08\x1dz\xb9\xa9\xb9I\xa9Ez\x86z\x101\x90'
|
| 65 |
+
b'\x1a\xdb\\0\x13\xab\xaa\xd0\xbc\xcc\x12[\xa7\xca\x92\xd4b\xac\xd2a\x899\xa5'
|
| 66 |
+
b'\xa9\xb6\x86F\x16\x00\x1e\xdd\t\xfd\x9e\x00\x00\x00'
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
COMPRESSION_CONFIG_128_BYTES = Config(
|
| 71 |
+
disable_request_compression=False,
|
| 72 |
+
request_min_compression_size_bytes=128,
|
| 73 |
+
)
|
| 74 |
+
COMPRESSION_CONFIG_1_BYTE = Config(
|
| 75 |
+
disable_request_compression=False,
|
| 76 |
+
request_min_compression_size_bytes=1,
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
class NonSeekableStream:
|
| 81 |
+
def __init__(self, buffer):
|
| 82 |
+
self._buffer = buffer
|
| 83 |
+
|
| 84 |
+
def read(self, size=None):
|
| 85 |
+
return self._buffer.read(size)
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def _request_dict(body=REQUEST_BODY, headers=None):
|
| 89 |
+
if headers is None:
|
| 90 |
+
headers = {}
|
| 91 |
+
|
| 92 |
+
return {
|
| 93 |
+
'body': body,
|
| 94 |
+
'headers': headers,
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def request_dict_non_seekable_text_stream():
|
| 99 |
+
stream = NonSeekableStream(io.StringIO(REQUEST_BODY.decode('utf-8')))
|
| 100 |
+
return _request_dict(stream)
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def request_dict_non_seekable_bytes_stream():
|
| 104 |
+
return _request_dict(NonSeekableStream(io.BytesIO(REQUEST_BODY)))
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
class StaticGzipFile(gzip.GzipFile):
|
| 108 |
+
def __init__(self, *args, **kwargs):
|
| 109 |
+
kwargs['mtime'] = 1
|
| 110 |
+
super().__init__(*args, **kwargs)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def static_compress(*args, **kwargs):
|
| 114 |
+
kwargs['mtime'] = 1
|
| 115 |
+
return gzip.compress(*args, **kwargs)
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def _bad_compression(body):
|
| 119 |
+
raise ValueError('Reached unintended compression algorithm "foo"')
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
MOCK_COMPRESSION = {'foo': _bad_compression}
|
| 123 |
+
MOCK_COMPRESSION.update(COMPRESSION_MAPPING)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
def _assert_compression_body(compressed_body, expected_body):
|
| 127 |
+
data = compressed_body
|
| 128 |
+
if hasattr(compressed_body, 'read'):
|
| 129 |
+
data = compressed_body.read()
|
| 130 |
+
assert data == expected_body
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def _assert_compression_header(headers, encoding='gzip'):
|
| 134 |
+
assert 'Content-Encoding' in headers
|
| 135 |
+
assert encoding in headers['Content-Encoding']
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def assert_request_compressed(request_dict, expected_body):
|
| 139 |
+
_assert_compression_body(request_dict['body'], expected_body)
|
| 140 |
+
_assert_compression_header(request_dict['headers'])
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
@pytest.mark.parametrize(
|
| 144 |
+
'request_dict, operation_model',
|
| 145 |
+
[
|
| 146 |
+
(
|
| 147 |
+
_request_dict(),
|
| 148 |
+
OP_WITH_COMPRESSION,
|
| 149 |
+
),
|
| 150 |
+
(
|
| 151 |
+
_request_dict(),
|
| 152 |
+
OP_MULTIPLE_COMPRESSIONS,
|
| 153 |
+
),
|
| 154 |
+
(
|
| 155 |
+
_request_dict(),
|
| 156 |
+
STREAMING_OP_WITH_COMPRESSION,
|
| 157 |
+
),
|
| 158 |
+
(
|
| 159 |
+
_request_dict(bytearray(REQUEST_BODY)),
|
| 160 |
+
OP_WITH_COMPRESSION,
|
| 161 |
+
),
|
| 162 |
+
(
|
| 163 |
+
_request_dict(headers={'Content-Encoding': 'identity'}),
|
| 164 |
+
OP_WITH_COMPRESSION,
|
| 165 |
+
),
|
| 166 |
+
(
|
| 167 |
+
_request_dict(REQUEST_BODY.decode('utf-8')),
|
| 168 |
+
OP_WITH_COMPRESSION,
|
| 169 |
+
),
|
| 170 |
+
(
|
| 171 |
+
_request_dict(io.BytesIO(REQUEST_BODY)),
|
| 172 |
+
OP_WITH_COMPRESSION,
|
| 173 |
+
),
|
| 174 |
+
(
|
| 175 |
+
_request_dict(io.StringIO(REQUEST_BODY.decode('utf-8'))),
|
| 176 |
+
OP_WITH_COMPRESSION,
|
| 177 |
+
),
|
| 178 |
+
(
|
| 179 |
+
request_dict_non_seekable_bytes_stream(),
|
| 180 |
+
STREAMING_OP_WITH_COMPRESSION,
|
| 181 |
+
),
|
| 182 |
+
(
|
| 183 |
+
request_dict_non_seekable_text_stream(),
|
| 184 |
+
STREAMING_OP_WITH_COMPRESSION,
|
| 185 |
+
),
|
| 186 |
+
],
|
| 187 |
+
)
|
| 188 |
+
@mock.patch.object(botocore.compress, 'GzipFile', StaticGzipFile)
|
| 189 |
+
@mock.patch.object(botocore.compress, 'gzip_compress', static_compress)
|
| 190 |
+
@pytest.mark.skipif(
|
| 191 |
+
sys.version_info < (3, 8), reason='requires python3.8 or higher'
|
| 192 |
+
)
|
| 193 |
+
def test_compression(request_dict, operation_model):
|
| 194 |
+
maybe_compress_request(
|
| 195 |
+
COMPRESSION_CONFIG_128_BYTES, request_dict, operation_model
|
| 196 |
+
)
|
| 197 |
+
assert_request_compressed(request_dict, REQUEST_BODY_COMPRESSED)
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
@pytest.mark.parametrize(
|
| 201 |
+
'config, request_dict, operation_model',
|
| 202 |
+
[
|
| 203 |
+
(
|
| 204 |
+
Config(
|
| 205 |
+
disable_request_compression=True,
|
| 206 |
+
request_min_compression_size_bytes=1,
|
| 207 |
+
),
|
| 208 |
+
_request_dict(),
|
| 209 |
+
OP_WITH_COMPRESSION,
|
| 210 |
+
),
|
| 211 |
+
(
|
| 212 |
+
Config(
|
| 213 |
+
disable_request_compression=False,
|
| 214 |
+
request_min_compression_size_bytes=256,
|
| 215 |
+
),
|
| 216 |
+
_request_dict(),
|
| 217 |
+
OP_WITH_COMPRESSION,
|
| 218 |
+
),
|
| 219 |
+
(
|
| 220 |
+
Config(
|
| 221 |
+
disable_request_compression=False,
|
| 222 |
+
request_min_compression_size_bytes=1,
|
| 223 |
+
signature_version='v2',
|
| 224 |
+
),
|
| 225 |
+
_request_dict(),
|
| 226 |
+
OP_WITH_COMPRESSION,
|
| 227 |
+
),
|
| 228 |
+
(
|
| 229 |
+
COMPRESSION_CONFIG_128_BYTES,
|
| 230 |
+
_request_dict(),
|
| 231 |
+
STREAMING_OP_WITH_COMPRESSION_REQUIRES_LENGTH,
|
| 232 |
+
),
|
| 233 |
+
(
|
| 234 |
+
COMPRESSION_CONFIG_128_BYTES,
|
| 235 |
+
_request_dict(),
|
| 236 |
+
OP_NO_COMPRESSION,
|
| 237 |
+
),
|
| 238 |
+
(
|
| 239 |
+
COMPRESSION_CONFIG_128_BYTES,
|
| 240 |
+
_request_dict(),
|
| 241 |
+
OP_UNKNOWN_COMPRESSION,
|
| 242 |
+
),
|
| 243 |
+
(
|
| 244 |
+
COMPRESSION_CONFIG_128_BYTES,
|
| 245 |
+
_request_dict(headers={'Content-Encoding': 'identity'}),
|
| 246 |
+
OP_UNKNOWN_COMPRESSION,
|
| 247 |
+
),
|
| 248 |
+
(
|
| 249 |
+
COMPRESSION_CONFIG_128_BYTES,
|
| 250 |
+
request_dict_non_seekable_bytes_stream(),
|
| 251 |
+
OP_WITH_COMPRESSION,
|
| 252 |
+
),
|
| 253 |
+
],
|
| 254 |
+
)
|
| 255 |
+
def test_no_compression(config, request_dict, operation_model):
|
| 256 |
+
ce_header = request_dict['headers'].get('Content-Encoding')
|
| 257 |
+
original_body = request_dict['body']
|
| 258 |
+
maybe_compress_request(config, request_dict, operation_model)
|
| 259 |
+
assert request_dict['body'] == original_body
|
| 260 |
+
assert ce_header == request_dict['headers'].get('Content-Encoding')
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
@pytest.mark.parametrize(
|
| 264 |
+
'operation_model, expected_body',
|
| 265 |
+
[
|
| 266 |
+
(
|
| 267 |
+
OP_WITH_COMPRESSION,
|
| 268 |
+
(
|
| 269 |
+
b'\x1f\x8b\x08\x00\x01\x00\x00\x00\x02\xffK\xcb'
|
| 270 |
+
b'\xcf\xb7MJ,\x02\x00v\x8e5\x1c\x07\x00\x00\x00'
|
| 271 |
+
),
|
| 272 |
+
),
|
| 273 |
+
(OP_NO_COMPRESSION, {'foo': 'bar'}),
|
| 274 |
+
],
|
| 275 |
+
)
|
| 276 |
+
@mock.patch.object(botocore.compress, 'gzip_compress', static_compress)
|
| 277 |
+
@pytest.mark.skipif(
|
| 278 |
+
sys.version_info < (3, 8), reason='requires python3.8 or higher'
|
| 279 |
+
)
|
| 280 |
+
def test_dict_compression(operation_model, expected_body):
|
| 281 |
+
request_dict = _request_dict({'foo': 'bar'})
|
| 282 |
+
maybe_compress_request(
|
| 283 |
+
COMPRESSION_CONFIG_1_BYTE, request_dict, operation_model
|
| 284 |
+
)
|
| 285 |
+
body = request_dict['body']
|
| 286 |
+
assert body == expected_body
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
@pytest.mark.parametrize('body', [1, object(), True, 1.0])
|
| 290 |
+
def test_maybe_compress_bad_types(body):
|
| 291 |
+
request_dict = _request_dict(body)
|
| 292 |
+
maybe_compress_request(
|
| 293 |
+
COMPRESSION_CONFIG_1_BYTE, request_dict, OP_WITH_COMPRESSION
|
| 294 |
+
)
|
| 295 |
+
assert request_dict['body'] == body
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
@mock.patch.object(botocore.compress, 'GzipFile', StaticGzipFile)
|
| 299 |
+
def test_body_streams_position_reset():
|
| 300 |
+
request_dict = _request_dict(io.BytesIO(REQUEST_BODY))
|
| 301 |
+
maybe_compress_request(
|
| 302 |
+
COMPRESSION_CONFIG_128_BYTES,
|
| 303 |
+
request_dict,
|
| 304 |
+
OP_WITH_COMPRESSION,
|
| 305 |
+
)
|
| 306 |
+
assert request_dict['body'].tell() == 0
|
| 307 |
+
assert_request_compressed(request_dict, REQUEST_BODY_COMPRESSED)
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
@mock.patch.object(botocore.compress, 'gzip_compress', static_compress)
|
| 311 |
+
@mock.patch.object(botocore.compress, 'COMPRESSION_MAPPING', MOCK_COMPRESSION)
|
| 312 |
+
@pytest.mark.skipif(
|
| 313 |
+
sys.version_info < (3, 8), reason='requires python3.8 or higher'
|
| 314 |
+
)
|
| 315 |
+
def test_only_compress_once():
|
| 316 |
+
request_dict = _request_dict()
|
| 317 |
+
maybe_compress_request(
|
| 318 |
+
COMPRESSION_CONFIG_128_BYTES,
|
| 319 |
+
request_dict,
|
| 320 |
+
OP_MULTIPLE_COMPRESSIONS,
|
| 321 |
+
)
|
| 322 |
+
assert_request_compressed(request_dict, REQUEST_BODY_COMPRESSED)
|
testbed/boto__botocore/tests/unit/test_config_provider.py
ADDED
|
@@ -0,0 +1,1148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 4 |
+
# may not use this file except in compliance with the License. A copy of
|
| 5 |
+
# the License is located at
|
| 6 |
+
#
|
| 7 |
+
# http://aws.amazon.com/apache2.0/
|
| 8 |
+
#
|
| 9 |
+
# or in the "license" file accompanying this file. This file is
|
| 10 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 11 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 12 |
+
# language governing permissions and limitations under the License.
|
| 13 |
+
import copy
|
| 14 |
+
import os
|
| 15 |
+
|
| 16 |
+
import pytest
|
| 17 |
+
|
| 18 |
+
import botocore.configprovider
|
| 19 |
+
import botocore.session as session
|
| 20 |
+
from botocore.configprovider import (
|
| 21 |
+
BaseProvider,
|
| 22 |
+
ChainProvider,
|
| 23 |
+
ConfigChainFactory,
|
| 24 |
+
ConfiguredEndpointProvider,
|
| 25 |
+
ConfigValueStore,
|
| 26 |
+
ConstantProvider,
|
| 27 |
+
DefaultConfigResolver,
|
| 28 |
+
EnvironmentProvider,
|
| 29 |
+
InstanceVarProvider,
|
| 30 |
+
ScopedConfigProvider,
|
| 31 |
+
SectionConfigProvider,
|
| 32 |
+
SmartDefaultsConfigStoreFactory,
|
| 33 |
+
)
|
| 34 |
+
from botocore.exceptions import ConnectTimeoutError
|
| 35 |
+
from botocore.utils import IMDSRegionProvider
|
| 36 |
+
from tests import mock, unittest
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class TestConfigChainFactory(unittest.TestCase):
|
| 40 |
+
def assert_chain_does_provide(
|
| 41 |
+
self,
|
| 42 |
+
instance_map,
|
| 43 |
+
environ_map,
|
| 44 |
+
scoped_config_map,
|
| 45 |
+
create_config_chain_args,
|
| 46 |
+
expected_value,
|
| 47 |
+
):
|
| 48 |
+
fake_session = mock.Mock(spec=session.Session)
|
| 49 |
+
fake_session.get_scoped_config.return_value = scoped_config_map
|
| 50 |
+
fake_session.instance_variables.return_value = instance_map
|
| 51 |
+
builder = ConfigChainFactory(fake_session, environ=environ_map)
|
| 52 |
+
chain = builder.create_config_chain(**create_config_chain_args)
|
| 53 |
+
value = chain.provide()
|
| 54 |
+
self.assertEqual(value, expected_value)
|
| 55 |
+
|
| 56 |
+
def test_chain_builder_can_provide_instance(self):
|
| 57 |
+
self.assert_chain_does_provide(
|
| 58 |
+
instance_map={'instance_var': 'from-instance'},
|
| 59 |
+
environ_map={},
|
| 60 |
+
scoped_config_map={},
|
| 61 |
+
create_config_chain_args={
|
| 62 |
+
'instance_name': 'instance_var',
|
| 63 |
+
},
|
| 64 |
+
expected_value='from-instance',
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
def test_chain_builder_can_skip_instance(self):
|
| 68 |
+
self.assert_chain_does_provide(
|
| 69 |
+
instance_map={'wrong_instance_var': 'instance'},
|
| 70 |
+
environ_map={'ENV_VAR': 'env'},
|
| 71 |
+
scoped_config_map={},
|
| 72 |
+
create_config_chain_args={
|
| 73 |
+
'instance_name': 'instance_var',
|
| 74 |
+
'env_var_names': 'ENV_VAR',
|
| 75 |
+
},
|
| 76 |
+
expected_value='env',
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
def test_chain_builder_can_provide_env_var(self):
|
| 80 |
+
self.assert_chain_does_provide(
|
| 81 |
+
instance_map={},
|
| 82 |
+
environ_map={'ENV_VAR': 'from-env'},
|
| 83 |
+
scoped_config_map={},
|
| 84 |
+
create_config_chain_args={
|
| 85 |
+
'env_var_names': 'ENV_VAR',
|
| 86 |
+
},
|
| 87 |
+
expected_value='from-env',
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
def test_does_provide_none_if_no_variable_exists_in_env_var_list(self):
|
| 91 |
+
self.assert_chain_does_provide(
|
| 92 |
+
instance_map={},
|
| 93 |
+
environ_map={},
|
| 94 |
+
scoped_config_map={},
|
| 95 |
+
create_config_chain_args={
|
| 96 |
+
'env_var_names': ['FOO'],
|
| 97 |
+
},
|
| 98 |
+
expected_value=None,
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
def test_does_provide_value_if_variable_exists_in_env_var_list(self):
|
| 102 |
+
self.assert_chain_does_provide(
|
| 103 |
+
instance_map={},
|
| 104 |
+
environ_map={'FOO': 'bar'},
|
| 105 |
+
scoped_config_map={},
|
| 106 |
+
create_config_chain_args={
|
| 107 |
+
'env_var_names': ['FOO'],
|
| 108 |
+
},
|
| 109 |
+
expected_value='bar',
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
def test_does_provide_first_non_none_value_first_in_env_var_list(self):
|
| 113 |
+
self.assert_chain_does_provide(
|
| 114 |
+
instance_map={},
|
| 115 |
+
environ_map={'FOO': 'baz'},
|
| 116 |
+
scoped_config_map={},
|
| 117 |
+
create_config_chain_args={
|
| 118 |
+
'env_var_names': ['FOO', 'BAR'],
|
| 119 |
+
},
|
| 120 |
+
expected_value='baz',
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
def test_does_provide_first_non_none_value_second_in_env_var_list(self):
|
| 124 |
+
self.assert_chain_does_provide(
|
| 125 |
+
instance_map={},
|
| 126 |
+
environ_map={'BAR': 'baz'},
|
| 127 |
+
scoped_config_map={},
|
| 128 |
+
create_config_chain_args={
|
| 129 |
+
'env_var_names': ['FOO', 'BAR'],
|
| 130 |
+
},
|
| 131 |
+
expected_value='baz',
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
def test_does_provide_none_if_all_list_env_vars_are_none(self):
|
| 135 |
+
self.assert_chain_does_provide(
|
| 136 |
+
instance_map={},
|
| 137 |
+
environ_map={},
|
| 138 |
+
scoped_config_map={},
|
| 139 |
+
create_config_chain_args={
|
| 140 |
+
'env_var_names': ['FOO', 'BAR'],
|
| 141 |
+
},
|
| 142 |
+
expected_value=None,
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
def test_does_provide_first_value_when_both_env_vars_exist(self):
|
| 146 |
+
self.assert_chain_does_provide(
|
| 147 |
+
instance_map={},
|
| 148 |
+
environ_map={'FOO': 'baz', 'BAR': 'buz'},
|
| 149 |
+
scoped_config_map={},
|
| 150 |
+
create_config_chain_args={
|
| 151 |
+
'env_var_names': ['FOO', 'BAR'],
|
| 152 |
+
},
|
| 153 |
+
expected_value='baz',
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
def test_chain_builder_can_provide_config_var(self):
|
| 157 |
+
self.assert_chain_does_provide(
|
| 158 |
+
instance_map={},
|
| 159 |
+
environ_map={},
|
| 160 |
+
scoped_config_map={'config_var': 'from-config'},
|
| 161 |
+
create_config_chain_args={
|
| 162 |
+
'config_property_names': 'config_var',
|
| 163 |
+
},
|
| 164 |
+
expected_value='from-config',
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
def test_chain_builder_can_provide_nested_config_var(self):
|
| 168 |
+
self.assert_chain_does_provide(
|
| 169 |
+
instance_map={},
|
| 170 |
+
environ_map={},
|
| 171 |
+
scoped_config_map={'config_var': {'nested-key': 'nested-val'}},
|
| 172 |
+
create_config_chain_args={
|
| 173 |
+
'config_property_names': ('config_var', 'nested-key'),
|
| 174 |
+
},
|
| 175 |
+
expected_value='nested-val',
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
+
def test_provide_value_from_config_list(self):
|
| 179 |
+
self.assert_chain_does_provide(
|
| 180 |
+
instance_map={},
|
| 181 |
+
environ_map={},
|
| 182 |
+
scoped_config_map={'var': 'val'},
|
| 183 |
+
create_config_chain_args={
|
| 184 |
+
'config_property_names': ['var'],
|
| 185 |
+
},
|
| 186 |
+
expected_value='val',
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
def test_provide_value_from_config_list_looks_for_non_none_vals(self):
|
| 190 |
+
self.assert_chain_does_provide(
|
| 191 |
+
instance_map={},
|
| 192 |
+
environ_map={},
|
| 193 |
+
scoped_config_map={'non_none_var': 'non_none_val'},
|
| 194 |
+
create_config_chain_args={
|
| 195 |
+
'config_property_names': ['none_var', 'non_none_var'],
|
| 196 |
+
},
|
| 197 |
+
expected_value='non_none_val',
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
def test_provide_value_from_config_list_retrieves_first_non_none_val(self):
|
| 201 |
+
self.assert_chain_does_provide(
|
| 202 |
+
instance_map={},
|
| 203 |
+
environ_map={},
|
| 204 |
+
scoped_config_map={'first': 'first_val', 'second': 'second_val'},
|
| 205 |
+
create_config_chain_args={
|
| 206 |
+
'config_property_names': ['first', 'second'],
|
| 207 |
+
},
|
| 208 |
+
expected_value='first_val',
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
def test_provide_value_from_config_list_if_all_vars_are_none(self):
|
| 212 |
+
self.assert_chain_does_provide(
|
| 213 |
+
instance_map={},
|
| 214 |
+
environ_map={},
|
| 215 |
+
scoped_config_map={},
|
| 216 |
+
create_config_chain_args={
|
| 217 |
+
'config_property_names': ['config1', 'config2'],
|
| 218 |
+
},
|
| 219 |
+
expected_value=None,
|
| 220 |
+
)
|
| 221 |
+
|
| 222 |
+
def test_provide_value_from_list_with_nested_var(self):
|
| 223 |
+
self.assert_chain_does_provide(
|
| 224 |
+
instance_map={},
|
| 225 |
+
environ_map={},
|
| 226 |
+
scoped_config_map={'section': {'nested_var': 'nested_val'}},
|
| 227 |
+
create_config_chain_args={
|
| 228 |
+
'config_property_names': [('section', 'nested_var')],
|
| 229 |
+
},
|
| 230 |
+
expected_value='nested_val',
|
| 231 |
+
)
|
| 232 |
+
|
| 233 |
+
def test_chain_builder_can_provide_default(self):
|
| 234 |
+
self.assert_chain_does_provide(
|
| 235 |
+
instance_map={},
|
| 236 |
+
environ_map={},
|
| 237 |
+
scoped_config_map={},
|
| 238 |
+
create_config_chain_args={'default': 'from-default'},
|
| 239 |
+
expected_value='from-default',
|
| 240 |
+
)
|
| 241 |
+
|
| 242 |
+
def test_chain_provider_does_follow_priority_instance_var(self):
|
| 243 |
+
self.assert_chain_does_provide(
|
| 244 |
+
instance_map={'instance_var': 'from-instance'},
|
| 245 |
+
environ_map={'ENV_VAR': 'from-env'},
|
| 246 |
+
scoped_config_map={'config_var': 'from-config'},
|
| 247 |
+
create_config_chain_args={
|
| 248 |
+
'instance_name': 'instance_var',
|
| 249 |
+
'env_var_names': 'ENV_VAR',
|
| 250 |
+
'config_property_names': 'config_var',
|
| 251 |
+
'default': 'from-default',
|
| 252 |
+
},
|
| 253 |
+
expected_value='from-instance',
|
| 254 |
+
)
|
| 255 |
+
|
| 256 |
+
def test_chain_provider_does_follow_priority_env_var(self):
|
| 257 |
+
self.assert_chain_does_provide(
|
| 258 |
+
instance_map={'wrong_instance_var': 'from-instance'},
|
| 259 |
+
environ_map={'ENV_VAR': 'from-env'},
|
| 260 |
+
scoped_config_map={'config_var': 'from-confi'},
|
| 261 |
+
create_config_chain_args={
|
| 262 |
+
'instance_name': 'instance_var',
|
| 263 |
+
'env_var_names': 'ENV_VAR',
|
| 264 |
+
'config_property_names': 'config_var',
|
| 265 |
+
'default': 'from-default',
|
| 266 |
+
},
|
| 267 |
+
expected_value='from-env',
|
| 268 |
+
)
|
| 269 |
+
|
| 270 |
+
def test_chain_provider_does_follow_priority_config(self):
|
| 271 |
+
self.assert_chain_does_provide(
|
| 272 |
+
instance_map={'wrong_instance_var': 'from-instance'},
|
| 273 |
+
environ_map={'WRONG_ENV_VAR': 'from-env'},
|
| 274 |
+
scoped_config_map={'config_var': 'from-config'},
|
| 275 |
+
create_config_chain_args={
|
| 276 |
+
'instance_name': 'instance_var',
|
| 277 |
+
'env_var_names': 'ENV_VAR',
|
| 278 |
+
'config_property_names': 'config_var',
|
| 279 |
+
'default': 'from-default',
|
| 280 |
+
},
|
| 281 |
+
expected_value='from-config',
|
| 282 |
+
)
|
| 283 |
+
|
| 284 |
+
def test_chain_provider_does_follow_priority_default(self):
|
| 285 |
+
self.assert_chain_does_provide(
|
| 286 |
+
instance_map={'wrong_instance_var': 'from-instance'},
|
| 287 |
+
environ_map={'WRONG_ENV_VAR': 'from-env'},
|
| 288 |
+
scoped_config_map={'wrong_config_var': 'from-config'},
|
| 289 |
+
create_config_chain_args={
|
| 290 |
+
'instance_name': 'instance_var',
|
| 291 |
+
'env_var_names': 'ENV_VAR',
|
| 292 |
+
'config_property_names': 'config_var',
|
| 293 |
+
'default': 'from-default',
|
| 294 |
+
},
|
| 295 |
+
expected_value='from-default',
|
| 296 |
+
)
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
class TestConfigValueStore(unittest.TestCase):
|
| 300 |
+
def test_does_provide_none_if_no_variable_exists(self):
|
| 301 |
+
provider = ConfigValueStore()
|
| 302 |
+
value = provider.get_config_variable('fake_variable')
|
| 303 |
+
self.assertIsNone(value)
|
| 304 |
+
|
| 305 |
+
def test_does_provide_value_if_variable_exists(self):
|
| 306 |
+
mock_value_provider = mock.Mock(spec=BaseProvider)
|
| 307 |
+
mock_value_provider.provide.return_value = 'foo'
|
| 308 |
+
provider = ConfigValueStore(
|
| 309 |
+
mapping={
|
| 310 |
+
'fake_variable': mock_value_provider,
|
| 311 |
+
}
|
| 312 |
+
)
|
| 313 |
+
value = provider.get_config_variable('fake_variable')
|
| 314 |
+
self.assertEqual(value, 'foo')
|
| 315 |
+
|
| 316 |
+
def test_can_set_variable(self):
|
| 317 |
+
provider = ConfigValueStore()
|
| 318 |
+
provider.set_config_variable('fake_variable', 'foo')
|
| 319 |
+
value = provider.get_config_variable('fake_variable')
|
| 320 |
+
self.assertEqual(value, 'foo')
|
| 321 |
+
|
| 322 |
+
def test_can_set_config_provider(self):
|
| 323 |
+
foo_value_provider = mock.Mock(spec=BaseProvider)
|
| 324 |
+
foo_value_provider.provide.return_value = 'foo'
|
| 325 |
+
provider = ConfigValueStore(
|
| 326 |
+
mapping={
|
| 327 |
+
'fake_variable': foo_value_provider,
|
| 328 |
+
}
|
| 329 |
+
)
|
| 330 |
+
|
| 331 |
+
value = provider.get_config_variable('fake_variable')
|
| 332 |
+
self.assertEqual(value, 'foo')
|
| 333 |
+
|
| 334 |
+
bar_value_provider = mock.Mock(spec=BaseProvider)
|
| 335 |
+
bar_value_provider.provide.return_value = 'bar'
|
| 336 |
+
provider.set_config_provider('fake_variable', bar_value_provider)
|
| 337 |
+
|
| 338 |
+
value = provider.get_config_variable('fake_variable')
|
| 339 |
+
self.assertEqual(value, 'bar')
|
| 340 |
+
|
| 341 |
+
def test_can_get_config_provider(self):
|
| 342 |
+
chain_provider = ChainProvider(
|
| 343 |
+
providers=[ConstantProvider(value='bar')]
|
| 344 |
+
)
|
| 345 |
+
config_value_store = ConfigValueStore(
|
| 346 |
+
mapping={
|
| 347 |
+
'fake_variable': chain_provider,
|
| 348 |
+
}
|
| 349 |
+
)
|
| 350 |
+
provider = config_value_store.get_config_provider('fake_variable')
|
| 351 |
+
value = config_value_store.get_config_variable('fake_variable')
|
| 352 |
+
self.assertIsInstance(provider, ChainProvider)
|
| 353 |
+
self.assertEqual(value, 'bar')
|
| 354 |
+
|
| 355 |
+
def test_can_get_config_provider_non_chain_provider(self):
|
| 356 |
+
constant_provider = ConstantProvider(value='bar')
|
| 357 |
+
config_value_store = ConfigValueStore(
|
| 358 |
+
mapping={
|
| 359 |
+
'fake_variable': constant_provider,
|
| 360 |
+
}
|
| 361 |
+
)
|
| 362 |
+
provider = config_value_store.get_config_provider('fake_variable')
|
| 363 |
+
value = config_value_store.get_config_variable('fake_variable')
|
| 364 |
+
self.assertIsInstance(provider, ConstantProvider)
|
| 365 |
+
self.assertEqual(value, 'bar')
|
| 366 |
+
|
| 367 |
+
def test_deepcopy_preserves_overrides(self):
|
| 368 |
+
provider = ConstantProvider(100)
|
| 369 |
+
config_store = ConfigValueStore(mapping={'fake_variable': provider})
|
| 370 |
+
config_store.set_config_variable('fake_variable', 'override-value')
|
| 371 |
+
|
| 372 |
+
config_store_deepcopy = copy.deepcopy(config_store)
|
| 373 |
+
|
| 374 |
+
value = config_store_deepcopy.get_config_variable('fake_variable')
|
| 375 |
+
self.assertEqual(value, 'override-value')
|
| 376 |
+
|
| 377 |
+
def test_copy_preserves_provider_identities(self):
|
| 378 |
+
fake_variable_provider = ConstantProvider(100)
|
| 379 |
+
config_store = ConfigValueStore(
|
| 380 |
+
mapping={
|
| 381 |
+
'fake_variable': fake_variable_provider,
|
| 382 |
+
}
|
| 383 |
+
)
|
| 384 |
+
|
| 385 |
+
config_store_copy = copy.copy(config_store)
|
| 386 |
+
|
| 387 |
+
self.assertIs(
|
| 388 |
+
config_store.get_config_provider('fake_variable'),
|
| 389 |
+
config_store_copy.get_config_provider('fake_variable'),
|
| 390 |
+
)
|
| 391 |
+
|
| 392 |
+
def test_copy_preserves_overrides(self):
|
| 393 |
+
provider = ConstantProvider(100)
|
| 394 |
+
config_store = ConfigValueStore(mapping={'fake_variable': provider})
|
| 395 |
+
config_store.set_config_variable('fake_variable', 'override-value')
|
| 396 |
+
|
| 397 |
+
config_store_copy = copy.copy(config_store)
|
| 398 |
+
|
| 399 |
+
value = config_store_copy.get_config_variable('fake_variable')
|
| 400 |
+
self.assertEqual(value, 'override-value')
|
| 401 |
+
|
| 402 |
+
def test_copy_update_does_not_mutate_source_config_store(self):
|
| 403 |
+
fake_variable_provider = ConstantProvider(100)
|
| 404 |
+
config_store = ConfigValueStore(
|
| 405 |
+
mapping={
|
| 406 |
+
'fake_variable': fake_variable_provider,
|
| 407 |
+
}
|
| 408 |
+
)
|
| 409 |
+
|
| 410 |
+
config_store_copy = copy.copy(config_store)
|
| 411 |
+
|
| 412 |
+
another_variable_provider = ConstantProvider('ABC')
|
| 413 |
+
|
| 414 |
+
config_store_copy.set_config_provider(
|
| 415 |
+
'fake_variable', another_variable_provider
|
| 416 |
+
)
|
| 417 |
+
|
| 418 |
+
assert config_store.get_config_variable('fake_variable') == 100
|
| 419 |
+
assert config_store_copy.get_config_variable('fake_variable') == 'ABC'
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
class TestInstanceVarProvider(unittest.TestCase):
|
| 423 |
+
def assert_provides_value(self, name, instance_map, expected_value):
|
| 424 |
+
fake_session = mock.Mock(spec=session.Session)
|
| 425 |
+
fake_session.instance_variables.return_value = instance_map
|
| 426 |
+
|
| 427 |
+
provider = InstanceVarProvider(
|
| 428 |
+
instance_var=name,
|
| 429 |
+
session=fake_session,
|
| 430 |
+
)
|
| 431 |
+
value = provider.provide()
|
| 432 |
+
self.assertEqual(value, expected_value)
|
| 433 |
+
|
| 434 |
+
def test_can_provide_value(self):
|
| 435 |
+
self.assert_provides_value(
|
| 436 |
+
name='foo',
|
| 437 |
+
instance_map={'foo': 'bar'},
|
| 438 |
+
expected_value='bar',
|
| 439 |
+
)
|
| 440 |
+
|
| 441 |
+
def test_does_provide_none_if_value_not_in_dict(self):
|
| 442 |
+
self.assert_provides_value(
|
| 443 |
+
name='foo',
|
| 444 |
+
instance_map={},
|
| 445 |
+
expected_value=None,
|
| 446 |
+
)
|
| 447 |
+
|
| 448 |
+
|
| 449 |
+
class TestEnvironmentProvider(unittest.TestCase):
|
| 450 |
+
def assert_does_provide(self, env, name, expected_value):
|
| 451 |
+
provider = EnvironmentProvider(name=name, env=env)
|
| 452 |
+
value = provider.provide()
|
| 453 |
+
self.assertEqual(value, expected_value)
|
| 454 |
+
|
| 455 |
+
def test_does_provide_none_if_no_variable_exists(self):
|
| 456 |
+
self.assert_does_provide(
|
| 457 |
+
name='FOO',
|
| 458 |
+
env={},
|
| 459 |
+
expected_value=None,
|
| 460 |
+
)
|
| 461 |
+
|
| 462 |
+
def test_does_provide_value_if_variable_exists(self):
|
| 463 |
+
self.assert_does_provide(
|
| 464 |
+
name='FOO',
|
| 465 |
+
env={
|
| 466 |
+
'FOO': 'bar',
|
| 467 |
+
},
|
| 468 |
+
expected_value='bar',
|
| 469 |
+
)
|
| 470 |
+
|
| 471 |
+
|
| 472 |
+
class TestScopedConfigProvider(unittest.TestCase):
|
| 473 |
+
def assert_provides_value(
|
| 474 |
+
self, config_file_values, config_var_name, expected_value
|
| 475 |
+
):
|
| 476 |
+
fake_session = mock.Mock(spec=session.Session)
|
| 477 |
+
fake_session.get_scoped_config.return_value = config_file_values
|
| 478 |
+
property_provider = ScopedConfigProvider(
|
| 479 |
+
config_var_name=config_var_name,
|
| 480 |
+
session=fake_session,
|
| 481 |
+
)
|
| 482 |
+
value = property_provider.provide()
|
| 483 |
+
self.assertEqual(value, expected_value)
|
| 484 |
+
|
| 485 |
+
def test_can_provide_value(self):
|
| 486 |
+
self.assert_provides_value(
|
| 487 |
+
config_file_values={'foo': 'bar'},
|
| 488 |
+
config_var_name='foo',
|
| 489 |
+
expected_value='bar',
|
| 490 |
+
)
|
| 491 |
+
|
| 492 |
+
def test_does_provide_none_if_var_not_in_config(self):
|
| 493 |
+
self.assert_provides_value(
|
| 494 |
+
config_file_values={'foo': 'bar'},
|
| 495 |
+
config_var_name='no_such_var',
|
| 496 |
+
expected_value=None,
|
| 497 |
+
)
|
| 498 |
+
|
| 499 |
+
def test_provide_nested_value(self):
|
| 500 |
+
self.assert_provides_value(
|
| 501 |
+
config_file_values={'section': {'nested_var': 'nested_val'}},
|
| 502 |
+
config_var_name=('section', 'nested_var'),
|
| 503 |
+
expected_value='nested_val',
|
| 504 |
+
)
|
| 505 |
+
|
| 506 |
+
def test_provide_nested_value_but_not_section(self):
|
| 507 |
+
self.assert_provides_value(
|
| 508 |
+
config_file_values={'section': 'not-nested'},
|
| 509 |
+
config_var_name=('section', 'nested_var'),
|
| 510 |
+
expected_value=None,
|
| 511 |
+
)
|
| 512 |
+
|
| 513 |
+
|
| 514 |
+
def _make_provider_that_returns(return_value):
|
| 515 |
+
provider = mock.Mock(spec=BaseProvider)
|
| 516 |
+
provider.provide.return_value = return_value
|
| 517 |
+
return provider
|
| 518 |
+
|
| 519 |
+
|
| 520 |
+
def _make_providers_that_return(return_values):
|
| 521 |
+
mocks = []
|
| 522 |
+
for return_value in return_values:
|
| 523 |
+
provider = _make_provider_that_returns(return_value)
|
| 524 |
+
mocks.append(provider)
|
| 525 |
+
return mocks
|
| 526 |
+
|
| 527 |
+
|
| 528 |
+
def assert_chain_does_provide(providers, expected_value):
|
| 529 |
+
provider = ChainProvider(
|
| 530 |
+
providers=providers,
|
| 531 |
+
)
|
| 532 |
+
assert provider.provide() == expected_value
|
| 533 |
+
|
| 534 |
+
|
| 535 |
+
@pytest.mark.parametrize(
|
| 536 |
+
'case',
|
| 537 |
+
(
|
| 538 |
+
(None, []),
|
| 539 |
+
(None, [None]),
|
| 540 |
+
('foo', ['foo']),
|
| 541 |
+
('foo', ['foo', 'bar']),
|
| 542 |
+
('bar', [None, 'bar']),
|
| 543 |
+
('foo', ['foo', None]),
|
| 544 |
+
('baz', [None, None, 'baz']),
|
| 545 |
+
('bar', [None, 'bar', None]),
|
| 546 |
+
('foo', ['foo', 'bar', None]),
|
| 547 |
+
('foo', ['foo', 'bar', 'baz']),
|
| 548 |
+
),
|
| 549 |
+
)
|
| 550 |
+
def test_chain_provider(case):
|
| 551 |
+
# Each case is a tuple with the first element being the expected return
|
| 552 |
+
# value from the ChainProvider. The second value being a list of return
|
| 553 |
+
# values from the individual providers that are in the chain.
|
| 554 |
+
assert_chain_does_provide(_make_providers_that_return(case[1]), case[0])
|
| 555 |
+
|
| 556 |
+
|
| 557 |
+
class TestChainProvider(unittest.TestCase):
|
| 558 |
+
def test_can_convert_provided_value(self):
|
| 559 |
+
chain_provider = ChainProvider(
|
| 560 |
+
providers=_make_providers_that_return(['1']),
|
| 561 |
+
conversion_func=int,
|
| 562 |
+
)
|
| 563 |
+
value = chain_provider.provide()
|
| 564 |
+
self.assertIsInstance(value, int)
|
| 565 |
+
self.assertEqual(value, 1)
|
| 566 |
+
|
| 567 |
+
|
| 568 |
+
class TestConstantProvider(unittest.TestCase):
|
| 569 |
+
def test_can_provide_value(self):
|
| 570 |
+
provider = ConstantProvider(value='foo')
|
| 571 |
+
value = provider.provide()
|
| 572 |
+
self.assertEqual(value, 'foo')
|
| 573 |
+
|
| 574 |
+
|
| 575 |
+
class TestSectionConfigProvider(unittest.TestCase):
|
| 576 |
+
def assert_provides_value(
|
| 577 |
+
self,
|
| 578 |
+
config_file_values,
|
| 579 |
+
section_name,
|
| 580 |
+
expected_value,
|
| 581 |
+
override_providers=None,
|
| 582 |
+
):
|
| 583 |
+
fake_session = mock.Mock(spec=session.Session)
|
| 584 |
+
fake_session.get_scoped_config.return_value = config_file_values
|
| 585 |
+
provider = SectionConfigProvider(
|
| 586 |
+
section_name=section_name,
|
| 587 |
+
session=fake_session,
|
| 588 |
+
override_providers=override_providers,
|
| 589 |
+
)
|
| 590 |
+
value = provider.provide()
|
| 591 |
+
self.assertEqual(value, expected_value)
|
| 592 |
+
|
| 593 |
+
def test_provide_section_config(self):
|
| 594 |
+
self.assert_provides_value(
|
| 595 |
+
config_file_values={'mysection': {'section_var': 'section_val'}},
|
| 596 |
+
section_name='mysection',
|
| 597 |
+
expected_value={'section_var': 'section_val'},
|
| 598 |
+
)
|
| 599 |
+
|
| 600 |
+
def test_provide_service_config_missing_service(self):
|
| 601 |
+
self.assert_provides_value(
|
| 602 |
+
config_file_values={},
|
| 603 |
+
section_name='mysection',
|
| 604 |
+
expected_value=None,
|
| 605 |
+
)
|
| 606 |
+
|
| 607 |
+
def test_provide_service_config_not_a_section(self):
|
| 608 |
+
self.assert_provides_value(
|
| 609 |
+
config_file_values={'myservice': 'not-a-section'},
|
| 610 |
+
section_name='mysection',
|
| 611 |
+
expected_value=None,
|
| 612 |
+
)
|
| 613 |
+
|
| 614 |
+
def test_provide_section_config_with_overrides(self):
|
| 615 |
+
self.assert_provides_value(
|
| 616 |
+
config_file_values={
|
| 617 |
+
'mysection': {
|
| 618 |
+
'override_var': 'from_config_file',
|
| 619 |
+
'no_override_var': 'from_config_file',
|
| 620 |
+
}
|
| 621 |
+
},
|
| 622 |
+
section_name='mysection',
|
| 623 |
+
override_providers={'override_var': ConstantProvider('override')},
|
| 624 |
+
expected_value={
|
| 625 |
+
'override_var': 'override',
|
| 626 |
+
'no_override_var': 'from_config_file',
|
| 627 |
+
},
|
| 628 |
+
)
|
| 629 |
+
|
| 630 |
+
def test_provide_section_config_with_only_overrides(self):
|
| 631 |
+
self.assert_provides_value(
|
| 632 |
+
config_file_values={},
|
| 633 |
+
section_name='mysection',
|
| 634 |
+
override_providers={'override_var': ConstantProvider('override')},
|
| 635 |
+
expected_value={
|
| 636 |
+
'override_var': 'override',
|
| 637 |
+
},
|
| 638 |
+
)
|
| 639 |
+
|
| 640 |
+
|
| 641 |
+
class TestSmartDefaults:
|
| 642 |
+
def _template(self):
|
| 643 |
+
return {
|
| 644 |
+
"base": {
|
| 645 |
+
"retryMode": "standard",
|
| 646 |
+
"stsRegionalEndpoints": "regional",
|
| 647 |
+
"s3UsEast1RegionalEndpoints": "regional",
|
| 648 |
+
"connectTimeoutInMillis": 1000,
|
| 649 |
+
"tlsNegotiationTimeoutInMillis": 1000,
|
| 650 |
+
},
|
| 651 |
+
"modes": {
|
| 652 |
+
"standard": {
|
| 653 |
+
"connectTimeoutInMillis": {"multiply": 2},
|
| 654 |
+
"tlsNegotiationTimeoutInMillis": {"multiply": 2},
|
| 655 |
+
},
|
| 656 |
+
"in-region": {
|
| 657 |
+
"connectTimeoutInMillis": {"multiply": 1},
|
| 658 |
+
"tlsNegotiationTimeoutInMillis": {"multiply": 1},
|
| 659 |
+
},
|
| 660 |
+
"cross-region": {
|
| 661 |
+
"connectTimeoutInMillis": {"multiply": 2.8},
|
| 662 |
+
"tlsNegotiationTimeoutInMillis": {"multiply": 2.8},
|
| 663 |
+
},
|
| 664 |
+
"mobile": {
|
| 665 |
+
"connectTimeoutInMillis": {"override": 10000},
|
| 666 |
+
"tlsNegotiationTimeoutInMillis": {"add": 10000},
|
| 667 |
+
"retryMode": {"override": "adaptive"},
|
| 668 |
+
},
|
| 669 |
+
},
|
| 670 |
+
}
|
| 671 |
+
|
| 672 |
+
def _create_default_config_resolver(self):
|
| 673 |
+
return DefaultConfigResolver(self._template())
|
| 674 |
+
|
| 675 |
+
@pytest.fixture
|
| 676 |
+
def smart_defaults_factory(self):
|
| 677 |
+
fake_session = mock.Mock(spec=session.Session)
|
| 678 |
+
fake_session.get_scoped_config.return_value = {}
|
| 679 |
+
default_config_resolver = self._create_default_config_resolver()
|
| 680 |
+
return SmartDefaultsConfigStoreFactory(
|
| 681 |
+
default_config_resolver, imds_region_provider=mock.Mock()
|
| 682 |
+
)
|
| 683 |
+
|
| 684 |
+
@pytest.fixture
|
| 685 |
+
def fake_session(self):
|
| 686 |
+
fake_session = mock.Mock(spec=session.Session)
|
| 687 |
+
fake_session.get_scoped_config.return_value = {}
|
| 688 |
+
return fake_session
|
| 689 |
+
|
| 690 |
+
def _create_config_value_store(self, s3_mapping={}, **override_kwargs):
|
| 691 |
+
constant_provider = ConstantProvider(value='my_sts_regional_endpoint')
|
| 692 |
+
environment_provider = EnvironmentProvider(
|
| 693 |
+
name='AWS_RETRY_MODE', env={'AWS_RETRY_MODE': None}
|
| 694 |
+
)
|
| 695 |
+
fake_session = mock.Mock(spec=session.Session)
|
| 696 |
+
fake_session.get_scoped_config.return_value = {}
|
| 697 |
+
# Testing with three different providers to validate
|
| 698 |
+
# SmartDefaultsConfigStoreFactory._get_new_chain_provider
|
| 699 |
+
mapping = {
|
| 700 |
+
'sts_regional_endpoints': ChainProvider(
|
| 701 |
+
providers=[constant_provider]
|
| 702 |
+
),
|
| 703 |
+
'retry_mode': ChainProvider(providers=[environment_provider]),
|
| 704 |
+
's3': SectionConfigProvider('s3', fake_session, s3_mapping),
|
| 705 |
+
}
|
| 706 |
+
mapping.update(**override_kwargs)
|
| 707 |
+
config_store = ConfigValueStore(mapping=mapping)
|
| 708 |
+
return config_store
|
| 709 |
+
|
| 710 |
+
def _create_os_environ_patcher(self):
|
| 711 |
+
return mock.patch.object(
|
| 712 |
+
botocore.configprovider.os, 'environ', mock.Mock(wraps=os.environ)
|
| 713 |
+
)
|
| 714 |
+
|
| 715 |
+
def test_config_store_deepcopy(self):
|
| 716 |
+
config_store = ConfigValueStore()
|
| 717 |
+
config_store.set_config_provider(
|
| 718 |
+
'constant_value', ConstantProvider('ABC')
|
| 719 |
+
)
|
| 720 |
+
config_store_copy = copy.deepcopy(config_store)
|
| 721 |
+
config_store_copy.set_config_provider(
|
| 722 |
+
'constant_value_copy', ConstantProvider('123')
|
| 723 |
+
)
|
| 724 |
+
assert config_store.get_config_variable('constant_value_copy') is None
|
| 725 |
+
assert config_store_copy.get_config_variable('constant_value') == 'ABC'
|
| 726 |
+
|
| 727 |
+
def _create_config_value_store_to_test_merge(self):
|
| 728 |
+
environment_provider = EnvironmentProvider(
|
| 729 |
+
name='AWS_S3_US_EAST_1_REGIONAL_ENDPOINT',
|
| 730 |
+
env={},
|
| 731 |
+
)
|
| 732 |
+
|
| 733 |
+
s3_mapping = {
|
| 734 |
+
'us_east_1_regional_endpoint': ChainProvider(
|
| 735 |
+
providers=[environment_provider]
|
| 736 |
+
)
|
| 737 |
+
}
|
| 738 |
+
|
| 739 |
+
override_kwargs = {'connect_timeout': ConstantProvider(value=None)}
|
| 740 |
+
|
| 741 |
+
config_value_store = self._create_config_value_store(
|
| 742 |
+
s3_mapping=s3_mapping, **override_kwargs
|
| 743 |
+
)
|
| 744 |
+
|
| 745 |
+
return config_value_store
|
| 746 |
+
|
| 747 |
+
@pytest.mark.parametrize(
|
| 748 |
+
'config_variable,expected_value_before,expected_value_after',
|
| 749 |
+
[
|
| 750 |
+
['retry_mode', None, 'standard'],
|
| 751 |
+
['sts_regional_endpoints', 'my_sts_regional_endpoint', 'regional'],
|
| 752 |
+
['connect_timeout', None, 2],
|
| 753 |
+
['s3', None, {'us_east_1_regional_endpoint': 'regional'}],
|
| 754 |
+
],
|
| 755 |
+
)
|
| 756 |
+
def test_config_store_providers_not_mutated_after_merge(
|
| 757 |
+
self,
|
| 758 |
+
config_variable,
|
| 759 |
+
expected_value_before,
|
| 760 |
+
expected_value_after,
|
| 761 |
+
smart_defaults_factory,
|
| 762 |
+
):
|
| 763 |
+
"""Test uses the standard default mode from the template"""
|
| 764 |
+
|
| 765 |
+
config_value_store = self._create_config_value_store_to_test_merge()
|
| 766 |
+
|
| 767 |
+
provider = config_value_store.get_config_provider(config_variable)
|
| 768 |
+
|
| 769 |
+
smart_defaults_factory.merge_smart_defaults(
|
| 770 |
+
config_value_store, 'standard', 'some-region'
|
| 771 |
+
)
|
| 772 |
+
|
| 773 |
+
assert provider.provide() == expected_value_before
|
| 774 |
+
|
| 775 |
+
assert (
|
| 776 |
+
config_value_store.get_config_variable(config_variable)
|
| 777 |
+
== expected_value_after
|
| 778 |
+
)
|
| 779 |
+
|
| 780 |
+
@pytest.mark.parametrize(
|
| 781 |
+
'defaults_mode, retry_mode, sts_regional_endpoints,'
|
| 782 |
+
' us_east_1_regional_endpoint, connect_timeout',
|
| 783 |
+
[
|
| 784 |
+
('standard', 'standard', 'regional', 'regional', 2000),
|
| 785 |
+
('in-region', 'standard', 'regional', 'regional', 1000),
|
| 786 |
+
('cross-region', 'standard', 'regional', 'regional', 2800),
|
| 787 |
+
('mobile', 'adaptive', 'regional', 'regional', 10000),
|
| 788 |
+
],
|
| 789 |
+
)
|
| 790 |
+
def test_get_defualt_config_values(
|
| 791 |
+
self,
|
| 792 |
+
defaults_mode,
|
| 793 |
+
retry_mode,
|
| 794 |
+
sts_regional_endpoints,
|
| 795 |
+
us_east_1_regional_endpoint,
|
| 796 |
+
connect_timeout,
|
| 797 |
+
):
|
| 798 |
+
default_config_resolver = self._create_default_config_resolver()
|
| 799 |
+
default_values = default_config_resolver.get_default_config_values(
|
| 800 |
+
defaults_mode
|
| 801 |
+
)
|
| 802 |
+
assert default_values['retryMode'] == retry_mode
|
| 803 |
+
assert default_values['stsRegionalEndpoints'] == sts_regional_endpoints
|
| 804 |
+
assert (
|
| 805 |
+
default_values['s3UsEast1RegionalEndpoints']
|
| 806 |
+
== us_east_1_regional_endpoint
|
| 807 |
+
)
|
| 808 |
+
assert default_values['connectTimeoutInMillis'] == connect_timeout
|
| 809 |
+
|
| 810 |
+
def test_resolve_default_values_on_config(
|
| 811 |
+
self, smart_defaults_factory, fake_session
|
| 812 |
+
):
|
| 813 |
+
config_store = self._create_config_value_store()
|
| 814 |
+
smart_defaults_factory.merge_smart_defaults(
|
| 815 |
+
config_store, 'standard', 'foo'
|
| 816 |
+
)
|
| 817 |
+
s3_config = config_store.get_config_variable('s3')
|
| 818 |
+
assert s3_config['us_east_1_regional_endpoint'] == 'regional'
|
| 819 |
+
assert config_store.get_config_variable('retry_mode') == 'standard'
|
| 820 |
+
assert (
|
| 821 |
+
config_store.get_config_variable('sts_regional_endpoints')
|
| 822 |
+
== 'regional'
|
| 823 |
+
)
|
| 824 |
+
assert config_store.get_config_variable('connect_timeout') == 2
|
| 825 |
+
|
| 826 |
+
def test_no_resolve_default_s3_values_on_config(
|
| 827 |
+
self, smart_defaults_factory
|
| 828 |
+
):
|
| 829 |
+
environment_provider = EnvironmentProvider(
|
| 830 |
+
name='AWS_S3_US_EAST_1_REGIONAL_ENDPOINT',
|
| 831 |
+
env={'AWS_S3_US_EAST_1_REGIONAL_ENDPOINT': 'legacy'},
|
| 832 |
+
)
|
| 833 |
+
s3_mapping = {
|
| 834 |
+
'us_east_1_regional_endpoint': ChainProvider(
|
| 835 |
+
providers=[environment_provider]
|
| 836 |
+
)
|
| 837 |
+
}
|
| 838 |
+
config_store = self._create_config_value_store(s3_mapping=s3_mapping)
|
| 839 |
+
smart_defaults_factory.merge_smart_defaults(
|
| 840 |
+
config_store, 'standard', 'foo'
|
| 841 |
+
)
|
| 842 |
+
s3_config = config_store.get_config_variable('s3')
|
| 843 |
+
assert s3_config['us_east_1_regional_endpoint'] == 'legacy'
|
| 844 |
+
assert config_store.get_config_variable('retry_mode') == 'standard'
|
| 845 |
+
assert (
|
| 846 |
+
config_store.get_config_variable('sts_regional_endpoints')
|
| 847 |
+
== 'regional'
|
| 848 |
+
)
|
| 849 |
+
assert config_store.get_config_variable('connect_timeout') == 2
|
| 850 |
+
|
| 851 |
+
def test_resolve_default_s3_values_on_config(
|
| 852 |
+
self, smart_defaults_factory, fake_session
|
| 853 |
+
):
|
| 854 |
+
s3_mapping = {
|
| 855 |
+
'use_arn_region': ChainProvider(
|
| 856 |
+
providers=[ConstantProvider(value=False)]
|
| 857 |
+
)
|
| 858 |
+
}
|
| 859 |
+
config_store = self._create_config_value_store(s3_mapping=s3_mapping)
|
| 860 |
+
smart_defaults_factory.merge_smart_defaults(
|
| 861 |
+
config_store, 'standard', 'foo'
|
| 862 |
+
)
|
| 863 |
+
s3_config = config_store.get_config_variable('s3')
|
| 864 |
+
assert s3_config['us_east_1_regional_endpoint'] == 'regional'
|
| 865 |
+
assert config_store.get_config_variable('retry_mode') == 'standard'
|
| 866 |
+
assert (
|
| 867 |
+
config_store.get_config_variable('sts_regional_endpoints')
|
| 868 |
+
== 'regional'
|
| 869 |
+
)
|
| 870 |
+
assert config_store.get_config_variable('connect_timeout') == 2
|
| 871 |
+
|
| 872 |
+
@pytest.mark.parametrize(
|
| 873 |
+
'execution_env_var, region_env_var, default_region_env_var, '
|
| 874 |
+
'imds_region, client_region, resolved_mode',
|
| 875 |
+
[
|
| 876 |
+
(
|
| 877 |
+
'AWS_Lambda_python3.6',
|
| 878 |
+
'us-east-1',
|
| 879 |
+
None,
|
| 880 |
+
None,
|
| 881 |
+
'us-east-1',
|
| 882 |
+
'in-region',
|
| 883 |
+
),
|
| 884 |
+
(
|
| 885 |
+
'AWS_Lambda_python3.6',
|
| 886 |
+
'us-west-2',
|
| 887 |
+
'us-west-2',
|
| 888 |
+
None,
|
| 889 |
+
'us-east-1',
|
| 890 |
+
'cross-region',
|
| 891 |
+
),
|
| 892 |
+
(
|
| 893 |
+
'AWS_Lambda_python3.6',
|
| 894 |
+
None,
|
| 895 |
+
None,
|
| 896 |
+
'us-west-2',
|
| 897 |
+
'us-east-1',
|
| 898 |
+
'cross-region',
|
| 899 |
+
),
|
| 900 |
+
(None, None, 'us-east-1', 'us-east-1', 'us-east-1', 'in-region'),
|
| 901 |
+
(None, None, None, 'us-west-2', 'us-east-1', 'cross-region'),
|
| 902 |
+
(None, None, None, None, 'us-west-2', 'standard'),
|
| 903 |
+
],
|
| 904 |
+
)
|
| 905 |
+
def test_resolve_auto_mode(
|
| 906 |
+
self,
|
| 907 |
+
execution_env_var,
|
| 908 |
+
region_env_var,
|
| 909 |
+
default_region_env_var,
|
| 910 |
+
imds_region,
|
| 911 |
+
client_region,
|
| 912 |
+
resolved_mode,
|
| 913 |
+
):
|
| 914 |
+
imds_region_provider = mock.Mock(spec=IMDSRegionProvider)
|
| 915 |
+
imds_region_provider.provide.return_value = imds_region
|
| 916 |
+
default_config_resolver = mock.Mock()
|
| 917 |
+
with mock.patch.object(
|
| 918 |
+
botocore.configprovider.os, 'environ', mock.Mock(wraps=os.environ)
|
| 919 |
+
) as os_environ_patcher:
|
| 920 |
+
os_environ_patcher.get.side_effect = [
|
| 921 |
+
execution_env_var,
|
| 922 |
+
default_region_env_var,
|
| 923 |
+
region_env_var,
|
| 924 |
+
]
|
| 925 |
+
smart_defaults_factory = SmartDefaultsConfigStoreFactory(
|
| 926 |
+
default_config_resolver, imds_region_provider
|
| 927 |
+
)
|
| 928 |
+
mode = smart_defaults_factory.resolve_auto_mode(client_region)
|
| 929 |
+
assert mode == resolved_mode
|
| 930 |
+
|
| 931 |
+
def test_resolve_auto_mode_imds_region_provider_connect_timeout(self):
|
| 932 |
+
imds_region_provider = mock.Mock(spec=IMDSRegionProvider)
|
| 933 |
+
imds_region_provider.provide.side_effect = ConnectTimeoutError(
|
| 934 |
+
endpoint_url='foo'
|
| 935 |
+
)
|
| 936 |
+
default_config_resolver = mock.Mock()
|
| 937 |
+
with mock.patch.object(
|
| 938 |
+
botocore.configprovider.os, 'environ', mock.Mock(wraps=os.environ)
|
| 939 |
+
) as os_environ_patcher:
|
| 940 |
+
os_environ_patcher.get.side_effect = [None] * 3
|
| 941 |
+
smart_defaults_factory = SmartDefaultsConfigStoreFactory(
|
| 942 |
+
default_config_resolver, imds_region_provider
|
| 943 |
+
)
|
| 944 |
+
mode = smart_defaults_factory.resolve_auto_mode('us-west-2')
|
| 945 |
+
assert mode == 'standard'
|
| 946 |
+
|
| 947 |
+
|
| 948 |
+
def create_cases():
|
| 949 |
+
service = 'batch'
|
| 950 |
+
|
| 951 |
+
return [
|
| 952 |
+
dict(
|
| 953 |
+
service=service,
|
| 954 |
+
environ_map={},
|
| 955 |
+
full_config_map={},
|
| 956 |
+
expected_value=None,
|
| 957 |
+
),
|
| 958 |
+
dict(
|
| 959 |
+
service=service,
|
| 960 |
+
environ_map={'AWS_ENDPOINT_URL': 'global-from-env'},
|
| 961 |
+
full_config_map={},
|
| 962 |
+
expected_value='global-from-env',
|
| 963 |
+
),
|
| 964 |
+
dict(
|
| 965 |
+
service=service,
|
| 966 |
+
environ_map={
|
| 967 |
+
f'AWS_ENDPOINT_URL_{service.upper()}': 'service-from-env',
|
| 968 |
+
'AWS_ENDPOINT_URL': 'global-from-env',
|
| 969 |
+
},
|
| 970 |
+
full_config_map={},
|
| 971 |
+
expected_value='service-from-env',
|
| 972 |
+
),
|
| 973 |
+
dict(
|
| 974 |
+
service=service,
|
| 975 |
+
environ_map={
|
| 976 |
+
'AWS_ENDPOINT_URL': 'global-from-env',
|
| 977 |
+
'AWS_ENDPOINT_URL_S3': 's3-endpoint-url',
|
| 978 |
+
},
|
| 979 |
+
full_config_map={},
|
| 980 |
+
expected_value='global-from-env',
|
| 981 |
+
),
|
| 982 |
+
dict(
|
| 983 |
+
service=service,
|
| 984 |
+
environ_map={},
|
| 985 |
+
full_config_map={
|
| 986 |
+
'profiles': {'default': {'endpoint_url': 'global-from-config'}}
|
| 987 |
+
},
|
| 988 |
+
expected_value='global-from-config',
|
| 989 |
+
),
|
| 990 |
+
dict(
|
| 991 |
+
service=service,
|
| 992 |
+
environ_map={},
|
| 993 |
+
full_config_map={
|
| 994 |
+
'profiles': {
|
| 995 |
+
'default': {
|
| 996 |
+
'services': 'my-services',
|
| 997 |
+
}
|
| 998 |
+
},
|
| 999 |
+
'services': {
|
| 1000 |
+
'my-services': {
|
| 1001 |
+
service: {'endpoint_url': "service-from-config"}
|
| 1002 |
+
}
|
| 1003 |
+
},
|
| 1004 |
+
},
|
| 1005 |
+
expected_value='service-from-config',
|
| 1006 |
+
),
|
| 1007 |
+
dict(
|
| 1008 |
+
service=service,
|
| 1009 |
+
environ_map={},
|
| 1010 |
+
full_config_map={
|
| 1011 |
+
'profiles': {
|
| 1012 |
+
'default': {
|
| 1013 |
+
'services': 'my-services',
|
| 1014 |
+
'endpoint_url': 'global-from-config',
|
| 1015 |
+
}
|
| 1016 |
+
},
|
| 1017 |
+
'services': {
|
| 1018 |
+
'my-services': {
|
| 1019 |
+
service: {'endpoint_url': "service-from-config"}
|
| 1020 |
+
}
|
| 1021 |
+
},
|
| 1022 |
+
},
|
| 1023 |
+
expected_value='service-from-config',
|
| 1024 |
+
),
|
| 1025 |
+
dict(
|
| 1026 |
+
service=service,
|
| 1027 |
+
environ_map={
|
| 1028 |
+
'AWS_ENDPOINT_URL': 'global-from-env',
|
| 1029 |
+
},
|
| 1030 |
+
full_config_map={
|
| 1031 |
+
'profiles': {
|
| 1032 |
+
'default': {
|
| 1033 |
+
'endpoint_url': 'global-from-config',
|
| 1034 |
+
}
|
| 1035 |
+
},
|
| 1036 |
+
},
|
| 1037 |
+
expected_value='global-from-env',
|
| 1038 |
+
),
|
| 1039 |
+
dict(
|
| 1040 |
+
service=service,
|
| 1041 |
+
environ_map={
|
| 1042 |
+
f'AWS_ENDPOINT_URL_{service.upper()}': 'service-from-env',
|
| 1043 |
+
},
|
| 1044 |
+
full_config_map={
|
| 1045 |
+
'profiles': {
|
| 1046 |
+
'default': {
|
| 1047 |
+
'endpoint_url': 'global-from-config',
|
| 1048 |
+
}
|
| 1049 |
+
},
|
| 1050 |
+
},
|
| 1051 |
+
expected_value='service-from-env',
|
| 1052 |
+
),
|
| 1053 |
+
dict(
|
| 1054 |
+
service='s3',
|
| 1055 |
+
environ_map={},
|
| 1056 |
+
full_config_map={
|
| 1057 |
+
'profiles': {
|
| 1058 |
+
'default': {
|
| 1059 |
+
'services': 'my-services',
|
| 1060 |
+
'endpoint_url': 'global-from-config',
|
| 1061 |
+
}
|
| 1062 |
+
},
|
| 1063 |
+
'services': {
|
| 1064 |
+
'my-services': {
|
| 1065 |
+
service: {'endpoint_url': "service-from-config"}
|
| 1066 |
+
}
|
| 1067 |
+
},
|
| 1068 |
+
},
|
| 1069 |
+
expected_value='global-from-config',
|
| 1070 |
+
),
|
| 1071 |
+
dict(
|
| 1072 |
+
service='runtime.sagemaker',
|
| 1073 |
+
environ_map={},
|
| 1074 |
+
full_config_map={
|
| 1075 |
+
'profiles': {
|
| 1076 |
+
'default': {
|
| 1077 |
+
'services': 'my-services',
|
| 1078 |
+
}
|
| 1079 |
+
},
|
| 1080 |
+
'services': {
|
| 1081 |
+
'my-services': {
|
| 1082 |
+
'sagemaker_runtime': {
|
| 1083 |
+
'endpoint_url': "service-from-config"
|
| 1084 |
+
}
|
| 1085 |
+
}
|
| 1086 |
+
},
|
| 1087 |
+
},
|
| 1088 |
+
expected_value='service-from-config',
|
| 1089 |
+
),
|
| 1090 |
+
dict(
|
| 1091 |
+
service='apigateway',
|
| 1092 |
+
environ_map={},
|
| 1093 |
+
full_config_map={
|
| 1094 |
+
'profiles': {
|
| 1095 |
+
'default': {
|
| 1096 |
+
'services': 'my-services',
|
| 1097 |
+
}
|
| 1098 |
+
},
|
| 1099 |
+
'services': {
|
| 1100 |
+
'my-services': {
|
| 1101 |
+
'api_gateway': {'endpoint_url': "service-from-config"}
|
| 1102 |
+
}
|
| 1103 |
+
},
|
| 1104 |
+
},
|
| 1105 |
+
expected_value='service-from-config',
|
| 1106 |
+
),
|
| 1107 |
+
]
|
| 1108 |
+
|
| 1109 |
+
|
| 1110 |
+
class TestConfiguredEndpointProvider:
|
| 1111 |
+
def assert_does_provide(
|
| 1112 |
+
self,
|
| 1113 |
+
service,
|
| 1114 |
+
environ_map,
|
| 1115 |
+
full_config_map,
|
| 1116 |
+
expected_value,
|
| 1117 |
+
):
|
| 1118 |
+
scoped_config_map = full_config_map.get('profiles', {}).get(
|
| 1119 |
+
'default', {}
|
| 1120 |
+
)
|
| 1121 |
+
|
| 1122 |
+
chain = ConfiguredEndpointProvider(
|
| 1123 |
+
scoped_config=scoped_config_map,
|
| 1124 |
+
full_config=full_config_map,
|
| 1125 |
+
client_name=service,
|
| 1126 |
+
environ=environ_map,
|
| 1127 |
+
)
|
| 1128 |
+
value = chain.provide()
|
| 1129 |
+
assert value == expected_value
|
| 1130 |
+
|
| 1131 |
+
@pytest.mark.parametrize('test_case', create_cases())
|
| 1132 |
+
def test_does_provide(self, test_case):
|
| 1133 |
+
self.assert_does_provide(**test_case)
|
| 1134 |
+
|
| 1135 |
+
def test_is_deepcopyable(self):
|
| 1136 |
+
env = {'AWS_ENDPOINT_URL_BATCH': 'https://endpoint-override'}
|
| 1137 |
+
provider = ConfiguredEndpointProvider(
|
| 1138 |
+
full_config={}, scoped_config={}, client_name='batch', environ=env
|
| 1139 |
+
)
|
| 1140 |
+
|
| 1141 |
+
provider_deepcopy = copy.deepcopy(provider)
|
| 1142 |
+
assert provider is not provider_deepcopy
|
| 1143 |
+
assert provider.provide() == 'https://endpoint-override'
|
| 1144 |
+
assert provider_deepcopy.provide() == 'https://endpoint-override'
|
| 1145 |
+
|
| 1146 |
+
env['AWS_ENDPOINT_URL_BATCH'] = 'https://another-new-endpoint-override'
|
| 1147 |
+
assert provider.provide() == 'https://another-new-endpoint-override'
|
| 1148 |
+
assert provider_deepcopy.provide() == 'https://endpoint-override'
|
testbed/boto__botocore/tests/unit/test_configloader.py
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env
|
| 2 |
+
# Copyright (c) 2012-2013 Mitch Garnaat http://garnaat.org/
|
| 3 |
+
# Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 4 |
+
#
|
| 5 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 6 |
+
# may not use this file except in compliance with the License. A copy of
|
| 7 |
+
# the License is located at
|
| 8 |
+
#
|
| 9 |
+
# http://aws.amazon.com/apache2.0/
|
| 10 |
+
#
|
| 11 |
+
# or in the "license" file accompanying this file. This file is
|
| 12 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 13 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 14 |
+
# language governing permissions and limitations under the License.
|
| 15 |
+
import os
|
| 16 |
+
import shutil
|
| 17 |
+
import tempfile
|
| 18 |
+
|
| 19 |
+
import botocore.exceptions
|
| 20 |
+
from botocore.configloader import (
|
| 21 |
+
load_config,
|
| 22 |
+
multi_file_load_config,
|
| 23 |
+
raw_config_parse,
|
| 24 |
+
)
|
| 25 |
+
from tests import mock, unittest
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def path(filename):
|
| 29 |
+
directory = os.path.join(os.path.dirname(__file__), 'cfg')
|
| 30 |
+
if isinstance(filename, bytes):
|
| 31 |
+
directory = directory.encode('latin-1')
|
| 32 |
+
return os.path.join(directory, filename)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class TestConfigLoader(unittest.TestCase):
|
| 36 |
+
def setUp(self):
|
| 37 |
+
self.tempdir = tempfile.mkdtemp()
|
| 38 |
+
|
| 39 |
+
def tearDown(self):
|
| 40 |
+
shutil.rmtree(self.tempdir)
|
| 41 |
+
|
| 42 |
+
def create_config_file(self, filename):
|
| 43 |
+
contents = (
|
| 44 |
+
'[default]\n'
|
| 45 |
+
'aws_access_key_id = foo\n'
|
| 46 |
+
'aws_secret_access_key = bar\n\n'
|
| 47 |
+
'[profile "personal"]\n'
|
| 48 |
+
'aws_access_key_id = fie\n'
|
| 49 |
+
'aws_secret_access_key = baz\n'
|
| 50 |
+
'aws_security_token = fiebaz\n'
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
directory = self.tempdir
|
| 54 |
+
if isinstance(filename, bytes):
|
| 55 |
+
directory = directory.encode('latin-1')
|
| 56 |
+
full_path = os.path.join(directory, filename)
|
| 57 |
+
|
| 58 |
+
with open(full_path, 'w') as f:
|
| 59 |
+
f.write(contents)
|
| 60 |
+
return full_path
|
| 61 |
+
|
| 62 |
+
def test_config_not_found(self):
|
| 63 |
+
with self.assertRaises(botocore.exceptions.ConfigNotFound):
|
| 64 |
+
raw_config_parse(path('aws_config_notfound'))
|
| 65 |
+
|
| 66 |
+
def test_config_parse_error(self):
|
| 67 |
+
filename = path('aws_config_bad')
|
| 68 |
+
with self.assertRaises(botocore.exceptions.ConfigParseError):
|
| 69 |
+
raw_config_parse(filename)
|
| 70 |
+
|
| 71 |
+
def test_config_parse_error_bad_unicode(self):
|
| 72 |
+
filename = path('aws_config_badbytes')
|
| 73 |
+
with self.assertRaises(botocore.exceptions.ConfigParseError):
|
| 74 |
+
raw_config_parse(filename)
|
| 75 |
+
|
| 76 |
+
def test_config_parse_error_filesystem_encoding_none(self):
|
| 77 |
+
filename = path('aws_config_bad')
|
| 78 |
+
with mock.patch('sys.getfilesystemencoding') as encoding:
|
| 79 |
+
encoding.return_value = None
|
| 80 |
+
with self.assertRaises(botocore.exceptions.ConfigParseError):
|
| 81 |
+
raw_config_parse(filename)
|
| 82 |
+
|
| 83 |
+
def test_config(self):
|
| 84 |
+
loaded_config = raw_config_parse(path('aws_config'))
|
| 85 |
+
self.assertIn('default', loaded_config)
|
| 86 |
+
self.assertIn('profile "personal"', loaded_config)
|
| 87 |
+
|
| 88 |
+
def test_profile_map_conversion(self):
|
| 89 |
+
loaded_config = load_config(path('aws_config'))
|
| 90 |
+
self.assertIn('profiles', loaded_config)
|
| 91 |
+
self.assertEqual(
|
| 92 |
+
sorted(loaded_config['profiles'].keys()), ['default', 'personal']
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
def test_bad_profiles_are_ignored(self):
|
| 96 |
+
filename = path('aws_bad_profile')
|
| 97 |
+
loaded_config = load_config(filename)
|
| 98 |
+
self.assertEqual(len(loaded_config['profiles']), 3)
|
| 99 |
+
profiles = loaded_config['profiles']
|
| 100 |
+
self.assertIn('my profile', profiles)
|
| 101 |
+
self.assertIn('personal1', profiles)
|
| 102 |
+
self.assertIn('default', profiles)
|
| 103 |
+
|
| 104 |
+
def test_nested_hierarchy_parsing(self):
|
| 105 |
+
filename = path('aws_config_nested')
|
| 106 |
+
loaded_config = load_config(filename)
|
| 107 |
+
config = loaded_config['profiles']['default']
|
| 108 |
+
self.assertEqual(config['aws_access_key_id'], 'foo')
|
| 109 |
+
self.assertEqual(config['region'], 'us-west-2')
|
| 110 |
+
self.assertEqual(config['s3']['signature_version'], 's3v4')
|
| 111 |
+
self.assertEqual(config['cloudwatch']['signature_version'], 'v4')
|
| 112 |
+
|
| 113 |
+
def test_nested_hierarchy_with_no_subsection_parsing(self):
|
| 114 |
+
filename = path('aws_config_nested')
|
| 115 |
+
raw_config = raw_config_parse(filename, False)['default']
|
| 116 |
+
self.assertEqual(raw_config['aws_access_key_id'], 'foo')
|
| 117 |
+
self.assertEqual(raw_config['region'], 'us-west-2')
|
| 118 |
+
# Specifying False for pase_subsections in raw_config_parse
|
| 119 |
+
# will make sure that indented sections such as singature_version
|
| 120 |
+
# will not be treated as another subsection but rather
|
| 121 |
+
# its literal value.
|
| 122 |
+
self.assertEqual(raw_config['cloudwatch'], '\nsignature_version = v4')
|
| 123 |
+
self.assertEqual(
|
| 124 |
+
raw_config['s3'],
|
| 125 |
+
'\nsignature_version = s3v4' '\naddressing_style = path',
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
def test_nested_bad_config(self):
|
| 129 |
+
filename = path('aws_config_nested_bad')
|
| 130 |
+
with self.assertRaises(botocore.exceptions.ConfigParseError):
|
| 131 |
+
load_config(filename)
|
| 132 |
+
|
| 133 |
+
def test_nested_bad_config_filesystem_encoding_none(self):
|
| 134 |
+
filename = path('aws_config_nested_bad')
|
| 135 |
+
with mock.patch('sys.getfilesystemencoding') as encoding:
|
| 136 |
+
encoding.return_value = None
|
| 137 |
+
with self.assertRaises(botocore.exceptions.ConfigParseError):
|
| 138 |
+
load_config(filename)
|
| 139 |
+
|
| 140 |
+
def test_multi_file_load(self):
|
| 141 |
+
filenames = [
|
| 142 |
+
path('aws_config_other'),
|
| 143 |
+
path('aws_config'),
|
| 144 |
+
path('aws_third_config'),
|
| 145 |
+
path('aws_config_notfound'),
|
| 146 |
+
]
|
| 147 |
+
loaded_config = multi_file_load_config(*filenames)
|
| 148 |
+
config = loaded_config['profiles']['default']
|
| 149 |
+
self.assertEqual(config['aws_access_key_id'], 'other_foo')
|
| 150 |
+
self.assertEqual(config['aws_secret_access_key'], 'other_bar')
|
| 151 |
+
second_config = loaded_config['profiles']['personal']
|
| 152 |
+
self.assertEqual(second_config['aws_access_key_id'], 'fie')
|
| 153 |
+
self.assertEqual(second_config['aws_secret_access_key'], 'baz')
|
| 154 |
+
self.assertEqual(second_config['aws_security_token'], 'fiebaz')
|
| 155 |
+
third_config = loaded_config['profiles']['third']
|
| 156 |
+
self.assertEqual(third_config['aws_access_key_id'], 'third_fie')
|
| 157 |
+
self.assertEqual(third_config['aws_secret_access_key'], 'third_baz')
|
| 158 |
+
self.assertEqual(third_config['aws_security_token'], 'third_fiebaz')
|
| 159 |
+
|
| 160 |
+
def test_unicode_bytes_path_not_found(self):
|
| 161 |
+
with self.assertRaises(botocore.exceptions.ConfigNotFound):
|
| 162 |
+
with mock.patch('sys.getfilesystemencoding') as encoding:
|
| 163 |
+
encoding.return_value = 'utf-8'
|
| 164 |
+
load_config(path(b'\xe2\x9c\x93'))
|
| 165 |
+
|
| 166 |
+
def test_unicode_bytes_path_not_found_filesystem_encoding_none(self):
|
| 167 |
+
with mock.patch('sys.getfilesystemencoding') as encoding:
|
| 168 |
+
encoding.return_value = None
|
| 169 |
+
with self.assertRaises(botocore.exceptions.ConfigNotFound):
|
| 170 |
+
load_config(path(b'\xe2\x9c\x93'))
|
| 171 |
+
|
| 172 |
+
def test_unicode_bytes_path(self):
|
| 173 |
+
filename = self.create_config_file(b'aws_config_unicode\xe2\x9c\x93')
|
| 174 |
+
with mock.patch('sys.getfilesystemencoding') as encoding:
|
| 175 |
+
encoding.return_value = 'utf-8'
|
| 176 |
+
loaded_config = load_config(filename)
|
| 177 |
+
self.assertIn('default', loaded_config['profiles'])
|
| 178 |
+
self.assertIn('personal', loaded_config['profiles'])
|
| 179 |
+
|
| 180 |
+
def test_sso_session_config(self):
|
| 181 |
+
filename = path('aws_sso_session_config')
|
| 182 |
+
loaded_config = load_config(filename)
|
| 183 |
+
self.assertIn('profiles', loaded_config)
|
| 184 |
+
self.assertIn('default', loaded_config['profiles'])
|
| 185 |
+
self.assertIn('sso_sessions', loaded_config)
|
| 186 |
+
self.assertIn('sso', loaded_config['sso_sessions'])
|
| 187 |
+
sso_config = loaded_config['sso_sessions']['sso']
|
| 188 |
+
self.assertEqual(sso_config['sso_region'], 'us-east-1')
|
| 189 |
+
self.assertEqual(sso_config['sso_start_url'], 'https://example.com')
|
| 190 |
+
|
| 191 |
+
def test_services_config(self):
|
| 192 |
+
filename = path('aws_services_config')
|
| 193 |
+
loaded_config = load_config(filename)
|
| 194 |
+
self.assertIn('profiles', loaded_config)
|
| 195 |
+
self.assertIn('default', loaded_config['profiles'])
|
| 196 |
+
self.assertIn('services', loaded_config)
|
| 197 |
+
self.assertIn('my-services', loaded_config['services'])
|
| 198 |
+
services_config = loaded_config['services']['my-services']
|
| 199 |
+
self.assertIn('s3', services_config)
|
| 200 |
+
self.assertIn('dynamodb', services_config)
|
| 201 |
+
self.assertEqual(
|
| 202 |
+
services_config['s3']['endpoint_url'], 'https://localhost:5678/'
|
| 203 |
+
)
|
| 204 |
+
self.assertEqual(
|
| 205 |
+
services_config['dynamodb']['endpoint_url'],
|
| 206 |
+
'https://localhost:8888/',
|
| 207 |
+
)
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
if __name__ == "__main__":
|
| 211 |
+
unittest.main()
|
testbed/boto__botocore/tests/unit/test_credentials.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
testbed/boto__botocore/tests/unit/test_discovery.py
ADDED
|
@@ -0,0 +1,495 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import time
|
| 2 |
+
|
| 3 |
+
from botocore.awsrequest import AWSRequest
|
| 4 |
+
from botocore.client import ClientMeta
|
| 5 |
+
from botocore.discovery import (
|
| 6 |
+
EndpointDiscoveryHandler,
|
| 7 |
+
EndpointDiscoveryManager,
|
| 8 |
+
EndpointDiscoveryRefreshFailed,
|
| 9 |
+
EndpointDiscoveryRequired,
|
| 10 |
+
block_endpoint_discovery_required_operations,
|
| 11 |
+
)
|
| 12 |
+
from botocore.exceptions import ConnectionError
|
| 13 |
+
from botocore.handlers import inject_api_version_header_if_needed
|
| 14 |
+
from botocore.hooks import HierarchicalEmitter
|
| 15 |
+
from botocore.model import ServiceModel
|
| 16 |
+
from tests import mock, unittest
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class BaseEndpointDiscoveryTest(unittest.TestCase):
|
| 20 |
+
def setUp(self):
|
| 21 |
+
self.service_description = {
|
| 22 |
+
'version': '2.0',
|
| 23 |
+
'metadata': {
|
| 24 |
+
'apiVersion': '2018-08-31',
|
| 25 |
+
'endpointPrefix': 'fooendpoint',
|
| 26 |
+
'jsonVersion': '1.1',
|
| 27 |
+
'protocol': 'json',
|
| 28 |
+
'serviceAbbreviation': 'FooService',
|
| 29 |
+
'serviceId': 'FooService',
|
| 30 |
+
'serviceFullName': 'AwsFooService',
|
| 31 |
+
'signatureVersion': 'v4',
|
| 32 |
+
'signingName': 'awsfooservice',
|
| 33 |
+
'targetPrefix': 'awsfooservice',
|
| 34 |
+
},
|
| 35 |
+
'operations': {
|
| 36 |
+
'DescribeEndpoints': {
|
| 37 |
+
'name': 'DescribeEndpoints',
|
| 38 |
+
'http': {'method': 'POST', 'requestUri': '/'},
|
| 39 |
+
'input': {'shape': 'DescribeEndpointsRequest'},
|
| 40 |
+
'output': {'shape': 'DescribeEndpointsResponse'},
|
| 41 |
+
'endpointoperation': True,
|
| 42 |
+
},
|
| 43 |
+
'TestDiscoveryRequired': {
|
| 44 |
+
'name': 'TestDiscoveryRequired',
|
| 45 |
+
'http': {'method': 'POST', 'requestUri': '/'},
|
| 46 |
+
'input': {'shape': 'TestDiscoveryIdsRequest'},
|
| 47 |
+
'output': {'shape': 'EmptyStruct'},
|
| 48 |
+
'endpointdiscovery': {'required': True},
|
| 49 |
+
},
|
| 50 |
+
'TestDiscoveryOptional': {
|
| 51 |
+
'name': 'TestDiscoveryOptional',
|
| 52 |
+
'http': {'method': 'POST', 'requestUri': '/'},
|
| 53 |
+
'input': {'shape': 'TestDiscoveryIdsRequest'},
|
| 54 |
+
'output': {'shape': 'EmptyStruct'},
|
| 55 |
+
'endpointdiscovery': {},
|
| 56 |
+
},
|
| 57 |
+
'TestDiscovery': {
|
| 58 |
+
'name': 'TestDiscovery',
|
| 59 |
+
'http': {'method': 'POST', 'requestUri': '/'},
|
| 60 |
+
'input': {'shape': 'EmptyStruct'},
|
| 61 |
+
'output': {'shape': 'EmptyStruct'},
|
| 62 |
+
'endpointdiscovery': {},
|
| 63 |
+
},
|
| 64 |
+
},
|
| 65 |
+
'shapes': {
|
| 66 |
+
'Boolean': {'type': 'boolean'},
|
| 67 |
+
'DescribeEndpointsRequest': {
|
| 68 |
+
'type': 'structure',
|
| 69 |
+
'members': {
|
| 70 |
+
'Operation': {'shape': 'String'},
|
| 71 |
+
'Identifiers': {'shape': 'Identifiers'},
|
| 72 |
+
},
|
| 73 |
+
},
|
| 74 |
+
'DescribeEndpointsResponse': {
|
| 75 |
+
'type': 'structure',
|
| 76 |
+
'required': ['Endpoints'],
|
| 77 |
+
'members': {'Endpoints': {'shape': 'Endpoints'}},
|
| 78 |
+
},
|
| 79 |
+
'Endpoint': {
|
| 80 |
+
'type': 'structure',
|
| 81 |
+
'required': ['Address', 'CachePeriodInMinutes'],
|
| 82 |
+
'members': {
|
| 83 |
+
'Address': {'shape': 'String'},
|
| 84 |
+
'CachePeriodInMinutes': {'shape': 'Long'},
|
| 85 |
+
},
|
| 86 |
+
},
|
| 87 |
+
'Endpoints': {'type': 'list', 'member': {'shape': 'Endpoint'}},
|
| 88 |
+
'Identifiers': {
|
| 89 |
+
'type': 'map',
|
| 90 |
+
'key': {'shape': 'String'},
|
| 91 |
+
'value': {'shape': 'String'},
|
| 92 |
+
},
|
| 93 |
+
'Long': {'type': 'long'},
|
| 94 |
+
'String': {'type': 'string'},
|
| 95 |
+
'TestDiscoveryIdsRequest': {
|
| 96 |
+
'type': 'structure',
|
| 97 |
+
'required': ['Foo', 'Nested'],
|
| 98 |
+
'members': {
|
| 99 |
+
'Foo': {
|
| 100 |
+
'shape': 'String',
|
| 101 |
+
'endpointdiscoveryid': True,
|
| 102 |
+
},
|
| 103 |
+
'Baz': {'shape': 'String'},
|
| 104 |
+
'Nested': {'shape': 'Nested'},
|
| 105 |
+
},
|
| 106 |
+
},
|
| 107 |
+
'EmptyStruct': {'type': 'structure', 'members': {}},
|
| 108 |
+
'Nested': {
|
| 109 |
+
'type': 'structure',
|
| 110 |
+
'required': 'Bar',
|
| 111 |
+
'members': {
|
| 112 |
+
'Bar': {
|
| 113 |
+
'shape': 'String',
|
| 114 |
+
'endpointdiscoveryid': True,
|
| 115 |
+
}
|
| 116 |
+
},
|
| 117 |
+
},
|
| 118 |
+
},
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
class TestEndpointDiscoveryManager(BaseEndpointDiscoveryTest):
|
| 123 |
+
def setUp(self):
|
| 124 |
+
super().setUp()
|
| 125 |
+
self.construct_manager()
|
| 126 |
+
|
| 127 |
+
def construct_manager(self, cache=None, time=None, side_effect=None):
|
| 128 |
+
self.service_model = ServiceModel(self.service_description)
|
| 129 |
+
self.meta = mock.Mock(spec=ClientMeta)
|
| 130 |
+
self.meta.service_model = self.service_model
|
| 131 |
+
self.client = mock.Mock()
|
| 132 |
+
if side_effect is None:
|
| 133 |
+
side_effect = [
|
| 134 |
+
{
|
| 135 |
+
'Endpoints': [
|
| 136 |
+
{
|
| 137 |
+
'Address': 'new.com',
|
| 138 |
+
'CachePeriodInMinutes': 2,
|
| 139 |
+
}
|
| 140 |
+
]
|
| 141 |
+
}
|
| 142 |
+
]
|
| 143 |
+
self.client.describe_endpoints.side_effect = side_effect
|
| 144 |
+
self.client.meta = self.meta
|
| 145 |
+
self.manager = EndpointDiscoveryManager(
|
| 146 |
+
self.client, cache=cache, current_time=time
|
| 147 |
+
)
|
| 148 |
+
|
| 149 |
+
def test_injects_api_version_if_endpoint_operation(self):
|
| 150 |
+
model = self.service_model.operation_model('DescribeEndpoints')
|
| 151 |
+
params = {'headers': {}}
|
| 152 |
+
inject_api_version_header_if_needed(model, params)
|
| 153 |
+
self.assertEqual(
|
| 154 |
+
params['headers'].get('x-amz-api-version'), '2018-08-31'
|
| 155 |
+
)
|
| 156 |
+
|
| 157 |
+
def test_no_inject_api_version_if_not_endpoint_operation(self):
|
| 158 |
+
model = self.service_model.operation_model('TestDiscoveryRequired')
|
| 159 |
+
params = {'headers': {}}
|
| 160 |
+
inject_api_version_header_if_needed(model, params)
|
| 161 |
+
self.assertNotIn('x-amz-api-version', params['headers'])
|
| 162 |
+
|
| 163 |
+
def test_gather_identifiers(self):
|
| 164 |
+
params = {'Foo': 'value1', 'Nested': {'Bar': 'value2'}}
|
| 165 |
+
operation = self.service_model.operation_model('TestDiscoveryRequired')
|
| 166 |
+
ids = self.manager.gather_identifiers(operation, params)
|
| 167 |
+
self.assertEqual(ids, {'Foo': 'value1', 'Bar': 'value2'})
|
| 168 |
+
|
| 169 |
+
def test_gather_identifiers_none(self):
|
| 170 |
+
operation = self.service_model.operation_model('TestDiscovery')
|
| 171 |
+
ids = self.manager.gather_identifiers(operation, {})
|
| 172 |
+
self.assertEqual(ids, {})
|
| 173 |
+
|
| 174 |
+
def test_describe_endpoint(self):
|
| 175 |
+
kwargs = {
|
| 176 |
+
'Operation': 'FooBar',
|
| 177 |
+
'Identifiers': {'Foo': 'value1', 'Bar': 'value2'},
|
| 178 |
+
}
|
| 179 |
+
self.manager.describe_endpoint(**kwargs)
|
| 180 |
+
self.client.describe_endpoints.assert_called_with(**kwargs)
|
| 181 |
+
|
| 182 |
+
def test_describe_endpoint_no_input(self):
|
| 183 |
+
describe = self.service_description['operations']['DescribeEndpoints']
|
| 184 |
+
del describe['input']
|
| 185 |
+
self.construct_manager()
|
| 186 |
+
self.manager.describe_endpoint(Operation='FooBar', Identifiers={})
|
| 187 |
+
self.client.describe_endpoints.assert_called_with()
|
| 188 |
+
|
| 189 |
+
def test_describe_endpoint_empty_input(self):
|
| 190 |
+
describe = self.service_description['operations']['DescribeEndpoints']
|
| 191 |
+
describe['input'] = {'shape': 'EmptyStruct'}
|
| 192 |
+
self.construct_manager()
|
| 193 |
+
self.manager.describe_endpoint(Operation='FooBar', Identifiers={})
|
| 194 |
+
self.client.describe_endpoints.assert_called_with()
|
| 195 |
+
|
| 196 |
+
def test_describe_endpoint_ids_and_operation(self):
|
| 197 |
+
cache = {}
|
| 198 |
+
self.construct_manager(cache=cache)
|
| 199 |
+
ids = {'Foo': 'value1', 'Bar': 'value2'}
|
| 200 |
+
kwargs = {
|
| 201 |
+
'Operation': 'TestDiscoveryRequired',
|
| 202 |
+
'Identifiers': ids,
|
| 203 |
+
}
|
| 204 |
+
self.manager.describe_endpoint(**kwargs)
|
| 205 |
+
self.client.describe_endpoints.assert_called_with(**kwargs)
|
| 206 |
+
key = ((('Bar', 'value2'), ('Foo', 'value1')), 'TestDiscoveryRequired')
|
| 207 |
+
self.assertIn(key, cache)
|
| 208 |
+
self.assertEqual(cache[key][0]['Address'], 'new.com')
|
| 209 |
+
self.manager.describe_endpoint(**kwargs)
|
| 210 |
+
call_count = self.client.describe_endpoints.call_count
|
| 211 |
+
self.assertEqual(call_count, 1)
|
| 212 |
+
|
| 213 |
+
def test_describe_endpoint_no_ids_or_operation(self):
|
| 214 |
+
cache = {}
|
| 215 |
+
describe = self.service_description['operations']['DescribeEndpoints']
|
| 216 |
+
describe['input'] = {'shape': 'EmptyStruct'}
|
| 217 |
+
self.construct_manager(cache=cache)
|
| 218 |
+
self.manager.describe_endpoint(
|
| 219 |
+
Operation='TestDiscoveryRequired', Identifiers={}
|
| 220 |
+
)
|
| 221 |
+
self.client.describe_endpoints.assert_called_with()
|
| 222 |
+
key = ()
|
| 223 |
+
self.assertIn(key, cache)
|
| 224 |
+
self.assertEqual(cache[key][0]['Address'], 'new.com')
|
| 225 |
+
self.manager.describe_endpoint(
|
| 226 |
+
Operation='TestDiscoveryRequired', Identifiers={}
|
| 227 |
+
)
|
| 228 |
+
call_count = self.client.describe_endpoints.call_count
|
| 229 |
+
self.assertEqual(call_count, 1)
|
| 230 |
+
|
| 231 |
+
def test_describe_endpoint_expired_entry(self):
|
| 232 |
+
current_time = time.time()
|
| 233 |
+
key = ()
|
| 234 |
+
cache = {
|
| 235 |
+
key: [{'Address': 'old.com', 'Expiration': current_time - 10}]
|
| 236 |
+
}
|
| 237 |
+
self.construct_manager(cache=cache)
|
| 238 |
+
kwargs = {
|
| 239 |
+
'Identifiers': {},
|
| 240 |
+
'Operation': 'TestDiscoveryRequired',
|
| 241 |
+
}
|
| 242 |
+
self.manager.describe_endpoint(**kwargs)
|
| 243 |
+
self.client.describe_endpoints.assert_called_with()
|
| 244 |
+
self.assertIn(key, cache)
|
| 245 |
+
self.assertEqual(cache[key][0]['Address'], 'new.com')
|
| 246 |
+
self.manager.describe_endpoint(**kwargs)
|
| 247 |
+
call_count = self.client.describe_endpoints.call_count
|
| 248 |
+
self.assertEqual(call_count, 1)
|
| 249 |
+
|
| 250 |
+
def test_describe_endpoint_cache_expiration(self):
|
| 251 |
+
def _time():
|
| 252 |
+
return float(0)
|
| 253 |
+
|
| 254 |
+
cache = {}
|
| 255 |
+
self.construct_manager(cache=cache, time=_time)
|
| 256 |
+
self.manager.describe_endpoint(
|
| 257 |
+
Operation='TestDiscoveryRequired', Identifiers={}
|
| 258 |
+
)
|
| 259 |
+
key = ()
|
| 260 |
+
self.assertIn(key, cache)
|
| 261 |
+
self.assertEqual(cache[key][0]['Expiration'], float(120))
|
| 262 |
+
|
| 263 |
+
def test_delete_endpoints_present(self):
|
| 264 |
+
key = ()
|
| 265 |
+
cache = {key: [{'Address': 'old.com', 'Expiration': 0}]}
|
| 266 |
+
self.construct_manager(cache=cache)
|
| 267 |
+
kwargs = {
|
| 268 |
+
'Identifiers': {},
|
| 269 |
+
'Operation': 'TestDiscoveryRequired',
|
| 270 |
+
}
|
| 271 |
+
self.manager.delete_endpoints(**kwargs)
|
| 272 |
+
self.assertEqual(cache, {})
|
| 273 |
+
|
| 274 |
+
def test_delete_endpoints_absent(self):
|
| 275 |
+
cache = {}
|
| 276 |
+
self.construct_manager(cache=cache)
|
| 277 |
+
kwargs = {
|
| 278 |
+
'Identifiers': {},
|
| 279 |
+
'Operation': 'TestDiscoveryRequired',
|
| 280 |
+
}
|
| 281 |
+
self.manager.delete_endpoints(**kwargs)
|
| 282 |
+
self.assertEqual(cache, {})
|
| 283 |
+
|
| 284 |
+
def test_describe_endpoint_optional_fails_no_cache(self):
|
| 285 |
+
side_effect = [ConnectionError(error=None)]
|
| 286 |
+
self.construct_manager(side_effect=side_effect)
|
| 287 |
+
kwargs = {'Operation': 'TestDiscoveryOptional'}
|
| 288 |
+
endpoint = self.manager.describe_endpoint(**kwargs)
|
| 289 |
+
self.assertIsNone(endpoint)
|
| 290 |
+
# This second call should be blocked as we just failed
|
| 291 |
+
endpoint = self.manager.describe_endpoint(**kwargs)
|
| 292 |
+
self.assertIsNone(endpoint)
|
| 293 |
+
self.client.describe_endpoints.call_args_list == [mock.call()]
|
| 294 |
+
|
| 295 |
+
def test_describe_endpoint_optional_fails_stale_cache(self):
|
| 296 |
+
key = ()
|
| 297 |
+
cache = {key: [{'Address': 'old.com', 'Expiration': 0}]}
|
| 298 |
+
side_effect = [ConnectionError(error=None)] * 2
|
| 299 |
+
self.construct_manager(cache=cache, side_effect=side_effect)
|
| 300 |
+
kwargs = {'Operation': 'TestDiscoveryOptional'}
|
| 301 |
+
endpoint = self.manager.describe_endpoint(**kwargs)
|
| 302 |
+
self.assertEqual(endpoint, 'old.com')
|
| 303 |
+
# This second call shouldn't go through as we just failed
|
| 304 |
+
endpoint = self.manager.describe_endpoint(**kwargs)
|
| 305 |
+
self.assertEqual(endpoint, 'old.com')
|
| 306 |
+
self.client.describe_endpoints.call_args_list == [mock.call()]
|
| 307 |
+
|
| 308 |
+
def test_describe_endpoint_required_fails_no_cache(self):
|
| 309 |
+
side_effect = [ConnectionError(error=None)] * 2
|
| 310 |
+
self.construct_manager(side_effect=side_effect)
|
| 311 |
+
kwargs = {'Operation': 'TestDiscoveryRequired'}
|
| 312 |
+
with self.assertRaises(EndpointDiscoveryRefreshFailed):
|
| 313 |
+
self.manager.describe_endpoint(**kwargs)
|
| 314 |
+
# This second call should go through, as we have no cache
|
| 315 |
+
with self.assertRaises(EndpointDiscoveryRefreshFailed):
|
| 316 |
+
self.manager.describe_endpoint(**kwargs)
|
| 317 |
+
describe_count = self.client.describe_endpoints.call_count
|
| 318 |
+
self.assertEqual(describe_count, 2)
|
| 319 |
+
|
| 320 |
+
def test_describe_endpoint_required_fails_stale_cache(self):
|
| 321 |
+
key = ()
|
| 322 |
+
cache = {key: [{'Address': 'old.com', 'Expiration': 0}]}
|
| 323 |
+
side_effect = [ConnectionError(error=None)] * 2
|
| 324 |
+
self.construct_manager(cache=cache, side_effect=side_effect)
|
| 325 |
+
kwargs = {'Operation': 'TestDiscoveryRequired'}
|
| 326 |
+
endpoint = self.manager.describe_endpoint(**kwargs)
|
| 327 |
+
self.assertEqual(endpoint, 'old.com')
|
| 328 |
+
# We have a stale endpoint, so this shouldn't fail or force a refresh
|
| 329 |
+
endpoint = self.manager.describe_endpoint(**kwargs)
|
| 330 |
+
self.assertEqual(endpoint, 'old.com')
|
| 331 |
+
self.client.describe_endpoints.call_args_list == [mock.call()]
|
| 332 |
+
|
| 333 |
+
def test_describe_endpoint_required_force_refresh_success(self):
|
| 334 |
+
side_effect = [
|
| 335 |
+
ConnectionError(error=None),
|
| 336 |
+
{
|
| 337 |
+
'Endpoints': [
|
| 338 |
+
{
|
| 339 |
+
'Address': 'new.com',
|
| 340 |
+
'CachePeriodInMinutes': 2,
|
| 341 |
+
}
|
| 342 |
+
]
|
| 343 |
+
},
|
| 344 |
+
]
|
| 345 |
+
self.construct_manager(side_effect=side_effect)
|
| 346 |
+
kwargs = {'Operation': 'TestDiscoveryRequired'}
|
| 347 |
+
# First call will fail
|
| 348 |
+
with self.assertRaises(EndpointDiscoveryRefreshFailed):
|
| 349 |
+
self.manager.describe_endpoint(**kwargs)
|
| 350 |
+
self.client.describe_endpoints.call_args_list == [mock.call()]
|
| 351 |
+
# Force a refresh if the cache is empty but discovery is required
|
| 352 |
+
endpoint = self.manager.describe_endpoint(**kwargs)
|
| 353 |
+
self.assertEqual(endpoint, 'new.com')
|
| 354 |
+
|
| 355 |
+
def test_describe_endpoint_retries_after_failing(self):
|
| 356 |
+
fake_time = mock.Mock()
|
| 357 |
+
fake_time.side_effect = [0, 100, 200]
|
| 358 |
+
side_effect = [
|
| 359 |
+
ConnectionError(error=None),
|
| 360 |
+
{
|
| 361 |
+
'Endpoints': [
|
| 362 |
+
{
|
| 363 |
+
'Address': 'new.com',
|
| 364 |
+
'CachePeriodInMinutes': 2,
|
| 365 |
+
}
|
| 366 |
+
]
|
| 367 |
+
},
|
| 368 |
+
]
|
| 369 |
+
self.construct_manager(side_effect=side_effect, time=fake_time)
|
| 370 |
+
kwargs = {'Operation': 'TestDiscoveryOptional'}
|
| 371 |
+
endpoint = self.manager.describe_endpoint(**kwargs)
|
| 372 |
+
self.assertIsNone(endpoint)
|
| 373 |
+
self.client.describe_endpoints.call_args_list == [mock.call()]
|
| 374 |
+
# Second time should try again as enough time has elapsed
|
| 375 |
+
endpoint = self.manager.describe_endpoint(**kwargs)
|
| 376 |
+
self.assertEqual(endpoint, 'new.com')
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
class TestEndpointDiscoveryHandler(BaseEndpointDiscoveryTest):
|
| 380 |
+
def setUp(self):
|
| 381 |
+
super().setUp()
|
| 382 |
+
self.manager = mock.Mock(spec=EndpointDiscoveryManager)
|
| 383 |
+
self.handler = EndpointDiscoveryHandler(self.manager)
|
| 384 |
+
self.service_model = ServiceModel(self.service_description)
|
| 385 |
+
|
| 386 |
+
def test_register_handler(self):
|
| 387 |
+
events = mock.Mock(spec=HierarchicalEmitter)
|
| 388 |
+
self.handler.register(events, 'foo-bar')
|
| 389 |
+
events.register.assert_any_call(
|
| 390 |
+
'before-parameter-build.foo-bar', self.handler.gather_identifiers
|
| 391 |
+
)
|
| 392 |
+
events.register.assert_any_call(
|
| 393 |
+
'needs-retry.foo-bar', self.handler.handle_retries
|
| 394 |
+
)
|
| 395 |
+
events.register_first.assert_called_with(
|
| 396 |
+
'request-created.foo-bar', self.handler.discover_endpoint
|
| 397 |
+
)
|
| 398 |
+
|
| 399 |
+
def test_discover_endpoint(self):
|
| 400 |
+
request = AWSRequest()
|
| 401 |
+
request.context = {'discovery': {'identifiers': {}}}
|
| 402 |
+
self.manager.describe_endpoint.return_value = 'https://new.foo'
|
| 403 |
+
self.handler.discover_endpoint(request, 'TestOperation')
|
| 404 |
+
self.assertEqual(request.url, 'https://new.foo')
|
| 405 |
+
self.manager.describe_endpoint.assert_called_with(
|
| 406 |
+
Operation='TestOperation', Identifiers={}
|
| 407 |
+
)
|
| 408 |
+
|
| 409 |
+
def test_discover_endpoint_fails(self):
|
| 410 |
+
request = AWSRequest()
|
| 411 |
+
request.context = {'discovery': {'identifiers': {}}}
|
| 412 |
+
request.url = 'old.com'
|
| 413 |
+
self.manager.describe_endpoint.return_value = None
|
| 414 |
+
self.handler.discover_endpoint(request, 'TestOperation')
|
| 415 |
+
self.assertEqual(request.url, 'old.com')
|
| 416 |
+
self.manager.describe_endpoint.assert_called_with(
|
| 417 |
+
Operation='TestOperation', Identifiers={}
|
| 418 |
+
)
|
| 419 |
+
|
| 420 |
+
def test_discover_endpoint_no_protocol(self):
|
| 421 |
+
request = AWSRequest()
|
| 422 |
+
request.context = {'discovery': {'identifiers': {}}}
|
| 423 |
+
self.manager.describe_endpoint.return_value = 'new.foo'
|
| 424 |
+
self.handler.discover_endpoint(request, 'TestOperation')
|
| 425 |
+
self.assertEqual(request.url, 'https://new.foo')
|
| 426 |
+
self.manager.describe_endpoint.assert_called_with(
|
| 427 |
+
Operation='TestOperation', Identifiers={}
|
| 428 |
+
)
|
| 429 |
+
|
| 430 |
+
def test_inject_no_context(self):
|
| 431 |
+
request = AWSRequest(url='https://original.foo')
|
| 432 |
+
self.handler.discover_endpoint(request, 'TestOperation')
|
| 433 |
+
self.assertEqual(request.url, 'https://original.foo')
|
| 434 |
+
self.manager.describe_endpoint.assert_not_called()
|
| 435 |
+
|
| 436 |
+
def test_gather_identifiers(self):
|
| 437 |
+
context = {}
|
| 438 |
+
params = {'Foo': 'value1', 'Nested': {'Bar': 'value2'}}
|
| 439 |
+
ids = {'Foo': 'value1', 'Bar': 'value2'}
|
| 440 |
+
model = self.service_model.operation_model('TestDiscoveryRequired')
|
| 441 |
+
self.manager.gather_identifiers.return_value = ids
|
| 442 |
+
self.handler.gather_identifiers(params, model, context)
|
| 443 |
+
self.assertEqual(context['discovery']['identifiers'], ids)
|
| 444 |
+
|
| 445 |
+
def test_gather_identifiers_not_discoverable(self):
|
| 446 |
+
context = {}
|
| 447 |
+
model = self.service_model.operation_model('DescribeEndpoints')
|
| 448 |
+
self.handler.gather_identifiers({}, model, context)
|
| 449 |
+
self.assertEqual(context, {})
|
| 450 |
+
|
| 451 |
+
def test_discovery_disabled_but_required(self):
|
| 452 |
+
model = self.service_model.operation_model('TestDiscoveryRequired')
|
| 453 |
+
with self.assertRaises(EndpointDiscoveryRequired):
|
| 454 |
+
block_endpoint_discovery_required_operations(model)
|
| 455 |
+
|
| 456 |
+
def test_discovery_disabled_but_optional(self):
|
| 457 |
+
context = {}
|
| 458 |
+
model = self.service_model.operation_model('TestDiscoveryOptional')
|
| 459 |
+
block_endpoint_discovery_required_operations(model, context=context)
|
| 460 |
+
self.assertEqual(context, {})
|
| 461 |
+
|
| 462 |
+
def test_does_not_retry_no_response(self):
|
| 463 |
+
retry = self.handler.handle_retries(None, None, None)
|
| 464 |
+
self.assertIsNone(retry)
|
| 465 |
+
|
| 466 |
+
def test_does_not_retry_other_errors(self):
|
| 467 |
+
parsed_response = {'ResponseMetadata': {'HTTPStatusCode': 200}}
|
| 468 |
+
response = (None, parsed_response)
|
| 469 |
+
retry = self.handler.handle_retries(None, response, None)
|
| 470 |
+
self.assertIsNone(retry)
|
| 471 |
+
|
| 472 |
+
def test_does_not_retry_if_no_context(self):
|
| 473 |
+
request_dict = {'context': {}}
|
| 474 |
+
parsed_response = {'ResponseMetadata': {'HTTPStatusCode': 421}}
|
| 475 |
+
response = (None, parsed_response)
|
| 476 |
+
retry = self.handler.handle_retries(request_dict, response, None)
|
| 477 |
+
self.assertIsNone(retry)
|
| 478 |
+
|
| 479 |
+
def _assert_retries(self, parsed_response):
|
| 480 |
+
request_dict = {'context': {'discovery': {'identifiers': {}}}}
|
| 481 |
+
response = (None, parsed_response)
|
| 482 |
+
model = self.service_model.operation_model('TestDiscoveryOptional')
|
| 483 |
+
retry = self.handler.handle_retries(request_dict, response, model)
|
| 484 |
+
self.assertEqual(retry, 0)
|
| 485 |
+
self.manager.delete_endpoints.assert_called_with(
|
| 486 |
+
Operation='TestDiscoveryOptional', Identifiers={}
|
| 487 |
+
)
|
| 488 |
+
|
| 489 |
+
def test_retries_421_status_code(self):
|
| 490 |
+
parsed_response = {'ResponseMetadata': {'HTTPStatusCode': 421}}
|
| 491 |
+
self._assert_retries(parsed_response)
|
| 492 |
+
|
| 493 |
+
def test_retries_invalid_endpoint_exception(self):
|
| 494 |
+
parsed_response = {'Error': {'Code': 'InvalidEndpointException'}}
|
| 495 |
+
self._assert_retries(parsed_response)
|
testbed/boto__botocore/tests/unit/test_endpoint.py
ADDED
|
@@ -0,0 +1,490 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 4 |
+
# may not use this file except in compliance with the License. A copy of
|
| 5 |
+
# the License is located at
|
| 6 |
+
#
|
| 7 |
+
# http://aws.amazon.com/apache2.0/
|
| 8 |
+
#
|
| 9 |
+
# or in the "license" file accompanying this file. This file is
|
| 10 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 11 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 12 |
+
# language governing permissions and limitations under the License.
|
| 13 |
+
import datetime
|
| 14 |
+
import io
|
| 15 |
+
import socket
|
| 16 |
+
|
| 17 |
+
import pytest
|
| 18 |
+
|
| 19 |
+
import botocore.endpoint
|
| 20 |
+
from botocore.config import Config
|
| 21 |
+
from botocore.endpoint import DEFAULT_TIMEOUT, Endpoint, EndpointCreator
|
| 22 |
+
from botocore.exceptions import HTTPClientError
|
| 23 |
+
from botocore.httpsession import URLLib3Session
|
| 24 |
+
from botocore.model import (
|
| 25 |
+
OperationModel,
|
| 26 |
+
ServiceId,
|
| 27 |
+
ServiceModel,
|
| 28 |
+
StructureShape,
|
| 29 |
+
)
|
| 30 |
+
from tests import mock, unittest
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def request_dict(**kwargs):
|
| 34 |
+
base = {
|
| 35 |
+
'headers': {},
|
| 36 |
+
'body': '',
|
| 37 |
+
'url_path': '/',
|
| 38 |
+
'query_string': '',
|
| 39 |
+
'method': 'POST',
|
| 40 |
+
'url': 'https://example.com',
|
| 41 |
+
'context': {},
|
| 42 |
+
}
|
| 43 |
+
base.update(kwargs)
|
| 44 |
+
return base
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
class RecordStreamResets(io.StringIO):
|
| 48 |
+
def __init__(self, value):
|
| 49 |
+
io.StringIO.__init__(self, value)
|
| 50 |
+
self.total_resets = 0
|
| 51 |
+
|
| 52 |
+
def seek(self, where, whence=0):
|
| 53 |
+
self.total_resets += 1
|
| 54 |
+
io.StringIO.seek(self, where, whence)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class TestEndpointBase(unittest.TestCase):
|
| 58 |
+
def setUp(self):
|
| 59 |
+
self.op = mock.Mock()
|
| 60 |
+
self.op.has_streaming_output = False
|
| 61 |
+
self.op.has_event_stream_output = False
|
| 62 |
+
self.op.metadata = {'protocol': 'json'}
|
| 63 |
+
self.event_emitter = mock.Mock()
|
| 64 |
+
self.event_emitter.emit.return_value = []
|
| 65 |
+
self.factory_patch = mock.patch(
|
| 66 |
+
'botocore.parsers.ResponseParserFactory'
|
| 67 |
+
)
|
| 68 |
+
self.factory = self.factory_patch.start()
|
| 69 |
+
self.endpoint = Endpoint(
|
| 70 |
+
'https://ec2.us-west-2.amazonaws.com/',
|
| 71 |
+
endpoint_prefix='ec2',
|
| 72 |
+
event_emitter=self.event_emitter,
|
| 73 |
+
)
|
| 74 |
+
self.http_session = mock.Mock()
|
| 75 |
+
self.http_session.send.return_value = mock.Mock(
|
| 76 |
+
status_code=200,
|
| 77 |
+
headers={},
|
| 78 |
+
content=b'{"Foo": "bar"}',
|
| 79 |
+
)
|
| 80 |
+
self.endpoint.http_session = self.http_session
|
| 81 |
+
|
| 82 |
+
def tearDown(self):
|
| 83 |
+
self.factory_patch.stop()
|
| 84 |
+
|
| 85 |
+
def get_emitter_responses(self, num_retries=0, sleep_time=0, num_events=4):
|
| 86 |
+
emitter_responses = []
|
| 87 |
+
# We emit the following events:
|
| 88 |
+
# 1. request-created
|
| 89 |
+
# 2. before-send
|
| 90 |
+
# 3. before-parse (may not be emitted if certain errors are thrown)
|
| 91 |
+
# 4. response-received
|
| 92 |
+
response_request_emitter_responses = [
|
| 93 |
+
[(None, None)] # emit() response for each emitted event
|
| 94 |
+
] * num_events
|
| 95 |
+
for _ in range(num_retries):
|
| 96 |
+
emitter_responses.extend(response_request_emitter_responses)
|
| 97 |
+
# emit() response for retry for sleep time
|
| 98 |
+
emitter_responses.append([(None, sleep_time)])
|
| 99 |
+
emitter_responses.extend(response_request_emitter_responses)
|
| 100 |
+
# emit() response for no retry
|
| 101 |
+
emitter_responses.append([(None, None)])
|
| 102 |
+
return emitter_responses
|
| 103 |
+
|
| 104 |
+
def get_events_emitted(self, event_emitter):
|
| 105 |
+
return [
|
| 106 |
+
call_arg[0][0] for call_arg in event_emitter.emit.call_args_list
|
| 107 |
+
]
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
class TestEndpointFeatures(TestEndpointBase):
|
| 111 |
+
def test_make_request_with_no_auth(self):
|
| 112 |
+
self.endpoint.auth = None
|
| 113 |
+
self.endpoint.make_request(self.op, request_dict())
|
| 114 |
+
|
| 115 |
+
# http_session should be used to send the request.
|
| 116 |
+
self.assertTrue(self.http_session.send.called)
|
| 117 |
+
prepared_request = self.http_session.send.call_args[0][0]
|
| 118 |
+
self.assertNotIn('Authorization', prepared_request.headers)
|
| 119 |
+
|
| 120 |
+
def test_make_request_no_signature_version(self):
|
| 121 |
+
self.endpoint.make_request(self.op, request_dict())
|
| 122 |
+
|
| 123 |
+
# http_session should be used to send the request.
|
| 124 |
+
self.assertTrue(self.http_session.send.called)
|
| 125 |
+
prepared_request = self.http_session.send.call_args[0][0]
|
| 126 |
+
self.assertNotIn('Authorization', prepared_request.headers)
|
| 127 |
+
|
| 128 |
+
def test_make_request_with_context(self):
|
| 129 |
+
r = request_dict()
|
| 130 |
+
r['context'] = {'signing': {'region': 'us-west-2'}}
|
| 131 |
+
with mock.patch(
|
| 132 |
+
'botocore.endpoint.Endpoint.prepare_request'
|
| 133 |
+
) as prepare:
|
| 134 |
+
self.endpoint.make_request(self.op, r)
|
| 135 |
+
request = prepare.call_args[0][0]
|
| 136 |
+
self.assertEqual(request.context['signing']['region'], 'us-west-2')
|
| 137 |
+
|
| 138 |
+
def test_make_request_sets_retries_config_in_context(self):
|
| 139 |
+
r = request_dict()
|
| 140 |
+
r['context'] = {'signing': {'region': 'us-west-2'}}
|
| 141 |
+
with mock.patch(
|
| 142 |
+
'botocore.endpoint.Endpoint.prepare_request'
|
| 143 |
+
) as prepare:
|
| 144 |
+
self.endpoint.make_request(self.op, r)
|
| 145 |
+
request = prepare.call_args[0][0]
|
| 146 |
+
self.assertIn('retries', request.context)
|
| 147 |
+
|
| 148 |
+
def test_exception_caught_when_constructing_retries_context(self):
|
| 149 |
+
r = request_dict()
|
| 150 |
+
datetime_patcher = mock.patch.object(
|
| 151 |
+
botocore.endpoint.datetime,
|
| 152 |
+
'datetime',
|
| 153 |
+
mock.Mock(wraps=datetime.datetime),
|
| 154 |
+
)
|
| 155 |
+
r['context'] = {'signing': {'region': 'us-west-2'}}
|
| 156 |
+
with mock.patch(
|
| 157 |
+
'botocore.endpoint.Endpoint.prepare_request'
|
| 158 |
+
) as prepare:
|
| 159 |
+
mocked_datetime = datetime_patcher.start()
|
| 160 |
+
mocked_datetime.side_effect = Exception()
|
| 161 |
+
self.endpoint.make_request(self.op, r)
|
| 162 |
+
datetime_patcher.stop()
|
| 163 |
+
request = prepare.call_args[0][0]
|
| 164 |
+
self.assertIn('retries', request.context)
|
| 165 |
+
|
| 166 |
+
def test_parses_modeled_exception_fields(self):
|
| 167 |
+
# Setup the service model to have exceptions to generate the mapping
|
| 168 |
+
self.service_model = mock.Mock(spec=ServiceModel)
|
| 169 |
+
self.op.service_model = self.service_model
|
| 170 |
+
self.exception_shape = mock.Mock(spec=StructureShape)
|
| 171 |
+
shape_for_error_code = self.service_model.shape_for_error_code
|
| 172 |
+
shape_for_error_code.return_value = self.exception_shape
|
| 173 |
+
|
| 174 |
+
r = request_dict()
|
| 175 |
+
self.http_session.send.return_value = mock.Mock(
|
| 176 |
+
status_code=400,
|
| 177 |
+
headers={},
|
| 178 |
+
content=b'',
|
| 179 |
+
)
|
| 180 |
+
parser = mock.Mock()
|
| 181 |
+
parser.parse.side_effect = [
|
| 182 |
+
{
|
| 183 |
+
'Error': {
|
| 184 |
+
'Code': 'ExceptionShape',
|
| 185 |
+
'Message': 'Some message',
|
| 186 |
+
}
|
| 187 |
+
},
|
| 188 |
+
{'SomeField': 'Foo'},
|
| 189 |
+
]
|
| 190 |
+
self.factory.return_value.create_parser.return_value = parser
|
| 191 |
+
_, response = self.endpoint.make_request(self.op, r)
|
| 192 |
+
# The parser should be called twice, once for the original
|
| 193 |
+
# error parse and once again for the modeled exception parse
|
| 194 |
+
self.assertEqual(parser.parse.call_count, 2)
|
| 195 |
+
parse_calls = parser.parse.call_args_list
|
| 196 |
+
self.assertEqual(parse_calls[1][0][1], self.exception_shape)
|
| 197 |
+
self.assertEqual(parse_calls[0][0][1], self.op.output_shape)
|
| 198 |
+
expected_response = {
|
| 199 |
+
'Error': {
|
| 200 |
+
'Code': 'ExceptionShape',
|
| 201 |
+
'Message': 'Some message',
|
| 202 |
+
},
|
| 203 |
+
'SomeField': 'Foo',
|
| 204 |
+
}
|
| 205 |
+
self.assertEqual(response, expected_response)
|
| 206 |
+
|
| 207 |
+
def test_close(self):
|
| 208 |
+
self.endpoint.close()
|
| 209 |
+
self.endpoint.http_session.close.assert_called_once_with()
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
class TestRetryInterface(TestEndpointBase):
|
| 213 |
+
def setUp(self):
|
| 214 |
+
super().setUp()
|
| 215 |
+
self.retried_on_exception = None
|
| 216 |
+
self._operation = mock.Mock(spec=OperationModel)
|
| 217 |
+
self._operation.name = 'DescribeInstances'
|
| 218 |
+
self._operation.metadata = {'protocol': 'query'}
|
| 219 |
+
self._operation.service_model.service_id = ServiceId('EC2')
|
| 220 |
+
self._operation.has_streaming_output = False
|
| 221 |
+
self._operation.has_event_stream_output = False
|
| 222 |
+
|
| 223 |
+
def assert_events_emitted(self, event_emitter, expected_events):
|
| 224 |
+
self.assertEqual(
|
| 225 |
+
self.get_events_emitted(event_emitter), expected_events
|
| 226 |
+
)
|
| 227 |
+
|
| 228 |
+
def test_retry_events_are_emitted(self):
|
| 229 |
+
self.endpoint.make_request(self._operation, request_dict())
|
| 230 |
+
call_args = self.event_emitter.emit.call_args
|
| 231 |
+
self.assertEqual(call_args[0][0], 'needs-retry.ec2.DescribeInstances')
|
| 232 |
+
|
| 233 |
+
def test_retry_events_can_alter_behavior(self):
|
| 234 |
+
self.event_emitter.emit.side_effect = self.get_emitter_responses(
|
| 235 |
+
num_retries=1
|
| 236 |
+
)
|
| 237 |
+
r = request_dict()
|
| 238 |
+
r['context']['client_config'] = Config()
|
| 239 |
+
self.endpoint.make_request(self._operation, r)
|
| 240 |
+
self.assert_events_emitted(
|
| 241 |
+
self.event_emitter,
|
| 242 |
+
expected_events=[
|
| 243 |
+
'request-created.ec2.DescribeInstances',
|
| 244 |
+
'before-send.ec2.DescribeInstances',
|
| 245 |
+
'before-parse.ec2.DescribeInstances',
|
| 246 |
+
'response-received.ec2.DescribeInstances',
|
| 247 |
+
'needs-retry.ec2.DescribeInstances',
|
| 248 |
+
]
|
| 249 |
+
* 2,
|
| 250 |
+
)
|
| 251 |
+
|
| 252 |
+
def test_retry_on_socket_errors(self):
|
| 253 |
+
self.event_emitter.emit.side_effect = self.get_emitter_responses(
|
| 254 |
+
num_retries=1, num_events=3
|
| 255 |
+
)
|
| 256 |
+
self.http_session.send.side_effect = HTTPClientError(error='wrapped')
|
| 257 |
+
with self.assertRaises(HTTPClientError):
|
| 258 |
+
self.endpoint.make_request(self._operation, request_dict())
|
| 259 |
+
self.assert_events_emitted(
|
| 260 |
+
self.event_emitter,
|
| 261 |
+
expected_events=[
|
| 262 |
+
'request-created.ec2.DescribeInstances',
|
| 263 |
+
'before-send.ec2.DescribeInstances',
|
| 264 |
+
'response-received.ec2.DescribeInstances',
|
| 265 |
+
'needs-retry.ec2.DescribeInstances',
|
| 266 |
+
]
|
| 267 |
+
* 2,
|
| 268 |
+
)
|
| 269 |
+
|
| 270 |
+
def test_retry_attempts_added_to_response_metadata(self):
|
| 271 |
+
self.event_emitter.emit.side_effect = self.get_emitter_responses(
|
| 272 |
+
num_retries=1
|
| 273 |
+
)
|
| 274 |
+
parser = mock.Mock()
|
| 275 |
+
parser.parse.return_value = {'ResponseMetadata': {}}
|
| 276 |
+
self.factory.return_value.create_parser.return_value = parser
|
| 277 |
+
r = request_dict()
|
| 278 |
+
r['context']['client_config'] = Config()
|
| 279 |
+
response = self.endpoint.make_request(self._operation, r)
|
| 280 |
+
self.assertEqual(response[1]['ResponseMetadata']['RetryAttempts'], 1)
|
| 281 |
+
|
| 282 |
+
def test_retry_attempts_is_zero_when_not_retried(self):
|
| 283 |
+
self.event_emitter.emit.side_effect = self.get_emitter_responses(
|
| 284 |
+
num_retries=0
|
| 285 |
+
)
|
| 286 |
+
parser = mock.Mock()
|
| 287 |
+
parser.parse.return_value = {'ResponseMetadata': {}}
|
| 288 |
+
self.factory.return_value.create_parser.return_value = parser
|
| 289 |
+
response = self.endpoint.make_request(self._operation, request_dict())
|
| 290 |
+
self.assertEqual(response[1]['ResponseMetadata']['RetryAttempts'], 0)
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
class TestS3ResetStreamOnRetry(TestEndpointBase):
|
| 294 |
+
def setUp(self):
|
| 295 |
+
super().setUp()
|
| 296 |
+
|
| 297 |
+
def max_attempts_retry_handler(self, attempts, **kwargs):
|
| 298 |
+
# Simulate a max requests of 3.
|
| 299 |
+
self.total_calls += 1
|
| 300 |
+
if attempts == 3:
|
| 301 |
+
return None
|
| 302 |
+
else:
|
| 303 |
+
# Returning anything non-None will trigger a retry,
|
| 304 |
+
# but 0 here is so that time.sleep(0) happens.
|
| 305 |
+
return 0
|
| 306 |
+
|
| 307 |
+
def test_reset_stream_on_retry(self):
|
| 308 |
+
op = mock.Mock()
|
| 309 |
+
body = RecordStreamResets('foobar')
|
| 310 |
+
op.name = 'PutObject'
|
| 311 |
+
op.has_streaming_output = True
|
| 312 |
+
op.has_event_stream_output = False
|
| 313 |
+
op.metadata = {'protocol': 'rest-xml'}
|
| 314 |
+
request = request_dict()
|
| 315 |
+
request['body'] = body
|
| 316 |
+
request['context']['client_config'] = Config()
|
| 317 |
+
self.event_emitter.emit.side_effect = self.get_emitter_responses(
|
| 318 |
+
num_retries=2
|
| 319 |
+
)
|
| 320 |
+
self.endpoint.make_request(op, request)
|
| 321 |
+
# 2 seeks for the resets and 6 (2 per creation) for content-length
|
| 322 |
+
self.assertEqual(body.total_resets, 8)
|
| 323 |
+
|
| 324 |
+
|
| 325 |
+
class TestEventStreamBody(TestEndpointBase):
|
| 326 |
+
def test_event_stream_body_is_streaming(self):
|
| 327 |
+
self.op.has_event_stream_output = True
|
| 328 |
+
request = request_dict()
|
| 329 |
+
self.endpoint.make_request(self.op, request)
|
| 330 |
+
sent_request = self.http_session.send.call_args[0][0]
|
| 331 |
+
self.assertTrue(sent_request.stream_output)
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
class TestEndpointCreator(unittest.TestCase):
|
| 335 |
+
def setUp(self):
|
| 336 |
+
self.service_model = mock.Mock(
|
| 337 |
+
endpoint_prefix='ec2', signature_version='v2', signing_name='ec2'
|
| 338 |
+
)
|
| 339 |
+
self.environ = {}
|
| 340 |
+
self.environ_patch = mock.patch('os.environ', self.environ)
|
| 341 |
+
self.environ_patch.start()
|
| 342 |
+
self.creator = EndpointCreator(mock.Mock())
|
| 343 |
+
self.mock_session = mock.Mock(spec=URLLib3Session)
|
| 344 |
+
|
| 345 |
+
def tearDown(self):
|
| 346 |
+
self.environ_patch.stop()
|
| 347 |
+
|
| 348 |
+
def test_creates_endpoint_with_configured_url(self):
|
| 349 |
+
endpoint = self.creator.create_endpoint(
|
| 350 |
+
self.service_model,
|
| 351 |
+
region_name='us-east-1',
|
| 352 |
+
endpoint_url='https://endpoint.url',
|
| 353 |
+
)
|
| 354 |
+
self.assertEqual(endpoint.host, 'https://endpoint.url')
|
| 355 |
+
|
| 356 |
+
def test_creates_endpoint_with_ipv4_url(self):
|
| 357 |
+
endpoint = self.creator.create_endpoint(
|
| 358 |
+
self.service_model,
|
| 359 |
+
region_name='us-east-1',
|
| 360 |
+
endpoint_url='https://192.168.0.0',
|
| 361 |
+
)
|
| 362 |
+
self.assertEqual(endpoint.host, 'https://192.168.0.0')
|
| 363 |
+
|
| 364 |
+
def test_creates_endpoint_with_ipv6_url(self):
|
| 365 |
+
endpoint = self.creator.create_endpoint(
|
| 366 |
+
self.service_model,
|
| 367 |
+
region_name='us-east-1',
|
| 368 |
+
endpoint_url='https://[100:0:2::61]:7480',
|
| 369 |
+
)
|
| 370 |
+
self.assertEqual(endpoint.host, 'https://[100:0:2::61]:7480')
|
| 371 |
+
|
| 372 |
+
def test_raises_error_with_invalid_url(self):
|
| 373 |
+
with pytest.raises(ValueError):
|
| 374 |
+
self.creator.create_endpoint(
|
| 375 |
+
self.service_model,
|
| 376 |
+
region_name='us-east-1',
|
| 377 |
+
endpoint_url='https://*.aws.amazon.com/',
|
| 378 |
+
)
|
| 379 |
+
|
| 380 |
+
def test_create_endpoint_with_default_timeout(self):
|
| 381 |
+
self.creator.create_endpoint(
|
| 382 |
+
self.service_model,
|
| 383 |
+
region_name='us-west-2',
|
| 384 |
+
endpoint_url='https://example.com',
|
| 385 |
+
http_session_cls=self.mock_session,
|
| 386 |
+
)
|
| 387 |
+
session_args = self.mock_session.call_args[1]
|
| 388 |
+
self.assertEqual(session_args.get('timeout'), DEFAULT_TIMEOUT)
|
| 389 |
+
|
| 390 |
+
def test_create_endpoint_with_customized_timeout(self):
|
| 391 |
+
self.creator.create_endpoint(
|
| 392 |
+
self.service_model,
|
| 393 |
+
region_name='us-west-2',
|
| 394 |
+
endpoint_url='https://example.com',
|
| 395 |
+
timeout=123,
|
| 396 |
+
http_session_cls=self.mock_session,
|
| 397 |
+
)
|
| 398 |
+
session_args = self.mock_session.call_args[1]
|
| 399 |
+
self.assertEqual(session_args.get('timeout'), 123)
|
| 400 |
+
|
| 401 |
+
def test_get_endpoint_default_verify_ssl(self):
|
| 402 |
+
self.creator.create_endpoint(
|
| 403 |
+
self.service_model,
|
| 404 |
+
region_name='us-west-2',
|
| 405 |
+
endpoint_url='https://example.com',
|
| 406 |
+
http_session_cls=self.mock_session,
|
| 407 |
+
)
|
| 408 |
+
session_args = self.mock_session.call_args[1]
|
| 409 |
+
self.assertTrue(session_args.get('verify'))
|
| 410 |
+
|
| 411 |
+
def test_verify_ssl_can_be_disabled(self):
|
| 412 |
+
self.creator.create_endpoint(
|
| 413 |
+
self.service_model,
|
| 414 |
+
region_name='us-west-2',
|
| 415 |
+
endpoint_url='https://example.com',
|
| 416 |
+
verify=False,
|
| 417 |
+
http_session_cls=self.mock_session,
|
| 418 |
+
)
|
| 419 |
+
session_args = self.mock_session.call_args[1]
|
| 420 |
+
self.assertFalse(session_args.get('verify'))
|
| 421 |
+
|
| 422 |
+
def test_verify_ssl_can_specify_cert_bundle(self):
|
| 423 |
+
self.creator.create_endpoint(
|
| 424 |
+
self.service_model,
|
| 425 |
+
region_name='us-west-2',
|
| 426 |
+
endpoint_url='https://example.com',
|
| 427 |
+
verify='/path/cacerts.pem',
|
| 428 |
+
http_session_cls=self.mock_session,
|
| 429 |
+
)
|
| 430 |
+
session_args = self.mock_session.call_args[1]
|
| 431 |
+
self.assertEqual(session_args.get('verify'), '/path/cacerts.pem')
|
| 432 |
+
|
| 433 |
+
def test_client_cert_can_specify_path(self):
|
| 434 |
+
client_cert = '/some/path/cert'
|
| 435 |
+
self.creator.create_endpoint(
|
| 436 |
+
self.service_model,
|
| 437 |
+
region_name='us-west-2',
|
| 438 |
+
endpoint_url='https://example.com',
|
| 439 |
+
client_cert=client_cert,
|
| 440 |
+
http_session_cls=self.mock_session,
|
| 441 |
+
)
|
| 442 |
+
session_args = self.mock_session.call_args[1]
|
| 443 |
+
self.assertEqual(session_args.get('client_cert'), '/some/path/cert')
|
| 444 |
+
|
| 445 |
+
def test_honor_cert_bundle_env_var(self):
|
| 446 |
+
self.environ['REQUESTS_CA_BUNDLE'] = '/env/cacerts.pem'
|
| 447 |
+
self.creator.create_endpoint(
|
| 448 |
+
self.service_model,
|
| 449 |
+
region_name='us-west-2',
|
| 450 |
+
endpoint_url='https://example.com',
|
| 451 |
+
http_session_cls=self.mock_session,
|
| 452 |
+
)
|
| 453 |
+
session_args = self.mock_session.call_args[1]
|
| 454 |
+
self.assertEqual(session_args.get('verify'), '/env/cacerts.pem')
|
| 455 |
+
|
| 456 |
+
def test_env_ignored_if_explicitly_passed(self):
|
| 457 |
+
self.environ['REQUESTS_CA_BUNDLE'] = '/env/cacerts.pem'
|
| 458 |
+
self.creator.create_endpoint(
|
| 459 |
+
self.service_model,
|
| 460 |
+
region_name='us-west-2',
|
| 461 |
+
endpoint_url='https://example.com',
|
| 462 |
+
verify='/path/cacerts.pem',
|
| 463 |
+
http_session_cls=self.mock_session,
|
| 464 |
+
)
|
| 465 |
+
session_args = self.mock_session.call_args[1]
|
| 466 |
+
# /path/cacerts.pem wins over the value from the env var.
|
| 467 |
+
self.assertEqual(session_args.get('verify'), '/path/cacerts.pem')
|
| 468 |
+
|
| 469 |
+
def test_can_specify_max_pool_conns(self):
|
| 470 |
+
self.creator.create_endpoint(
|
| 471 |
+
self.service_model,
|
| 472 |
+
region_name='us-west-2',
|
| 473 |
+
endpoint_url='https://example.com',
|
| 474 |
+
max_pool_connections=100,
|
| 475 |
+
http_session_cls=self.mock_session,
|
| 476 |
+
)
|
| 477 |
+
session_args = self.mock_session.call_args[1]
|
| 478 |
+
self.assertEqual(session_args.get('max_pool_connections'), 100)
|
| 479 |
+
|
| 480 |
+
def test_socket_options(self):
|
| 481 |
+
socket_options = [(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)]
|
| 482 |
+
self.creator.create_endpoint(
|
| 483 |
+
self.service_model,
|
| 484 |
+
region_name='us-west-2',
|
| 485 |
+
endpoint_url='https://example.com',
|
| 486 |
+
http_session_cls=self.mock_session,
|
| 487 |
+
socket_options=socket_options,
|
| 488 |
+
)
|
| 489 |
+
session_args = self.mock_session.call_args[1]
|
| 490 |
+
self.assertEqual(session_args.get('socket_options'), socket_options)
|
testbed/boto__botocore/tests/unit/test_endpoint_provider.py
ADDED
|
@@ -0,0 +1,512 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2012-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 4 |
+
# may not use this file except in compliance with the License. A copy of
|
| 5 |
+
# the License is located at
|
| 6 |
+
#
|
| 7 |
+
# http://aws.amazon.com/apache2.0/
|
| 8 |
+
#
|
| 9 |
+
# or in the "license" file accompanying this file. This file is
|
| 10 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 11 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 12 |
+
# language governing permissions and limitations under the License.
|
| 13 |
+
|
| 14 |
+
import json
|
| 15 |
+
import logging
|
| 16 |
+
import os
|
| 17 |
+
from unittest.mock import Mock
|
| 18 |
+
|
| 19 |
+
import pytest
|
| 20 |
+
|
| 21 |
+
from botocore.endpoint_provider import (
|
| 22 |
+
EndpointProvider,
|
| 23 |
+
EndpointRule,
|
| 24 |
+
ErrorRule,
|
| 25 |
+
RuleCreator,
|
| 26 |
+
RuleSet,
|
| 27 |
+
RuleSetStandardLibrary,
|
| 28 |
+
TreeRule,
|
| 29 |
+
)
|
| 30 |
+
from botocore.exceptions import (
|
| 31 |
+
EndpointResolutionError,
|
| 32 |
+
MissingDependencyException,
|
| 33 |
+
UnknownSignatureVersionError,
|
| 34 |
+
)
|
| 35 |
+
from botocore.loaders import Loader
|
| 36 |
+
from botocore.regions import EndpointRulesetResolver
|
| 37 |
+
from tests import requires_crt
|
| 38 |
+
|
| 39 |
+
REGION_TEMPLATE = "{Region}"
|
| 40 |
+
REGION_REF = {"ref": "Region"}
|
| 41 |
+
BUCKET_ARN_REF = {"ref": "bucketArn"}
|
| 42 |
+
PARSE_ARN_FUNC = {
|
| 43 |
+
"fn": "aws.parseArn",
|
| 44 |
+
"argv": [{"ref": "Bucket"}],
|
| 45 |
+
"assign": "bucketArn",
|
| 46 |
+
}
|
| 47 |
+
STRING_EQUALS_FUNC = {
|
| 48 |
+
"fn": "stringEquals",
|
| 49 |
+
"argv": [
|
| 50 |
+
{
|
| 51 |
+
"fn": "getAttr",
|
| 52 |
+
"argv": [BUCKET_ARN_REF, "region"],
|
| 53 |
+
"assign": "bucketRegion",
|
| 54 |
+
},
|
| 55 |
+
"",
|
| 56 |
+
],
|
| 57 |
+
}
|
| 58 |
+
DNS_SUFFIX_TEMPLATE = "{PartitionResults#dnsSuffix}"
|
| 59 |
+
URL_TEMPLATE = (
|
| 60 |
+
f"https://{REGION_TEMPLATE}.myGreatService.{DNS_SUFFIX_TEMPLATE}"
|
| 61 |
+
)
|
| 62 |
+
ENDPOINT_DICT = {
|
| 63 |
+
"url": URL_TEMPLATE,
|
| 64 |
+
"properties": {
|
| 65 |
+
"authSchemes": [
|
| 66 |
+
{
|
| 67 |
+
"signingName": "s3",
|
| 68 |
+
"signingScope": REGION_TEMPLATE,
|
| 69 |
+
"name": "s3v4",
|
| 70 |
+
}
|
| 71 |
+
],
|
| 72 |
+
},
|
| 73 |
+
"headers": {
|
| 74 |
+
"x-amz-region-set": [
|
| 75 |
+
REGION_REF,
|
| 76 |
+
{
|
| 77 |
+
"fn": "getAttr",
|
| 78 |
+
"argv": [BUCKET_ARN_REF, "region"],
|
| 79 |
+
},
|
| 80 |
+
"us-east-2",
|
| 81 |
+
],
|
| 82 |
+
},
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
@pytest.fixture(scope="module")
|
| 87 |
+
def loader():
|
| 88 |
+
return Loader()
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
@pytest.fixture(scope="module")
|
| 92 |
+
def partitions(loader):
|
| 93 |
+
return loader.load_data("partitions")
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
@pytest.fixture(scope="module")
|
| 97 |
+
def rule_lib(partitions):
|
| 98 |
+
return RuleSetStandardLibrary(partitions)
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
@pytest.fixture(scope="module")
|
| 102 |
+
def ruleset_dict():
|
| 103 |
+
path = os.path.join(
|
| 104 |
+
os.path.dirname(__file__),
|
| 105 |
+
"data",
|
| 106 |
+
"endpoints",
|
| 107 |
+
"valid-rules",
|
| 108 |
+
"deprecated-param.json",
|
| 109 |
+
)
|
| 110 |
+
with open(path) as f:
|
| 111 |
+
return json.load(f)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
@pytest.fixture(scope="module")
|
| 115 |
+
def endpoint_provider(ruleset_dict, partitions):
|
| 116 |
+
return EndpointProvider(ruleset_dict, partitions)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
@pytest.fixture(scope="module")
|
| 120 |
+
def endpoint_rule():
|
| 121 |
+
return EndpointRule(
|
| 122 |
+
endpoint=ENDPOINT_DICT,
|
| 123 |
+
conditions=[
|
| 124 |
+
PARSE_ARN_FUNC,
|
| 125 |
+
{
|
| 126 |
+
"fn": "not",
|
| 127 |
+
"argv": [STRING_EQUALS_FUNC],
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"fn": "aws.partition",
|
| 131 |
+
"argv": [REGION_REF],
|
| 132 |
+
"assign": "PartitionResults",
|
| 133 |
+
},
|
| 134 |
+
],
|
| 135 |
+
)
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def ruleset_testcases():
|
| 139 |
+
filenames = [
|
| 140 |
+
"aws-region",
|
| 141 |
+
"default-values",
|
| 142 |
+
"eventbridge",
|
| 143 |
+
"fns",
|
| 144 |
+
"headers",
|
| 145 |
+
"is-virtual-hostable-s3-bucket",
|
| 146 |
+
"local-region-override",
|
| 147 |
+
"parse-arn",
|
| 148 |
+
"parse-url",
|
| 149 |
+
"substring",
|
| 150 |
+
"uri-encode",
|
| 151 |
+
"valid-hostlabel",
|
| 152 |
+
]
|
| 153 |
+
error_cases = []
|
| 154 |
+
endpoint_cases = []
|
| 155 |
+
base_path = os.path.join(os.path.dirname(__file__), "data", "endpoints")
|
| 156 |
+
for name in filenames:
|
| 157 |
+
with open(os.path.join(base_path, "valid-rules", f"{name}.json")) as f:
|
| 158 |
+
ruleset = json.load(f)
|
| 159 |
+
with open(os.path.join(base_path, "test-cases", f"{name}.json")) as f:
|
| 160 |
+
tests = json.load(f)
|
| 161 |
+
|
| 162 |
+
for test in tests["testCases"]:
|
| 163 |
+
input_params = test["params"]
|
| 164 |
+
expected_object = test["expect"]
|
| 165 |
+
if "error" in expected_object:
|
| 166 |
+
error_cases.append(
|
| 167 |
+
(ruleset, input_params, expected_object["error"])
|
| 168 |
+
)
|
| 169 |
+
elif "endpoint" in expected_object:
|
| 170 |
+
endpoint_cases.append(
|
| 171 |
+
(ruleset, input_params, expected_object["endpoint"])
|
| 172 |
+
)
|
| 173 |
+
else:
|
| 174 |
+
raise ValueError("Expected `error` or `endpoint` in test case")
|
| 175 |
+
return error_cases, endpoint_cases
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
ERROR_TEST_CASES, ENDPOINT_TEST_CASES = ruleset_testcases()
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
@pytest.mark.parametrize(
|
| 182 |
+
"ruleset,input_params,expected_error",
|
| 183 |
+
ERROR_TEST_CASES,
|
| 184 |
+
)
|
| 185 |
+
def test_endpoint_resolution_raises(
|
| 186 |
+
partitions, ruleset, input_params, expected_error
|
| 187 |
+
):
|
| 188 |
+
endpoint_provider = EndpointProvider(ruleset, partitions)
|
| 189 |
+
with pytest.raises(EndpointResolutionError) as exc_info:
|
| 190 |
+
endpoint_provider.resolve_endpoint(**input_params)
|
| 191 |
+
assert str(exc_info.value) == expected_error
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
@pytest.mark.parametrize(
|
| 195 |
+
"ruleset,input_params,expected_endpoint",
|
| 196 |
+
ENDPOINT_TEST_CASES,
|
| 197 |
+
)
|
| 198 |
+
def test_endpoint_resolution(
|
| 199 |
+
partitions, ruleset, input_params, expected_endpoint
|
| 200 |
+
):
|
| 201 |
+
endpoint_provider = EndpointProvider(ruleset, partitions)
|
| 202 |
+
endpoint = endpoint_provider.resolve_endpoint(**input_params)
|
| 203 |
+
assert endpoint.url == expected_endpoint["url"]
|
| 204 |
+
assert endpoint.properties == expected_endpoint.get("properties", {})
|
| 205 |
+
assert endpoint.headers == expected_endpoint.get("headers", {})
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
def test_none_returns_default_partition(rule_lib):
|
| 209 |
+
partition_dict = rule_lib.aws_partition(None)
|
| 210 |
+
assert partition_dict['name'] == "aws"
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
def test_no_match_region_returns_default_partition(rule_lib):
|
| 214 |
+
partition_dict = rule_lib.aws_partition("invalid-region-42")
|
| 215 |
+
assert partition_dict['name'] == "aws"
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def test_invalid_arn_returns_none(rule_lib):
|
| 219 |
+
assert rule_lib.aws_parse_arn("arn:aws:this-is-not-an-arn:foo") is None
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
@pytest.mark.parametrize(
|
| 223 |
+
"arn, expected_resource_id",
|
| 224 |
+
[
|
| 225 |
+
(
|
| 226 |
+
"arn:aws:s3:::myBucket/key",
|
| 227 |
+
{
|
| 228 |
+
"partition": "aws",
|
| 229 |
+
"service": "s3",
|
| 230 |
+
"region": "",
|
| 231 |
+
"accountId": "",
|
| 232 |
+
"resourceId": ["myBucket", "key"],
|
| 233 |
+
},
|
| 234 |
+
),
|
| 235 |
+
(
|
| 236 |
+
"arn:aws:kinesis:us-east-1:1234567890:stream/mystream:foo",
|
| 237 |
+
{
|
| 238 |
+
"partition": "aws",
|
| 239 |
+
"service": "kinesis",
|
| 240 |
+
"region": "us-east-1",
|
| 241 |
+
"accountId": "1234567890",
|
| 242 |
+
"resourceId": ["stream", "mystream", "foo"],
|
| 243 |
+
},
|
| 244 |
+
),
|
| 245 |
+
(
|
| 246 |
+
"arn:aws:s3:::myBucket",
|
| 247 |
+
{
|
| 248 |
+
"partition": "aws",
|
| 249 |
+
"service": "s3",
|
| 250 |
+
"region": "",
|
| 251 |
+
"accountId": "",
|
| 252 |
+
"resourceId": ["myBucket"],
|
| 253 |
+
},
|
| 254 |
+
),
|
| 255 |
+
],
|
| 256 |
+
)
|
| 257 |
+
def test_parse_arn_delimiters(rule_lib, arn, expected_resource_id):
|
| 258 |
+
parsed_arn = rule_lib.aws_parse_arn(arn)
|
| 259 |
+
assert parsed_arn == expected_resource_id
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
def test_uri_encode_none_returns_none(rule_lib):
|
| 263 |
+
assert rule_lib.uri_encode(None) is None
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
def test_parse_url_none_return_none(rule_lib):
|
| 267 |
+
assert rule_lib.parse_url(None) is None
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
def test_string_equals_wrong_type_raises(rule_lib):
|
| 271 |
+
with pytest.raises(EndpointResolutionError) as exc_info:
|
| 272 |
+
rule_lib.string_equals(1, 2)
|
| 273 |
+
assert "Both values must be strings" in str(exc_info.value)
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
def test_boolean_equals_wrong_type_raises(rule_lib):
|
| 277 |
+
with pytest.raises(EndpointResolutionError) as exc_info:
|
| 278 |
+
rule_lib.boolean_equals(1, 2)
|
| 279 |
+
assert "Both arguments must be bools" in str(exc_info.value)
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
def test_substring_wrong_type_raises(rule_lib):
|
| 283 |
+
with pytest.raises(EndpointResolutionError) as exc_info:
|
| 284 |
+
rule_lib.substring(["h", "e", "l", "l", "o"], 0, 5, False)
|
| 285 |
+
assert "Input must be a string" in str(exc_info.value)
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
def test_creator_unknown_type_raises():
|
| 289 |
+
with pytest.raises(EndpointResolutionError) as exc_info:
|
| 290 |
+
RuleCreator.create(type="foo")
|
| 291 |
+
assert "Unknown rule type: foo." in str(exc_info.value)
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
def test_parameter_wrong_type_raises(endpoint_provider):
|
| 295 |
+
param = endpoint_provider.ruleset.parameters["Region"]
|
| 296 |
+
with pytest.raises(EndpointResolutionError) as exc_info:
|
| 297 |
+
param.validate_input(1)
|
| 298 |
+
assert "Value (Region) is the wrong type" in str(exc_info.value)
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def test_deprecated_parameter_logs(endpoint_provider, caplog):
|
| 302 |
+
caplog.set_level(logging.INFO)
|
| 303 |
+
param = endpoint_provider.ruleset.parameters["Region"]
|
| 304 |
+
param.validate_input("foo")
|
| 305 |
+
assert "Region has been deprecated." in caplog.text
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
def test_no_endpoint_found_error(endpoint_provider):
|
| 309 |
+
with pytest.raises(EndpointResolutionError) as exc_info:
|
| 310 |
+
endpoint_provider.resolve_endpoint(
|
| 311 |
+
**{"Endpoint": "mygreatendpoint.com", "Bucket": "mybucket"}
|
| 312 |
+
)
|
| 313 |
+
assert "No endpoint found for parameters" in str(exc_info.value)
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
@pytest.mark.parametrize(
|
| 317 |
+
"rule_dict,expected_rule_type",
|
| 318 |
+
[
|
| 319 |
+
(
|
| 320 |
+
{
|
| 321 |
+
"type": "endpoint",
|
| 322 |
+
"conditions": [],
|
| 323 |
+
"endpoint": {
|
| 324 |
+
"url": (
|
| 325 |
+
"https://{Region}.myGreatService."
|
| 326 |
+
"{PartitionResult#dualStackDnsSuffix}"
|
| 327 |
+
),
|
| 328 |
+
"properties": {},
|
| 329 |
+
"headers": {},
|
| 330 |
+
},
|
| 331 |
+
},
|
| 332 |
+
EndpointRule,
|
| 333 |
+
),
|
| 334 |
+
(
|
| 335 |
+
{
|
| 336 |
+
"type": "error",
|
| 337 |
+
"conditions": [],
|
| 338 |
+
"error": (
|
| 339 |
+
"Dualstack is enabled but this partition "
|
| 340 |
+
"does not support DualStack"
|
| 341 |
+
),
|
| 342 |
+
},
|
| 343 |
+
ErrorRule,
|
| 344 |
+
),
|
| 345 |
+
({"type": "tree", "conditions": [], "rules": []}, TreeRule),
|
| 346 |
+
],
|
| 347 |
+
)
|
| 348 |
+
def test_rule_creation(rule_dict, expected_rule_type):
|
| 349 |
+
rule = RuleCreator.create(**rule_dict)
|
| 350 |
+
assert isinstance(rule, expected_rule_type)
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
def test_assign_existing_scope_var_raises(rule_lib):
|
| 354 |
+
rule = EndpointRule(
|
| 355 |
+
conditions=[
|
| 356 |
+
{
|
| 357 |
+
'fn': 'aws.parseArn',
|
| 358 |
+
'argv': ['{Bucket}'],
|
| 359 |
+
'assign': 'bucketArn',
|
| 360 |
+
},
|
| 361 |
+
{
|
| 362 |
+
'fn': 'aws.parseArn',
|
| 363 |
+
'argv': ['{Bucket}'],
|
| 364 |
+
'assign': 'bucketArn',
|
| 365 |
+
},
|
| 366 |
+
],
|
| 367 |
+
endpoint={'url': 'foo.bar'},
|
| 368 |
+
)
|
| 369 |
+
with pytest.raises(EndpointResolutionError) as exc_info:
|
| 370 |
+
rule.evaluate_conditions(
|
| 371 |
+
scope_vars={
|
| 372 |
+
'Bucket': 'arn:aws:s3:us-east-1:123456789012:mybucket'
|
| 373 |
+
},
|
| 374 |
+
rule_lib=rule_lib,
|
| 375 |
+
)
|
| 376 |
+
assert str(exc_info.value) == (
|
| 377 |
+
"Assignment bucketArn already exists in "
|
| 378 |
+
"scoped variables and cannot be overwritten"
|
| 379 |
+
)
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
def test_ruleset_unknown_parameter_type_raises(partitions):
|
| 383 |
+
with pytest.raises(EndpointResolutionError) as exc_info:
|
| 384 |
+
RuleSet(
|
| 385 |
+
version='1.0',
|
| 386 |
+
parameters={
|
| 387 |
+
'Bucket': {"type": "list"},
|
| 388 |
+
},
|
| 389 |
+
rules=[],
|
| 390 |
+
partitions=partitions,
|
| 391 |
+
)
|
| 392 |
+
assert "Unknown parameter type: list." in str(exc_info.value)
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
@pytest.fixture()
|
| 396 |
+
def empty_resolver():
|
| 397 |
+
return EndpointRulesetResolver(
|
| 398 |
+
endpoint_ruleset_data={
|
| 399 |
+
'version': '1.0',
|
| 400 |
+
'parameters': {},
|
| 401 |
+
'rules': [],
|
| 402 |
+
},
|
| 403 |
+
partition_data={},
|
| 404 |
+
service_model=None,
|
| 405 |
+
builtins={},
|
| 406 |
+
client_context=None,
|
| 407 |
+
event_emitter=None,
|
| 408 |
+
use_ssl=True,
|
| 409 |
+
requested_auth_scheme=None,
|
| 410 |
+
)
|
| 411 |
+
|
| 412 |
+
|
| 413 |
+
def test_auth_schemes_conversion_sigv4(empty_resolver):
|
| 414 |
+
auth_schemes = [
|
| 415 |
+
{
|
| 416 |
+
'name': 'sigv4',
|
| 417 |
+
'signingName': 'dynamodb',
|
| 418 |
+
'signingRegion': 'my-region-1',
|
| 419 |
+
'disableDoubleEncoding': True,
|
| 420 |
+
'otherParameter': 'otherValue',
|
| 421 |
+
}
|
| 422 |
+
]
|
| 423 |
+
at, sc = empty_resolver.auth_schemes_to_signing_ctx(auth_schemes)
|
| 424 |
+
assert at == 'v4'
|
| 425 |
+
assert sc == {
|
| 426 |
+
'region': 'my-region-1',
|
| 427 |
+
'signing_name': 'dynamodb',
|
| 428 |
+
'disableDoubleEncoding': True,
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
|
| 432 |
+
@requires_crt()
|
| 433 |
+
def test_auth_schemes_conversion_sigv4a_with_crt(monkeypatch, empty_resolver):
|
| 434 |
+
monkeypatch.setattr('botocore.regions.HAS_CRT', True)
|
| 435 |
+
auth_schemes = [
|
| 436 |
+
{'name': 'sigv4a', 'signingName': 's3', 'signingRegionSet': ['*']}
|
| 437 |
+
]
|
| 438 |
+
at, sc = empty_resolver.auth_schemes_to_signing_ctx(auth_schemes)
|
| 439 |
+
assert at == 'v4a'
|
| 440 |
+
assert sc == {'region': '*', 'signing_name': 's3'}
|
| 441 |
+
|
| 442 |
+
|
| 443 |
+
def test_auth_schemes_conversion_sigv4a_without_crt(
|
| 444 |
+
monkeypatch, empty_resolver
|
| 445 |
+
):
|
| 446 |
+
monkeypatch.setattr('botocore.regions.HAS_CRT', False)
|
| 447 |
+
monkeypatch.setattr('botocore.regions.AUTH_TYPE_MAPS', {})
|
| 448 |
+
auth_schemes = [
|
| 449 |
+
{'name': 'sigv4a', 'signingName': 's3', 'signingRegionSet': ['*']}
|
| 450 |
+
]
|
| 451 |
+
with pytest.raises(MissingDependencyException):
|
| 452 |
+
empty_resolver.auth_schemes_to_signing_ctx(auth_schemes)
|
| 453 |
+
|
| 454 |
+
|
| 455 |
+
def test_auth_schemes_conversion_no_known_auth_types(empty_resolver):
|
| 456 |
+
auth_schemes = [
|
| 457 |
+
{'name': 'foo', 'signingName': 's3', 'signingRegion': 'ap-south-2'},
|
| 458 |
+
{'name': 'bar', 'otherParamKey': 'otherParamVal'},
|
| 459 |
+
]
|
| 460 |
+
with pytest.raises(UnknownSignatureVersionError):
|
| 461 |
+
empty_resolver.auth_schemes_to_signing_ctx(auth_schemes)
|
| 462 |
+
|
| 463 |
+
|
| 464 |
+
def test_auth_schemes_conversion_first_authtype_unknown(
|
| 465 |
+
monkeypatch, empty_resolver
|
| 466 |
+
):
|
| 467 |
+
monkeypatch.setattr('botocore.regions.HAS_CRT', False)
|
| 468 |
+
monkeypatch.setattr('botocore.regions.AUTH_TYPE_MAPS', {'bar': None})
|
| 469 |
+
auth_schemes = [
|
| 470 |
+
{'name': 'foo', 'signingName': 's3', 'signingRegion': 'ap-south-1'},
|
| 471 |
+
{'name': 'bar', 'signingName': 's3', 'signingRegion': 'ap-south-2'},
|
| 472 |
+
]
|
| 473 |
+
at, sc = empty_resolver.auth_schemes_to_signing_ctx(auth_schemes)
|
| 474 |
+
assert at == 'bar'
|
| 475 |
+
assert sc == {'region': 'ap-south-2', 'signing_name': 's3'}
|
| 476 |
+
|
| 477 |
+
|
| 478 |
+
def test_endpoint_resolution_caches(endpoint_provider, monkeypatch):
|
| 479 |
+
mock_evaluate = Mock()
|
| 480 |
+
monkeypatch.setattr(RuleSet, "evaluate", mock_evaluate)
|
| 481 |
+
for _ in range(5):
|
| 482 |
+
endpoint_provider.resolve_endpoint(Region="us-east-2")
|
| 483 |
+
mock_evaluate.assert_called_once_with({"Region": "us-east-2"})
|
| 484 |
+
|
| 485 |
+
|
| 486 |
+
def test_endpoint_reevaluates_result(endpoint_provider, monkeypatch):
|
| 487 |
+
regions = ["us-east-1", "us-west-2"]
|
| 488 |
+
mock_evaluate = Mock()
|
| 489 |
+
monkeypatch.setattr(RuleSet, "evaluate", mock_evaluate)
|
| 490 |
+
for region in regions:
|
| 491 |
+
endpoint_provider.resolve_endpoint(Region=region)
|
| 492 |
+
assert mock_evaluate.call_count == 2
|
| 493 |
+
|
| 494 |
+
|
| 495 |
+
@pytest.mark.parametrize(
|
| 496 |
+
"bucket, expected_value",
|
| 497 |
+
[
|
| 498 |
+
("mybucket", True),
|
| 499 |
+
("ab", False),
|
| 500 |
+
("a.b", True),
|
| 501 |
+
("my.great.bucket.aws.com", True),
|
| 502 |
+
("mY.GREAT.bucket.aws.com", False),
|
| 503 |
+
("192.168.1.1", False),
|
| 504 |
+
],
|
| 505 |
+
)
|
| 506 |
+
def test_aws_is_virtual_hostable_s3_bucket_allow_subdomains(
|
| 507 |
+
rule_lib, bucket, expected_value
|
| 508 |
+
):
|
| 509 |
+
assert (
|
| 510 |
+
rule_lib.aws_is_virtual_hostable_s3_bucket(bucket, True)
|
| 511 |
+
== expected_value
|
| 512 |
+
)
|
testbed/boto__botocore/tests/unit/test_errorfactory.py
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 4 |
+
# may not use this file except in compliance with the License. A copy of
|
| 5 |
+
# the License is located at
|
| 6 |
+
#
|
| 7 |
+
# http://aws.amazon.com/apache2.0/
|
| 8 |
+
#
|
| 9 |
+
# or in the "license" file accompanying this file. This file is
|
| 10 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 11 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 12 |
+
# language governing permissions and limitations under the License.
|
| 13 |
+
from botocore.errorfactory import BaseClientExceptions, ClientExceptionsFactory
|
| 14 |
+
from botocore.exceptions import ClientError
|
| 15 |
+
from botocore.model import ServiceModel
|
| 16 |
+
from tests import unittest
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class TestBaseClientExceptions(unittest.TestCase):
|
| 20 |
+
def setUp(self):
|
| 21 |
+
self.code_to_exception = {}
|
| 22 |
+
self.exceptions = BaseClientExceptions(self.code_to_exception)
|
| 23 |
+
|
| 24 |
+
def test_has_client_error(self):
|
| 25 |
+
self.assertIs(self.exceptions.ClientError, ClientError)
|
| 26 |
+
|
| 27 |
+
def test_from_code(self):
|
| 28 |
+
exception_cls = type('MyException', (ClientError,), {})
|
| 29 |
+
self.code_to_exception['MyExceptionCode'] = exception_cls
|
| 30 |
+
self.assertIs(
|
| 31 |
+
self.exceptions.from_code('MyExceptionCode'), exception_cls
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
def test_from_code_nonmatch_defaults_to_client_error(self):
|
| 35 |
+
self.assertIs(
|
| 36 |
+
self.exceptions.from_code('SomeUnknownErrorCode'), ClientError
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
def test_gettattr_message(self):
|
| 40 |
+
exception_cls = type('MyException', (ClientError,), {})
|
| 41 |
+
self.code_to_exception['MyExceptionCode'] = exception_cls
|
| 42 |
+
with self.assertRaisesRegex(
|
| 43 |
+
AttributeError, 'Valid exceptions are: MyException'
|
| 44 |
+
):
|
| 45 |
+
self.exceptions.SomeUnmodeledError
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class TestClientExceptionsFactory(unittest.TestCase):
|
| 49 |
+
def setUp(self):
|
| 50 |
+
self.model = {
|
| 51 |
+
"metadata": {
|
| 52 |
+
'endpointPrefix': 'myservice',
|
| 53 |
+
'serviceFullName': 'MyService',
|
| 54 |
+
},
|
| 55 |
+
'operations': {
|
| 56 |
+
'OperationName': {
|
| 57 |
+
'name': 'OperationName',
|
| 58 |
+
'errors': [
|
| 59 |
+
{'shape': 'ExceptionMissingCode'},
|
| 60 |
+
{'shape': 'ExceptionWithModeledCode'},
|
| 61 |
+
],
|
| 62 |
+
},
|
| 63 |
+
'AnotherOperationName': {
|
| 64 |
+
'name': 'AnotherOperationName',
|
| 65 |
+
'errors': [
|
| 66 |
+
{'shape': 'ExceptionForAnotherOperation'},
|
| 67 |
+
{'shape': 'ExceptionWithModeledCode'},
|
| 68 |
+
],
|
| 69 |
+
},
|
| 70 |
+
},
|
| 71 |
+
'shapes': {
|
| 72 |
+
'ExceptionWithModeledCode': {
|
| 73 |
+
'type': 'structure',
|
| 74 |
+
'members': {},
|
| 75 |
+
'error': {'code': 'ModeledCode'},
|
| 76 |
+
'exception': True,
|
| 77 |
+
},
|
| 78 |
+
'ExceptionMissingCode': {
|
| 79 |
+
'type': 'structure',
|
| 80 |
+
'members': {},
|
| 81 |
+
'exception': True,
|
| 82 |
+
},
|
| 83 |
+
'ExceptionForAnotherOperation': {
|
| 84 |
+
'type': 'structure',
|
| 85 |
+
'members': {},
|
| 86 |
+
'exception': True,
|
| 87 |
+
},
|
| 88 |
+
},
|
| 89 |
+
}
|
| 90 |
+
self.service_model = ServiceModel(self.model)
|
| 91 |
+
self.exceptions_factory = ClientExceptionsFactory()
|
| 92 |
+
|
| 93 |
+
def test_class_name(self):
|
| 94 |
+
exceptions = self.exceptions_factory.create_client_exceptions(
|
| 95 |
+
self.service_model
|
| 96 |
+
)
|
| 97 |
+
self.assertEqual(exceptions.__class__.__name__, 'MyServiceExceptions')
|
| 98 |
+
|
| 99 |
+
def test_creates_modeled_exception(self):
|
| 100 |
+
exceptions = self.exceptions_factory.create_client_exceptions(
|
| 101 |
+
self.service_model
|
| 102 |
+
)
|
| 103 |
+
self.assertTrue(hasattr(exceptions, 'ExceptionWithModeledCode'))
|
| 104 |
+
modeled_exception = exceptions.ExceptionWithModeledCode
|
| 105 |
+
self.assertEqual(
|
| 106 |
+
modeled_exception.__name__, 'ExceptionWithModeledCode'
|
| 107 |
+
)
|
| 108 |
+
self.assertTrue(issubclass(modeled_exception, ClientError))
|
| 109 |
+
|
| 110 |
+
def test_collects_modeled_exceptions_for_all_operations(self):
|
| 111 |
+
exceptions = self.exceptions_factory.create_client_exceptions(
|
| 112 |
+
self.service_model
|
| 113 |
+
)
|
| 114 |
+
# Make sure exceptions were added for all operations by checking
|
| 115 |
+
# an exception only found on an a different operation.
|
| 116 |
+
self.assertTrue(hasattr(exceptions, 'ExceptionForAnotherOperation'))
|
| 117 |
+
modeled_exception = exceptions.ExceptionForAnotherOperation
|
| 118 |
+
self.assertEqual(
|
| 119 |
+
modeled_exception.__name__, 'ExceptionForAnotherOperation'
|
| 120 |
+
)
|
| 121 |
+
self.assertTrue(issubclass(modeled_exception, ClientError))
|
| 122 |
+
|
| 123 |
+
def test_creates_modeled_exception_mapping_that_has_code(self):
|
| 124 |
+
exceptions = self.exceptions_factory.create_client_exceptions(
|
| 125 |
+
self.service_model
|
| 126 |
+
)
|
| 127 |
+
exception = exceptions.from_code('ModeledCode')
|
| 128 |
+
self.assertEqual(exception.__name__, 'ExceptionWithModeledCode')
|
| 129 |
+
self.assertTrue(issubclass(exception, ClientError))
|
| 130 |
+
|
| 131 |
+
def test_creates_modeled_exception_mapping_that_has_no_code(self):
|
| 132 |
+
exceptions = self.exceptions_factory.create_client_exceptions(
|
| 133 |
+
self.service_model
|
| 134 |
+
)
|
| 135 |
+
# For exceptions that do not have an explicit code associated to them,
|
| 136 |
+
# the code is the name of the exception.
|
| 137 |
+
exception = exceptions.from_code('ExceptionMissingCode')
|
| 138 |
+
self.assertEqual(exception.__name__, 'ExceptionMissingCode')
|
| 139 |
+
self.assertTrue(issubclass(exception, ClientError))
|
testbed/boto__botocore/tests/unit/test_eventstream.py
ADDED
|
@@ -0,0 +1,568 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 4 |
+
# may not use this file except in compliance with the License. A copy of
|
| 5 |
+
# the License is located at
|
| 6 |
+
#
|
| 7 |
+
# http://aws.amazon.com/apache2.0/
|
| 8 |
+
#
|
| 9 |
+
# or in the "license" file accompanying this file. This file is
|
| 10 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 11 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 12 |
+
# language governing permissions and limitations under the License.
|
| 13 |
+
"""Unit tests for the binary event stream decoder."""
|
| 14 |
+
|
| 15 |
+
import pytest
|
| 16 |
+
|
| 17 |
+
from botocore.eventstream import (
|
| 18 |
+
ChecksumMismatch,
|
| 19 |
+
DecodeUtils,
|
| 20 |
+
DuplicateHeader,
|
| 21 |
+
EventStream,
|
| 22 |
+
EventStreamBuffer,
|
| 23 |
+
EventStreamHeaderParser,
|
| 24 |
+
EventStreamMessage,
|
| 25 |
+
InvalidHeadersLength,
|
| 26 |
+
InvalidPayloadLength,
|
| 27 |
+
MessagePrelude,
|
| 28 |
+
NoInitialResponseError,
|
| 29 |
+
)
|
| 30 |
+
from botocore.exceptions import EventStreamError
|
| 31 |
+
from botocore.parsers import EventStreamXMLParser
|
| 32 |
+
from tests import mock
|
| 33 |
+
|
| 34 |
+
EMPTY_MESSAGE = (
|
| 35 |
+
b'\x00\x00\x00\x10\x00\x00\x00\x00\x05\xc2H\xeb}\x98\xc8\xff',
|
| 36 |
+
EventStreamMessage(
|
| 37 |
+
prelude=MessagePrelude(
|
| 38 |
+
total_length=0x10,
|
| 39 |
+
headers_length=0,
|
| 40 |
+
crc=0x05C248EB,
|
| 41 |
+
),
|
| 42 |
+
headers={},
|
| 43 |
+
payload=b'',
|
| 44 |
+
crc=0x7D98C8FF,
|
| 45 |
+
),
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
INT8_HEADER = (
|
| 49 |
+
(
|
| 50 |
+
b"\x00\x00\x00\x17\x00\x00\x00\x07)\x86\x01X\x04"
|
| 51 |
+
b"byte\x02\xff\xc2\xf8i\xdc"
|
| 52 |
+
),
|
| 53 |
+
EventStreamMessage(
|
| 54 |
+
prelude=MessagePrelude(
|
| 55 |
+
total_length=0x17,
|
| 56 |
+
headers_length=0x7,
|
| 57 |
+
crc=0x29860158,
|
| 58 |
+
),
|
| 59 |
+
headers={'byte': -1},
|
| 60 |
+
payload=b'',
|
| 61 |
+
crc=0xC2F869DC,
|
| 62 |
+
),
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
INT16_HEADER = (
|
| 66 |
+
(
|
| 67 |
+
b"\x00\x00\x00\x19\x00\x00\x00\tq\x0e\x92>\x05"
|
| 68 |
+
b"short\x03\xff\xff\xb2|\xb6\xcc"
|
| 69 |
+
),
|
| 70 |
+
EventStreamMessage(
|
| 71 |
+
prelude=MessagePrelude(
|
| 72 |
+
total_length=0x19,
|
| 73 |
+
headers_length=0x9,
|
| 74 |
+
crc=0x710E923E,
|
| 75 |
+
),
|
| 76 |
+
headers={'short': -1},
|
| 77 |
+
payload=b'',
|
| 78 |
+
crc=0xB27CB6CC,
|
| 79 |
+
),
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
INT32_HEADER = (
|
| 83 |
+
(
|
| 84 |
+
b"\x00\x00\x00\x1d\x00\x00\x00\r\x83\xe3\xf0\xe7\x07"
|
| 85 |
+
b"integer\x04\xff\xff\xff\xff\x8b\x8e\x12\xeb"
|
| 86 |
+
),
|
| 87 |
+
EventStreamMessage(
|
| 88 |
+
prelude=MessagePrelude(
|
| 89 |
+
total_length=0x1D,
|
| 90 |
+
headers_length=0xD,
|
| 91 |
+
crc=0x83E3F0E7,
|
| 92 |
+
),
|
| 93 |
+
headers={'integer': -1},
|
| 94 |
+
payload=b'',
|
| 95 |
+
crc=0x8B8E12EB,
|
| 96 |
+
),
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
INT64_HEADER = (
|
| 100 |
+
(
|
| 101 |
+
b"\x00\x00\x00\x1e\x00\x00\x00\x0e]J\xdb\x8d\x04"
|
| 102 |
+
b"long\x05\xff\xff\xff\xff\xff\xff\xff\xffK\xc22\xda"
|
| 103 |
+
),
|
| 104 |
+
EventStreamMessage(
|
| 105 |
+
prelude=MessagePrelude(
|
| 106 |
+
total_length=0x1E,
|
| 107 |
+
headers_length=0xE,
|
| 108 |
+
crc=0x5D4ADB8D,
|
| 109 |
+
),
|
| 110 |
+
headers={'long': -1},
|
| 111 |
+
payload=b'',
|
| 112 |
+
crc=0x4BC232DA,
|
| 113 |
+
),
|
| 114 |
+
)
|
| 115 |
+
|
| 116 |
+
PAYLOAD_NO_HEADERS = (
|
| 117 |
+
b"\x00\x00\x00\x1d\x00\x00\x00\x00\xfdR\x8cZ{'foo':'bar'}\xc3e96",
|
| 118 |
+
EventStreamMessage(
|
| 119 |
+
prelude=MessagePrelude(
|
| 120 |
+
total_length=0x1D,
|
| 121 |
+
headers_length=0,
|
| 122 |
+
crc=0xFD528C5A,
|
| 123 |
+
),
|
| 124 |
+
headers={},
|
| 125 |
+
payload=b"{'foo':'bar'}",
|
| 126 |
+
crc=0xC3653936,
|
| 127 |
+
),
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
PAYLOAD_ONE_STR_HEADER = (
|
| 131 |
+
(
|
| 132 |
+
b"\x00\x00\x00=\x00\x00\x00 \x07\xfd\x83\x96\x0ccontent-type\x07\x00\x10"
|
| 133 |
+
b"application/json{'foo':'bar'}\x8d\x9c\x08\xb1"
|
| 134 |
+
),
|
| 135 |
+
EventStreamMessage(
|
| 136 |
+
prelude=MessagePrelude(
|
| 137 |
+
total_length=0x3D,
|
| 138 |
+
headers_length=0x20,
|
| 139 |
+
crc=0x07FD8396,
|
| 140 |
+
),
|
| 141 |
+
headers={'content-type': 'application/json'},
|
| 142 |
+
payload=b"{'foo':'bar'}",
|
| 143 |
+
crc=0x8D9C08B1,
|
| 144 |
+
),
|
| 145 |
+
)
|
| 146 |
+
|
| 147 |
+
ALL_HEADERS_TYPES = (
|
| 148 |
+
(
|
| 149 |
+
b"\x00\x00\x00\x62\x00\x00\x00\x52\x03\xb5\xcb\x9c"
|
| 150 |
+
b"\x010\x00\x011\x01\x012\x02\x02\x013\x03\x00\x03"
|
| 151 |
+
b"\x014\x04\x00\x00\x00\x04\x015\x05\x00\x00\x00\x00\x00\x00\x00\x05"
|
| 152 |
+
b"\x016\x06\x00\x05bytes\x017\x07\x00\x04utf8"
|
| 153 |
+
b"\x018\x08\x00\x00\x00\x00\x00\x00\x00\x08\x019\x090123456789abcdef"
|
| 154 |
+
b"\x63\x35\x36\x71"
|
| 155 |
+
),
|
| 156 |
+
EventStreamMessage(
|
| 157 |
+
prelude=MessagePrelude(
|
| 158 |
+
total_length=0x62,
|
| 159 |
+
headers_length=0x52,
|
| 160 |
+
crc=0x03B5CB9C,
|
| 161 |
+
),
|
| 162 |
+
headers={
|
| 163 |
+
'0': True,
|
| 164 |
+
'1': False,
|
| 165 |
+
'2': 0x02,
|
| 166 |
+
'3': 0x03,
|
| 167 |
+
'4': 0x04,
|
| 168 |
+
'5': 0x05,
|
| 169 |
+
'6': b'bytes',
|
| 170 |
+
'7': 'utf8',
|
| 171 |
+
'8': 0x08,
|
| 172 |
+
'9': b'0123456789abcdef',
|
| 173 |
+
},
|
| 174 |
+
payload=b"",
|
| 175 |
+
crc=0x63353671,
|
| 176 |
+
),
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
+
ERROR_EVENT_MESSAGE = (
|
| 180 |
+
(
|
| 181 |
+
b"\x00\x00\x00\x52\x00\x00\x00\x42\xbf\x23\x63\x7e"
|
| 182 |
+
b"\x0d:message-type\x07\x00\x05error"
|
| 183 |
+
b"\x0b:error-code\x07\x00\x04code"
|
| 184 |
+
b"\x0e:error-message\x07\x00\x07message"
|
| 185 |
+
b"\x6b\x6c\xea\x3d"
|
| 186 |
+
),
|
| 187 |
+
EventStreamMessage(
|
| 188 |
+
prelude=MessagePrelude(
|
| 189 |
+
total_length=0x52,
|
| 190 |
+
headers_length=0x42,
|
| 191 |
+
crc=0xBF23637E,
|
| 192 |
+
),
|
| 193 |
+
headers={
|
| 194 |
+
':message-type': 'error',
|
| 195 |
+
':error-code': 'code',
|
| 196 |
+
':error-message': 'message',
|
| 197 |
+
},
|
| 198 |
+
payload=b'',
|
| 199 |
+
crc=0x6B6CEA3D,
|
| 200 |
+
),
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
+
# Tuples of encoded messages and their expected decoded output
|
| 204 |
+
POSITIVE_CASES = [
|
| 205 |
+
EMPTY_MESSAGE,
|
| 206 |
+
INT8_HEADER,
|
| 207 |
+
INT16_HEADER,
|
| 208 |
+
INT32_HEADER,
|
| 209 |
+
INT64_HEADER,
|
| 210 |
+
PAYLOAD_NO_HEADERS,
|
| 211 |
+
PAYLOAD_ONE_STR_HEADER,
|
| 212 |
+
ALL_HEADERS_TYPES,
|
| 213 |
+
ERROR_EVENT_MESSAGE,
|
| 214 |
+
]
|
| 215 |
+
|
| 216 |
+
CORRUPTED_HEADER_LENGTH = (
|
| 217 |
+
(
|
| 218 |
+
b"\x00\x00\x00=\xff\x00\x01\x02\x07\xfd\x83\x96\x0ccontent-type\x07\x00"
|
| 219 |
+
b"\x10application/json{'foo':'bar'}\x8d\x9c\x08\xb1"
|
| 220 |
+
),
|
| 221 |
+
ChecksumMismatch,
|
| 222 |
+
)
|
| 223 |
+
|
| 224 |
+
CORRUPTED_HEADERS = (
|
| 225 |
+
(
|
| 226 |
+
b"\x00\x00\x00=\x00\x00\x00 \x07\xfd\x83\x96\x0ccontent+type\x07\x00\x10"
|
| 227 |
+
b"application/json{'foo':'bar'}\x8d\x9c\x08\xb1"
|
| 228 |
+
),
|
| 229 |
+
ChecksumMismatch,
|
| 230 |
+
)
|
| 231 |
+
|
| 232 |
+
CORRUPTED_LENGTH = (
|
| 233 |
+
b"\x01\x00\x00\x1d\x00\x00\x00\x00\xfdR\x8cZ{'foo':'bar'}\xc3e96",
|
| 234 |
+
ChecksumMismatch,
|
| 235 |
+
)
|
| 236 |
+
|
| 237 |
+
CORRUPTED_PAYLOAD = (
|
| 238 |
+
b"\x00\x00\x00\x1d\x00\x00\x00\x00\xfdR\x8cZ{'foo':'bar'\x8d\xc3e96",
|
| 239 |
+
ChecksumMismatch,
|
| 240 |
+
)
|
| 241 |
+
|
| 242 |
+
DUPLICATE_HEADER = (
|
| 243 |
+
(
|
| 244 |
+
b"\x00\x00\x00\x24\x00\x00\x00\x14\x4b\xb9\x82\xd0"
|
| 245 |
+
b"\x04test\x04asdf\x04test\x04asdf\xf3\xf4\x75\x63"
|
| 246 |
+
),
|
| 247 |
+
DuplicateHeader,
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
# In contrast to the CORRUPTED_HEADERS case, this message is otherwise
|
| 251 |
+
# well-formed - the checksums match.
|
| 252 |
+
INVALID_HEADERS_LENGTH = (
|
| 253 |
+
(
|
| 254 |
+
b"\x00\x00\x00\x3d" # total length
|
| 255 |
+
b"\xff\x00\x01\x02" # headers length
|
| 256 |
+
b"\x15\x83\xf5\xc2" # prelude crc
|
| 257 |
+
b"\x0ccontent-type\x07\x00\x10application/json" # headers
|
| 258 |
+
b"{'foo':'bar'}" # payload
|
| 259 |
+
b"\x2f\x37\x7f\x5d" # message crc
|
| 260 |
+
),
|
| 261 |
+
InvalidHeadersLength,
|
| 262 |
+
)
|
| 263 |
+
|
| 264 |
+
# In contrast to the CORRUPTED_PAYLOAD case, this message is otherwise
|
| 265 |
+
# well-formed - the checksums match.
|
| 266 |
+
INVALID_PAYLOAD_LENGTH = (
|
| 267 |
+
b"\x01\x00\x00\x11" # total length
|
| 268 |
+
+ b"\x00\x00\x00\x00" # headers length
|
| 269 |
+
+ b"\xf4\x08\x61\xc5" # prelude crc
|
| 270 |
+
+ b"0" * (16 * 1024**2 + 1) # payload
|
| 271 |
+
+ b"\x2a\xb4\xc5\xa5", # message crc
|
| 272 |
+
InvalidPayloadLength,
|
| 273 |
+
)
|
| 274 |
+
|
| 275 |
+
# Tuples of encoded messages and their expected exception
|
| 276 |
+
NEGATIVE_CASES = [
|
| 277 |
+
CORRUPTED_LENGTH,
|
| 278 |
+
CORRUPTED_PAYLOAD,
|
| 279 |
+
CORRUPTED_HEADERS,
|
| 280 |
+
CORRUPTED_HEADER_LENGTH,
|
| 281 |
+
DUPLICATE_HEADER,
|
| 282 |
+
INVALID_HEADERS_LENGTH,
|
| 283 |
+
INVALID_PAYLOAD_LENGTH,
|
| 284 |
+
]
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
def assert_message_equal(message_a, message_b):
|
| 288 |
+
"""Asserts all fields for two messages are equal."""
|
| 289 |
+
assert message_a.prelude.total_length == message_b.prelude.total_length
|
| 290 |
+
assert message_a.prelude.headers_length == message_b.prelude.headers_length
|
| 291 |
+
assert message_a.prelude.crc == message_b.prelude.crc
|
| 292 |
+
assert message_a.headers == message_b.headers
|
| 293 |
+
assert message_a.payload == message_b.payload
|
| 294 |
+
assert message_a.crc == message_b.crc
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
def test_partial_message():
|
| 298 |
+
"""Ensure that we can receive partial payloads."""
|
| 299 |
+
data = EMPTY_MESSAGE[0]
|
| 300 |
+
event_buffer = EventStreamBuffer()
|
| 301 |
+
# This mid point is an arbitrary break in the middle of the headers
|
| 302 |
+
mid_point = 15
|
| 303 |
+
event_buffer.add_data(data[:mid_point])
|
| 304 |
+
messages = list(event_buffer)
|
| 305 |
+
assert messages == []
|
| 306 |
+
event_buffer.add_data(data[mid_point : len(data)])
|
| 307 |
+
for message in event_buffer:
|
| 308 |
+
assert_message_equal(message, EMPTY_MESSAGE[1])
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
def check_message_decodes(encoded, decoded):
|
| 312 |
+
"""Ensure the message decodes to what we expect."""
|
| 313 |
+
event_buffer = EventStreamBuffer()
|
| 314 |
+
event_buffer.add_data(encoded)
|
| 315 |
+
messages = list(event_buffer)
|
| 316 |
+
assert len(messages) == 1
|
| 317 |
+
assert_message_equal(messages[0], decoded)
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
@pytest.mark.parametrize("encoded, decoded", POSITIVE_CASES)
|
| 321 |
+
def test_positive_cases(encoded, decoded):
|
| 322 |
+
"""Test that all positive cases decode how we expect."""
|
| 323 |
+
check_message_decodes(encoded, decoded)
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
def test_all_positive_cases():
|
| 327 |
+
"""Test all positive cases can be decoded on the same buffer."""
|
| 328 |
+
event_buffer = EventStreamBuffer()
|
| 329 |
+
# add all positive test cases to the same buffer
|
| 330 |
+
for encoded, _ in POSITIVE_CASES:
|
| 331 |
+
event_buffer.add_data(encoded)
|
| 332 |
+
# collect all of the expected messages
|
| 333 |
+
expected_messages = [decoded for (_, decoded) in POSITIVE_CASES]
|
| 334 |
+
# collect all of the decoded messages
|
| 335 |
+
decoded_messages = list(event_buffer)
|
| 336 |
+
# assert all messages match what we expect
|
| 337 |
+
for expected, decoded in zip(expected_messages, decoded_messages):
|
| 338 |
+
assert_message_equal(expected, decoded)
|
| 339 |
+
|
| 340 |
+
|
| 341 |
+
@pytest.mark.parametrize(
|
| 342 |
+
"encoded, exception",
|
| 343 |
+
NEGATIVE_CASES,
|
| 344 |
+
ids=[
|
| 345 |
+
"corrupted-length",
|
| 346 |
+
"corrupted-payload",
|
| 347 |
+
"corrupted-headers",
|
| 348 |
+
"corrupted-headers-length",
|
| 349 |
+
"duplicate-headers",
|
| 350 |
+
"invalid-headers-length",
|
| 351 |
+
"invalid-payload-length",
|
| 352 |
+
],
|
| 353 |
+
)
|
| 354 |
+
def test_negative_cases(encoded, exception):
|
| 355 |
+
"""Test that all negative cases raise the expected exception."""
|
| 356 |
+
with pytest.raises(exception):
|
| 357 |
+
check_message_decodes(encoded, None)
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
def test_header_parser():
|
| 361 |
+
"""Test that the header parser supports all header types."""
|
| 362 |
+
headers_data = (
|
| 363 |
+
b"\x010\x00\x011\x01\x012\x02\x02\x013\x03\x00\x03"
|
| 364 |
+
b"\x014\x04\x00\x00\x00\x04\x015\x05\x00\x00\x00\x00\x00\x00\x00\x05"
|
| 365 |
+
b"\x016\x06\x00\x05bytes\x017\x07\x00\x04utf8"
|
| 366 |
+
b"\x018\x08\x00\x00\x00\x00\x00\x00\x00\x08\x019\x090123456789abcdef"
|
| 367 |
+
)
|
| 368 |
+
|
| 369 |
+
expected_headers = {
|
| 370 |
+
'0': True,
|
| 371 |
+
'1': False,
|
| 372 |
+
'2': 0x02,
|
| 373 |
+
'3': 0x03,
|
| 374 |
+
'4': 0x04,
|
| 375 |
+
'5': 0x05,
|
| 376 |
+
'6': b'bytes',
|
| 377 |
+
'7': 'utf8',
|
| 378 |
+
'8': 0x08,
|
| 379 |
+
'9': b'0123456789abcdef',
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
parser = EventStreamHeaderParser()
|
| 383 |
+
headers = parser.parse(headers_data)
|
| 384 |
+
assert headers == expected_headers
|
| 385 |
+
|
| 386 |
+
|
| 387 |
+
def test_message_prelude_properties():
|
| 388 |
+
"""Test that calculated properties from the payload are correct."""
|
| 389 |
+
# Total length: 40, Headers Length: 15, random crc
|
| 390 |
+
prelude = MessagePrelude(40, 15, 0x00000000)
|
| 391 |
+
assert prelude.payload_length == 9
|
| 392 |
+
assert prelude.headers_end == 27
|
| 393 |
+
assert prelude.payload_end == 36
|
| 394 |
+
|
| 395 |
+
|
| 396 |
+
def test_message_to_response_dict():
|
| 397 |
+
response_dict = PAYLOAD_ONE_STR_HEADER[1].to_response_dict()
|
| 398 |
+
assert response_dict['status_code'] == 200
|
| 399 |
+
|
| 400 |
+
expected_headers = {'content-type': 'application/json'}
|
| 401 |
+
assert response_dict['headers'] == expected_headers
|
| 402 |
+
assert response_dict['body'] == b"{'foo':'bar'}"
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
def test_message_to_response_dict_error():
|
| 406 |
+
response_dict = ERROR_EVENT_MESSAGE[1].to_response_dict()
|
| 407 |
+
assert response_dict['status_code'] == 400
|
| 408 |
+
headers = {
|
| 409 |
+
':message-type': 'error',
|
| 410 |
+
':error-code': 'code',
|
| 411 |
+
':error-message': 'message',
|
| 412 |
+
}
|
| 413 |
+
assert response_dict['headers'] == headers
|
| 414 |
+
assert response_dict['body'] == b''
|
| 415 |
+
|
| 416 |
+
|
| 417 |
+
def test_unpack_uint8():
|
| 418 |
+
(value, bytes_consumed) = DecodeUtils.unpack_uint8(b'\xde')
|
| 419 |
+
assert bytes_consumed == 1
|
| 420 |
+
assert value == 0xDE
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
def test_unpack_uint32():
|
| 424 |
+
(value, bytes_consumed) = DecodeUtils.unpack_uint32(b'\xde\xad\xbe\xef')
|
| 425 |
+
assert bytes_consumed == 4
|
| 426 |
+
assert value == 0xDEADBEEF
|
| 427 |
+
|
| 428 |
+
|
| 429 |
+
def test_unpack_int8():
|
| 430 |
+
(value, bytes_consumed) = DecodeUtils.unpack_int8(b'\xfe')
|
| 431 |
+
assert bytes_consumed == 1
|
| 432 |
+
assert value == -2
|
| 433 |
+
|
| 434 |
+
|
| 435 |
+
def test_unpack_int16():
|
| 436 |
+
(value, bytes_consumed) = DecodeUtils.unpack_int16(b'\xff\xfe')
|
| 437 |
+
assert bytes_consumed == 2
|
| 438 |
+
assert value == -2
|
| 439 |
+
|
| 440 |
+
|
| 441 |
+
def test_unpack_int32():
|
| 442 |
+
(value, bytes_consumed) = DecodeUtils.unpack_int32(b'\xff\xff\xff\xfe')
|
| 443 |
+
assert bytes_consumed == 4
|
| 444 |
+
assert value == -2
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
def test_unpack_int64():
|
| 448 |
+
test_bytes = b'\xff\xff\xff\xff\xff\xff\xff\xfe'
|
| 449 |
+
(value, bytes_consumed) = DecodeUtils.unpack_int64(test_bytes)
|
| 450 |
+
assert bytes_consumed == 8
|
| 451 |
+
assert value == -2
|
| 452 |
+
|
| 453 |
+
|
| 454 |
+
def test_unpack_array_short():
|
| 455 |
+
test_bytes = b'\x00\x10application/json'
|
| 456 |
+
(value, bytes_consumed) = DecodeUtils.unpack_byte_array(test_bytes)
|
| 457 |
+
assert bytes_consumed == 18
|
| 458 |
+
assert value == b'application/json'
|
| 459 |
+
|
| 460 |
+
|
| 461 |
+
def test_unpack_byte_array_int():
|
| 462 |
+
(value, array_bytes_consumed) = DecodeUtils.unpack_byte_array(
|
| 463 |
+
b'\x00\x00\x00\x10application/json', length_byte_size=4
|
| 464 |
+
)
|
| 465 |
+
assert array_bytes_consumed == 20
|
| 466 |
+
assert value == b'application/json'
|
| 467 |
+
|
| 468 |
+
|
| 469 |
+
def test_unpack_utf8_string():
|
| 470 |
+
length = b'\x00\x09'
|
| 471 |
+
utf8_string = b'\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e'
|
| 472 |
+
encoded = length + utf8_string
|
| 473 |
+
(value, bytes_consumed) = DecodeUtils.unpack_utf8_string(encoded)
|
| 474 |
+
assert bytes_consumed == 11
|
| 475 |
+
assert value == utf8_string.decode('utf-8')
|
| 476 |
+
|
| 477 |
+
|
| 478 |
+
def test_unpack_prelude():
|
| 479 |
+
data = b'\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03'
|
| 480 |
+
prelude = DecodeUtils.unpack_prelude(data)
|
| 481 |
+
assert prelude == ((1, 2, 3), 12)
|
| 482 |
+
|
| 483 |
+
|
| 484 |
+
def create_mock_raw_stream(*data):
|
| 485 |
+
raw_stream = mock.Mock()
|
| 486 |
+
|
| 487 |
+
def generator():
|
| 488 |
+
yield from data
|
| 489 |
+
|
| 490 |
+
raw_stream.stream = generator
|
| 491 |
+
return raw_stream
|
| 492 |
+
|
| 493 |
+
|
| 494 |
+
def test_event_stream_wrapper_iteration():
|
| 495 |
+
raw_stream = create_mock_raw_stream(
|
| 496 |
+
b"\x00\x00\x00+\x00\x00\x00\x0e4\x8b\xec{\x08event-id\x04\x00",
|
| 497 |
+
b"\x00\xa0\x0c{'foo':'bar'}\xd3\x89\x02\x85",
|
| 498 |
+
)
|
| 499 |
+
parser = mock.Mock(spec=EventStreamXMLParser)
|
| 500 |
+
output_shape = mock.Mock()
|
| 501 |
+
event_stream = EventStream(raw_stream, output_shape, parser, '')
|
| 502 |
+
events = list(event_stream)
|
| 503 |
+
assert len(events) == 1
|
| 504 |
+
|
| 505 |
+
response_dict = {
|
| 506 |
+
'headers': {'event-id': 0x0000A00C},
|
| 507 |
+
'body': b"{'foo':'bar'}",
|
| 508 |
+
'status_code': 200,
|
| 509 |
+
}
|
| 510 |
+
parser.parse.assert_called_with(response_dict, output_shape)
|
| 511 |
+
|
| 512 |
+
|
| 513 |
+
def test_eventstream_wrapper_iteration_error():
|
| 514 |
+
raw_stream = create_mock_raw_stream(ERROR_EVENT_MESSAGE[0])
|
| 515 |
+
parser = mock.Mock(spec=EventStreamXMLParser)
|
| 516 |
+
parser.parse.return_value = {}
|
| 517 |
+
output_shape = mock.Mock()
|
| 518 |
+
event_stream = EventStream(raw_stream, output_shape, parser, '')
|
| 519 |
+
with pytest.raises(EventStreamError):
|
| 520 |
+
list(event_stream)
|
| 521 |
+
|
| 522 |
+
|
| 523 |
+
def test_event_stream_wrapper_close():
|
| 524 |
+
raw_stream = mock.Mock()
|
| 525 |
+
event_stream = EventStream(raw_stream, None, None, '')
|
| 526 |
+
event_stream.close()
|
| 527 |
+
raw_stream.close.assert_called_once_with()
|
| 528 |
+
|
| 529 |
+
|
| 530 |
+
def test_event_stream_initial_response():
|
| 531 |
+
raw_stream = create_mock_raw_stream(
|
| 532 |
+
b'\x00\x00\x00~\x00\x00\x00O\xc5\xa3\xdd\xc6\r:message-type\x07\x00',
|
| 533 |
+
b'\x05event\x0b:event-type\x07\x00\x10initial-response\r:content-type',
|
| 534 |
+
b'\x07\x00\ttext/json{"InitialResponse": "sometext"}\xf6\x98$\x83',
|
| 535 |
+
)
|
| 536 |
+
parser = mock.Mock(spec=EventStreamXMLParser)
|
| 537 |
+
output_shape = mock.Mock()
|
| 538 |
+
event_stream = EventStream(raw_stream, output_shape, parser, '')
|
| 539 |
+
event = event_stream.get_initial_response()
|
| 540 |
+
headers = {
|
| 541 |
+
':message-type': 'event',
|
| 542 |
+
':event-type': 'initial-response',
|
| 543 |
+
':content-type': 'text/json',
|
| 544 |
+
}
|
| 545 |
+
payload = b'{"InitialResponse": "sometext"}'
|
| 546 |
+
assert event.headers == headers
|
| 547 |
+
assert event.payload == payload
|
| 548 |
+
|
| 549 |
+
|
| 550 |
+
def test_event_stream_initial_response_wrong_type():
|
| 551 |
+
raw_stream = create_mock_raw_stream(
|
| 552 |
+
b"\x00\x00\x00+\x00\x00\x00\x0e4\x8b\xec{\x08event-id\x04\x00",
|
| 553 |
+
b"\x00\xa0\x0c{'foo':'bar'}\xd3\x89\x02\x85",
|
| 554 |
+
)
|
| 555 |
+
parser = mock.Mock(spec=EventStreamXMLParser)
|
| 556 |
+
output_shape = mock.Mock()
|
| 557 |
+
event_stream = EventStream(raw_stream, output_shape, parser, '')
|
| 558 |
+
with pytest.raises(NoInitialResponseError):
|
| 559 |
+
event_stream.get_initial_response()
|
| 560 |
+
|
| 561 |
+
|
| 562 |
+
def test_event_stream_initial_response_no_event():
|
| 563 |
+
raw_stream = create_mock_raw_stream(b'')
|
| 564 |
+
parser = mock.Mock(spec=EventStreamXMLParser)
|
| 565 |
+
output_shape = mock.Mock()
|
| 566 |
+
event_stream = EventStream(raw_stream, output_shape, parser, '')
|
| 567 |
+
with pytest.raises(NoInitialResponseError):
|
| 568 |
+
event_stream.get_initial_response()
|
testbed/boto__botocore/tests/unit/test_exceptions.py
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env
|
| 2 |
+
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
| 5 |
+
# may not use this file except in compliance with the License. A copy of
|
| 6 |
+
# the License is located at
|
| 7 |
+
#
|
| 8 |
+
# http://aws.amazon.com/apache2.0/
|
| 9 |
+
#
|
| 10 |
+
# or in the "license" file accompanying this file. This file is
|
| 11 |
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
| 12 |
+
# ANY KIND, either express or implied. See the License for the specific
|
| 13 |
+
# language governing permissions and limitations under the License.
|
| 14 |
+
import pickle
|
| 15 |
+
|
| 16 |
+
import botocore.awsrequest
|
| 17 |
+
import botocore.session
|
| 18 |
+
from botocore import exceptions
|
| 19 |
+
from tests import unittest
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def test_client_error_can_handle_missing_code_or_message():
|
| 23 |
+
response = {'Error': {}}
|
| 24 |
+
expect = 'An error occurred (Unknown) when calling the blackhole operation: Unknown'
|
| 25 |
+
assert str(exceptions.ClientError(response, 'blackhole')) == expect
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def test_client_error_has_operation_name_set():
|
| 29 |
+
response = {'Error': {}}
|
| 30 |
+
exception = exceptions.ClientError(response, 'blackhole')
|
| 31 |
+
assert hasattr(exception, 'operation_name')
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def test_client_error_set_correct_operation_name():
|
| 35 |
+
response = {'Error': {}}
|
| 36 |
+
exception = exceptions.ClientError(response, 'blackhole')
|
| 37 |
+
assert exception.operation_name == 'blackhole'
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def test_retry_info_added_when_present():
|
| 41 |
+
response = {
|
| 42 |
+
'Error': {},
|
| 43 |
+
'ResponseMetadata': {
|
| 44 |
+
'MaxAttemptsReached': True,
|
| 45 |
+
'RetryAttempts': 3,
|
| 46 |
+
},
|
| 47 |
+
}
|
| 48 |
+
error_msg = str(exceptions.ClientError(response, 'operation'))
|
| 49 |
+
if '(reached max retries: 3)' not in error_msg:
|
| 50 |
+
raise AssertionError(
|
| 51 |
+
"retry information not inject into error " f"message: {error_msg}"
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def test_retry_info_not_added_if_retry_attempts_not_present():
|
| 56 |
+
response = {
|
| 57 |
+
'Error': {},
|
| 58 |
+
'ResponseMetadata': {
|
| 59 |
+
'MaxAttemptsReached': True,
|
| 60 |
+
},
|
| 61 |
+
}
|
| 62 |
+
# Because RetryAttempts is missing, retry info is not
|
| 63 |
+
# in the error message.
|
| 64 |
+
error_msg = str(exceptions.ClientError(response, 'operation'))
|
| 65 |
+
if 'max retries' in error_msg:
|
| 66 |
+
raise AssertionError(
|
| 67 |
+
"Retry information should not be in exception "
|
| 68 |
+
"message when retry attempts not in response "
|
| 69 |
+
f"metadata: {error_msg}"
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def test_can_handle_when_response_missing_error_key():
|
| 74 |
+
response = {
|
| 75 |
+
'ResponseMetadata': {
|
| 76 |
+
'HTTPHeaders': {},
|
| 77 |
+
'HTTPStatusCode': 503,
|
| 78 |
+
'MaxAttemptsReached': True,
|
| 79 |
+
'RetryAttempts': 4,
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
e = exceptions.ClientError(response, 'SomeOperation')
|
| 83 |
+
if 'An error occurred (Unknown)' not in str(e):
|
| 84 |
+
raise AssertionError(
|
| 85 |
+
"Error code should default to 'Unknown' "
|
| 86 |
+
f"when missing error response, instead got: {str(e)}"
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
class TestPickleExceptions(unittest.TestCase):
|
| 91 |
+
def test_single_kwarg_botocore_error(self):
|
| 92 |
+
exception = botocore.exceptions.DataNotFoundError(data_path='mypath')
|
| 93 |
+
unpickled_exception = pickle.loads(pickle.dumps(exception))
|
| 94 |
+
self.assertIsInstance(
|
| 95 |
+
unpickled_exception, botocore.exceptions.DataNotFoundError
|
| 96 |
+
)
|
| 97 |
+
self.assertEqual(str(unpickled_exception), str(exception))
|
| 98 |
+
self.assertEqual(unpickled_exception.kwargs, exception.kwargs)
|
| 99 |
+
|
| 100 |
+
def test_multiple_kwarg_botocore_error(self):
|
| 101 |
+
exception = botocore.exceptions.UnknownServiceError(
|
| 102 |
+
service_name='myservice', known_service_names=['s3']
|
| 103 |
+
)
|
| 104 |
+
unpickled_exception = pickle.loads(pickle.dumps(exception))
|
| 105 |
+
self.assertIsInstance(
|
| 106 |
+
unpickled_exception, botocore.exceptions.UnknownServiceError
|
| 107 |
+
)
|
| 108 |
+
self.assertEqual(str(unpickled_exception), str(exception))
|
| 109 |
+
self.assertEqual(unpickled_exception.kwargs, exception.kwargs)
|
| 110 |
+
|
| 111 |
+
def test_client_error(self):
|
| 112 |
+
exception = botocore.exceptions.ClientError(
|
| 113 |
+
error_response={
|
| 114 |
+
'Error': {'Code': 'MyCode', 'Message': 'MyMessage'}
|
| 115 |
+
},
|
| 116 |
+
operation_name='myoperation',
|
| 117 |
+
)
|
| 118 |
+
unpickled_exception = pickle.loads(pickle.dumps(exception))
|
| 119 |
+
self.assertIsInstance(
|
| 120 |
+
unpickled_exception, botocore.exceptions.ClientError
|
| 121 |
+
)
|
| 122 |
+
self.assertEqual(str(unpickled_exception), str(exception))
|
| 123 |
+
self.assertEqual(
|
| 124 |
+
unpickled_exception.operation_name, exception.operation_name
|
| 125 |
+
)
|
| 126 |
+
self.assertEqual(unpickled_exception.response, exception.response)
|
| 127 |
+
|
| 128 |
+
def test_dynamic_client_error(self):
|
| 129 |
+
session = botocore.session.Session()
|
| 130 |
+
client = session.create_client('s3', 'us-west-2')
|
| 131 |
+
exception = client.exceptions.NoSuchKey(
|
| 132 |
+
error_response={
|
| 133 |
+
'Error': {'Code': 'NoSuchKey', 'Message': 'Not Found'}
|
| 134 |
+
},
|
| 135 |
+
operation_name='myoperation',
|
| 136 |
+
)
|
| 137 |
+
unpickled_exception = pickle.loads(pickle.dumps(exception))
|
| 138 |
+
self.assertIsInstance(
|
| 139 |
+
unpickled_exception, botocore.exceptions.ClientError
|
| 140 |
+
)
|
| 141 |
+
self.assertEqual(str(unpickled_exception), str(exception))
|
| 142 |
+
self.assertEqual(
|
| 143 |
+
unpickled_exception.operation_name, exception.operation_name
|
| 144 |
+
)
|
| 145 |
+
self.assertEqual(unpickled_exception.response, exception.response)
|
| 146 |
+
|
| 147 |
+
def test_http_client_error(self):
|
| 148 |
+
exception = botocore.exceptions.HTTPClientError(
|
| 149 |
+
botocore.awsrequest.AWSRequest(),
|
| 150 |
+
botocore.awsrequest.AWSResponse(
|
| 151 |
+
url='https://foo.com', status_code=400, headers={}, raw=b''
|
| 152 |
+
),
|
| 153 |
+
error='error',
|
| 154 |
+
)
|
| 155 |
+
unpickled_exception = pickle.loads(pickle.dumps(exception))
|
| 156 |
+
self.assertIsInstance(
|
| 157 |
+
unpickled_exception, botocore.exceptions.HTTPClientError
|
| 158 |
+
)
|
| 159 |
+
self.assertEqual(str(unpickled_exception), str(exception))
|
| 160 |
+
self.assertEqual(unpickled_exception.kwargs, exception.kwargs)
|
| 161 |
+
# The request/response properties on the HTTPClientError do not have
|
| 162 |
+
# __eq__ defined so we want to make sure properties are at least
|
| 163 |
+
# of the expected type
|
| 164 |
+
self.assertIsInstance(
|
| 165 |
+
unpickled_exception.request, botocore.awsrequest.AWSRequest
|
| 166 |
+
)
|
| 167 |
+
self.assertIsInstance(
|
| 168 |
+
unpickled_exception.response, botocore.awsrequest.AWSResponse
|
| 169 |
+
)
|