From 40718cb98c71b802364412207f59b9c3e9fe7692 Mon Sep 17 00:00:00 2001 From: Philippe-Adrien Nousse Date: Tue, 24 Jul 2018 20:26:12 +0200 Subject: [PATCH] Added User related tests --- client/apps.go | 34 ++++++ client/auth.go | 21 ++-- client/groups.go | 30 +++-- client/interface.go | 5 + client/routes.go | 5 +- client/types/app.go | 67 +++++++++++ client/types/errors.go | 19 +++ client/types/responses.go | 72 +++++------ client/types/user.go | 2 +- client/users.go | 50 +++++--- client/utils.go | 10 ++ gonextcloud_test.go | 245 ++++++++++++++++++++++++++++++++++++++ 12 files changed, 478 insertions(+), 82 deletions(-) create mode 100644 client/types/app.go create mode 100644 client/types/errors.go create mode 100644 gonextcloud_test.go diff --git a/client/apps.go b/client/apps.go index da13c8e..ffd6911 100644 --- a/client/apps.go +++ b/client/apps.go @@ -1 +1,35 @@ package client + +import ( + req "github.com/levigross/grequests" + "github.com/partitio/gonextcloud/client/types" +) + +func (c *Client) AppList() ([]string, error) { + if !c.loggedIn() { + return nil, unauthorized + } + u := c.baseURL.ResolveReference(routes.apps) + res, err := c.session.Get(u.String(), nil) + if err != nil { + return nil, err + } + var r types.AppListResponse + res.JSON(&r) + return r.Ocs.Data.Apps, nil + return nil, nil +} + +func (c *Client) appsBaseRequest(name string, route string, ro *req.RequestOptions, method string) error { + res, err := c.baseRequest(routes.apps, name, route, ro, method) + if err != nil { + return err + } + var r types.UserResponse + res.JSON(&r) + if r.Ocs.Meta.Statuscode != 100 { + e := types.ErrorFromMeta(r.Ocs.Meta) + return &e + } + return nil +} diff --git a/client/auth.go b/client/auth.go index 9c2a85d..398e316 100644 --- a/client/auth.go +++ b/client/auth.go @@ -18,16 +18,22 @@ func (c *Client) Login(username string, password string) error { c.session = req.NewSession(&options) // TODO What to do with capabilities ? (other thant connection validation) u := c.baseURL.ResolveReference(routes.capabilities) - r, err := c.session.Get(u.String(), nil) + res, err := c.session.Get(u.String(), nil) if err != nil { return err } - var cs types.CapabilitiesResponse - r.JSON(&cs) - if cs.Ocs.Meta.Statuscode != 100 { - return fmt.Errorf("%d : %s", cs.Ocs.Meta.Statuscode, cs.Ocs.Meta.Message) + var r types.CapabilitiesResponse + res.JSON(&r) + if r.Ocs.Meta.Statuscode != 100 { + e := types.ErrorFromMeta(r.Ocs.Meta) + return &e + } + c.capabilities = &r.Ocs.Data.Capabilities + // Check if authentication failed + if !c.loggedIn() { + e := types.APIError{Message: "authentication failed"} + return &e } - c.capabilities = &cs.Ocs.Data.Capabilities return nil } @@ -37,5 +43,6 @@ func (c *Client) Logout() error { } func (c *Client) loggedIn() bool { - return c.capabilities != nil + // When authentication failed, capabilities doesn't contains core information + return c.capabilities.Core.WebdavRoot != "" } diff --git a/client/groups.go b/client/groups.go index 4682f2e..5b4d75a 100644 --- a/client/groups.go +++ b/client/groups.go @@ -1,7 +1,6 @@ package client import ( - "fmt" req "github.com/levigross/grequests" "github.com/partitio/gonextcloud/client/types" "net/http" @@ -12,12 +11,13 @@ func (c *Client) GroupList() ([]string, error) { if err != nil { return nil, err } - var gr types.GroupListResponse - res.JSON(&gr) - if gr.Ocs.Meta.Statuscode != 100 { - return nil, fmt.Errorf("%d : %s", gr.Ocs.Meta.Statuscode, gr.Ocs.Meta.Message) + var r types.GroupListResponse + res.JSON(&r) + if r.Ocs.Meta.Statuscode != 100 { + e := types.ErrorFromMeta(r.Ocs.Meta) + return nil, &e } - return gr.Ocs.Data.Groups, nil + return r.Ocs.Data.Groups, nil } func (c *Client) GroupUsers(name string) ([]string, error) { @@ -28,7 +28,8 @@ func (c *Client) GroupUsers(name string) ([]string, error) { var r types.UserListResponse res.JSON(&r) if r.Ocs.Meta.Statuscode != 100 { - return nil, fmt.Errorf("%d : %s", r.Ocs.Meta.Statuscode, r.Ocs.Meta.Message) + e := types.ErrorFromMeta(r.Ocs.Meta) + return nil, &e } return r.Ocs.Data.Users, nil } @@ -44,7 +45,8 @@ func (c *Client) GroupSearch(search string) ([]string, error) { var r types.GroupListResponse res.JSON(&r) if r.Ocs.Meta.Statuscode != 100 { - return nil, fmt.Errorf("%d : %s", r.Ocs.Meta.Statuscode, r.Ocs.Meta.Message) + e := types.ErrorFromMeta(r.Ocs.Meta) + return nil, &e } return r.Ocs.Data.Groups, nil } @@ -76,7 +78,8 @@ func (c *Client) GroupSubAdminList(name string) ([]string, error) { var r types.UserListResponse res.JSON(&r) if r.Ocs.Meta.Statuscode != 100 { - return nil, fmt.Errorf("%d : %s", r.Ocs.Meta.Statuscode, r.Ocs.Meta.Message) + e := types.ErrorFromMeta(r.Ocs.Meta) + return nil, &e } return r.Ocs.Data.Users, nil } @@ -86,10 +89,11 @@ func (c *Client) groupBaseRequest(name string, route string, ro *req.RequestOpti if err != nil { return err } - var ur types.GroupListResponse - res.JSON(&ur) - if ur.Ocs.Meta.Statuscode != 100 { - return fmt.Errorf("%d : %s", ur.Ocs.Meta.Statuscode, ur.Ocs.Meta.Message) + var r types.GroupListResponse + res.JSON(&r) + if r.Ocs.Meta.Statuscode != 100 { + e := types.ErrorFromMeta(r.Ocs.Meta) + return &e } return nil } diff --git a/client/interface.go b/client/interface.go index 0a76823..c9c3b21 100644 --- a/client/interface.go +++ b/client/interface.go @@ -38,4 +38,9 @@ type BaseClient interface { GroupCreate(name string) error GroupDelete(name string) error GroupSubAdminList(name string) ([]string, error) + + AppList() ([]string, error) + App(name string) (types.App, error) + AppEnable(name string) error + AppDisable(name string) error } diff --git a/client/routes.go b/client/routes.go index 24ba993..a2d7a91 100644 --- a/client/routes.go +++ b/client/routes.go @@ -6,14 +6,17 @@ type Routes struct { capabilities *url.URL users *url.URL groups *url.URL + apps *url.URL } +const badRequest = 998 + var ( apiPath = &url.URL{Path: "/ocs/v1.php/cloud"} routes = Routes{ capabilities: &url.URL{Path: apiPath.Path + "/capabilities"}, users: &url.URL{Path: apiPath.Path + "/users"}, groups: &url.URL{Path: apiPath.Path + "/groups"}, + apps: &url.URL{Path: apiPath.Path + "/apps"}, } - badRequest = 998 ) diff --git a/client/types/app.go b/client/types/app.go new file mode 100644 index 0000000..ef75b6c --- /dev/null +++ b/client/types/app.go @@ -0,0 +1,67 @@ +package types + +type App struct { + ID string `json:"id"` + Ocsid string `json:"ocsid"` + Name string `json:"name"` + Summary string `json:"summary"` + Description string `json:"description"` + Licence string `json:"licence"` + Author string `json:"author"` + Version string `json:"version"` + Namespace string `json:"namespace"` + Types []string `json:"types"` + Documentation struct { + Admin string `json:"admin"` + Developer string `json:"developer"` + User string `json:"user"` + } `json:"documentation"` + Category []string `json:"category"` + Website string `json:"website"` + Bugs string `json:"bugs"` + Repository struct { + Attributes struct { + Type string `json:"type"` + } `json:"@attributes"` + Value string `json:"@value"` + } `json:"repository"` + Screenshot []interface{} `json:"screenshot"` + Dependencies struct { + Owncloud struct { + Attributes struct { + MinVersion string `json:"min-version"` + MaxVersion string `json:"max-version"` + } `json:"@attributes"` + } `json:"owncloud"` + Nextcloud struct { + Attributes struct { + MinVersion string `json:"min-version"` + MaxVersion string `json:"max-version"` + } `json:"@attributes"` + } `json:"nextcloud"` + } `json:"dependencies"` + Settings struct { + Admin []string `json:"admin"` + AdminSection []string `json:"admin-section"` + Personal []interface{} `json:"personal"` + PersonalSection []interface{} `json:"personal-section"` + } `json:"settings"` + Info []interface{} `json:"info"` + Remote []interface{} `json:"remote"` + Public []interface{} `json:"public"` + RepairSteps struct { + Install []interface{} `json:"install"` + PreMigration []interface{} `json:"pre-migration"` + PostMigration []interface{} `json:"post-migration"` + LiveMigration []interface{} `json:"live-migration"` + Uninstall []interface{} `json:"uninstall"` + } `json:"repair-steps"` + BackgroundJobs []interface{} `json:"background-jobs"` + TwoFactorProviders []interface{} `json:"two-factor-providers"` + Commands []interface{} `json:"commands"` + Activity struct { + Filters []interface{} `json:"filters"` + Settings []interface{} `json:"settings"` + Providers []interface{} `json:"providers"` + } `json:"activity"` +} diff --git a/client/types/errors.go b/client/types/errors.go new file mode 100644 index 0000000..783a8e9 --- /dev/null +++ b/client/types/errors.go @@ -0,0 +1,19 @@ +package types + +import "fmt" + +type APIError struct { + Code int + Message string +} + +func ErrorFromMeta(meta Meta) APIError { + return APIError{ + meta.Statuscode, + meta.Message, + } +} + +func (e *APIError) Error() string { + return fmt.Sprintf("%d : %s", e.Code, e.Message) +} diff --git a/client/types/responses.go b/client/types/responses.go index b7db77a..15bd49b 100644 --- a/client/types/responses.go +++ b/client/types/responses.go @@ -1,27 +1,23 @@ package types +type Meta struct { + Status string `json:"status"` + Statuscode int `json:"statuscode"` + Message string `json:"message"` + Totalitems string `json:"totalitems"` + Itemsperpage string `json:"itemsperpage"` +} + type ErrorResponse struct { Ocs struct { - Meta struct { - Status string `json:"status"` - Statuscode int `json:"statuscode"` - Message string `json:"message"` - Totalitems string `json:"totalitems"` - Itemsperpage string `json:"itemsperpage"` - } `json:"meta"` + Meta Meta `json:"meta"` Data []interface{} `json:"data"` } `json:"ocs"` } type UserListResponse struct { Ocs struct { - Meta struct { - Status string `json:"status"` - Statuscode int `json:"statuscode"` - Message string `json:"message"` - Totalitems string `json:"totalitems"` - Itemsperpage string `json:"itemsperpage"` - } `json:"meta"` + Meta Meta `json:"meta"` Data struct { Users []string `json:"users"` } `json:"data"` @@ -30,54 +26,46 @@ type UserListResponse struct { type UserResponse struct { Ocs struct { - Meta struct { - Status string `json:"status"` - Statuscode int `json:"statuscode"` - Message string `json:"message"` - Totalitems string `json:"totalitems"` - Itemsperpage string `json:"itemsperpage"` - } `json:"meta"` + Meta Meta `json:"meta"` Data User `json:"data"` } `json:"ocs"` } type BaseResponse struct { Ocs struct { - Meta struct { - Status string `json:"status"` - Statuscode int `json:"statuscode"` - Message string `json:"message"` - Totalitems string `json:"totalitems"` - Itemsperpage string `json:"itemsperpage"` - } `json:"meta"` + Meta Meta `json:"meta"` Data []string `json:"data"` } `json:"ocs"` } type GroupListResponse struct { Ocs struct { - Meta struct { - Status string `json:"status"` - Statuscode int `json:"statuscode"` - Message string `json:"message"` - Totalitems string `json:"totalitems"` - Itemsperpage string `json:"itemsperpage"` - } `json:"meta"` + Meta Meta `json:"meta"` Data struct { Groups []string `json:"groups"` } `json:"data"` } `json:"ocs"` } +type AppListResponse struct { + Ocs struct { + Meta Meta `json:"meta"` + Data struct { + Apps []string `json:"apps"` + } `json:"data"` + } `json:"ocs"` +} + +type AppResponse struct { + Ocs struct { + Meta Meta `json:"meta"` + Data App `json:"data"` + } `json:"ocs"` +} + type CapabilitiesResponse struct { Ocs struct { - Meta struct { - Status string `json:"status"` - Statuscode int `json:"statuscode"` - Message string `json:"message"` - Totalitems string `json:"totalitems"` - Itemsperpage string `json:"itemsperpage"` - } `json:"meta"` + Meta Meta `json:"meta"` Data struct { Version struct { Major int `json:"major"` diff --git a/client/types/user.go b/client/types/user.go index c749dc2..bae7fce 100644 --- a/client/types/user.go +++ b/client/types/user.go @@ -1,7 +1,7 @@ package types type User struct { - Enabled string `json:"enabled"` + Enabled bool `json:"enabled"` ID string `json:"id"` Quota struct { Free int64 `json:"free"` diff --git a/client/users.go b/client/users.go index f65178f..9ffc287 100644 --- a/client/users.go +++ b/client/users.go @@ -1,11 +1,12 @@ package client import ( - "fmt" + "encoding/json" req "github.com/levigross/grequests" "github.com/partitio/gonextcloud/client/types" "net/http" "path" + "strconv" ) func (c *Client) UserList() ([]string, error) { @@ -17,12 +18,15 @@ func (c *Client) UserList() ([]string, error) { if err != nil { return nil, err } - var ul types.UserListResponse - res.JSON(&ul) - return ul.Ocs.Data.Users, nil + var r types.UserListResponse + res.JSON(&r) + return r.Ocs.Data.Users, nil } func (c *Client) User(name string) (*types.User, error) { + if name == "" { + return nil, &types.APIError{Message: "name cannot be empty"} + } if !c.loggedIn() { return nil, unauthorized } @@ -32,12 +36,18 @@ func (c *Client) User(name string) (*types.User, error) { if err != nil { return nil, err } - var ur types.UserResponse - res.JSON(&ur) - if ur.Ocs.Meta.Statuscode != 100 { - return nil, fmt.Errorf("%d : %s", ur.Ocs.Meta.Statuscode, ur.Ocs.Meta.Message) + var r types.UserResponse + js := res.String() + // Nextcloud does not encode JSON properly + js = reformatJSON(js) + if err := json.Unmarshal([]byte(js), &r); err != nil { + return nil, err } - return &ur.Ocs.Data, nil + if r.Ocs.Meta.Statuscode != 100 { + e := types.ErrorFromMeta(r.Ocs.Meta) + return nil, &e + } + return &r.Ocs.Data, nil } func (c *Client) UserSearch(search string) ([]string, error) { @@ -55,7 +65,8 @@ func (c *Client) UserSearch(search string) ([]string, error) { var r types.UserListResponse res.JSON(&r) if r.Ocs.Meta.Statuscode != 100 { - return nil, fmt.Errorf("%d : %s", r.Ocs.Meta.Statuscode, r.Ocs.Meta.Message) + e := types.ErrorFromMeta(r.Ocs.Meta) + return nil, &e } return r.Ocs.Data.Users, nil } @@ -120,8 +131,8 @@ func (c *Client) UserUpdatePassword(name string, password string) error { return c.userUpdateAttribute(name, "password", password) } -func (c *Client) UserUpdateQuota(name string, quota string) error { - return c.userUpdateAttribute(name, "quota", quota) +func (c *Client) UserUpdateQuota(name string, quota int) error { + return c.userUpdateAttribute(name, "quota", strconv.Itoa(quota)) } func (c *Client) UserGroupList(name string) ([]string, error) { @@ -137,7 +148,8 @@ func (c *Client) UserGroupList(name string) ([]string, error) { var r types.GroupListResponse res.JSON(&r) if r.Ocs.Meta.Statuscode != 100 { - return nil, fmt.Errorf("%d : %s", r.Ocs.Meta.Statuscode, r.Ocs.Meta.Message) + e := types.ErrorFromMeta(r.Ocs.Meta) + return nil, &e } return r.Ocs.Data.Groups, nil } @@ -191,7 +203,8 @@ func (c *Client) UserGroupSubAdminList(name string) ([]string, error) { var r types.BaseResponse res.JSON(&r) if r.Ocs.Meta.Statuscode != 100 { - return nil, fmt.Errorf("%d : %s", r.Ocs.Meta.Statuscode, r.Ocs.Meta.Message) + e := types.ErrorFromMeta(r.Ocs.Meta) + return nil, &e } return r.Ocs.Data, nil } @@ -211,10 +224,11 @@ func (c *Client) userBaseRequest(name string, route string, ro *req.RequestOptio if err != nil { return err } - var ur types.UserResponse - res.JSON(&ur) - if ur.Ocs.Meta.Statuscode != 100 { - return fmt.Errorf("%d : %s", ur.Ocs.Meta.Statuscode, ur.Ocs.Meta.Message) + var r types.UserResponse + res.JSON(&r) + if r.Ocs.Meta.Statuscode != 100 { + e := types.ErrorFromMeta(r.Ocs.Meta) + return &e } return nil } diff --git a/client/utils.go b/client/utils.go index b48446a..090a0b1 100644 --- a/client/utils.go +++ b/client/utils.go @@ -5,6 +5,7 @@ import ( "net/http" "net/url" "path" + "strings" ) func (c *Client) baseRequest(route *url.URL, name string, subroute string, ro *req.RequestOptions, method string) (*req.Response, error) { @@ -36,3 +37,12 @@ func (c *Client) baseRequest(route *url.URL, name string, subroute string, ro *r } return res, nil } + +func reformatJSON(json string) string { + // Nextcloud encode boolean as string + json = strings.Replace(json, "\"true\"", "true", -1) + json = strings.Replace(json, "\"false\"", "false", -1) + // Nextcloud encode quota as an empty array for never connected users + json = strings.Replace(json, "\"quota\":[],", "", -1) + return json +} diff --git a/gonextcloud_test.go b/gonextcloud_test.go new file mode 100644 index 0000000..ac4a01d --- /dev/null +++ b/gonextcloud_test.go @@ -0,0 +1,245 @@ +package gonextcloud + +import ( + "github.com/partitio/gonextcloud/client" + "github.com/stretchr/testify/assert" + "gopkg.in/yaml.v2" + "io/ioutil" + "os" + "testing" +) + +var config = Config{} +var c *client.Client + +type Config struct { + URL string `yaml:"url"` + Login string `yaml:"login"` + Password string `yaml:"password"` + AppName string `yaml:"app-name"` + GroupsToCreate []string `yaml:"groups-to-create"` + NotExistingUser string `yaml:"not-existing-user"` + NotExistingGroup string `yaml:"not-existing-group"` +} + +func LoadConfig() error { + f, err := os.Open("./config.yml") + if err != nil { + return err + } + b, err := ioutil.ReadAll(f) + if err != nil { + return err + } + if err := yaml.Unmarshal(b, &config); err != nil { + return err + } + return nil +} + +func TestTruth(t *testing.T) { + assert.Equal(t, true, true, "seriously ??!") +} + +func TestLoadConfig(t *testing.T) { + err := LoadConfig() + assert.Nil(t, err) +} + +func TestClient(t *testing.T) { + var err error + c, err = client.NewClient(config.URL) + assert.Nil(t, err, "aie") +} + +func TestLoginFail(t *testing.T) { + err := c.Login("", "") + assert.NotNil(t, err) +} + +func TestLogin(t *testing.T) { + err := c.Login(config.Login, config.Password) + assert.Nil(t, err) +} + +func TestUserList(t *testing.T) { + us, err := c.UserList() + assert.Nil(t, err) + + assert.Contains(t, us, config.Login) +} + +func TestExistingUser(t *testing.T) { + u, err := c.User(config.Login) + assert.Nil(t, err) + assert.NotNil(t, u) +} + +func TestEmptyUser(t *testing.T) { + u, err := c.User("") + assert.NotNil(t, err) + assert.Empty(t, u) +} + +func TestNonExistingUser(t *testing.T) { + _, err := c.User(config.NotExistingUser) + assert.NotNil(t, err) +} + +func TestUserSearch(t *testing.T) { + us, err := c.UserSearch(config.Login) + assert.Nil(t, err) + assert.Contains(t, us, config.Login) +} + +func TestUserCreate(t *testing.T) { + err := c.UserCreate(config.NotExistingUser, "somecomplicatedpassword") + assert.Nil(t, err) +} + +func TestUserCreateExisting(t *testing.T) { + err := c.UserCreate(config.NotExistingUser, "somecomplicatedpassword") + assert.NotNil(t, err) +} + +func TestGroupList(t *testing.T) { + gs, err := c.GroupList() + assert.Nil(t, err) + assert.Contains(t, gs, "admin") +} + +func TestGroupCreate(t *testing.T) { + err := c.GroupCreate(config.NotExistingGroup) + assert.Nil(t, err) +} + +func TestUserUpdateEmail(t *testing.T) { + email := "my@mail.com" + err := c.UserUpdateEmail(config.NotExistingUser, email) + assert.Nil(t, err) + u, err := c.User(config.NotExistingUser) + assert.Nil(t, err) + assert.Equal(t, email, u.Email) +} + +func TestUserUpdateDisplayName(t *testing.T) { + displayName := "Display Name" + err := c.UserUpdateDisplayName(config.NotExistingUser, displayName) + assert.Nil(t, err) + u, err := c.User(config.NotExistingUser) + assert.Nil(t, err) + assert.Equal(t, displayName, u.Displayname) +} + +func TestUserUpdatePhone(t *testing.T) { + phone := "+33 42 42 42 42" + err := c.UserUpdatePhone(config.NotExistingUser, phone) + assert.Nil(t, err) + u, err := c.User(config.NotExistingUser) + assert.Nil(t, err) + assert.Equal(t, phone, u.Phone) +} + +func TestUserUpdateAddress(t *testing.T) { + address := "Main Street, Galifrey" + err := c.UserUpdateAddress(config.NotExistingUser, address) + assert.Nil(t, err) + u, err := c.User(config.NotExistingUser) + assert.Nil(t, err) + assert.Equal(t, address, u.Address) +} + +func TestUserUpdateWebSite(t *testing.T) { + website := "www.doctor.who" + err := c.UserUpdateWebSite(config.NotExistingUser, website) + assert.Nil(t, err) + u, err := c.User(config.NotExistingUser) + assert.Nil(t, err) + assert.Equal(t, website, u.Website) +} + +func TestUserUpdateTwitter(t *testing.T) { + twitter := "@doctorwho" + err := c.UserUpdateTwitter(config.NotExistingUser, twitter) + assert.Nil(t, err) + u, err := c.User(config.NotExistingUser) + assert.Nil(t, err) + assert.Equal(t, twitter, u.Twitter) +} + +func TestUserUpdateQuota(t *testing.T) { + quota := 1024 * 1024 * 1024 + err := c.UserUpdateQuota(config.NotExistingUser, quota) + assert.Nil(t, err) + // TODO : Find better verification : A never connected User does not have quota available + //u, err := c.User(config.NotExistingUser) + //assert.Nil(t, err) + //assert.Equal(t, quota, u.Quota.Quota) +} + +func TestUserUpdatePassword(t *testing.T) { + password := "newcomplexpassword" + err := c.UserUpdatePassword(config.NotExistingUser, password) + assert.Nil(t, err) +} + +func TestUserGroupAdd(t *testing.T) { + err := c.UserGroupAdd(config.NotExistingUser, config.NotExistingGroup) + assert.Nil(t, err) + gs, err := c.UserGroupList(config.NotExistingUser) + assert.Nil(t, err) + assert.Contains(t, gs, config.NotExistingGroup) +} + +func TestUserGroupSubAdminList(t *testing.T) { + gs, err := c.UserGroupSubAdminList(config.NotExistingUser) + assert.NotNil(t, err) + assert.Empty(t, gs) +} + +func TestUserGroupPromote(t *testing.T) { + err := c.UserGroupPromote(config.NotExistingUser, config.NotExistingGroup) + assert.Nil(t, err) + gs, err := c.UserGroupSubAdminList(config.NotExistingUser) + assert.Nil(t, err) + assert.Contains(t, gs, config.NotExistingGroup) +} + +func TestUserGroupDemote(t *testing.T) { + err := c.UserGroupDemote(config.NotExistingUser, config.NotExistingGroup) + assert.Nil(t, err) + //gs, err := c.UserGroupSubAdminList(config.NotExistingUser) + //assert.Nil(t, err) + //assert.Empty(t, gs) +} + +func TestUserDisable(t *testing.T) { + err := c.UserDisable(config.NotExistingUser) + assert.Nil(t, err) + u, err := c.User(config.NotExistingUser) + assert.Nil(t, err) + assert.False(t, u.Enabled) +} + +func TestUserEnable(t *testing.T) { + err := c.UserEnable(config.NotExistingUser) + assert.Nil(t, err) + u, err := c.User(config.NotExistingUser) + assert.Nil(t, err) + assert.True(t, u.Enabled) +} + +func TestGroupDelete(t *testing.T) { + err := c.GroupDelete(config.NotExistingGroup) + assert.Nil(t, err) +} + +func TestUserDelete(t *testing.T) { + err := c.UserDelete(config.NotExistingUser) + assert.Nil(t, err) +} + +func TestLogout(t *testing.T) { + err := c.Logout() + assert.Nil(t, err) +}