diff --git a/internal/web/job/ldap_sync_job.go b/internal/web/job/ldap_sync_job.go index bc965b2e7..25789624e 100644 --- a/internal/web/job/ldap_sync_job.go +++ b/internal/web/job/ldap_sync_job.go @@ -189,7 +189,7 @@ func (j *LdapSyncJob) buildClient(email string, defGB, defExpiryDays, defLimitIP Email: email, Enable: true, LimitIP: defLimitIP, - TotalGB: int64(defGB), + TotalGB: int64(defGB) * 1024 * 1024 * 1024, } if defExpiryDays > 0 { c.ExpiryTime = time.Now().Add(time.Duration(defExpiryDays) * 24 * time.Hour).UnixMilli() diff --git a/internal/web/job/ldap_sync_job_test.go b/internal/web/job/ldap_sync_job_test.go index f3ce38d7e..1df9dba3e 100644 --- a/internal/web/job/ldap_sync_job_test.go +++ b/internal/web/job/ldap_sync_job_test.go @@ -19,6 +19,14 @@ func initLdapJobDB(t *testing.T) { t.Cleanup(func() { _ = database.CloseDB() }) } +func TestBuildClient_ConvertsDefaultTotalGBToBytes(t *testing.T) { + j := NewLdapSyncJob() + c := j.buildClient("user@example.com", 10, 0, 0) + if want := int64(10) * 1024 * 1024 * 1024; c.TotalGB != want { + t.Errorf("TotalGB = %d, want %d", c.TotalGB, want) + } +} + func TestLdapCreateClients_AttachesToAllConfiguredInbounds(t *testing.T) { initLdapJobDB(t) db := database.GetDB()