Skip to content

Commit 9054fa9

Browse files
committed
chore(rename): rename noath and iam authenticators to camel case
1 parent e89e1a1 commit 9054fa9

File tree

8 files changed

+37
-37
lines changed

8 files changed

+37
-37
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ This indicates that IAM token authentication is to be used. Users can pass in a
3838
```py
3939
from ibm_cloud_sdk_core.authenticators import IamAuthenticator
4040

41-
authenticator = IamAuthenticator(<your_apikey>)
41+
authenticator = IAMAuthenticator(<your_apikey>)
4242
```
4343

4444
### Cloud Pak for Data
@@ -63,9 +63,9 @@ authenticator = BearerTokenAuthenticator(<your_bearer_token>)
6363
This indicates that no authentication is needed when sending requests to the service
6464

6565
```py
66-
from ibm_cloud_sdk_core.authenticators import NoauthAuthenticator
66+
from ibm_cloud_sdk_core.authenticators import NoAuthAuthenticator
6767

68-
authenticator = NoauthAuthenticator()
68+
authenticator = NoAuthAuthenticator()
6969
```
7070

7171
## Issues

ibm_cloud_sdk_core/authenticators/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
from .basic_authenticator import BasicAuthenticator
1919
from .bearer_token_authenticator import BearerTokenAuthenticator
2020
from .cp4d_authenticator import CloudPakForDataAuthenticator
21-
from .iam_authenticator import IamAuthenticator
22-
from .no_auth_authenticator import NoauthAuthenticator
21+
from .iam_authenticator import IAMAuthenticator
22+
from .no_auth_authenticator import NoAuthAuthenticator

ibm_cloud_sdk_core/authenticators/iam_authenticator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from ..utils import has_bad_first_or_last_char
2020

2121

22-
class IamAuthenticator(Authenticator):
22+
class IAMAuthenticator(Authenticator):
2323
authentication_type = 'iam'
2424

