Basic Authentication
Karate Tools will send the HTTP requests with the "Authorization" header made of "Basic", a space character, and a Base64-encoded string "username:password".
Configuration
The default settings for Basic authentication are:
-
defaultAuthMode
:basic
-
auth.authMode
when used in a specific request.
-
-
defaultUsername
: default username.-
auth.username
when used in a specific request.
-
-
credentials
: pairs of username: password.-
auth.password
when used in a specific request.
-
Examples
Default settings
# defaultAuthMode: basic | jwt. 'auth.authMode' when used in a specific request.
defaultAuthMode: basic
# defaultUsername: default username. 'auth.username' when used in a specific request.
defaultUsername: username100
# credentials: pairs of username: password. 'auth.password' when used in a specific request.
credentials:
# username100: Fixed username:password example
username100: username100p
Error Management
The errors applicable to Basic authentication are:
-
invalid authMode
:>> auth >> Trying to authenticate with no authMode or invalid authMode. auth.authMode:BASIC
-
no username
:>> auth >> Trying to authenticate with no username. auth.authMode:basic auth.username:null
-
no password
:>> auth >> Trying to authenticate with no password. auth.authMode:basic auth.username:username100 auth.password:undefined