Vault SSH: Dynamic Key test case fix

This commit is contained in:
Vishal Nayak
2015-07-24 12:13:26 -04:00
parent 9d4c5f718b
commit 0a4854e542
5 changed files with 11 additions and 10 deletions

View File

@@ -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 {

View File

@@ -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),
},

View File

@@ -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),

View File

@@ -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{

View File

@@ -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)