Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Vault
Commits
765fa374
Unverified
Commit
765fa374
authored
6 years ago
by
Clint Shryock
Browse files
Options
Download
Email Patches
Plain Diff
rename tests, fix error message check
parent
75e5092d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
builtin/logical/database/path_roles.go
+1
-1
builtin/logical/database/path_roles.go
builtin/logical/database/path_roles_test.go
+3
-11
builtin/logical/database/path_roles_test.go
builtin/logical/database/path_rotate_role_credentials_test.go
+2
-2
...tin/logical/database/path_rotate_role_credentials_test.go
with
6 additions
and
14 deletions
+6
-14
builtin/logical/database/path_roles.go
+
1
-
1
View file @
765fa374
...
...
@@ -258,7 +258,7 @@ func (b *databaseBackend) pathRoleCreateUpdate() framework.OperationFunc {
frequency
:=
data
.
Get
(
"rotation_frequency"
)
if
frequency
==
0
&&
req
.
Operation
==
logical
.
CreateOperation
{
return
logical
.
ErrorResponse
(
"rotation_frequency is
a
required to create static accounts"
),
nil
return
logical
.
ErrorResponse
(
"rotation_frequency is required to create static accounts"
),
nil
}
role
.
StaticAccount
.
RotationFrequency
,
err
=
parseutil
.
ParseDurationSecond
(
frequency
)
...
...
This diff is collapsed.
Click to expand it.
builtin/logical/database/path_roles_test.go
+
3
-
11
View file @
765fa374
...
...
@@ -9,12 +9,11 @@ import (
"github.com/hashicorp/vault/helper/namespace"
"github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/logical/framework"
"github.com/y0ssar1an/q"
)
var
dataKeys
=
[]
string
{
"username"
,
"password"
,
"last_vault_rotation"
,
"rotation_frequency"
}
func
TestBackend_Static_Config
(
t
*
testing
.
T
)
{
func
TestBackend_Static
Role
_Config
(
t
*
testing
.
T
)
{
cluster
,
sys
:=
getCluster
(
t
)
defer
cluster
.
Cleanup
()
...
...
@@ -76,7 +75,7 @@ func TestBackend_Static_Config(t *testing.T) {
account
:
map
[
string
]
interface
{}{
"username"
:
"statictest"
,
},
err
:
errors
.
New
(
"rotation_frequency is
a
required
field for
static accounts"
),
err
:
errors
.
New
(
"rotation_frequency is required
to create
static accounts"
),
},
"missing username frequency"
:
{
account
:
map
[
string
]
interface
{}{
...
...
@@ -102,7 +101,6 @@ func TestBackend_Static_Config(t *testing.T) {
for
name
,
tc
:=
range
testCases
{
t
.
Run
(
name
,
func
(
t
*
testing
.
T
)
{
q
.
Q
(
">>>"
)
data
:=
map
[
string
]
interface
{}{
"name"
:
"plugin-role-test"
,
"db_name"
:
"plugin-test"
,
...
...
@@ -201,16 +199,11 @@ func TestBackend_Static_Config(t *testing.T) {
if
err
!=
nil
||
(
resp
!=
nil
&&
resp
.
IsError
())
{
t
.
Fatalf
(
"err:%s resp:%#v
\n
"
,
err
,
resp
)
}
q
.
Q
(
"<<<"
)
q
.
Q
(
""
)
})
}
q
.
Q
(
""
)
q
.
Q
(
" ------"
)
q
.
Q
(
""
)
}
func
TestBackend_Static_Config_Update
(
t
*
testing
.
T
)
{
func
TestBackend_Static
Role
_Config_Update
(
t
*
testing
.
T
)
{
cluster
,
sys
:=
getCluster
(
t
)
defer
cluster
.
Cleanup
()
...
...
@@ -251,7 +244,6 @@ func TestBackend_Static_Config_Update(t *testing.T) {
t
.
Fatalf
(
"err:%s resp:%#v
\n
"
,
err
,
resp
)
}
q
.
Q
(
">>>"
)
data
=
map
[
string
]
interface
{}{
"name"
:
"plugin-role-test"
,
"db_name"
:
"plugin-test"
,
...
...
This diff is collapsed.
Click to expand it.
builtin/logical/database/path_rotate_role_credentials_test.go
+
2
-
2
View file @
765fa374
...
...
@@ -13,7 +13,7 @@ import (
_
"github.com/lib/pq"
)
func
TestBackend_Role_Rotate
_Static
(
t
*
testing
.
T
)
{
func
TestBackend_
Static
Role_Rotate
(
t
*
testing
.
T
)
{
cluster
,
sys
:=
getCluster
(
t
)
defer
cluster
.
Cleanup
()
...
...
@@ -140,7 +140,7 @@ func TestBackend_Role_Rotate_Static(t *testing.T) {
// sanity check to make sure we don't allow an attempt of rotating credentials
// for non-static accounts, which doesn't make sense anyway, but doesn't hurt to
// verify we return an error
func
TestBackend_
Role_Rotate_Normal
(
t
*
testing
.
T
)
{
func
TestBackend_
StaticRole_NonStaticError
(
t
*
testing
.
T
)
{
cluster
,
sys
:=
getCluster
(
t
)
defer
cluster
.
Cleanup
()
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment