• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Chaffelson / nipyapi / #2

25 Mar 2025 10:32AM UTC coverage: 69.867% (+69.9%) from 0.0%
#2

push

coveralls-python

web-flow
V022release (#384)

* Update history for release

* Bump version: 0.21.0 → 0.22.0

1 of 1 new or added line in 1 file covered. (100.0%)

1048 of 1500 relevant lines covered (69.87%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/nipyapi/config.py
1
# coding: utf-8
2

3
"""
4
A set of defaults and parameters used elsewhere in the project.
5
Also provides a handy link to the low-level client SDK configuration singleton
6
objects.
7
"""
8

9
from __future__ import absolute_import
1✔
10
import os
1✔
11
import ssl
1✔
12
import urllib3
1✔
13
from nipyapi.nifi import configuration as nifi_config
1✔
14
from nipyapi.registry import configuration as registry_config
1✔
15

16

17
# --- Default Host URLs -----
18
# Note that changing the default hosts below will not
19
# affect an API connection that's already running.
20
# You'll need to change the .api_client.host for that, and there is a
21
# convenience function for this in nipyapi.utils.set_endpoint
22

23
# Set Default Host for NiFi
24
default_host = "localhost"  # Default to localhost for release
1✔
25
#
26
nifi_config.host = os.getenv(
1✔
27
    "NIFI_API_ENDPOINT", "http://" + default_host + ":8080/nifi-api"
28
)
29
# Set Default Host for NiFi-Registry
30
registry_config.host = "http://" + default_host + ":18080/nifi-registry-api"
1✔
31

32
# ---  Project Root ------
33
# Is is helpful to have a reference to the root directory of the project
34
PROJECT_ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
1✔
35

36

37
# --- Task wait delays ------
38
# Set how fast to recheck for completion of a short running task in seconds
39
short_retry_delay = 0.5
1✔
40
# Set the max amount of time we will wait for a short running task to complete
41
# in seconds
42
short_max_wait = 3
1✔
43
# Long running task delay
44
long_retry_delay = 5
1✔
45
# and long max wait
46
long_max_wait = 120
1✔
47

48

49
# --- Object Filters ------
50
# This sets the mappings of where in the native datatype objects to find
51
# particularly useful fields, like UUID or NAME.
52
# This saves hunting them down all the damn time.
53
# The format is the string to be used in the identifier_type field, followed by
54
# a list of which parameters form a tree to that field.
55
# Note that 'id' is used for UUID by convention, but should not be confused
56
# with 'identity' in security contexts.
57
registered_filters = {
1✔
58
    'Bucket': {'id': ['identifier'], 'name': ['name']},
59
    'VersionedFlow': {'id': ['identifier'], 'name': ['name']},
60
    'FlowRegistryClientEntity': {'id': ['id'], 'name': ['component', 'name']},
61
    'ProcessGroupEntity': {'id': ['id'], 'name': ['status', 'name']},
62
    'DocumentedTypeDTO': {'bundle': ['bundle', 'artifact'],
63
                          'name': ['type'],
64
                          'tag': ['tags']},
65
    'ProcessorEntity': {'id': ['id'], 'name': ['status', 'name']},
66
    'User': {'identity': ['identity'], 'id': ['identifier']},
67
    'UserGroupEntity': {'identity': ['component', 'identity'], 'id': ['id']},
68
    'UserGroup': {'identity': ['identity'], 'id': ['identifier']},
69
    'UserEntity': {'identity': ['component', 'identity'], 'id': ['id']},
70
    'TemplateEntity': {'id': ['id'], 'name': ['template', 'name']},
71
    'ControllerServiceEntity': {'id': ['id'], 'name': ['component', 'name']},
72
    'ParameterContextEntity': {'id': ['id'], 'name': ['component', 'name']},
73
    'ReportingTaskEntity': {'id': ['id'], 'name': ['component', 'name']}
74
}
75

76

77
# --- Version Checking
78
# Method to check if we're compatible with the API endpoint
79
# NOT YET IMPLEMENTED
80
# If None, then no check has been done
81
# If True, then we have tested and there are no issues
82
# If False, then we believe we are incompatible
83
nifi_config.version_check = None
1✔
84
registry_config.version_check = None
1✔
85

86

87
# --- Simple Cache
88
# This is a simple session-wide insecure cache for certain slow calls to speed
89
# up subsequent requests. It is very stupid, so do not expect session handling,
90
# or on-demand refresh if not handled by the function itself
91
cache = {}
1✔
92

93

94
# --- Security Context
95
# This allows easy reference to a set of certificates for use in automation
96
# By default it points to our demo certs, change it for your environment
97
default_certs_path = os.path.join(PROJECT_ROOT_DIR, "demo/keys")
1✔
98
default_ssl_context = {
99
    "ca_file": os.path.join(default_certs_path, "localhost-ts.pem"),
100
    "client_cert_file": os.path.join(default_certs_path, "client-cert.pem"),
101
    "client_key_file": os.path.join(default_certs_path, "client-key.pem"),
102
    "client_key_password": "clientPassword",
103
}
104
# Identities and passwords to be used for service login if called for
105
default_nifi_username = "nobel"
1✔
106
default_nifi_password = "password"
107
default_registry_username = "nobel"
1✔
108
default_registry_password = "password"
109
# Identity to be used for mTLS authentication
110
default_mtls_identity = "CN=user1, OU=nifi"
1✔
111
# Identity to be used in the Registry Client Proxy setup
112
# If called for during policy setup, particularly bootstrap_policies
113
default_proxy_user = "CN=user1, OU=nifi"
1✔
114

115
# Auth handling
116
# If set, NiPyAPI will always include the Basic Authorization header
117
global_force_basic_auth = False
1✔
118
nifi_config.username = default_nifi_username
1✔
119
nifi_config.password = default_nifi_password
120
nifi_config.force_basic_auth = global_force_basic_auth
1✔
121
registry_config.username = default_registry_username
1✔
122
registry_config.password = default_registry_password
123
registry_config.force_basic_auth = global_force_basic_auth
1✔
124

125
# Set SSL Handling
126
# When operating with self signed certs, your log can fill up with
127
# unnecessary warnings
128
# Set to True by default, change to false if necessary
129
global_ssl_verify = True
1✔
130
disable_insecure_request_warnings = False
1✔
131

132
nifi_config.verify_ssl = global_ssl_verify
1✔
133
registry_config.verify_ssl = global_ssl_verify
1✔
134
if not global_ssl_verify or disable_insecure_request_warnings:
1✔
135
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
×
136

137
# Enforce no host checking when SSL context is disabled
138
global_ssl_host_check = False
1✔
139
if not global_ssl_host_check:
1✔
140
    nifi_config.ssl_context = ssl.create_default_context()
1✔
141
    nifi_config.ssl_context.check_hostname = False
1✔
142
    nifi_config.ssl_context.verify_mode = ssl.CERT_NONE
1✔
143

144
    registry_config.ssl_context = ssl.create_default_context()
1✔
145
    registry_config.ssl_context.check_hostname = False
1✔
146
    registry_config.ssl_context.verify_mode = ssl.CERT_NONE
1✔
147

148
if os.getenv("NIFI_CA_CERT") is not None:
1✔
149
    nifi_config.ssl_ca_cert = os.getenv("NIFI_CA_CERT")
×
150
    nifi_config.cert_file = os.getenv("NIFI_CLIENT_CERT")
×
151
    nifi_config.key_file = os.getenv("NIFI_CLIENT_KEY")
×
152

153
# --- Encoding
154
# URL Encoding bypass characters will not be encoded during submission
155
default_safe_chars = ""
1✔
156

157
# Default String Encoding
158
default_string_encoding = "utf8"
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc