-
Notifications
You must be signed in to change notification settings - Fork 2
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
guide: basic auth with JS #40
base: main
Are you sure you want to change the base?
Conversation
HttpProtocolBuilder httpProtocol = http | ||
.baseUrl("https://api.example.com") | ||
.acceptHeader("application/json") | ||
.authorizationHeader(session -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we have a built-in for this https://docs.gatling.io/reference/script/protocols/http/protocol/#authorization.
).protocols(httpProtocol); | ||
} | ||
} | ||
//#basic-auth-example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git friendly empty line
.acceptHeader("application/json") | ||
// Use built-in basicAuth with dynamic credentials from the feeder | ||
.basicAuth( | ||
(session) => session.get("username"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
val httpProtocol = http | ||
.baseUrl("https://api.example.com") | ||
.acceptHeader("application/json") | ||
.basicAuth({ session -> session.getString("username") }) { session -> session.getString("password") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
) | ||
).protocols(httpProtocol) | ||
} | ||
//#basic-auth-example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git friendly empty line
@@ -38,8 +38,7 @@ export default simulation((setUp) => { | |||
.acceptHeader("application/json") | |||
// Use built-in basicAuth with dynamic credentials from the feeder | |||
.basicAuth( | |||
(session) => session.get("username"), | |||
(session) => session.get("password") | |||
"#{username}", "#{password}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single line like in Scala and Kotlin, otherwise it won't be consistent across programming languages.
ff44298
to
8f4e51b
Compare
.basicAuth("#{username}", "#{password}" | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.basicAuth("#{username}", "#{password}" | |
); | |
.basicAuth("#{username}", "#{password}"); |
.basicAuth( "#{username}", "#{password}" | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.basicAuth( "#{username}", "#{password}" | |
); | |
.basicAuth( "#{username}", "#{password}"); |
Don't merge! This is only for testing a doc tool.