2525
def __init__(self,

ibm_cloud_sdk_core/authenticators/no_auth_authenticator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from .authenticator import Authenticator
1818

19-
class NoauthAuthenticator(Authenticator):
19+
class NoAuthAuthenticator(Authenticator):
2020
authentication_type = 'noauth'
2121

2222
def validate(self):

ibm_cloud_sdk_core/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def read_from_vcap_services(service_name):
150150
def contruct_authenticator(config):
151151
auth_type = config.get('auth_type') if config.get('auth_type') else 'iam'
152152
authenticator = None
153-
from .authenticators import BasicAuthenticator, BearerTokenAuthenticator, CloudPakForDataAuthenticator, IamAuthenticator, NoauthAuthenticator
153+
from .authenticators import BasicAuthenticator, BearerTokenAuthenticator, CloudPakForDataAuthenticator, IAMAuthenticator, NoAuthAuthenticator
154154

155155
if auth_type == 'basic':
156156
authenticator = BasicAuthenticator(
@@ -166,13 +166,13 @@ def contruct_authenticator(config):
166166
url=config.get('auth_url'),
167167
disable_ssl_verification=config.get('auth_disable_ssl'))
168168
elif auth_type == 'iam' and config.get('apikey'):
169-
authenticator = IamAuthenticator(
169+
authenticator = IAMAuthenticator(
170170
apikey=config.get('apikey'),
171171
url=config.get('auth_url'),
172172
client_id=config.get('client_id'),
173173
client_secret=config.get('client_secret'),
174174
disable_ssl_verification=config.get('auth_disable_ssl'))
175175
elif auth_type == 'noauth':
176-
authenticator = NoauthAuthenticator()
176+
authenticator = NoAuthAuthenticator()
177177

178178
return authenticator

test/test_base_service.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ibm_cloud_sdk_core import BaseService
99
from ibm_cloud_sdk_core import ApiException
1010
from ibm_cloud_sdk_core import CP4DTokenManager
11-
from ibm_cloud_sdk_core.authenticators import IamAuthenticator, NoauthAuthenticator, Authenticator, BasicAuthenticator, CloudPakForDataAuthenticator
11+
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator, NoAuthAuthenticator, Authenticator, BasicAuthenticator, CloudPakForDataAuthenticator
1212

1313

1414
class AnyServiceV1(BaseService):
@@ -81,7 +81,7 @@ def get_access_token():
8181

8282
@responses.activate
8383
def test_url_encoding():
84-
service = AnyServiceV1('2017-07-07', authenticator=NoauthAuthenticator())
84+
service = AnyServiceV1('2017-07-07', authenticator=NoAuthAuthenticator())
8585

8686
# All characters in path0 _must_ be encoded in path segments
8787
path0 = ' \"<>^`{}|/\\?#%[]'
@@ -112,7 +112,7 @@ def test_url_encoding():
112112

113113
@responses.activate
114114
def test_http_config():
115-
service = AnyServiceV1('2017-07-07', authenticator=NoauthAuthenticator())
115+
service = AnyServiceV1('2017-07-07', authenticator=NoAuthAuthenticator())
116116
responses.add(
117117
responses.GET,
118118
service.default_url,
@@ -128,14 +128,14 @@ def test_http_config():
128128

129129

130130
def test_fail_http_config():
131-
service = AnyServiceV1('2017-07-07', authenticator=NoauthAuthenticator())
131+
service = AnyServiceV1('2017-07-07', authenticator=NoAuthAuthenticator())
132132
with pytest.raises(TypeError):
133133
service.with_http_config(None)
134134

135135

136136
@responses.activate
137137
def test_iam():
138-
iam_authenticator = IamAuthenticator('my_apikey', 'https://iam-test.cloud.ibm.com/identity/token')
138+
iam_authenticator = IAMAuthenticator('my_apikey', 'https://iam-test.cloud.ibm.com/identity/token')
139139
file_path = os.path.join(
140140
os.path.dirname(__file__), '../resources/ibm-credentials-iam.env')
141141
os.environ['IBM_CREDENTIALS_FILE'] = file_path
@@ -179,7 +179,7 @@ def __init__(self):
179179
AnyServiceV1('2017-07-07', authenticator=MadeUp())
180180
assert str(err.value) == 'authenticator should be of type Authenticator'
181181

182-
service = AnyServiceV1('2017-07-07', authenticator=NoauthAuthenticator())
182+
service = AnyServiceV1('2017-07-07', authenticator=NoAuthAuthenticator())
183183
assert service.authenticator is not None
184184
assert isinstance(service.authenticator, Authenticator)
185185

@@ -196,7 +196,7 @@ def test_for_cp4d():
196196

197197

198198
def test_disable_ssl_verification():
199-
service1 = AnyServiceV1('2017-07-07', authenticator=NoauthAuthenticator(), disable_ssl_verification=True)
199+
service1 = AnyServiceV1('2017-07-07', authenticator=NoAuthAuthenticator(), disable_ssl_verification=True)
200200
assert service1.disable_ssl_verification is True
201201

202202
service1.set_disable_ssl_verification(False)
@@ -212,7 +212,7 @@ def test_disable_ssl_verification():
212212

213213
@responses.activate
214214
def test_http_head():
215-
service = AnyServiceV1('2018-11-20', authenticator=NoauthAuthenticator())
215+
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
216216
expectedHeaders = {'Test-Header1': 'value1', 'Test-Header2': 'value2'}
217217
responses.add(
218218
responses.HEAD,
@@ -230,7 +230,7 @@ def test_http_head():
230230

231231
@responses.activate
232232
def test_response_with_no_body():
233-
service = AnyServiceV1('2018-11-20', authenticator=NoauthAuthenticator())
233+
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
234234
responses.add(responses.GET, service.default_url, status=200, body=None)
235235

236236
response = service.any_service_call()
@@ -257,7 +257,7 @@ def test_request_server_error():
257257
'error': 'internal server error'
258258
}),
259259
content_type='application/json')
260-
service = AnyServiceV1('2018-11-20', authenticator=NoauthAuthenticator())
260+
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
261261
try:
262262
prepped = service.prepare_request('GET', url='')
263263
service.send(prepped)
@@ -274,7 +274,7 @@ def test_request_success_json():
274274
'foo': 'bar'
275275
}),
276276
content_type='application/json')
277-
service = AnyServiceV1('2018-11-20', authenticator=NoauthAuthenticator())
277+
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
278278
prepped = service.prepare_request('GET', url='')
279279
detailed_response = service.send(prepped)
280280
assert detailed_response.get_result() == {'foo': 'bar'}
@@ -296,7 +296,7 @@ def test_request_success_response():
296296
'foo': 'bar'
297297
}),
298298
content_type='application/json')
299-
service = AnyServiceV1('2018-11-20', authenticator=NoauthAuthenticator())
299+
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
300300
prepped = service.prepare_request('GET', url='')
301301
detailed_response = service.send(prepped)
302302
assert detailed_response.get_result() == {"foo": "bar"}
@@ -311,7 +311,7 @@ def test_request_fail_401():
311311
'foo': 'bar'
312312
}),
313313
content_type='application/json')
314-
service = AnyServiceV1('2018-11-20', authenticator=NoauthAuthenticator())
314+
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
315315
try:
316316
prepped = service.prepare_request('GET', url='')
317317
service.send(prepped)
@@ -339,7 +339,7 @@ def _from_dict(cls, _dict):
339339
return cls(**args)
340340

