2022-08-16 10:06:38 -04:00
|
|
|
//go:build integration
|
|
|
|
|
2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-11-22 06:44:06 -05:00
|
|
|
package integration
|
2022-08-16 10:06:38 -04:00
|
|
|
|
|
|
|
import (
|
2022-08-17 07:50:43 -04:00
|
|
|
"context"
|
2022-08-16 10:06:38 -04:00
|
|
|
"testing"
|
|
|
|
|
2023-11-22 06:44:06 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/license"
|
2022-08-16 10:06:38 -04:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2022-08-25 08:06:29 -04:00
|
|
|
func TestQuotaCheckIntegration(t *testing.T) {
|
2022-08-16 10:06:38 -04:00
|
|
|
testCases := map[string]struct {
|
|
|
|
license string
|
|
|
|
wantQuota int
|
|
|
|
wantError bool
|
|
|
|
}{
|
|
|
|
"OSS license has quota 8": {
|
2023-11-22 06:44:06 -05:00
|
|
|
license: license.CommunityLicense,
|
2022-08-16 10:06:38 -04:00
|
|
|
wantQuota: 8,
|
|
|
|
},
|
|
|
|
"Empty license assumes community": {
|
|
|
|
license: "",
|
|
|
|
wantQuota: 8,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for name, tc := range testCases {
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
2023-11-22 06:44:06 -05:00
|
|
|
client := license.NewClient()
|
2022-08-16 10:06:38 -04:00
|
|
|
|
2023-11-22 06:44:06 -05:00
|
|
|
req := license.QuotaCheckRequest{
|
|
|
|
Action: license.Action("test"),
|
2022-08-16 10:06:38 -04:00
|
|
|
License: tc.license,
|
2022-08-17 07:50:43 -04:00
|
|
|
}
|
2022-08-25 08:06:29 -04:00
|
|
|
resp, err := client.QuotaCheck(context.Background(), req)
|
2022-08-16 10:06:38 -04:00
|
|
|
|
|
|
|
if tc.wantError {
|
|
|
|
assert.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
assert.NoError(err)
|
|
|
|
assert.Equal(tc.wantQuota, resp.Quota)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|