Repository navigation
Accept Robot Framework Secret values in connection and login keywords - #490
Open
boluwatifeajayi wants to merge 1 commit into
Open
boluwatifeajayi wants to merge 1 commit into
boluwatifeajayi wants to merge 1 commit into
Conversation
Open Connection (host), Login (username, password) and Login With Public
Key (username, keyfile, password) now unwrap robot.api.types.Secret
arguments, so users no longer have to pass ${PASSWORD.value} and expose
the value. Older Robot Framework versions without Secret are unaffected.
Fixes MarketSquare#486
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #486.
Robot Framework 7.4 added
robot.api.types.Secret. SSHLibrary passed these objects straight to paramiko, soOpen Connection ${HOST}with a secret host tried to resolve the string form of the object as a hostname, and the only way around it was${PASSWORD.value}, which puts the real value back into the logs.This adds a small
_reveal()helper that returnsvalue.valuefor aSecretand leaves anything else untouched, and uses it for the arguments the issue lists:hostinOpen Connection,usernameandpasswordinLogin, andusername,keyfileandpasswordinLogin With Public Key. The import ofSecretis guarded, so Robot Framework versions before 7.4 (the package still allows 5.0 and up) keep working as before. The keyword docs mention it.I checked it with a small robot suite that builds the secrets with
Evaluate. Before the changeOpen Connectionfails withgaierror: nodename nor servname providedbecause the Secret object is used as the hostname, and after it the library connects to the real host. I also addedutest/test_secret.pywith pytest tests for the helper and the three keywords using a mocked client, they run withPYTHONPATH=src pytest uteston Robot Framework 7.4 or newer and skip on older versions. I did not run the acceptance tests since they need the SSH docker setup.