Tests retructuration

This commit is contained in:
Adphi 2018-10-16 09:34:56 +02:00
parent 9e549dd740
commit 74ee331f4f
4 changed files with 567 additions and 427 deletions

View File

@ -1,42 +1,3 @@
/*
Package client is a Go client for the Nextcloud Provisioning API.
For more information about the Provisioning API, see the documentation:
https://docs.nextcloud.com/server/13/admin_manual/configuration_user/user_provisioning_api.html
Usage
You use the library by creating a client object and calling methods on it.
For example, to list all the Nextcloud's instance users:
package main
import (
"fmt"
"gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/client"
)
func main() {
url := "https://www.mynextcloud.com"
username := "admin"
password := "password"
c, err := client.NewClient(url)
if err != nil {
panic(err)
}
if err := c.Login(username, password); err != nil {
panic(err)
}
defer c.Logout()
users, err := c.UserList()
if err != nil {
panic(err)
}
fmt.Println("Users :", users)
}
*/
package gonextcloud package gonextcloud
import ( import (

40
doc.go Normal file
View File

@ -0,0 +1,40 @@
/*
Package client is a Go client for the Nextcloud Provisioning API.
For more information about the Provisioning API, see the documentation:
https://docs.nextcloud.com/server/13/admin_manual/configuration_user/user_provisioning_api.html
Usage
You use the library by creating a client object and calling methods on it.
For example, to list all the Nextcloud's instance users:
package main
import (
"fmt"
"gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/client"
)
func main() {
url := "https://www.mynextcloud.com"
username := "admin"
password := "password"
c, err := client.NewClient(url)
if err != nil {
panic(err)
}
if err := c.Login(username, password); err != nil {
panic(err)
}
defer c.Logout()
users, err := c.UserList()
if err != nil {
panic(err)
}
fmt.Println("Users :", users)
}
*/
package gonextcloud

View File

@ -1,9 +1,8 @@
package gonextcloud package gonextcloud
import ( import (
"gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/types"
"github.com/partitio/swarmmanager/libnextcloudpartitio/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud/types"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -12,11 +11,6 @@ import (
"testing" "testing"
) )
var config = Config{}
var c *Client
const password = "somecomplicatedpassword"
type Config struct { type Config struct {
URL string `yaml:"url"` URL string `yaml:"url"`
Login string `yaml:"login"` Login string `yaml:"login"`
@ -27,76 +21,105 @@ type Config struct {
NotExistingGroup string `yaml:"not-existing-group"` NotExistingGroup string `yaml:"not-existing-group"`
} }
// LoadConfig loads the test configuration const password = "somecomplicatedpassword"
func LoadConfig() error {
f, err := os.Open("./config.yml")
if err != nil {
return err
}
b, err := ioutil.ReadAll(f)
if err != nil {
return err
}
return yaml.Unmarshal(b, &config)
}
func TestLoadConfig(t *testing.T) { type test = func(t *testing.T)
var (
config = Config{}
c *Client
groupID = 37
provisionningTests = []struct {
string
test
}{
{
"TestLoadConfig",
func(t *testing.T) {
err := LoadConfig() err := LoadConfig()
assert.NoError(t, err) assert.NoError(t, err)
} },
},
func TestClient(t *testing.T) { {
"create client",
func(t *testing.T) {
var err error var err error
c, err = NewClient(config.URL) c, err = NewClient(config.URL)
assert.NoError(t, err, "aie") assert.NoError(t, err, "aie")
} },
},
func TestLoginFail(t *testing.T) { {
"login failed",
func(t *testing.T) {
err := c.Login("", "") err := c.Login("", "")
assert.Error(t, err) assert.Error(t, err)
} },
},
func TestLogin(t *testing.T) { {
"login",
func(t *testing.T) {
err := c.Login(config.Login, config.Password) err := c.Login(config.Login, config.Password)
assert.NoError(t, err) assert.NoError(t, err)
} },
},
func TestUserList(t *testing.T) { {
"user list",
func(t *testing.T) {
us, err := c.UserList() us, err := c.UserList()
assert.NoError(t, err) assert.NoError(t, err)
assert.Contains(t, us, config.Login) assert.Contains(t, us, config.Login)
} },
},
func TestExistingUser(t *testing.T) { {
"existing user",
func(t *testing.T) {
u, err := c.User(config.Login) u, err := c.User(config.Login)
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, u) assert.NotNil(t, u)
} },
},
func TestEmptyUser(t *testing.T) { {
"empty user",
func(t *testing.T) {
u, err := c.User("") u, err := c.User("")
assert.Error(t, err) assert.Error(t, err)
assert.Empty(t, u) assert.Empty(t, u)
} },
},
func TestNonExistingUser(t *testing.T) { {
"TestNonExistingUser",
func(t *testing.T) {
_, err := c.User(config.NotExistingUser) _, err := c.User(config.NotExistingUser)
assert.Error(t, err) assert.Error(t, err)
} },
},
func TestUserSearch(t *testing.T) { {
"TestUserSearch",
func(t *testing.T) {
us, err := c.UserSearch(config.Login) us, err := c.UserSearch(config.Login)
assert.NoError(t, err) assert.NoError(t, err)
assert.Contains(t, us, config.Login) assert.Contains(t, us, config.Login)
} },
},
func TestUserCreate(t *testing.T) { {
"TestUserCreate",
func(t *testing.T) {
err := c.UserCreate(config.NotExistingUser, password, nil) err := c.UserCreate(config.NotExistingUser, password, nil)
assert.NoError(t, err) assert.NoError(t, err)
} },
},
//func TestUserCreateFull(t *testing.T) { //{
// "TestUserCreateFull",
// func(t *testing.T) {
// if err := initClient(); err != nil { // if err := initClient(); err != nil {
// return // return
// } // }
@ -111,7 +134,7 @@ func TestUserCreate(t *testing.T) {
// Website: "my.site.com", // Website: "my.site.com",
// } // }
// err := c.UserCreate(username, password, user) // err := c.UserCreate(username, password, user)
// assert.Nil(t, err) // assert.NoError(t, err)
// u, err := c.User(username) // u, err := c.User(username)
// assert.NoError(t, err) // assert.NoError(t, err)
// o := structs.Map(user) // o := structs.Map(user)
@ -125,15 +148,18 @@ func TestUserCreate(t *testing.T) {
// // Clean up // // Clean up
// err = c.UserDelete(u.ID) // err = c.UserDelete(u.ID)
// assert.NoError(t, err) // assert.NoError(t, err)
//} // },
//},
//func TestUserUpdate(t *testing.T) { //
//{
// "TestUserUpdate",
// func(t *testing.T) {
// if err := initClient(); err != nil { // if err := initClient(); err != nil {
// return // return
// } // }
// username := fmt.Sprintf("%s-2", config.NotExistingUser) // username := fmt.Sprintf("%s-2", config.NotExistingUser)
// err := c.UserCreate(username, password, nil) // err := c.UserCreate(username, password, nil)
// assert.Nil(t, err) // assert.NoError(t, err)
// user := &types.User{ // user := &types.User{
// ID: username, // ID: username,
// Displayname: strings.ToUpper(username), // Displayname: strings.ToUpper(username),
@ -144,9 +170,9 @@ func TestUserCreate(t *testing.T) {
// Website: "my.site.com", // Website: "my.site.com",
// } // }
// err = c.UserUpdate(user) // err = c.UserUpdate(user)
// assert.Nil(t, err) // assert.NoError(t, err)
// u, err := c.User(username) // u, err := c.User(username)
// assert.Nil(t, err) // assert.NoError(t, err)
// o := structs.Map(user) // o := structs.Map(user)
// r := structs.Map(u) // r := structs.Map(u)
// for k := range o { // for k := range o {
@ -158,267 +184,377 @@ func TestUserCreate(t *testing.T) {
// // Clean up // // Clean up
// err = c.UserDelete(u.ID) // err = c.UserDelete(u.ID)
// assert.NoError(t, err) // assert.NoError(t, err)
//} // },
//},
func TestUserCreateExisting(t *testing.T) { {
"TestUserCreateExisting",
func(t *testing.T) {
err := c.UserCreate(config.NotExistingUser, password, nil) err := c.UserCreate(config.NotExistingUser, password, nil)
assert.Error(t, err) assert.Error(t, err)
} },
},
func TestGroupList(t *testing.T) { {
"TestGroupList",
func(t *testing.T) {
gs, err := c.GroupList() gs, err := c.GroupList()
assert.NoError(t, err) assert.NoError(t, err)
assert.Contains(t, gs, "admin") assert.Contains(t, gs, "admin")
} },
},
func TestGroupCreate(t *testing.T) { {
"TestGroupCreate",
func(t *testing.T) {
err := c.GroupCreate(config.NotExistingGroup) err := c.GroupCreate(config.NotExistingGroup)
assert.NoError(t, err) assert.NoError(t, err)
} },
},
func TestUserUpdateEmail(t *testing.T) { {
"TestUserUpdateEmail",
func(t *testing.T) {
email := "my@mail.com" email := "my@mail.com"
err := c.UserUpdateEmail(config.NotExistingUser, email) err := c.UserUpdateEmail(config.NotExistingUser, email)
assert.Nil(t, err) assert.NoError(t, err)
u, err := c.User(config.NotExistingUser) u, err := c.User(config.NotExistingUser)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, email, u.Email) if err != nil {
t.Fail()
return
} }
assert.Equal(t, email, u.Email)
},
},
func TestUserUpdateDisplayName(t *testing.T) { {
"TestUserUpdateDisplayName",
func(t *testing.T) {
displayName := "Display Name" displayName := "Display Name"
err := c.UserUpdateDisplayName(config.NotExistingUser, displayName) err := c.UserUpdateDisplayName(config.NotExistingUser, displayName)
assert.Nil(t, err) assert.NoError(t, err)
u, err := c.User(config.NotExistingUser) u, err := c.User(config.NotExistingUser)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, displayName, u.Displayname) if err != nil {
t.Fail()
return
} }
assert.Equal(t, displayName, u.Displayname)
},
},
func TestUserUpdatePhone(t *testing.T) { {
"TestUserUpdatePhone",
func(t *testing.T) {
phone := "+33 42 42 42 42" phone := "+33 42 42 42 42"
err := c.UserUpdatePhone(config.NotExistingUser, phone) err := c.UserUpdatePhone(config.NotExistingUser, phone)
assert.Nil(t, err) assert.NoError(t, err)
u, err := c.User(config.NotExistingUser) u, err := c.User(config.NotExistingUser)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, phone, u.Phone) if err != nil {
t.Fail()
return
} }
assert.Equal(t, phone, u.Phone)
},
},
func TestUserUpdateAddress(t *testing.T) { {
"TestUserUpdateAddress",
func(t *testing.T) {
address := "Main Street, Galifrey" address := "Main Street, Galifrey"
err := c.UserUpdateAddress(config.NotExistingUser, address) err := c.UserUpdateAddress(config.NotExistingUser, address)
assert.NoError(t, err) assert.NoError(t, err)
u, err := c.User(config.NotExistingUser) u, err := c.User(config.NotExistingUser)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, address, u.Address) if err != nil {
t.Fail()
return
} }
assert.Equal(t, address, u.Address)
},
},
func TestUserUpdateWebSite(t *testing.T) { {
"TestUserUpdateWebSite",
func(t *testing.T) {
website := "www.doctor.who" website := "www.doctor.who"
err := c.UserUpdateWebSite(config.NotExistingUser, website) err := c.UserUpdateWebSite(config.NotExistingUser, website)
assert.NoError(t, err) assert.NoError(t, err)
u, err := c.User(config.NotExistingUser) u, err := c.User(config.NotExistingUser)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, website, u.Website) if err != nil {
t.Fail()
return
} }
assert.Equal(t, website, u.Website)
func TestUserUpdateTwitter(t *testing.T) { },
},
{
"TestUserUpdateTwitter",
func(t *testing.T) {
twitter := "@doctorwho" twitter := "@doctorwho"
err := c.UserUpdateTwitter(config.NotExistingUser, twitter) err := c.UserUpdateTwitter(config.NotExistingUser, twitter)
assert.NoError(t, err) assert.NoError(t, err)
u, err := c.User(config.NotExistingUser) u, err := c.User(config.NotExistingUser)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, twitter, u.Twitter) if err != nil {
t.Fail()
return
} }
assert.Equal(t, twitter, u.Twitter)
func TestUserUpdateQuota(t *testing.T) { },
},
{
"TestUserUpdateQuota",
func(t *testing.T) {
quota := 1024 * 1024 * 1024 quota := 1024 * 1024 * 1024
err := c.UserUpdateQuota(config.NotExistingUser, quota) err := c.UserUpdateQuota(config.NotExistingUser, quota)
assert.NoError(t, err) assert.NoError(t, err)
// TODO : Find better verification : A never connected User does not have quota available // TODO : Find better verification : A never connected User does not have quota available
//u, err := c.User(config.NotExistingUser) //u, err := c.User(config.NotExistingUser)
//assert.Nil(t, err) //assert.NoError(t, err)
//assert.Equal(t, quota, u.Quota.Quota) //assert.Equal(t, quota, u.Quota.Quota)
} },
},
func TestUserUpdatePassword(t *testing.T) { {
"TestUserUpdatePassword",
func(t *testing.T) {
password := "newcomplexpassword" password := "newcomplexpassword"
err := c.UserUpdatePassword(config.NotExistingUser, password) err := c.UserUpdatePassword(config.NotExistingUser, password)
assert.NoError(t, err) assert.NoError(t, err)
} }},
{
func TestUserGroupAdd(t *testing.T) { "TestUserGroupAdd",
func(t *testing.T) {
err := c.UserGroupAdd(config.NotExistingUser, config.NotExistingGroup) err := c.UserGroupAdd(config.NotExistingUser, config.NotExistingGroup)
assert.Nil(t, err) assert.NoError(t, err)
gs, err := c.UserGroupList(config.NotExistingUser) gs, err := c.UserGroupList(config.NotExistingUser)
assert.NoError(t, err) assert.NoError(t, err)
assert.Contains(t, gs, config.NotExistingGroup) assert.Contains(t, gs, config.NotExistingGroup)
} },
},
func TestUserGroupSubAdminList(t *testing.T) { {
"TestUserGroupSubAdminList",
func(t *testing.T) {
gs, err := c.UserGroupSubAdminList(config.NotExistingUser) gs, err := c.UserGroupSubAdminList(config.NotExistingUser)
assert.NoError(t, err) assert.NoError(t, err)
assert.Empty(t, gs) assert.Empty(t, gs)
} },
},
func TestUserGroupPromote(t *testing.T) { {
"TestUserGroupPromote",
func(t *testing.T) {
err := c.UserGroupPromote(config.NotExistingUser, config.NotExistingGroup) err := c.UserGroupPromote(config.NotExistingUser, config.NotExistingGroup)
assert.Nil(t, err) assert.NoError(t, err)
gs, err := c.UserGroupSubAdminList(config.NotExistingUser) gs, err := c.UserGroupSubAdminList(config.NotExistingUser)
assert.NoError(t, err) assert.NoError(t, err)
assert.Contains(t, gs, config.NotExistingGroup) assert.Contains(t, gs, config.NotExistingGroup)
} },
},
func TestUserGroupDemote(t *testing.T) { {
"TestUserGroupDemote",
func(t *testing.T) {
err := c.UserGroupDemote(config.NotExistingUser, config.NotExistingGroup) err := c.UserGroupDemote(config.NotExistingUser, config.NotExistingGroup)
assert.NoError(t, err) assert.NoError(t, err)
//gs, err := c.UserGroupSubAdminList(config.NotExistingUser) //gs, err := c.UserGroupSubAdminList(config.NotExistingUser)
//assert.Nil(t, err) //assert.NoError(t, err)
//assert.Empty(t, gs) //assert.Empty(t, gs)
} },
},
func TestUserDisable(t *testing.T) { {
"TestUserDisable",
func(t *testing.T) {
err := c.UserDisable(config.NotExistingUser) err := c.UserDisable(config.NotExistingUser)
assert.Nil(t, err) assert.NoError(t, err)
u, err := c.User(config.NotExistingUser) u, err := c.User(config.NotExistingUser)
assert.NoError(t, err) assert.NoError(t, err)
if err != nil {
t.Fail()
return
}
assert.False(t, u.Enabled) assert.False(t, u.Enabled)
} },
},
func TestUserEnable(t *testing.T) { {
"TestUserEnable",
func(t *testing.T) {
err := c.UserEnable(config.NotExistingUser) err := c.UserEnable(config.NotExistingUser)
assert.Nil(t, err) assert.NoError(t, err)
u, err := c.User(config.NotExistingUser) u, err := c.User(config.NotExistingUser)
assert.NoError(t, err) assert.NoError(t, err)
if err != nil {
t.Fail()
return
}
assert.True(t, u.Enabled) assert.True(t, u.Enabled)
} },
},
func TestGroupDelete(t *testing.T) { {
"TestGroupDelete",
func(t *testing.T) {
err := c.GroupDelete(config.NotExistingGroup) err := c.GroupDelete(config.NotExistingGroup)
assert.Nil(t, err) assert.NoError(t, err)
} },
},
func TestUserDelete(t *testing.T) { {
"TestUserDelete",
func(t *testing.T) {
err := c.UserDelete(config.NotExistingUser) err := c.UserDelete(config.NotExistingUser)
assert.NoError(t, err) assert.NoError(t, err)
} },
},
func TestInvalidBaseRequest(t *testing.T) { {
"TestInvalidBaseRequest",
func(t *testing.T) {
c.baseURL = &url.URL{} c.baseURL = &url.URL{}
_, err := c.baseRequest(http.MethodGet, routes.capabilities, nil, "admin", "invalid") _, err := c.baseRequest(http.MethodGet, routes.capabilities, nil, "admin", "invalid")
c = nil c = nil
assert.Error(t, err) assert.Error(t, err)
} },
},
func TestShareList(t *testing.T) { {
"TestShareList",
func(t *testing.T) {
if err := initClient(); err != nil { if err := initClient(); err != nil {
return return
} }
s, err := c.SharesList() s, err := c.SharesList()
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, s) assert.NotNil(t, s)
} },
},
func TestLogout(t *testing.T) { {
"TestLogout",
func(t *testing.T) {
err := c.Logout() err := c.Logout()
assert.NoError(t, err) assert.NoError(t, err)
assert.Nil(t, c.session.HTTPClient.Jar) assert.Nil(t, c.session.HTTPClient.Jar)
} },
},
func TestLoggedIn(t *testing.T) { {
"TestLoggedIn",
func(t *testing.T) {
c := &Client{} c := &Client{}
c.capabilities = &types.Capabilities{} c.capabilities = &types.Capabilities{}
assert.False(t, c.loggedIn()) assert.False(t, c.loggedIn())
} },
},
func TestLoginInvalidURL(t *testing.T) { {
"TestLoginInvalidURL",
func(t *testing.T) {
c, _ = NewClient("") c, _ = NewClient("")
err := c.Login("", "") err := c.Login("", "")
assert.Error(t, err) assert.Error(t, err)
} },
},
func TestBaseRequest(t *testing.T) { {
"TestBaseRequest",
func(t *testing.T) {
c, _ = NewClient("") c, _ = NewClient("")
_, err := c.baseRequest(http.MethodGet, routes.capabilities, nil, "admin", "invalid") _, err := c.baseRequest(http.MethodGet, routes.capabilities, nil, "admin", "invalid")
assert.Error(t, err) assert.Error(t, err)
},
},
} }
var groupID = 37 groupFoldersTests = []struct {
string
func TestGroupFoldersCreate(t *testing.T) { test
c = nil }{
if err := initClient(); err != nil { {
return "TestGroupFoldersCreate",
} func(t *testing.T) {
// Recreate client
var err error var err error
groupID, err = c.GroupFoldersCreate("API") groupID, err = c.GroupFoldersCreate("API")
assert.NoError(t, err) assert.NoError(t, err)
} },
},
func TestGroupFoldersList(t *testing.T) { {
c = nil "TestGroupFoldersList",
if err := initClient(); err != nil { func(t *testing.T) {
return
}
gfs, err := c.GroupFoldersList() gfs, err := c.GroupFoldersList()
assert.NoError(t, err) assert.NoError(t, err)
utils.PrettyPrint(gfs)
assert.NotNil(t, gfs[groupID]) assert.NotNil(t, gfs[groupID])
},
},
{
"TestGroupFolders",
func(t *testing.T) {
gf, err := c.GroupFolders(groupID)
assert.NoError(t, err)
assert.NotNil(t, gf)
},
},
{
"TestGroupFolderRename",
func(t *testing.T) {
err := c.GroupFoldersRename(groupID, "API_Renamed")
assert.NoError(t, err)
},
},
{
"TestGroupFoldersAddGroup",
func(t *testing.T) {
err := c.GroupFoldersAddGroup(groupID, "admin")
assert.NoError(t, err)
},
},
{
"TestGroupFoldersSetGroupPermissions",
func(t *testing.T) {
err := c.GroupFoldersSetGroupPermissions(groupID, "admin", types.ReadPermission)
assert.NoError(t, err)
},
},
{
"TestGroupFoldersSetQuota",
func(t *testing.T) {
err := c.GroupFoldersSetQuota(groupID, 100)
assert.NoError(t, err)
},
},
{
"TestGroupFolderRemoveGroup",
func(t *testing.T) {
err := c.GroupFoldersRemoveGroup(groupID, "admin")
assert.NoError(t, err)
},
},
}
)
func TestClient(t *testing.T) {
if err := initClient(); err != nil {
t.Fatal(err)
}
for _, tt := range provisionningTests {
t.Run(tt.string, tt.test)
}
} }
func TestGroupFolders(t *testing.T) { func TestGroupFolders(t *testing.T) {
c = nil c = nil
if err := initClient(); err != nil { if err := initClient(); err != nil {
return t.Fatal(err)
}
for _, tt := range groupFoldersTests {
t.Run(tt.string, tt.test)
} }
gf, err := c.GroupFolders(groupID)
assert.NoError(t, err)
utils.PrettyPrint(gf)
assert.NotNil(t, gf)
} }
func TestGroupFolderRename(t *testing.T) { // LoadConfig loads the test configuration
c = nil func LoadConfig() error {
if err := initClient(); err != nil { f, err := os.Open("./config.yml")
return if err != nil {
return err
} }
err := c.GroupFoldersRename(groupID, "API_Renamed") b, err := ioutil.ReadAll(f)
assert.NoError(t, err) if err != nil {
return err
} }
return yaml.Unmarshal(b, &config)
func TestGroupFoldersAddGroup(t *testing.T) {
c = nil
if err := initClient(); err != nil {
return
}
err := c.GroupFoldersAddGroup(groupID, "admin")
assert.NoError(t, err)
}
func TestGroupFoldersSetGroupPermissions(t *testing.T) {
c = nil
if err := initClient(); err != nil {
return
}
err := c.GroupFoldersSetGroupPermissions(groupID, "admin", types.ReadPermission)
assert.NoError(t, err)
}
func TestGroupFoldersSetQuota(t *testing.T) {
c = nil
if err := initClient(); err != nil {
return
}
err := c.GroupFoldersSetQuota(groupID, 100)
assert.NoError(t, err)
}
func TestGroupFolderRemoveGroup(t *testing.T) {
c = nil
if err := initClient(); err != nil {
return
}
err := c.GroupFoldersRemoveGroup(groupID, "admin")
assert.NoError(t, err)
} }
func initClient() error { func initClient() error {

View File

@ -59,6 +59,7 @@ func (c *Client) UserSearch(search string) ([]string, error) {
// UserCreate create a new user // UserCreate create a new user
func (c *Client) UserCreate(username string, password string, user *types.User) error { func (c *Client) UserCreate(username string, password string, user *types.User) error {
// Create base User
ro := &req.RequestOptions{ ro := &req.RequestOptions{
Data: map[string]string{ Data: map[string]string{
"userid": username, "userid": username,
@ -68,9 +69,11 @@ func (c *Client) UserCreate(username string, password string, user *types.User)
if err := c.userBaseRequest(http.MethodPost, ro); err != nil { if err := c.userBaseRequest(http.MethodPost, ro); err != nil {
return err return err
} }
// Check if we need to add user details information
if user == nil { if user == nil {
return nil return nil
} }
// Add user details information
return c.UserUpdate(user) return c.UserUpdate(user)
} }