Skip to content

Commit

Permalink
debasishg#293 unit tests exposing the issue with redis clients in bat…
Browse files Browse the repository at this point in the history
…ch mode.
  • Loading branch information
noahlz committed Nov 3, 2021
1 parent e866752 commit 23caaa1
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/test/scala/com/redis/PipelineSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,55 @@ class PipelineSpec extends AnyFunSpec
}
}
}

class SecureBatchedPipelineSpec extends AnyFunSpec
with Matchers
with IntSpec
with Inside {

override protected lazy val r: RedisClient =
new RedisClient(redisContainerHost, redisContainerPort)

override val redisPassword = Some("antirez")

private def shutdown(client: RedisClient) {
client.disconnect
client.close()
}

describe("a redis client in batch mode connecting to a password-protected redis instance") {
it("should be able to connect to the instance") {
val client = new RedisClient(redisContainerHost, redisContainerPort, secret = redisPassword,
batch = RedisClient.BATCH)

noException should be thrownBy {
val res = client.batchedPipeline(List(() => { client.ping }))
res.get should contain only ("PONG")
}

shutdown(client)
}

it("should be rejected when it is not initialized with a password") {
val client = new RedisClient(redisContainerHost, redisContainerPort, secret = None,
batch = RedisClient.BATCH)

an[Exception] shouldBe thrownBy {
client.batchedPipeline(List(() => { client.ping }))
}

shutdown(client)
}

it("should be rejected when it is initialized with an incorrect password") {
val client = new RedisClient(redisContainerHost, redisContainerPort, secret = Some("WRONG"),
batch = RedisClient.BATCH)

an[Exception] shouldBe thrownBy {
client.batchedPipeline(List(() => { client.ping }))
}

shutdown(client)
}
}
}

0 comments on commit 23caaa1

Please sign in to comment.