mirror of
https://github.com/Icinga/icingadb.git
synced 2026-06-03 14:00:11 -04:00
Merge pull request #205 from Icinga/feature/password-authentication
Add Redis password authentication
This commit is contained in:
commit
75c6bdebea
8 changed files with 11 additions and 8 deletions
|
|
@ -21,7 +21,7 @@ import (
|
|||
var mysqlTestObserver = connection.DbIoSeconds.WithLabelValues("mysql", "test")
|
||||
|
||||
func SetupConfigSync(t *testing.T, objectTypes []*configobject.ObjectInformation) (*supervisor.Supervisor, []chan int) {
|
||||
rdbw := connection.NewRDBWrapper(testbackends.RedisTestAddr, 64)
|
||||
rdbw := connection.NewRDBWrapper(testbackends.RedisTestAddr, "", 64)
|
||||
dbw, err := connection.NewDBWrapper(testbackends.MysqlTestDsn, 50)
|
||||
require.NoError(t, err, "Is the MySQL server running?")
|
||||
|
||||
|
|
|
|||
|
|
@ -112,11 +112,12 @@ func (rdbw *RDBWrapper) CompareAndSetConnected(connected bool) (swapped bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func NewRDBWrapper(address string, poolSize int) *RDBWrapper {
|
||||
func NewRDBWrapper(address string, password string, poolSize int) *RDBWrapper {
|
||||
log.Info("Connecting to Redis")
|
||||
|
||||
rdb := redis.NewClient(&redis.Options{
|
||||
Addr: address,
|
||||
Password: password,
|
||||
DialTimeout: time.Minute / 2,
|
||||
ReadTimeout: time.Minute,
|
||||
WriteTimeout: time.Minute,
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ func NewTestRDBW(rdb RedisClient) RDBWrapper {
|
|||
}
|
||||
|
||||
func TestNewRDBWrapper(t *testing.T) {
|
||||
rdbw := NewRDBWrapper(testbackends.RedisTestAddr, 64)
|
||||
rdbw := NewRDBWrapper(testbackends.RedisTestAddr, "", 64)
|
||||
assert.True(t, rdbw.CheckConnection(false), "Redis should be connected")
|
||||
|
||||
rdbw = NewRDBWrapper("asdasdasdasdasd:5123", 64)
|
||||
rdbw = NewRDBWrapper("asdasdasdasdasd:5123", "", 64)
|
||||
assert.False(t, rdbw.CheckConnection(false), "Redis should not be connected")
|
||||
//TODO: Add more tests here
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ Option | Description
|
|||
-------------------------|-----------------------------------------------
|
||||
host | **Optional.** Redis host. Defaults to `127.0.0.1`.
|
||||
port | **Optional.** Redis port. Defaults to `6380`.
|
||||
password | **Optional.** Redis password. Not set by default.
|
||||
pool\_size | **Optional.** Maximum number of socket connections. Defaults to `64`.
|
||||
|
||||
### MySQL Configuration <a id="configuration-general-mysql"></a>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import (
|
|||
)
|
||||
|
||||
func createTestingHA(t *testing.T, redisAddr string) *HA {
|
||||
redisConn := connection.NewRDBWrapper(redisAddr, 64)
|
||||
redisConn := connection.NewRDBWrapper(redisAddr, "", 64)
|
||||
|
||||
mysqlConn, err := connection.NewDBWrapper(testbackends.MysqlTestDsn, 50)
|
||||
if err != nil {
|
||||
|
|
@ -149,7 +149,7 @@ func TestHA_setAndInsertEnvironment(t *testing.T) {
|
|||
ha := createTestingHA(t, testbackends.RedisTestAddr)
|
||||
|
||||
env := Environment{
|
||||
ID: utils.EncodeChecksum(utils.Checksum("herp")),
|
||||
ID: utils.EncodeChecksum(utils.Checksum("herp")),
|
||||
Name: "herp",
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ const app = "{\"status\": " +
|
|||
const dump = "false"
|
||||
|
||||
func TestIcingaHeartbeatListener(t *testing.T) {
|
||||
rdb := connection.NewRDBWrapper(testbackends.RedisTestAddr, 64)
|
||||
rdb := connection.NewRDBWrapper(testbackends.RedisTestAddr, "", 64)
|
||||
assert.True(t, rdb.CheckConnection(false), "This test needs a working Redis connection")
|
||||
|
||||
chEnv := make(chan *Environment)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[redis]
|
||||
host="127.0.0.1"
|
||||
;port=6380
|
||||
;password="icingadb"
|
||||
|
||||
[mysql]
|
||||
host="127.0.0.1"
|
||||
|
|
|
|||
2
main.go
2
main.go
|
|
@ -104,7 +104,7 @@ func main() {
|
|||
mysqlInfo := config.GetMysqlInfo()
|
||||
metricsInfo := config.GetMetricsInfo()
|
||||
|
||||
redisConn := connection.NewRDBWrapper(redisInfo.Host+":"+redisInfo.Port, redisInfo.PoolSize)
|
||||
redisConn := connection.NewRDBWrapper(redisInfo.Host+":"+redisInfo.Port, redisInfo.Password, redisInfo.PoolSize)
|
||||
|
||||
mysqlConn, err := connection.NewDBWrapper(
|
||||
mysqlInfo.User+":"+mysqlInfo.Password+"@tcp("+mysqlInfo.Host+":"+mysqlInfo.Port+")/"+mysqlInfo.Database,
|
||||
|
|
|
|||
Loading…
Reference in a new issue