341341
mock = MockModel('foo')
342-
service = AnyServiceV1('2018-11-20', authenticator=NoauthAuthenticator())
342+
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
343343
model1 = service._convert_model(mock)
344344
assert model1 == {'x': 'foo'}
345345

@@ -352,14 +352,14 @@ def _from_dict(cls, _dict):
352352
assert res_str == 'default,123'
353353

354354
def test_default_headers():
355-
service = AnyServiceV1('2018-11-20', authenticator=NoauthAuthenticator())
355+
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
356356
service.set_default_headers({'xxx': 'yyy'})
357357
assert service.default_headers == {'xxx': 'yyy'}
358358
with pytest.raises(TypeError):
359359
service.set_default_headers('xxx')
360360

361361
def test_set_url():
362-
service = AnyServiceV1('2018-11-20', authenticator=NoauthAuthenticator())
362+
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
363363
with pytest.raises(ValueError) as err:
364364
service.set_url('{url}')
365365
assert str(err.value) == 'The url shouldn\'t start or end with curly brackets or quotes. Be sure to remove any {} and \" characters surrounding your url'
@@ -373,7 +373,7 @@ def test_get_authenticator():
373373

374374
@responses.activate
375375
def test_user_agent_header():
376-
service = AnyServiceV1('2018-11-20', authenticator=NoauthAuthenticator())
376+
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
377377
user_agent_header = service.user_agent_header
378378
assert user_agent_header is not None
379379
assert user_agent_header['User-Agent'] is not None
@@ -397,7 +397,7 @@ def test_user_agent_header():
397397

398398
@responses.activate
399399
def test_files():
400-
service = AnyServiceV1('2018-11-20', authenticator=NoauthAuthenticator())
400+
service = AnyServiceV1('2018-11-20', authenticator=NoAuthAuthenticator())
401401

402402
responses.add(
403403
responses.GET,

test/test_iam_authenticator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import time
44
import jwt
55
import json
6-
from ibm_cloud_sdk_core.authenticators import IamAuthenticator
6+
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
77

88

99
def test_iam_authenticator():
10-
authenticator = IamAuthenticator('my_apikey')
10+
authenticator = IAMAuthenticator('my_apikey')
1111
assert authenticator is not None
1212
assert authenticator.token_manager.url == 'https://iam.cloud.ibm.com/identity/token'
1313
assert authenticator.token_manager.client_id is None
@@ -38,22 +38,22 @@ def test_iam_authenticator():
3838

3939
def test_iam_authenticator_validate_failed():
4040
with pytest.raises(ValueError) as err:
41-
IamAuthenticator(None)
41+
IAMAuthenticator(None)
4242
assert str(err.value) == 'The apikey shouldn\'t be None.'
4343

4444
with pytest.raises(ValueError) as err:
45-
IamAuthenticator('{apikey}')
45+
IAMAuthenticator('{apikey}')
4646
assert str(
4747
err.value
4848
) == 'The apikey shouldn\'t start or end with curly brackets or quotes. Please remove any surrounding {, }, or \" characters.'
4949

5050
with pytest.raises(ValueError) as err:
51-
IamAuthenticator('my_apikey', client_id='my_client_id')
51+
IAMAuthenticator('my_apikey', client_id='my_client_id')
5252
assert str(
5353
err.value) == 'Both client id and client secret should be initialized.'
5454

5555
with pytest.raises(ValueError) as err:
56-
IamAuthenticator('my_apikey', client_secret='my_client_secret')
56+
IAMAuthenticator('my_apikey', client_secret='my_client_secret')
5757
assert str(
5858
err.value) == 'Both client id and client secret should be initialized.'
5959

@@ -91,7 +91,7 @@ def test_get_token():
9191
responses.add(
9292
responses.POST, url=url, body=json.dumps(response), status=200)
9393

94-
authenticator = IamAuthenticator('my_apikey')
94+
authenticator = IAMAuthenticator('my_apikey')
9595
request = {'headers': {}}
9696
authenticator.authenticate(request)
9797
assert request['headers']['Authorization'] is not None

test/test_no_auth_authenticator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import time
44
import jwt
55
import json
6-
from ibm_cloud_sdk_core.authenticators import NoauthAuthenticator
6+
from ibm_cloud_sdk_core.authenticators import NoAuthAuthenticator
77

88
def test_no_auth_authenticator():
9-
authenticator = NoauthAuthenticator()
9+
authenticator = NoAuthAuthenticator()
1010
assert authenticator is not None
1111
assert authenticator.authentication_type == 'noauth'
1212

0 commit comments

Comments
 (0)