Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to prepare the client with basic authentication #105

Open
akefirad opened this issue Jun 5, 2024 · 0 comments
Open

Add a method to prepare the client with basic authentication #105

akefirad opened this issue Jun 5, 2024 · 0 comments

Comments

@akefirad
Copy link

akefirad commented Jun 5, 2024

Since basic auth is quite well-known, I'd suggest to have a helper method like before:

    def setup() {
        gru.basicAuth('some-username', 'some-password')
    }

Currently I implement it using an extension method:

    static TestDefinitionBuilder basicAuth(TestDefinitionBuilder self, String username, String password) {
        return self.command(HttpMinion) {
            def cred = "$username:$password".bytes.encodeBase64().toString()
            requestHeaders.put('Authorization', ['Basic ' + cred])
        }
    }

A small improvement, but I'd say it's worth it. LMK if you need a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant