Update update operation and uuid references
This commit is contained in:
parent
264c9cc40e
commit
bcaac7f876
|
@ -58,7 +58,7 @@ func testAccPreCheck(t *testing.T) {
|
||||||
|
|
||||||
func testAccStepConfig(t *testing.T) logicaltest.TestStep {
|
func testAccStepConfig(t *testing.T) logicaltest.TestStep {
|
||||||
return logicaltest.TestStep{
|
return logicaltest.TestStep{
|
||||||
Operation: logical.WriteOperation,
|
Operation: logical.UpdateOperation,
|
||||||
Path: "config/connection",
|
Path: "config/connection",
|
||||||
Data: map[string]interface{}{
|
Data: map[string]interface{}{
|
||||||
"uri": os.Getenv("RABBITMQ_MG_URI"),
|
"uri": os.Getenv("RABBITMQ_MG_URI"),
|
||||||
|
@ -70,7 +70,7 @@ func testAccStepConfig(t *testing.T) logicaltest.TestStep {
|
||||||
|
|
||||||
func testAccStepRole(t *testing.T) logicaltest.TestStep {
|
func testAccStepRole(t *testing.T) logicaltest.TestStep {
|
||||||
return logicaltest.TestStep{
|
return logicaltest.TestStep{
|
||||||
Operation: logical.WriteOperation,
|
Operation: logical.UpdateOperation,
|
||||||
Path: "roles/web",
|
Path: "roles/web",
|
||||||
Data: map[string]interface{}{
|
Data: map[string]interface{}{
|
||||||
"tags": "administrator",
|
"tags": "administrator",
|
||||||
|
|
|
@ -27,7 +27,7 @@ func pathConfigConnection(b *backend) *framework.Path {
|
||||||
},
|
},
|
||||||
|
|
||||||
Callbacks: map[logical.Operation]framework.OperationFunc{
|
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||||
logical.WriteOperation: b.pathConnectionWrite,
|
logical.UpdateOperation: b.pathConnectionWrite,
|
||||||
},
|
},
|
||||||
|
|
||||||
HelpSynopsis: pathConfigConnectionHelpSyn,
|
HelpSynopsis: pathConfigConnectionHelpSyn,
|
||||||
|
|
|
@ -25,7 +25,7 @@ func pathConfigLease(b *backend) *framework.Path {
|
||||||
|
|
||||||
Callbacks: map[logical.Operation]framework.OperationFunc{
|
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||||
logical.ReadOperation: b.pathLeaseRead,
|
logical.ReadOperation: b.pathLeaseRead,
|
||||||
logical.WriteOperation: b.pathLeaseWrite,
|
logical.UpdateOperation: b.pathLeaseWrite,
|
||||||
},
|
},
|
||||||
|
|
||||||
HelpSynopsis: pathConfigLeaseHelpSyn,
|
HelpSynopsis: pathConfigLeaseHelpSyn,
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/uuid"
|
"github.com/hashicorp/go-uuid"
|
||||||
"github.com/hashicorp/vault/logical"
|
"github.com/hashicorp/vault/logical"
|
||||||
"github.com/hashicorp/vault/logical/framework"
|
"github.com/hashicorp/vault/logical/framework"
|
||||||
"github.com/michaelklishin/rabbit-hole"
|
"github.com/michaelklishin/rabbit-hole"
|
||||||
|
@ -56,11 +56,18 @@ func (b *backend) pathRoleCreateRead(
|
||||||
if len(displayName) > 26 {
|
if len(displayName) > 26 {
|
||||||
displayName = displayName[:26]
|
displayName = displayName[:26]
|
||||||
}
|
}
|
||||||
username := fmt.Sprintf("%s-%s", displayName, uuid.GenerateUUID())
|
userUUID, err := uuid.GenerateUUID()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
username := fmt.Sprintf("%s-%s", displayName, userUUID)
|
||||||
if len(username) > 63 {
|
if len(username) > 63 {
|
||||||
username = username[:63]
|
username = username[:63]
|
||||||
}
|
}
|
||||||
password := uuid.GenerateUUID()
|
password, err := uuid.GenerateUUID()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// Get our connection
|
// Get our connection
|
||||||
client, err := b.Client(req.Storage)
|
client, err := b.Client(req.Storage)
|
||||||
|
|
|
@ -30,7 +30,7 @@ func pathRoles(b *backend) *framework.Path {
|
||||||
|
|
||||||
Callbacks: map[logical.Operation]framework.OperationFunc{
|
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||||
logical.ReadOperation: b.pathRoleRead,
|
logical.ReadOperation: b.pathRoleRead,
|
||||||
logical.WriteOperation: b.pathRoleCreate,
|
logical.UpdateOperation: b.pathRoleCreate,
|
||||||
logical.DeleteOperation: b.pathRoleDelete,
|
logical.DeleteOperation: b.pathRoleDelete,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package rabbitmq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/hashicorp/vault/logical"
|
"github.com/hashicorp/vault/logical"
|
||||||
"github.com/hashicorp/vault/logical/framework"
|
"github.com/hashicorp/vault/logical/framework"
|
||||||
|
@ -26,9 +25,6 @@ func secretCreds(b *backend) *framework.Secret {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
DefaultDuration: 1 * time.Hour,
|
|
||||||
DefaultGracePeriod: 10 * time.Minute,
|
|
||||||
|
|
||||||
Renew: b.secretCredsRenew,
|
Renew: b.secretCredsRenew,
|
||||||
Revoke: b.secretCredsRevoke,
|
Revoke: b.secretCredsRevoke,
|
||||||
}
|
}
|
||||||
|
@ -42,10 +38,10 @@ func (b *backend) secretCredsRenew(
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if lease == nil {
|
if lease == nil {
|
||||||
lease = &configLease{Lease: 1 * time.Hour}
|
lease = &configLease{}
|
||||||
}
|
}
|
||||||
|
|
||||||
f := framework.LeaseExtend(lease.Lease, lease.LeaseMax, false)
|
f := framework.LeaseExtend(lease.Lease, lease.LeaseMax, b.System())
|
||||||
resp, err := f(req, d)
|
resp, err := f(req, d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue