From 133937822c9bb801fabcfebcf24ad978cd13aa16 Mon Sep 17 00:00:00 2001 From: Igor Artamonov Date: Wed, 27 Oct 2021 20:34:04 -0400 Subject: [PATCH] solution: configuration for Websocket proxy --- .../emeraldpay/dshackle/config/ProxyConfigReader.kt | 3 +++ .../dshackle/config/ProxyConfigReaderSpec.groovy | 12 ++++++++++++ src/test/resources/dshackle-proxy-no-ws.yaml | 6 ++++++ 3 files changed, 21 insertions(+) create mode 100644 src/test/resources/dshackle-proxy-no-ws.yaml diff --git a/src/main/kotlin/io/emeraldpay/dshackle/config/ProxyConfigReader.kt b/src/main/kotlin/io/emeraldpay/dshackle/config/ProxyConfigReader.kt index e75f80c4..390453f0 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/config/ProxyConfigReader.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/config/ProxyConfigReader.kt @@ -58,6 +58,9 @@ class ProxyConfigReader : YamlConfigReader(), ConfigReader { getValueAsBool(input, "enabled")?.let { config.enabled = it } + getValueAsBool(input, "websocket")?.let { + config.websocketEnabled = it + } val currentRoutes = HashSet() getList(input, "routes")?.let { routes -> config.routes = routes.value.map { route -> diff --git a/src/test/groovy/io/emeraldpay/dshackle/config/ProxyConfigReaderSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/config/ProxyConfigReaderSpec.groovy index 3cdbe6dc..6ac07a94 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/config/ProxyConfigReaderSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/config/ProxyConfigReaderSpec.groovy @@ -30,6 +30,7 @@ class ProxyConfigReaderSpec extends Specification { then: act.enabled + act.websocketEnabled act.port == 8080 act.host == '127.0.0.1' act.routes.size() == 1 @@ -39,6 +40,17 @@ class ProxyConfigReaderSpec extends Specification { } } + def "Read proxy config with websocket disabled"() { + setup: + def config = this.class.getClassLoader().getResourceAsStream("dshackle-proxy-no-ws.yaml") + when: + def act = reader.read(config) + + then: + act.enabled + !act.websocketEnabled + } + def "Read proxy config with two elements"() { setup: def config = this.class.getClassLoader().getResourceAsStream("dshackle-proxy-two.yaml") diff --git a/src/test/resources/dshackle-proxy-no-ws.yaml b/src/test/resources/dshackle-proxy-no-ws.yaml new file mode 100644 index 00000000..faaf01b8 --- /dev/null +++ b/src/test/resources/dshackle-proxy-no-ws.yaml @@ -0,0 +1,6 @@ +proxy: + port: 8080 + websocket: false + routes: + - id: ethereum + blockchain: ethereum \ No newline at end of file