fix limitclass creation in test (#606)

This commit is contained in:
Michael Quigley 2024-06-05 14:55:39 -04:00
parent e2a55393a5
commit 7b8c9483e7
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
3 changed files with 24 additions and 11 deletions

View File

@ -3,15 +3,8 @@ package limits
import (
"github.com/jmoiron/sqlx"
"github.com/openziti/zrok/controller/store"
"github.com/openziti/zrok/sdk/golang/sdk"
)
type UserLimits struct {
resource store.ResourceCountClass
bandwidth store.BandwidthClass
scopes map[sdk.BackendMode]store.BandwidthClass
}
type AccountAction interface {
HandleAccount(a *store.Account, rxBytes, txBytes int64, limit store.BandwidthClass, trx *sqlx.Tx) error
}

View File

@ -0,0 +1,17 @@
package limits
import (
"github.com/jmoiron/sqlx"
"github.com/openziti/zrok/controller/store"
"github.com/openziti/zrok/sdk/golang/sdk"
)
type userLimits struct {
resource store.ResourceCountClass
bandwidth store.BandwidthClass
scopes map[sdk.BackendMode]store.BandwidthClass
}
func (a *Agent) getUserLimits(acctId int, trx *sqlx.Tx) (*userLimits, error) {
return nil, nil
}

View File

@ -37,15 +37,18 @@ func TestBandwidthLimitJournal(t *testing.T) {
assert.Equal(t, int64(1024), latestJe.RxBytes)
assert.Equal(t, int64(2048), latestJe.TxBytes)
lcId, err := str.CreateLimitClass(&LimitClass{
ShareMode: sdk.PrivateShareMode,
BackendMode: sdk.VpnBackendMode,
lc := &LimitClass{
ShareMode: new(sdk.ShareMode),
BackendMode: new(sdk.BackendMode),
PeriodMinutes: 60,
RxBytes: 4096,
TxBytes: 8192,
TotalBytes: 10240,
LimitAction: LimitLimitAction,
}, trx)
}
*lc.ShareMode = sdk.PrivateShareMode
*lc.BackendMode = sdk.ProxyBackendMode
lcId, err := str.CreateLimitClass(lc, trx)
assert.NoError(t, err)
_, err = str.CreateBandwidthLimitJournalEntry(&BandwidthLimitJournalEntry{AccountId: acctId, LimitClassId: &lcId, Action: LimitLimitAction, RxBytes: 10240, TxBytes: 20480}, trx)