mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-26 07:59:37 -05:00
519efe637d
* Clean up license checker code Signed-off-by: Daniel Weiße <dw@edgeless.systems> * Create license check depending on init/upgrade actions Signed-off-by: Daniel Weiße <dw@edgeless.systems> * Run license check in Terraform provider Signed-off-by: Daniel Weiße <dw@edgeless.systems> * fix license integration test action Signed-off-by: Daniel Weiße <dw@edgeless.systems> * Run tests with enterprise tag Signed-off-by: Daniel Weiße <dw@edgeless.systems> * Allow b64 encoding for license ID Signed-off-by: Daniel Weiße <dw@edgeless.systems> * Update checker_enterprise.go --------- Signed-off-by: Daniel Weiße <dw@edgeless.systems> Co-authored-by: Thomas Tendyck <51411342+thomasten@users.noreply.github.com>
53 lines
1011 B
Go
53 lines
1011 B
Go
//go:build integration
|
|
|
|
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package integration
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
|
"github.com/edgelesssys/constellation/v2/internal/license"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestQuotaCheckIntegration(t *testing.T) {
|
|
testCases := map[string]struct {
|
|
license string
|
|
wantQuota int
|
|
wantError bool
|
|
}{
|
|
"OSS license has quota 8": {
|
|
license: license.CommunityLicense,
|
|
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)
|
|
|
|
client := license.NewChecker()
|
|
|
|
quota, err := client.CheckLicense(context.Background(), cloudprovider.Unknown, "test", tc.license)
|
|
|
|
if tc.wantError {
|
|
assert.Error(err)
|
|
return
|
|
}
|
|
assert.NoError(err)
|
|
assert.Equal(tc.wantQuota, quota)
|
|
})
|
|
}
|
|
}
|