Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ing_lib/apps/ProjConfigCreateUpdateCS.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def parse_custom_script_xml(xml_file, base_path):

script_elem = script_elements[0]
script_name = script_elem.get("script_name")
is_command = script_elem.get('is_command')
is_command = script_elem.get('is_command', 'false').lower() == 'true' # Default to false if not provided
script_path = script_elem.get("script_path")
description = script_elem.get("description")
hash_value = script_elem.get("hash") # Get hash from XML if provided
Expand Down Expand Up @@ -763,7 +763,7 @@ def parse_custom_script_json(json_file, base_path):

def validate_script_data(script_data):
"""
Validate that a script data dictionary has all required fields
Validate that a script data dictionary has all required fields and valid values

Parameters
----------
Expand All @@ -779,6 +779,7 @@ def validate_script_data(script_data):

required_fields = ['script_name', 'script_path', 'description', 'script_id', 'is_command']

# Check for missing required fields
for field in required_fields:
if not script_data.get(field):
logger.error(f"Script data missing required field: {field}")
Expand Down
12 changes: 8 additions & 4 deletions ing_lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def ingenium_rest_get(endpoint):

# If needed, refresh the token
if _stale_token():
refresh_endpoint(_extact_server(endpoint), False)
refresh_auth(_extract_server(endpoint), False)

data = None

Expand Down Expand Up @@ -130,7 +130,7 @@ def ingenium_rest_get_paginated(endpoint, query_params={}):

# If needed, refresh the token
if _stale_token():
refresh_endpoint(_extact_server(endpoint), False)
refresh_auth(_extract_server(endpoint), False)

_INITIAL_LIMIT = 1000
_INITIAL_OFFSET = 0
Expand Down Expand Up @@ -352,6 +352,10 @@ def refresh_auth(server, force=False):

"""

refresh_time = get_refresh_time()
if refresh_time is None:
raise IngeniumLibError("Cannot refresh token: No refresh time available. Please authenticate first.")

token_time_remaining = (datetime.datetime.utcnow() - get_refresh_time()).total_seconds()

if force or _stale_token():
Expand All @@ -372,7 +376,7 @@ def refresh_auth(server, force=False):


if response_handler(refresh):
_store['token'] = f"Bearer {json.loads(logon.text)['access_token']}"
_store['token'] = f"Bearer {json.loads(refresh.text)['access_token']}"
_store['refresh_time'] = datetime.datetime.utcnow()
msg = f"Successfully refreshed token with: {server}"
logger.debug(msg)
Expand Down Expand Up @@ -415,6 +419,6 @@ def _stale_token():
return elapsed > _TOKEN_REFRESH_DURATION


def _extact_server(endpoint):
def _extract_server(endpoint):
parsed = urlparse(endpoint)
return f'{parsed.scheme}://{parsed.netloc}'
Loading