Skip to content

Commit c7af549

Browse files
committed
[mw] Improve reading of data source credentials from environment vars
Before, the system would happily use empty credentials induced by CI when running from foreign repositories, where the GitHub secrets attached to the repository are not active, but the GHA workflow configuration still sets the environment variables - to empty values.
1 parent 22a2008 commit c7af549

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

patzilla/access/depatech/clientpool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def from_settings(datasource_settings):
4343

4444
@staticmethod
4545
def from_environment():
46+
if not os.environ["DEPATECH_API_USERNAME"] or not os.environ["DEPATECH_API_PASSWORD"]:
47+
raise KeyError("DEPATECH_API_USERNAME or DEPATECH_API_PASSWORD is empty")
4648
return {
4749
"api_username": os.environ["DEPATECH_API_USERNAME"],
4850
"api_password": os.environ["DEPATECH_API_PASSWORD"],

patzilla/access/epo/ops/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def from_settings(datasource_settings):
3838

3939
@staticmethod
4040
def from_environment():
41+
if not os.environ["OPS_API_CONSUMER_KEY"] or not os.environ["OPS_API_CONSUMER_SECRET"]:
42+
raise KeyError("OPS_API_CONSUMER_KEY or OPS_API_CONSUMER_SECRET is empty")
4143
return {
4244
"consumer_key": os.environ["OPS_API_CONSUMER_KEY"],
4345
"consumer_secret": os.environ["OPS_API_CONSUMER_SECRET"],

patzilla/access/ificlaims/clientpool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def from_settings(datasource_settings):
4646

4747
@staticmethod
4848
def from_environment():
49+
if not os.environ["IFICLAIMS_API_USERNAME"] or not os.environ["IFICLAIMS_API_PASSWORD"]:
50+
raise KeyError("IFICLAIMS_API_USERNAME or IFICLAIMS_API_PASSWORD is empty")
4951
return {
5052
"api_username": os.environ["IFICLAIMS_API_USERNAME"],
5153
"api_password": os.environ["IFICLAIMS_API_PASSWORD"],

patzilla/access/sip/clientpool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def from_settings(datasource_settings):
4646

4747
@staticmethod
4848
def from_environment():
49+
if not os.environ["SIP_API_USERNAME"] or not os.environ["SIP_API_PASSWORD"]:
50+
raise KeyError("SIP_API_USERNAME or SIP_API_PASSWORD is empty")
4951
return {
5052
"api_username": os.environ["SIP_API_USERNAME"],
5153
"api_password": os.environ["SIP_API_PASSWORD"],

0 commit comments

Comments
 (0)