mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
Vault SSH: Dynamic Key test case fix
This commit is contained in:
@@ -22,7 +22,7 @@ func (c *SSH) KeyRevoke(id string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Invokes the SSH backend API to create a dynamic key
|
||||
// Invokes the SSH backend API to create a dynamic key or an OTP
|
||||
func (c *SSH) KeyCreate(role string, data map[string]interface{}) (*Secret, error) {
|
||||
r := c.c.NewRequest("PUT", fmt.Sprintf("/v1/ssh/creds/%s", role))
|
||||
if err := r.SetJSONBody(data); err != nil {
|
||||
|
||||
@@ -41,7 +41,7 @@ func Backend(conf *logical.BackendConfig) (*framework.Backend, error) {
|
||||
pathConfigLease(&b),
|
||||
pathKeys(&b),
|
||||
pathRoles(&b),
|
||||
pathRoleCreate(&b),
|
||||
pathCredsCreate(&b),
|
||||
pathLookup(&b),
|
||||
pathVerify(&b),
|
||||
},
|
||||
|
||||
@@ -74,13 +74,13 @@ func init() {
|
||||
testAdminUser = u.Username
|
||||
}
|
||||
|
||||
func TestSSHBackend(t *testing.T) {
|
||||
func TestSSHDynamicKeyBackend(t *testing.T) {
|
||||
logicaltest.Test(t, logicaltest.TestCase{
|
||||
Backend: Backend(),
|
||||
Factory: Factory,
|
||||
Steps: []logicaltest.TestStep{
|
||||
testNamedKeys(t),
|
||||
testNewRole(t),
|
||||
testRoleCreate(t),
|
||||
testNewDynamicKeyRole(t),
|
||||
testDynamicKeyCredsCreate(t),
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -95,11 +95,12 @@ func testNamedKeys(t *testing.T) logicaltest.TestStep {
|
||||
}
|
||||
}
|
||||
|
||||
func testNewRole(t *testing.T) logicaltest.TestStep {
|
||||
func testNewDynamicKeyRole(t *testing.T) logicaltest.TestStep {
|
||||
return logicaltest.TestStep{
|
||||
Operation: logical.WriteOperation,
|
||||
Path: fmt.Sprintf("roles/%s", testRoleName),
|
||||
Data: map[string]interface{}{
|
||||
"key_type": "dynamic",
|
||||
"key": testKey,
|
||||
"admin_user": testAdminUser,
|
||||
"cidr": testCidr,
|
||||
@@ -108,7 +109,7 @@ func testNewRole(t *testing.T) logicaltest.TestStep {
|
||||
}
|
||||
}
|
||||
|
||||
func testRoleCreate(t *testing.T) logicaltest.TestStep {
|
||||
func testDynamicKeyCredsCreate(t *testing.T) logicaltest.TestStep {
|
||||
return logicaltest.TestStep{
|
||||
Operation: logical.WriteOperation,
|
||||
Path: fmt.Sprintf("creds/%s", testRoleName),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/hashicorp/vault/logical/framework"
|
||||
)
|
||||
|
||||
func pathRoleCreate(b *backend) *framework.Path {
|
||||
func pathCredsCreate(b *backend) *framework.Path {
|
||||
return &framework.Path{
|
||||
Pattern: "creds/(?P<name>[-\\w]+)",
|
||||
Fields: map[string]*framework.FieldSchema{
|
||||
|
||||
@@ -74,7 +74,7 @@ func init() {
|
||||
testAdminUser = u.Username
|
||||
}
|
||||
|
||||
func TestSSH(t *testing.T) {
|
||||
func testSSH(t *testing.T) {
|
||||
// Add the SSH backend to the unsealed test core.
|
||||
// This should be done before the unsealed core is created.
|
||||
err := vault.AddTestLogicalBackend("ssh", logicalssh.Factory)
|
||||
|
||||
Reference in New Issue
Block a user