Package io.karatelabs.core
Class KarateConfig
java.lang.Object
io.karatelabs.core.KarateConfig
- All Implemented Interfaces:
io.karatelabs.js.ObjectLike,io.karatelabs.js.SimpleObject
Holds runtime configuration settings set via the 'configure' keyword.
This is distinct from:
KaratePom- Project file (karate-pom.json) for CLI options- karate-config.js - Runtime bootstrap that runs per-scenario
Example usage:
* configure ssl = true * configure proxy = 'http://proxy:8080' * configure readTimeout = 60000 * def cfg = karate.config * match cfg.sslEnabled == true
Implements SimpleObject so it can be accessed as a JavaScript object
via karate.config.
-
Field Summary
Fields inherited from interface io.karatelabs.js.SimpleObject
TO_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidPush this config's logging settings into the given LogContext.booleanApply configuration from a key-value pair.copy()Create a deep copy of this configuration.voidcopyFrom(KarateConfig other) Copy all configuration values from another KarateConfig.getAuth()intCompiled HTTP log mask.intgetProxy()intgetRetry()intintgetSsl()getUrl()booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanjsKeys()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.karatelabs.js.ObjectLike
getMember, getPrototype, isExtensible, isFrozen, isOwnProperty, isSealed, putMember, removeMember, setExtensible, setFrozen, setSealedMethods inherited from interface io.karatelabs.js.SimpleObject
getMember, jsToString, putMember, removeMember, toMap
-
Constructor Details
-
KarateConfig
public KarateConfig()
-
-
Method Details
-
copy
Create a deep copy of this configuration. Used to snapshot config state for callonce/callSingle isolation.- Returns:
- a new KarateConfig with copied values
-
copyFrom
Copy all configuration values from another KarateConfig. Used to propagate config changes from called features back to the caller.- Parameters:
other- the source config to copy from
-
configure
Apply configuration from a key-value pair.- Parameters:
key- the configure key (e.g., "ssl", "proxy", "readTimeout")value- the value to set- Returns:
- true if HTTP client needs to be rebuilt, false otherwise
- Throws:
RuntimeException- if key is not recognized
-
applyLoggingToContext
Push this config's logging settings into the given LogContext. Called byScenarioRuntime.call()after it allocates a fresh thread-local LogContext, so any mask / pretty values set in karate-config.js (or a prior step) survive into the scenario's HTTP logging. -
getCompiledMask
Compiled HTTP log mask. Source of truth —LogContextmirrors this for per-thread reads byHttpLogger. -
jsKeys
- Specified by:
jsKeysin interfaceio.karatelabs.js.SimpleObject
-
jsGet
- Specified by:
jsGetin interfaceio.karatelabs.js.SimpleObject
-
getUrl
-
getReadTimeout
public int getReadTimeout() -
getConnectTimeout
public int getConnectTimeout() -
isFollowRedirects
public boolean isFollowRedirects() -
getLocalAddress
-
getCharset
-
getSsl
-
isSslEnabled
public boolean isSslEnabled() -
getSslAlgorithm
-
getSslKeyStore
-
getSslKeyStorePassword
-
getSslKeyStoreType
-
getSslTrustStore
-
getSslTrustStorePassword
-
getSslTrustStoreType
-
isSslTrustAll
public boolean isSslTrustAll() -
getProxy
-
getProxyUri
-
getProxyUsername
-
getProxyPassword
-
getNonProxyHosts
-
getNtlmAuth
-
getNtlmUsername
-
getNtlmPassword
-
getNtlmDomain
-
getNtlmWorkstation
-
getAuth
-
getAuthType
-
getAuthUsername
-
getAuthPassword
-
getAuthToken
-
getAuthAccessTokenUrl
-
getAuthClientId
-
getAuthClientSecret
-
getAuthScope
-
getRetry
-
getRetryInterval
public int getRetryInterval() -
getRetryCount
public int getRetryCount() -
getReport
-
isShowLog
public boolean isShowLog() -
isShowAllSteps
public boolean isShowAllSteps() -
getLogging
-
getLoggingReportLevel
-
getLoggingConsoleLevel
-
isLoggingPretty
public boolean isLoggingPretty() -
getCallSingleCache
-
getCallSingleCacheMinutes
public int getCallSingleCacheMinutes() -
getCallSingleCacheDir
-
getHeaders
-
getCookies
-
isHttpRetryEnabled
public boolean isHttpRetryEnabled() -
isContinueOnStepFailure
public boolean isContinueOnStepFailure() -
isAbortedStepsShouldPass
public boolean isAbortedStepsShouldPass() -
isAbortSuiteOnFailure
public boolean isAbortSuiteOnFailure() -
isMatchEachEmptyAllowed
public boolean isMatchEachEmptyAllowed() -
isCorsEnabled
public boolean isCorsEnabled() -
getResponseHeaders
-
getBeforeScenario
-
getAfterScenario
-
getAfterScenarioOutline
-
getAfterFeature
-
getOnStepFailure
-
getDriverConfig
-