2023-03-15 16:00:52 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2016-05-21 05:51:09 +00:00
|
|
|
package rabbitmq
|
|
|
|
|
2016-06-08 14:46:46 +00:00
|
|
|
import (
|
2018-01-08 20:26:13 +00:00
|
|
|
"context"
|
2016-06-08 14:46:46 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
2016-05-21 05:51:09 +00:00
|
|
|
|
2019-04-12 21:54:35 +00:00
|
|
|
"github.com/hashicorp/vault/sdk/logical"
|
2016-06-08 14:46:46 +00:00
|
|
|
)
|
2016-05-21 05:51:09 +00:00
|
|
|
|
2016-06-08 14:46:46 +00:00
|
|
|
func TestBackend_config_lease_RU(t *testing.T) {
|
|
|
|
var resp *logical.Response
|
|
|
|
var err error
|
|
|
|
config := logical.TestBackendConfig()
|
|
|
|
config.StorageView = &logical.InmemStorage{}
|
|
|
|
b := Backend()
|
2018-01-19 06:44:44 +00:00
|
|
|
if err = b.Setup(context.Background(), config); err != nil {
|
2016-06-08 14:46:46 +00:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
configData := map[string]interface{}{
|
|
|
|
"ttl": "10h",
|
|
|
|
"max_ttl": "20h",
|
|
|
|
}
|
|
|
|
configReq := &logical.Request{
|
|
|
|
Operation: logical.UpdateOperation,
|
|
|
|
Path: "config/lease",
|
|
|
|
Storage: config.StorageView,
|
|
|
|
Data: configData,
|
|
|
|
}
|
2018-01-08 20:26:13 +00:00
|
|
|
resp, err = b.HandleRequest(context.Background(), configReq)
|
2016-06-08 14:46:46 +00:00
|
|
|
if err != nil || (resp != nil && resp.IsError()) {
|
|
|
|
t.Fatalf("bad: resp: %#v\nerr:%s", resp, err)
|
|
|
|
}
|
|
|
|
if resp != nil {
|
|
|
|
t.Fatal("expected a nil response")
|
|
|
|
}
|
|
|
|
|
|
|
|
configReq.Operation = logical.ReadOperation
|
2018-01-08 20:26:13 +00:00
|
|
|
resp, err = b.HandleRequest(context.Background(), configReq)
|
2016-06-08 14:46:46 +00:00
|
|
|
if err != nil || (resp != nil && resp.IsError()) {
|
|
|
|
t.Fatalf("bad: resp: %#v\nerr:%s", resp, err)
|
|
|
|
}
|
|
|
|
if resp == nil {
|
|
|
|
t.Fatal("expected a response")
|
|
|
|
}
|
|
|
|
|
|
|
|
if resp.Data["ttl"].(time.Duration) != 36000 {
|
|
|
|
t.Fatalf("bad: ttl: expected:36000 actual:%d", resp.Data["ttl"].(time.Duration))
|
|
|
|
}
|
|
|
|
if resp.Data["max_ttl"].(time.Duration) != 72000 {
|
|
|
|
t.Fatalf("bad: ttl: expected:72000 actual:%d", resp.Data["ttl"].(time.Duration))
|
|
|
|
}
|
2016-05-21 05:51:09 +00:00
|
|
|
}
|