Skip to content

Commit

Permalink
Support basic account action for admin (yorkie-team#934)
Browse files Browse the repository at this point in the history
Add the admin APIs ChangePassword and DeleteAccount to enhance the functionality and provide basic account actions for administrators themselves.
  • Loading branch information
gusah009 authored Jul 27, 2024
1 parent bcb246b commit 52d2732
Show file tree
Hide file tree
Showing 18 changed files with 1,811 additions and 1,066 deletions.
652 changes: 379 additions & 273 deletions api/docs/yorkie/v1/admin.openapi.yaml

Large diffs are not rendered by default.

409 changes: 204 additions & 205 deletions api/docs/yorkie/v1/resources.openapi.yaml

Large diffs are not rendered by default.

453 changes: 226 additions & 227 deletions api/docs/yorkie/v1/yorkie.openapi.yaml

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions api/types/signup_fields.go → api/types/user_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ import (
"github.com/yorkie-team/yorkie/internal/validation"
)

// SignupFields is a set of fields that use to sign up to yorkie server.
type SignupFields struct {
// UserFields is a set of fields that use to sign up or change password to yorkie server.
type UserFields struct {
// Username is the name of user.
Username *string `bson:"username" validate:"required,min=2,max=30,slug"`

// Password is the password of user.
Password *string `bson:"password" validate:"required,min=8,max=30,alpha_num_special"`
}

// Validate validates the SignupFields.
func (i *SignupFields) Validate() error {
// Validate validates the UserFields.
func (i *UserFields) Validate() error {
return validation.ValidateStruct(i)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,56 +31,56 @@ func TestSignupFields(t *testing.T) {
t.Run("password validation test", func(t *testing.T) {
validUsername := "test"
validPassword := "pass123!"
fields := &types.SignupFields{
fields := &types.UserFields{
Username: &validUsername,
Password: &validPassword,
}
assert.NoError(t, fields.Validate())

invalidPassword := "1234"
fields = &types.SignupFields{
fields = &types.UserFields{
Username: &validUsername,
Password: &invalidPassword,
}
assert.ErrorAs(t, fields.Validate(), &structError)

invalidPassword = "abcd"
fields = &types.SignupFields{
fields = &types.UserFields{
Username: &validUsername,
Password: &invalidPassword,
}
assert.ErrorAs(t, fields.Validate(), &structError)

invalidPassword = "!@#$"
fields = &types.SignupFields{
fields = &types.UserFields{
Username: &validUsername,
Password: &invalidPassword,
}
assert.ErrorAs(t, fields.Validate(), &structError)

invalidPassword = "abcd1234"
fields = &types.SignupFields{
fields = &types.UserFields{
Username: &validUsername,
Password: &invalidPassword,
}
assert.ErrorAs(t, fields.Validate(), &structError)

invalidPassword = "abcd!@#$"
fields = &types.SignupFields{
fields = &types.UserFields{
Username: &validUsername,
Password: &invalidPassword,
}
assert.ErrorAs(t, fields.Validate(), &structError)

invalidPassword = "1234!@#$"
fields = &types.SignupFields{
fields = &types.UserFields{
Username: &validUsername,
Password: &invalidPassword,
}
assert.ErrorAs(t, fields.Validate(), &structError)

invalidPassword = "abcd1234!@abcd1234!@abcd1234!@1"
fields = &types.SignupFields{
fields = &types.UserFields{
Username: &validUsername,
Password: &invalidPassword,
}
Expand Down
Loading

0 comments on commit 52d2732

Please sign in to comment.