Skip to content

Commit

Permalink
Put logic deciding whether response needs auth into separate method
Browse files Browse the repository at this point in the history
  • Loading branch information
davedoesdev committed Nov 29, 2023
1 parent 67f861c commit 7439f20
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 37 deletions.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/_build/html/.buildinfo
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 3944fb644cff524c03880bf3672bb799
config: 1dda82f69b14a8da0e9d57865aac78f3
tags: 645f666f9bcd5a90fca523b33c5a78b7
2 changes: 1 addition & 1 deletion docs/_build/html/_static/documentation_options.js
@@ -1,5 +1,5 @@
const DOCUMENTATION_OPTIONS = {
VERSION: '11.3.0',
VERSION: '11.4.0',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
8 changes: 4 additions & 4 deletions docs/_build/html/genindex.html
Expand Up @@ -4,10 +4,10 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Index &#8212; python-dxf 11.3.0 documentation</title>
<title>Index &#8212; python-dxf 11.4.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/nature.css?v=601dbdee" />
<script src="_static/documentation_options.js?v=5c566949"></script>
<script src="_static/documentation_options.js?v=d20d9887"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="index" title="Index" href="#" />
Expand All @@ -22,7 +22,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">python-dxf 11.3.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">python-dxf 11.4.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Index</a></li>
</ul>
</div>
Expand Down Expand Up @@ -259,7 +259,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">python-dxf 11.3.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">python-dxf 11.4.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Index</a></li>
</ul>
</div>
Expand Down
8 changes: 4 additions & 4 deletions docs/_build/html/index.html
Expand Up @@ -5,10 +5,10 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>dxf module &#8212; python-dxf 11.3.0 documentation</title>
<title>dxf module &#8212; python-dxf 11.4.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/nature.css?v=601dbdee" />
<script src="_static/documentation_options.js?v=5c566949"></script>
<script src="_static/documentation_options.js?v=d20d9887"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="index" title="Index" href="genindex.html" />
Expand All @@ -23,7 +23,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="#">python-dxf 11.3.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="#">python-dxf 11.4.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">dxf module</a></li>
</ul>
</div>
Expand Down Expand Up @@ -695,7 +695,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="#">python-dxf 11.3.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="#">python-dxf 11.4.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">dxf module</a></li>
</ul>
</div>
Expand Down
Binary file modified docs/_build/html/objects.inv
Binary file not shown.
8 changes: 4 additions & 4 deletions docs/_build/html/py-modindex.html
Expand Up @@ -4,10 +4,10 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Python Module Index &#8212; python-dxf 11.3.0 documentation</title>
<title>Python Module Index &#8212; python-dxf 11.4.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/nature.css?v=601dbdee" />
<script src="_static/documentation_options.js?v=5c566949"></script>
<script src="_static/documentation_options.js?v=d20d9887"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="index" title="Index" href="genindex.html" />
Expand All @@ -25,7 +25,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="#" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">python-dxf 11.3.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">python-dxf 11.4.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Python Module Index</a></li>
</ul>
</div>
Expand Down Expand Up @@ -89,7 +89,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="#" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">python-dxf 11.3.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">python-dxf 11.4.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Python Module Index</a></li>
</ul>
</div>
Expand Down
8 changes: 4 additions & 4 deletions docs/_build/html/search.html
Expand Up @@ -4,11 +4,11 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Search &#8212; python-dxf 11.3.0 documentation</title>
<title>Search &#8212; python-dxf 11.4.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/nature.css?v=601dbdee" />

<script src="_static/documentation_options.js?v=5c566949"></script>
<script src="_static/documentation_options.js?v=d20d9887"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/searchtools.js"></script>
Expand All @@ -28,7 +28,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">python-dxf 11.3.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">python-dxf 11.4.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Search</a></li>
</ul>
</div>
Expand Down Expand Up @@ -88,7 +88,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">python-dxf 11.3.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">python-dxf 11.4.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Search</a></li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/searchindex.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/conf.py
Expand Up @@ -58,9 +58,9 @@
# built documents.
#
# The short X.Y version.
version = '11.3'
version = '11.4'
# The full version, including alpha/beta/rc tags.
release = '11.3.0'
release = '11.4.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
18 changes: 12 additions & 6 deletions dxf/__init__.py
Expand Up @@ -234,6 +234,17 @@ def make_kwargs():
_raise_for_status(r)
return r

def _response_needs_auth(self, response):
if response.ok:
return False

# pylint: disable=no-member
if response.status_code != requests.codes.unauthorized:
raise exceptions.DXFUnexpectedStatusCodeError(response.status_code,
requests.codes.unauthorized)

return True

def authenticate(self,
username: Optional[str]=None, password: Optional[str]=None,
actions: Optional[List[str]]=None, response: Optional[requests.Response]=None,
Expand Down Expand Up @@ -265,14 +276,9 @@ def authenticate(self,
verify=self._tlsverify,
timeout=self._timeout)

if response.ok:
if not self._response_needs_auth(response):
return None

# pylint: disable=no-member
if response.status_code != requests.codes.unauthorized:
raise exceptions.DXFUnexpectedStatusCodeError(response.status_code,
requests.codes.unauthorized)

if self._insecure:
raise exceptions.DXFAuthInsecureError()

Expand Down
16 changes: 8 additions & 8 deletions htmlcov/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion htmlcov/status.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -8,7 +8,7 @@ def read(name):

setup(
name='python-dxf',
version='11.3.0',
version='11.4.0',
description="Package for accessing a Docker v2 registry",
long_description=read('README.rst'),
keywords='docker registry',
Expand Down

0 comments on commit 7439f20

Please sign in to comment.