@@ -136,13 +136,30 @@ def test_get_authenticator_from_credential_file():
136
136
assert authenticator .bearer_token is not None
137
137
del os .environ ['IBM_CREDENTIALS_FILE' ]
138
138
139
+ file_path = os .path .join (
140
+ os .path .dirname (__file__ ), '../resources/ibm-credentials.env' )
141
+ os .environ ['IBM_CREDENTIALS_FILE' ] = file_path
142
+ authenticator = get_authenticator_from_environment ('service_1' )
143
+ assert authenticator is not None
144
+ assert authenticator .token_manager .apikey == 'V4HXmoUtMjohnsnow=KotN'
145
+ assert authenticator .token_manager .client_id == 'somefake========id'
146
+ assert authenticator .token_manager .client_secret == '==my-client-secret=='
147
+ assert authenticator .token_manager .url == 'https://iamhost/iam/api='
148
+ del os .environ ['IBM_CREDENTIALS_FILE' ]
149
+
139
150
def test_get_authenticator_from_env_variables ():
140
151
os .environ ['TEST_APIKEY' ] = '5678efgh'
141
152
authenticator = get_authenticator_from_environment ('test' )
142
153
assert authenticator is not None
143
154
assert authenticator .token_manager .apikey == '5678efgh'
144
155
del os .environ ['TEST_APIKEY' ]
145
156
157
+ os .environ ['SERVICE_1_APIKEY' ] = 'V4HXmoUtMjohnsnow=KotN'
158
+ authenticator = get_authenticator_from_environment ('service_1' )
159
+ assert authenticator is not None
160
+ assert authenticator .token_manager .apikey == 'V4HXmoUtMjohnsnow=KotN'
161
+ del os .environ ['SERVICE_1_APIKEY' ]
162
+
146
163
def test_vcap_credentials ():
147
164
vcap_services = '{"test":[{"credentials":{ \
148
165
"url":"https://gateway.watsonplatform.net/compare-comply/api",\
@@ -205,13 +222,26 @@ def test_vcap_credentials_2():
205
222
"credentials":{ \
206
223
"url":"https://gateway.watsonplatform.net/compare-comply/api",\
207
224
"username":"bogus username", \
208
- "password":"bogus password"}}]}'
225
+ "password":"bogus password"}}],\
226
+ "equals_sign_test":[{"name": "equals_sign_test",\
227
+ "credentials":{ \
228
+ "iam_apikey": "V4HXmoUtMjohnsnow=KotN",\
229
+ "iam_apikey_description": "Auto generated apikey...",\
230
+ "iam_apikey_name": "auto-generated-apikey-111-222-333",\
231
+ "iam_role_crn": "crn:v1:bluemix:public:iam::::serviceRole:Manager",\
232
+ "iam_serviceid_crn": "crn:v1:staging:public:iam-identity::a/::serviceid:ServiceID-1234",\
233
+ "url": "https://gateway.watsonplatform.net/testService",\
234
+ "auth_url": "https://iamhost/iam/api="}}]}'
209
235
210
236
os .environ ['VCAP_SERVICES' ] = vcap_services
211
237
authenticator = get_authenticator_from_environment ('testname' )
212
238
assert isinstance (authenticator , BasicAuthenticator )
213
239
assert authenticator .username == 'bogus username2'
214
240
assert authenticator .password == 'bogus password2'
241
+
242
+ authenticator = get_authenticator_from_environment ('equals_sign_test' )
243
+ assert isinstance (authenticator , IAMAuthenticator )
244
+ assert authenticator .token_manager .apikey == 'V4HXmoUtMjohnsnow=KotN'
215
245
del os .environ ['VCAP_SERVICES' ]
216
246
217
247
vcap_services = '{"test":[{\
0 commit comments