Skip to content

Commit 3e34733

Browse files
tox fixes
1 parent 8aa6511 commit 3e34733

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

SoftLayer/API.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ def authenticate_with_password(self, username, password, security_question_id=No
405405
error = json.loads(response.text)
406406
raise exceptions.IAMError(response.status_code,
407407
error.get('errorMessage'),
408-
'https://iam.cloud.ibm.com/identity/token')
408+
'https://iam.cloud.ibm.com/identity/token') from ex
409409

410410
self.settings['softlayer']['access_token'] = tokens['access_token']
411411
self.settings['softlayer']['refresh_token'] = tokens['refresh_token']
@@ -452,7 +452,7 @@ def authenticate_with_passcode(self, passcode):
452452
error = json.loads(response.text)
453453
raise exceptions.IAMError(response.status_code,
454454
error.get('errorMessage'),
455-
'https://iam.cloud.ibm.com/identity/token')
455+
'https://iam.cloud.ibm.com/identity/token') from ex
456456

457457
self.settings['softlayer']['access_token'] = tokens['access_token']
458458
self.settings['softlayer']['refresh_token'] = tokens['refresh_token']
@@ -516,7 +516,7 @@ def refresh_iam_token(self, r_token, account_id=None, ims_account=None):
516516
error = json.loads(response.text)
517517
raise exceptions.IAMError(response.status_code,
518518
error.get('errorMessage'),
519-
'https://iam.cloud.ibm.com/identity/token')
519+
'https://iam.cloud.ibm.com/identity/token') from ex
520520

521521
a_expire = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(tokens['expiration']))
522522
r_expire = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(tokens['refresh_token_expiration']))

SoftLayer/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ def get_config(config_file=None):
102102
config_file = '~/.softlayer'
103103
config = configparser.ConfigParser()
104104
config.read(os.path.expanduser(config_file))
105+
# No configuration file found.
106+
if not config.has_section('softlayer'):
107+
config.add_section('softlayer')
108+
config['softlayer']['username'] = ''
109+
config['softlayer']['endpoint_url'] = ''
110+
config['softlayer']['api_key'] = ''
111+
config['softlayer']['timeout'] = 0
112+
105113
return config
106114

107115

SoftLayer/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class SoftLayerError(Exception):
1515
class Unauthenticated(SoftLayerError):
1616
"""Unauthenticated."""
1717

18+
1819
class IAMError(SoftLayerError):
1920
"""Errors from iam.cloud.ibm.com"""
2021

tests/CLI/modules/config_tests.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,11 @@ def test_sso_login(self, api_call, token, passcode, get_accounts, get_sso_url, m
165165
token.return_value = {"access_token": "zzzzzz", "refresh_token": "fffffff"}
166166
test_key = "zz112233"
167167
user_object_1 = {
168-
"apiAuthenticationKeys": [{"authenticationKey":test_key}],
169-
"username":"testerson",
170-
"id":99}
168+
"apiAuthenticationKeys": [{"authenticationKey": test_key}],
169+
"username": "testerson",
170+
"id": 99}
171171
api_call.side_effect = [user_object_1]
172172

173173
user, apikey = config.sso_login(self.env)
174174
self.assertEqual("testerson", user)
175175
self.assertEqual(test_key, apikey)
176-

0 commit comments

Comments
 (0)