Class KarateConfig

java.lang.Object
io.karatelabs.core.KarateConfig
All Implemented Interfaces:
io.karatelabs.js.ObjectLike, io.karatelabs.js.SimpleObject

public class KarateConfig extends Object implements 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.

  • Constructor Details

    • KarateConfig

      public KarateConfig()
  • Method Details

    • copy

      public KarateConfig 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

      public void copyFrom(KarateConfig other)
      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

      public boolean configure(String key, Object value)
      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
    • jsKeys

      public Collection<String> jsKeys()
      Specified by:
      jsKeys in interface io.karatelabs.js.SimpleObject
    • jsGet

      public Object jsGet(String name)
      Specified by:
      jsGet in interface io.karatelabs.js.SimpleObject
    • getUrl

      public String getUrl()
    • getReadTimeout

      public int getReadTimeout()
    • getConnectTimeout

      public int getConnectTimeout()
    • isFollowRedirects

      public boolean isFollowRedirects()
    • getLocalAddress

      public String getLocalAddress()
    • getCharset

      public Charset getCharset()
    • getSsl

      public Map<String,Object> getSsl()
    • isSslEnabled

      public boolean isSslEnabled()
    • getSslAlgorithm

      public String getSslAlgorithm()
    • getSslKeyStore

      public String getSslKeyStore()
    • getSslKeyStorePassword

      public String getSslKeyStorePassword()
    • getSslKeyStoreType

      public String getSslKeyStoreType()
    • getSslTrustStore

      public String getSslTrustStore()
    • getSslTrustStorePassword

      public String getSslTrustStorePassword()
    • getSslTrustStoreType

      public String getSslTrustStoreType()
    • isSslTrustAll

      public boolean isSslTrustAll()
    • getProxy

      public Map<String,Object> getProxy()
    • getProxyUri

      public String getProxyUri()
    • getProxyUsername

      public String getProxyUsername()
    • getProxyPassword

      public String getProxyPassword()
    • getNonProxyHosts

      public List<String> getNonProxyHosts()
    • getNtlmAuth

      public Map<String,Object> getNtlmAuth()
    • getNtlmUsername

      public String getNtlmUsername()
    • getNtlmPassword

      public String getNtlmPassword()
    • getNtlmDomain

      public String getNtlmDomain()
    • getNtlmWorkstation

      public String getNtlmWorkstation()
    • getAuth

      public Map<String,Object> getAuth()
    • getAuthType

      public String getAuthType()
    • getAuthUsername

      public String getAuthUsername()
    • getAuthPassword

      public String getAuthPassword()
    • getAuthToken

      public String getAuthToken()
    • getAuthAccessTokenUrl

      public String getAuthAccessTokenUrl()
    • getAuthClientId

      public String getAuthClientId()
    • getAuthClientSecret

      public String getAuthClientSecret()
    • getAuthScope

      public String getAuthScope()
    • getRetry

      public Map<String,Object> getRetry()
    • getRetryInterval

      public int getRetryInterval()
    • getRetryCount

      public int getRetryCount()
    • getReport

      public Map<String,Object> getReport()
    • isShowLog

      public boolean isShowLog()
    • isShowAllSteps

      public boolean isShowAllSteps()
    • getCallSingleCache

      public Map<String,Object> getCallSingleCache()
    • getCallSingleCacheMinutes

      public int getCallSingleCacheMinutes()
    • getCallSingleCacheDir

      public String getCallSingleCacheDir()
    • getHeaders

      public Object getHeaders()
    • getCookies

      public Object 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

      public Object getResponseHeaders()
    • getBeforeScenario

      public Object getBeforeScenario()
    • getAfterScenario

      public Object getAfterScenario()
    • getAfterScenarioOutline

      public Object getAfterScenarioOutline()
    • getAfterFeature

      public Object getAfterFeature()
    • getDriverConfig

      public Object getDriverConfig()
    • getChannelOptions

      public Map<String,Object> getChannelOptions(String type)
    • getChannelFactoryClass

      public static String getChannelFactoryClass(String type)
    • isChannelType

      public static boolean isChannelType(String type)