mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-02 12:06:09 -04:00
AB#2299 License check in CLI during init (#366)
* license server interaction * logic to read from license file * print license information during init Signed-off-by: Fabian Kammel <fk@edgeless.systems> Co-authored-by: Moritz Eckert <m1gh7ym0@gmail.com>
This commit is contained in:
parent
170a8bf5e0
commit
82eb9f4544
8 changed files with 387 additions and 4 deletions
64
internal/license/license_integration_test.go
Normal file
64
internal/license/license_integration_test.go
Normal file
|
@ -0,0 +1,64 @@
|
|||
//go:build integration
|
||||
|
||||
package license
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCheckQuotaIntegration(t *testing.T) {
|
||||
testCases := map[string]struct {
|
||||
license string
|
||||
action string
|
||||
wantQuota int
|
||||
wantError bool
|
||||
}{
|
||||
"ES license has quota 256": {
|
||||
license: "***REMOVED***",
|
||||
action: test,
|
||||
wantQuota: 256,
|
||||
},
|
||||
"OSS license has quota 8": {
|
||||
license: CommunityLicense,
|
||||
action: test,
|
||||
wantQuota: 8,
|
||||
},
|
||||
"OSS license missing action": {
|
||||
license: CommunityLicense,
|
||||
action: "",
|
||||
wantQuota: 8,
|
||||
},
|
||||
"Empty license assumes community": {
|
||||
license: "",
|
||||
action: test,
|
||||
wantQuota: 8,
|
||||
},
|
||||
"Empty request": {
|
||||
license: "",
|
||||
action: "",
|
||||
wantQuota: 8,
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range testCases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
client := NewClient()
|
||||
|
||||
resp, err := client.CheckQuota(CheckQuotaRequest{
|
||||
Action: tc.action,
|
||||
License: tc.license,
|
||||
})
|
||||
|
||||
if tc.wantError {
|
||||
assert.Error(err)
|
||||
return
|
||||
}
|
||||
assert.NoError(err)
|
||||
assert.Equal(tc.wantQuota, resp.Quota)
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue