From 9b1cc82d30814110a81bf65c63dcd3244720ea38 Mon Sep 17 00:00:00 2001 From: Miguel Sama Date: Wed, 9 Mar 2022 12:46:30 +0100 Subject: [PATCH 1/2] Add test for testing Edge case when setting DeployedVmQuota and StoredVmQuota to 0 Signed-off-by: Miguel Sama --- govcd/user_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/govcd/user_test.go b/govcd/user_test.go index 967f2091b..d521f04f7 100644 --- a/govcd/user_test.go +++ b/govcd/user_test.go @@ -184,6 +184,19 @@ func (vcd *TestVCD) Test_UserCRUD(check *C) { check.Assert(user.User.DeployedVmQuota, Equals, userDefinition.DeployedVmQuota) check.Assert(user.User.IsExternal, Equals, userDefinition.IsExternal) + // change DeployedVmQuota and StoredVmQuota to 0 and assert + // this will make DeployedVmQuota and StoredVmQuota unlimited + user.User.DeployedVmQuota = 0 + user.User.StoredVmQuota = 0 + err = user.Update() + check.Assert(err, IsNil) + + // Get the user from API again + user, err = adminOrg.GetUserByHref(user.User.Href) + check.Assert(err, IsNil) + check.Assert(user.User.DeployedVmQuota, Equals, 0) + check.Assert(user.User.StoredVmQuota, Equals, 0) + err = user.Disable() check.Assert(err, IsNil) check.Assert(user.User.IsEnabled, Equals, false) From e2bfb6dd9db289c87eef0bad894ffd52f01a497c Mon Sep 17 00:00:00 2001 From: Miguel Sama Date: Wed, 9 Mar 2022 12:47:14 +0100 Subject: [PATCH 2/2] Fix bug that wasn't sending StoredVmQuota and DeployedVmQuota when set to 0 Signed-off-by: Miguel Sama --- types/v56/types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/v56/types.go b/types/v56/types.go index b9c712cd9..ebccdf6aa 100644 --- a/types/v56/types.go +++ b/types/v56/types.go @@ -2873,8 +2873,8 @@ type User struct { IsExternal bool `xml:"IsExternal,omitempty"` ProviderType string `xml:"ProviderType,omitempty"` IsGroupRole bool `xml:"IsGroupRole,omitempty"` - StoredVmQuota int `xml:"StoredVmQuota,omitempty"` - DeployedVmQuota int `xml:"DeployedVmQuota,omitempty"` + StoredVmQuota int `xml:"StoredVmQuota"` + DeployedVmQuota int `xml:"DeployedVmQuota"` Role *Reference `xml:"Role,omitempty"` GroupReferences *GroupReference `xml:"GroupReferences,omitempty"` Password string `xml:"Password,omitempty"`