Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
one place for all ignoreProxy cases except for asynhttpclient which h…
…as inbuild proxy server
- Loading branch information
Showing
5 changed files
with
96 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
core/shared/src/test/scala/com/softwaremill/sttp/SttpBackendOptionsProxyTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.softwaremill.sttp | ||
|
||
import org.scalatest.{FlatSpec, Matchers} | ||
|
||
class SttpBackendOptionsProxyTest extends FlatSpec with Matchers { | ||
|
||
"ignoreProxy" should "return true for a exact match with nonProxyHosts" in { | ||
val proxySetting = SttpBackendOptions.Proxy( | ||
"fakeproxyserverhost", 8080, | ||
SttpBackendOptions.ProxyType.Http, | ||
List("a.nonproxy.host", "localhost", "127.*") | ||
) | ||
|
||
proxySetting.ignoreProxy("a.nonproxy.host") should be(true) | ||
proxySetting.ignoreProxy("localhost") should be(true) | ||
} | ||
|
||
it should "return true for wildcard suffix match" in { | ||
val proxySetting = SttpBackendOptions.Proxy( | ||
"fakeproxyserverhost", 8080, | ||
SttpBackendOptions.ProxyType.Http, | ||
List("localhost", "127.*") | ||
) | ||
|
||
proxySetting.ignoreProxy("127.0.0.1") should be(true) | ||
proxySetting.ignoreProxy("127.1.0.1") should be(true) | ||
} | ||
|
||
it should "return true for wildcard prefix match" in { | ||
val proxySetting = SttpBackendOptions.Proxy( | ||
"fakeproxyserverhost", 8080, | ||
SttpBackendOptions.ProxyType.Http, | ||
List("localhost", "*.local", "127.*") | ||
) | ||
|
||
proxySetting.ignoreProxy("sttp.local") should be(true) | ||
proxySetting.ignoreProxy("www.sttp.local") should be(true) | ||
} | ||
|
||
it should "return false for others" in { | ||
val proxySetting = SttpBackendOptions.Proxy( | ||
"fakeproxyserverhost", 8080, | ||
SttpBackendOptions.ProxyType.Http, | ||
List("localhost", "*.local", "127.*") | ||
) | ||
|
||
proxySetting.ignoreProxy("sttp.local.com") should be(false) | ||
proxySetting.ignoreProxy("10.127.0.1") should be(false) | ||
} | ||
} |