Skip to content

Commit 481f59e

Browse files
committed
chore: use temporary IAM authenticator to validate our IAM delegate
Signed-off-by: Norbert Biczo <[email protected]>
1 parent a35431e commit 481f59e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

ibm_cloud_sdk_core/authenticators/iam_assume_authenticator.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from typing import Any, Dict, Optional
1818

19+
from ibm_cloud_sdk_core.authenticators.iam_authenticator import IAMAuthenticator
1920
from ibm_cloud_sdk_core.token_managers.iam_assume_token_manager import IAMAssumeTokenManager
2021

2122
from .authenticator import Authenticator
@@ -127,14 +128,11 @@ def validate(self) -> None:
127128
"""
128129
super().validate()
129130

130-
if self.token_manager.iam_delegate.apikey is None:
131-
raise ValueError('The apikey shouldn\'t be None.')
132-
133-
if has_bad_first_or_last_char(self.token_manager.iam_delegate.apikey):
134-
raise ValueError(
135-
'The apikey shouldn\'t start or end with curly brackets or quotes. '
136-
'Please remove any surrounding {, }, or \" characters.'
137-
)
131+
# Create a temporary IAM authenticator that we can use to validat our delegate.
132+
tmp_authenticator = IAMAuthenticator("")
133+
tmp_authenticator.token_manager = self.token_manager.iam_delegate
134+
tmp_authenticator.validate()
135+
del tmp_authenticator
138136

139137
# Only one of the following arguments must be specified.
140138
mutually_exclusive_attributes = [

0 commit comments

Comments
 (0)