Vault SSH: Refactoring and fixes

This commit is contained in:
Vishal Nayak
2015-07-10 17:27:21 -06:00
parent dae996c994
commit 47a9f548fe
3 changed files with 37 additions and 31 deletions

View File

@@ -55,6 +55,8 @@ var testPort string
var testUserName string
var testAdminUser string
// Starts the server and initializes the servers IP address,
// port and usernames to be used by the test cases.
func init() {
addr, err := vault.StartTestServer()
if err != nil {
@@ -83,6 +85,29 @@ func TestSSHBackend(t *testing.T) {
})
}
func testNamedKeys(t *testing.T) logicaltest.TestStep {
return logicaltest.TestStep{
Operation: logical.WriteOperation,
Path: fmt.Sprintf("keys/%s", testKey),
Data: map[string]interface{}{
"key": testSharedPrivateKey,
},
}
}
func testNewRole(t *testing.T) logicaltest.TestStep {
return logicaltest.TestStep{
Operation: logical.WriteOperation,
Path: fmt.Sprintf("roles/%s", testRoleName),
Data: map[string]interface{}{
"key": testKey,
"admin_user": testAdminUser,
"cidr": testCidr,
"port": testPort,
},
}
}
func testRoleCreate(t *testing.T) logicaltest.TestStep {
return logicaltest.TestStep{
Operation: logical.WriteOperation,
@@ -110,26 +135,3 @@ func testRoleCreate(t *testing.T) logicaltest.TestStep {
},
}
}
func testNewRole(t *testing.T) logicaltest.TestStep {
return logicaltest.TestStep{
Operation: logical.WriteOperation,
Path: fmt.Sprintf("roles/%s", testRoleName),
Data: map[string]interface{}{
"key": testKey,
"admin_user": testAdminUser,
"cidr": testCidr,
"port": testPort,
},
}
}
func testNamedKeys(t *testing.T) logicaltest.TestStep {
return logicaltest.TestStep{
Operation: logical.WriteOperation,
Path: fmt.Sprintf("keys/%s", testKey),
Data: map[string]interface{}{
"key": testSharedPrivateKey,
},
}
}