Skip to content

Commit f45d5a8

Browse files
committed
Minor fixes for NiFi 12.x matching release
Removed force reset of configuration.password and configuration.username to empty string. This was not increasing security, and was causing unexpected errors for users connecting to multiple services in a single script. Add greedy control to versioning.get_registry_bucket and versioning.get_flow_in_bucket to avoid undesirable partial string match. Update readme to reflect switch from 'master' branch naming to 'main'. Update tox to pin testing to Python 3.8, as Python 3.9 is producing unexpected and unrelated SSL failures Minor lint formatting improvements Signed-off-by: Daniel Chaffelson <[email protected]>
1 parent 292aa1e commit f45d5a8

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Nifi-Python-Api: A rich Apache NiFi Python Client SDK
1111
:target: https://pypi.python.org/pypi/nipyapi
1212
:alt: Release Status
1313

14-
.. image:: https://img.shields.io/travis/Chaffelson/nipyapi.svg
14+
.. image:: https://img.shields.io/travis/Chaffelson/nipyapi/main.svg
1515
:target: https://travis-ci.org/Chaffelson/nipyapi
1616
:alt: Build Status
1717

@@ -23,8 +23,8 @@ Nifi-Python-Api: A rich Apache NiFi Python Client SDK
2323
:target: https://pyup.io/repos/github/Chaffelson/nipyapi/
2424
:alt: Python Updates
2525

26-
.. image:: https://coveralls.io/repos/github/Chaffelson/nipyapi/badge.svg?branch=master
27-
:target: https://coveralls.io/github/Chaffelson/nipyapi?branch=master&service=github
26+
.. image:: https://coveralls.io/repos/github/Chaffelson/nipyapi/badge.svg?branch=main
27+
:target: https://coveralls.io/github/Chaffelson/nipyapi?branch=main&service=github
2828
:alt: test coverage
2929

3030
.. image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg

nipyapi/security.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,6 @@ def service_logout(service='nifi'):
395395
# Logout throws error with incorrect ssl setup
396396
else:
397397
raise e
398-
# Set to empty string and not None as basic auth setup will still
399-
# run even if not used
400-
getattr(nipyapi, service).configuration.password = ''
401-
getattr(nipyapi, service).configuration.username = ''
402398
if not status:
403399
return True
404400
return False

nipyapi/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,8 @@ def check_version(base, comparator=None, service='nifi'):
492492
if config.api_client is None:
493493
config.api_client = nipyapi.registry.ApiClient()
494494
reg_swagger_def = config.api_client.call_api(
495-
resource_path='/swagger/swagger.json', method='GET', _preload_content=False,
495+
resource_path='/swagger/swagger.json',
496+
method='GET', _preload_content=False,
496497
auth_settings=['tokenAuth', 'Authorization']
497498
)
498499
reg_json = load(reg_swagger_def[0].data)

nipyapi/versioning.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,23 @@ def delete_registry_bucket(bucket):
161161
_raise(ValueError(e), e)
162162

163163

164-
def get_registry_bucket(identifier, identifier_type='name'):
164+
def get_registry_bucket(identifier, identifier_type='name', greedy=True):
165165
"""
166166
Filters the Bucket list to a particular identifier
167167
168168
Args:
169169
identifier (str): the filter string
170170
identifier_type (str): the param to filter on
171+
greedy (bool): False for exact match, True for greedy match
171172
172173
Returns:
173174
None for no matches, Single Object for unique match,
174175
list(Objects) for multiple matches
175176
"""
176177
with nipyapi.utils.rest_exceptions():
177178
obj = list_registry_buckets()
178-
return nipyapi.utils.filter_obj(obj, identifier, identifier_type)
179+
return nipyapi.utils.filter_obj(
180+
obj, identifier, identifier_type, greedy=greedy)
179181

180182

181183
def list_flows_in_bucket(bucket_id):
@@ -192,22 +194,24 @@ def list_flows_in_bucket(bucket_id):
192194
return nipyapi.registry.BucketFlowsApi().get_flows(bucket_id)
193195

194196

195-
def get_flow_in_bucket(bucket_id, identifier, identifier_type='name'):
197+
def get_flow_in_bucket(bucket_id, identifier, identifier_type='name', greedy=True):
196198
"""
197199
Filters the Flows in a Bucket against a particular identifier
198200
199201
Args:
200202
bucket_id (str): UUID of the Bucket to filter against
201203
identifier (str): The string to filter on
202204
identifier_type (str): The param to check
205+
greedy (bool): False for exact match, True for greedy match
203206
204207
Returns:
205208
None for no matches, Single Object for unique match,
206209
list(Objects) for multiple matches
207210
"""
208211
with nipyapi.utils.rest_exceptions():
209212
obj = list_flows_in_bucket(bucket_id)
210-
return nipyapi.utils.filter_obj(obj, identifier, identifier_type)
213+
return nipyapi.utils.filter_obj(
214+
obj, identifier, identifier_type, greedy=greedy)
211215

212216

213217
def save_flow_ver(process_group, registry_client, bucket, flow_name=None,

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ envlist = py27, py3, flake8, lint
33

44
[travis]
55
python =
6-
3: py3
6+
3.8: py3
77
2.7: py27
88

99
[flake8]
@@ -34,7 +34,7 @@ omit =
3434
nipyapi/registry/*
3535
nipyapi/demo/*
3636
nipyapi/docs/*
37-
37+
3838
[testenv]
3939
setenv =
4040
PYTHONPATH = {toxinidir}

0 commit comments

Comments
 (0)