Skip to content

Commit

Permalink
Split credentials for test and prod datacite
Browse files Browse the repository at this point in the history
  • Loading branch information
BenGalewsky committed Dec 21, 2023
1 parent 226691d commit b86a363
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
14 changes: 10 additions & 4 deletions aws/automate_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def authorizer_callback(*args, **kwargs):

class AutomateManager:

def __init__(self, secrets):
def __init__(self, secrets: dict, is_test: bool = False):
# Globals needed for the authorizer_callback
global tokens, mdf_flow

Expand All @@ -45,9 +45,15 @@ def __init__(self, secrets):
self.api_client_id = secrets['API_CLIENT_ID']
self.api_client_secret = secrets['API_CLIENT_SECRET']

self.datacite_username = secrets['DATACITE_USERNAME']
self.datacite_password = secrets['DATACITE_PASSWORD']
self.datacite_prefix = secrets['DATACITE_PREFIX']
if not is_test:
self.datacite_username = secrets['DATACITE_USERNAME_PROD']
self.datacite_password = secrets['DATACITE_PASSWORD_PROD']
self.datacite_prefix = secrets['DATACITE_PREFIX_PROD']
else:
self.datacite_username = secrets['DATACITE_USERNAME_TEST']
self.datacite_password = secrets['DATACITE_PASSWORD_TEST']
self.datacite_prefix = secrets['DATACITE_PREFIX_TEST']


self.portal_url = os.environ.get('PORTAL_URL', None)

Expand Down
2 changes: 1 addition & 1 deletion aws/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def lambda_handler(event, context):
print("status info", status_info)

automate_manager = AutomateManager(get_secret(secret_name=os.environ['MDF_SECRETS_NAME'],
region_name=os.environ['MDF_AWS_REGION']))
region_name=os.environ['MDF_AWS_REGION']), is_test)
automate_manager.authenticate()

try:
Expand Down
9 changes: 6 additions & 3 deletions aws/tests/test_automate_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ def secrets(self):
"SES_SECRET": "shhh",
"API_CLIENT_ID": "55-321",
"API_CLIENT_SECRET": "hhhhs",
"DATACITE_USERNAME": "datacite_test_usrname_1234",
"DATACITE_PASSWORD": "datacite_test_passwrd_1234",
"DATACITE_PREFIX": "10.12345"
"DATACITE_USERNAME_PROD": "datacite_prod_usrname_1234",
"DATACITE_PASSWORD_PROD": "datacite_prod_passwrd_1234",
"DATACITE_PREFIX_PROD": "10.12345",
"DATACITE_USERNAME_TEST": "datacite_test_usrname_1234",
"DATACITE_PASSWORD_TEST": "datacite_test_passwrd_1234",
"DATACITE_PREFIX_TEST": "10.12347"
}


Expand Down

0 comments on commit b86a363

Please sign in to comment.