-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Userpass: Update the password and policies associated to user #1216
Conversation
@@ -109,6 +109,98 @@ func TestBackend_userCrud(t *testing.T) { | |||
}) | |||
} | |||
|
|||
func TestBacken_userCreateOperation(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestBacken
-> TestBackend
return false, fmt.Errorf("missing username") | ||
} | ||
|
||
entry, err := req.Storage.Get("user/" + strings.ToLower(username)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use the same logic here that you're using in userCreateUpdate
, just to be safe in case something diverges. So that probably means using b.user()
here.
d3d9e06
to
cfbab2c
Compare
return false, fmt.Errorf("missing username") | ||
} | ||
|
||
userEntry, err := b.user(req.Storage, username) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If username
is always the name of the value, you can simply pass in data
to b.user
and have it return an error if there is a missing username. This lets you remove this check in a few other places too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is called in pathLoginRenew
. Even so, you can pass data.Get("username").(string)
directly in and check if it's empty in b.user
} | ||
} | ||
|
||
func (b *backend) userPasswordExistenceCheck(req *logical.Request, data *framework.FieldData) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks much better -- please do add a comment though explaining why this existence check always returns true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(For future code-browsers to avoid scratching heads.)
Userpass: Update the password and policies associated to user
No description provided.