1
0
Fork 0
mirror of synced 2024-06-13 16:05:06 +12:00
budibase/qa-core/src/integrations/validators/redis.integration.spec.ts

73 lines
2 KiB
TypeScript
Raw Normal View History

2023-05-16 02:53:32 +12:00
import redis from "../../../../packages/server/src/integrations/redis"
2023-05-15 20:16:06 +12:00
import { GenericContainer } from "testcontainers"
2023-05-16 02:53:55 +12:00
import { generator } from "../../shared"
2023-05-15 20:16:06 +12:00
describe("datasource validators", () => {
describe("redis", () => {
describe("unsecured", () => {
let host: string
let port: number
beforeAll(async () => {
const container = await new GenericContainer("redis")
.withExposedPorts(6379)
.start()
host = container.getContainerIpAddress()
port = container.getMappedPort(6379)
})
it("test valid connection", async () => {
const integration = new redis.integration({
host,
port,
username: "",
})
const result = await integration.testConnection()
2023-05-17 19:57:43 +12:00
expect(result).toEqual({ connected: true })
2023-05-15 20:16:06 +12:00
})
it("test invalid connection even with wrong user/password", async () => {
const integration = new redis.integration({
host,
port,
username: generator.name(),
password: generator.hash(),
})
const result = await integration.testConnection()
expect(result).toEqual({
2023-05-17 20:14:13 +12:00
connected: false,
2023-05-15 20:16:06 +12:00
error:
"WRONGPASS invalid username-password pair or user is disabled.",
})
})
})
describe("secured", () => {
let host: string
let port: number
beforeAll(async () => {
const container = await new GenericContainer("redis")
.withExposedPorts(6379)
.withCmd(["redis-server", "--requirepass", "P@ssW0rd!"])
.start()
host = container.getContainerIpAddress()
port = container.getMappedPort(6379)
})
it("test valid connection", async () => {
const integration = new redis.integration({
host,
port,
username: "",
password: "P@ssW0rd!",
})
const result = await integration.testConnection()
2023-05-17 19:57:43 +12:00
expect(result).toEqual({ connected: true })
2023-05-15 20:16:06 +12:00
})
})
})
})