feat(users): add roles APIs (#63)

* feat(kvstore): add namespace operations for bool

* feat(userstore): add methods for roles

* chore(multiusers): remove useless todo

* feat(multiusers): add apis for roles

* test(roles): add e2e tests for role APIs

* test(e2e/files): enable files tests
This commit is contained in:
Hexxa 2021-07-10 07:08:32 -05:00 committed by GitHub
parent 4b6f6d9e1f
commit 9748d0cab4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 316 additions and 11 deletions

View file

@ -61,11 +61,50 @@ func (cl *SingleUserClient) AddUser(name, pwd, role string, token *http.Cookie)
}).
End()
if len(errs) > 0 {
return nil, nil, errs
}
auResp := &multiusers.AddUserResp{}
err := json.Unmarshal([]byte(body), auResp)
if err != nil {
errs = append(errs, err)
return nil, nil, errs
}
return resp, auResp, nil
return resp, auResp, errs
}
func (cl *SingleUserClient) AddRole(role string, token *http.Cookie) (*http.Response, string, []error) {
return cl.r.Post(cl.url("/v1/roles/")).
AddCookie(token).
Send(multiusers.AddRoleReq{
Role: role,
}).
End()
}
func (cl *SingleUserClient) DelRole(role string, token *http.Cookie) (*http.Response, string, []error) {
return cl.r.Delete(cl.url("/v1/roles/")).
AddCookie(token).
Send(multiusers.DelRoleReq{
Role: role,
}).
End()
}
func (cl *SingleUserClient) ListRoles(token *http.Cookie) (*http.Response, *multiusers.ListRolesResp, []error) {
resp, body, errs := cl.r.Get(cl.url("/v1/roles/")).
AddCookie(token).
End()
if len(errs) > 0 {
return nil, nil, errs
}
lsResp := &multiusers.ListRolesResp{}
err := json.Unmarshal([]byte(body), lsResp)
if err != nil {
errs = append(errs, err)
return nil, nil, errs
}
return resp, lsResp, errs
}