fix: friendly labels as args (including wildcards) #204
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The intention of this PR is to allow the ability to supply idp and role friendly labels as args. The current implementation works if you select the idp and role interactively but when supplied as args fails as it tries to use the friendly label for the idp and the configured wildcard matcher for role.
For example you might get the error (note the friendly label for IDP and role attempting to be used)
Error: STS Assume Role With SAML API error; given idp: "My IdP", role: "arn:aws:iam::.*:role/never", error: InvalidParameter: 1 validation error(s) found.
In my first commit here I moved calling OktaConfig() up a level to promptForIdpAndRole so we could pass the config as args to the individual idp and role functions. I wrote some tests that demonstrate the issue so if you check that out you can see the test results which i'll post here a the end as well.
In order to simplify the logic I refactored the methods so that there are no string variables that may be an ARN, maybe a friendly label, or may be a configured arn with a wildcard. The common denominator here is the friendly label so all logic now chooses the friendly label then converts to the arn using the same map the prompt would use. This is safe when no friendly labels are configured as the map defaults to using the arn as the key if no friendly label is found.
The one area i'd like to call out specifically is the else-if block on the prompts where we may pretty print the selection. These are decided off the
fedAppAlreadySelected
orIsProcessCredentialsFormat
properties. It wasn't immediately obvious to me what these use cases are so would appreciate some help with the comments there.Test results prior to fix: