config: make possible to set absolute paths for TLS cert and key (#3765)

This commit is contained in:
Ivan Kushmantsev
2019-07-01 12:48:54 +04:00
committed by Anton Kaliaev
parent d4cf204087
commit d9481e3648
5 changed files with 39 additions and 8 deletions

View File

@ -36,3 +36,19 @@ func TestConfigValidateBasic(t *testing.T) {
cfg.Consensus.TimeoutPropose = -10 * time.Second
assert.Error(t, cfg.ValidateBasic())
}
func TestTLSConfiguration(t *testing.T) {
assert := assert.New(t)
cfg := DefaultConfig()
cfg.SetRoot("/home/user")
cfg.RPC.TLSCertFile = "file.crt"
assert.Equal("/home/user/config/file.crt", cfg.RPC.CertFile())
cfg.RPC.TLSKeyFile = "file.key"
assert.Equal("/home/user/config/file.key", cfg.RPC.KeyFile())
cfg.RPC.TLSCertFile = "/abs/path/to/file.crt"
assert.Equal("/abs/path/to/file.crt", cfg.RPC.CertFile())
cfg.RPC.TLSKeyFile = "/abs/path/to/file.key"
assert.Equal("/abs/path/to/file.key", cfg.RPC.KeyFile())
}