forked from linkerd/linkerd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite path using regex capture groups (linkerd#1144)
Problem Missing feature for ingress identifier path rewriting Solution Use regexp capture groups as the rewritten path segments Validation Unit testing Fixes linkerd#1144
- Loading branch information
1 parent
0cdd700
commit 13a5c75
Showing
4 changed files
with
118 additions
and
14 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
45 changes: 45 additions & 0 deletions
45
...ol/http/src/test/scala/io/buoyant/linkerd/protocol/http/IngressIdentifierConfigTest.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,45 @@ | ||
package io.buoyant.linkerd.protocol.http | ||
|
||
import com.twitter.finagle.Path | ||
import com.twitter.finagle.util.LoadService | ||
import io.buoyant.config.Parser | ||
import io.buoyant.linkerd.IdentifierInitializer | ||
import org.scalatest.FunSuite | ||
|
||
class IngressIdentifierConfigTest extends FunSuite { | ||
|
||
test("sanity") { | ||
// ensure it doesn't totally blowup | ||
val _ = new IngressIdentifierConfig(None, None, None, None).newIdentifier(Path.empty) | ||
} | ||
|
||
test("service registration") { | ||
assert(LoadService[IdentifierInitializer].exists(_.isInstanceOf[IngressIdentifierInitializer])) | ||
} | ||
|
||
test("parse config") { | ||
val yaml = s""" | ||
|kind: io.l5d.ingress | ||
|useCapturingGroups: true | ||
|namespace: myNameSpace | ||
|host: 127.0.0.1 | ||
|port: 6666 | ||
""".stripMargin | ||
|
||
val mapper = Parser.objectMapper(yaml, Iterable(Seq(IngressIdentifierInitializer))) | ||
val config = mapper.readValue[IngressIdentifierConfig](yaml) | ||
|
||
assert(config.namespace.isDefined) | ||
assert(config.namespace.get == "myNameSpace") | ||
|
||
assert(config.host.isDefined) | ||
assert(config.host.get == "127.0.0.1") | ||
|
||
assert(config.port.isDefined) | ||
assert(config.port.get.port == 6666) | ||
|
||
assert(config.useCapturingGroups.isDefined) | ||
assert(config.useCapturingGroups.get) | ||
} | ||
|
||
} |