From 438daebdb9faa9f85af29161c3fdfe865aaa901b Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Tue, 23 Feb 2021 17:05:47 +0100 Subject: [PATCH] fix: cherry pick fixes from master (#1339) * fix: return api config in ApplicationView (#1330) (cherry picked from commit 16a47c65421e97d2151a76b3272efa598041e0ce) * fix tests --- .../grpc/management/application_converter.go | 11 +++ internal/crypto/code_mocker.go | 8 +- internal/eventstore/example_test.go | 4 +- .../database/kinds/backups/bucket/mock.go | 6 +- .../kinds/databases/managed/adapt_test.go | 76 +++++++++---------- .../iam/zitadel/ambassador/adapt_test.go | 42 +++++----- .../iam/zitadel/ambassador/grpc/adapt_test.go | 18 ++--- .../zitadel/ambassador/hosts/adapt_test.go | 22 +++--- .../iam/zitadel/ambassador/http/adapt_test.go | 34 ++++----- .../iam/zitadel/ambassador/ui/adapt_test.go | 12 +-- .../iam/zitadel/configuration/ready_test.go | 70 ++++++++--------- .../kinds/iam/zitadel/database/adapt_test.go | 4 +- pkg/grpc/management/proto/management.proto | 1 + 13 files changed, 160 insertions(+), 148 deletions(-) diff --git a/internal/api/grpc/management/application_converter.go b/internal/api/grpc/management/application_converter.go index 3051fb82e8..ccaee66ab6 100644 --- a/internal/api/grpc/management/application_converter.go +++ b/internal/api/grpc/management/application_converter.go @@ -142,6 +142,13 @@ func oidcConfigFromApplicationViewModel(app *proj_model.ApplicationView) *manage } } +func apiConfigFromApplicationViewModel(app *proj_model.ApplicationView) *management.APIConfig { + return &management.APIConfig{ + ClientId: app.OIDCClientID, + AuthMethodType: apiAuthMethodTypeFromModel(proj_model.APIAuthMethodType(app.OIDCAuthMethodType)), + } +} + func complianceProblemsToLocalizedMessages(problems []string) []*message.LocalizedMessage { converted := make([]*message.LocalizedMessage, len(problems)) for i, p := range problems { @@ -326,6 +333,10 @@ func applicationViewFromModel(application *proj_model.ApplicationView) *manageme converted.AppConfig = &management.ApplicationView_OidcConfig{ OidcConfig: oidcConfigFromApplicationViewModel(application), } + } else { + converted.AppConfig = &management.ApplicationView_ApiConfig{ + ApiConfig: apiConfigFromApplicationViewModel(application), + } } return converted } diff --git a/internal/crypto/code_mocker.go b/internal/crypto/code_mocker.go index dd441259d9..7baa1cf3c4 100644 --- a/internal/crypto/code_mocker.go +++ b/internal/crypto/code_mocker.go @@ -11,12 +11,12 @@ func CreateMockEncryptionAlg(ctrl *gomock.Controller) EncryptionAlgorithm { mCrypto.EXPECT().Algorithm().AnyTimes().Return("enc") mCrypto.EXPECT().EncryptionKeyID().AnyTimes().Return("id") mCrypto.EXPECT().DecryptionKeyIDs().AnyTimes().Return([]string{"id"}) - mCrypto.EXPECT().Encrypt(gomock.Any()).DoAndReturn( + mCrypto.EXPECT().Encrypt(gomock.Any()).AnyTimes().DoAndReturn( func(code []byte) ([]byte, error) { return code, nil }, ) - mCrypto.EXPECT().DecryptString(gomock.Any(), gomock.Any()).DoAndReturn( + mCrypto.EXPECT().DecryptString(gomock.Any(), gomock.Any()).AnyTimes().DoAndReturn( func(code []byte, keyID string) (string, error) { if keyID != "id" { return "", errors.ThrowInternal(nil, "id", "invalid key id") @@ -30,12 +30,12 @@ func CreateMockEncryptionAlg(ctrl *gomock.Controller) EncryptionAlgorithm { func CreateMockHashAlg(ctrl *gomock.Controller) HashAlgorithm { mCrypto := NewMockHashAlgorithm(ctrl) mCrypto.EXPECT().Algorithm().AnyTimes().Return("hash") - mCrypto.EXPECT().Hash(gomock.Any()).DoAndReturn( + mCrypto.EXPECT().Hash(gomock.Any()).AnyTimes().DoAndReturn( func(code []byte) ([]byte, error) { return code, nil }, ) - mCrypto.EXPECT().CompareHash(gomock.Any(), gomock.Any()).DoAndReturn( + mCrypto.EXPECT().CompareHash(gomock.Any(), gomock.Any()).AnyTimes().DoAndReturn( func(hashed, comparer []byte) error { if string(hashed) != string(comparer) { return errors.ThrowInternal(nil, "id", "invalid") diff --git a/internal/eventstore/example_test.go b/internal/eventstore/example_test.go index 0fba62ec94..112c2a8e46 100644 --- a/internal/eventstore/example_test.go +++ b/internal/eventstore/example_test.go @@ -4,11 +4,11 @@ import ( "context" "encoding/json" "fmt" - "github.com/caos/zitadel/internal/eventstore" "testing" "time" "github.com/caos/zitadel/internal/api/authz" + "github.com/caos/zitadel/internal/eventstore" "github.com/caos/zitadel/internal/eventstore/repository" "github.com/caos/zitadel/internal/eventstore/repository/sql" ) @@ -30,7 +30,7 @@ func NewUserAggregate(id string) *eventstore.Aggregate { // ------------------------------------------------------------ type UserAddedEvent struct { - eventstore.eventstore `json:"-"` + eventstore.BaseEvent `json:"-"` FirstName string `json:"firstName"` } diff --git a/operator/database/kinds/backups/bucket/mock.go b/operator/database/kinds/backups/bucket/mock.go index d39b5d0189..dc6ab66708 100644 --- a/operator/database/kinds/backups/bucket/mock.go +++ b/operator/database/kinds/backups/bucket/mock.go @@ -35,7 +35,7 @@ func SetInstantBackup( }, StringData: map[string]string{secretKey: saJson}, Type: "Opaque", - }).Times(1).Return(nil) + }).MinTimes(1).MaxTimes(1).Return(nil) k8sClient.EXPECT().ApplyJob(gomock.Any()).Times(1).Return(nil) k8sClient.EXPECT().GetJob(namespace, backup.GetJobName(backupName)).Times(1).Return(nil, macherrs.NewNotFound(schema.GroupResource{"batch", "jobs"}, backup.GetJobName(backupName))) @@ -57,7 +57,7 @@ func SetBackup( }, StringData: map[string]string{secretKey: saJson}, Type: "Opaque", - }).Times(1).Return(nil) + }).MinTimes(1).MaxTimes(1).Return(nil) k8sClient.EXPECT().ApplyCronJob(gomock.Any()).Times(1).Return(nil) } @@ -88,7 +88,7 @@ func SetRestore( }, StringData: map[string]string{secretKey: saJson}, Type: "Opaque", - }).Times(1).Return(nil) + }).MinTimes(1).MaxTimes(1).Return(nil) k8sClient.EXPECT().ApplyJob(gomock.Any()).Times(1).Return(nil) k8sClient.EXPECT().GetJob(namespace, restore.GetJobName(backupName)).Times(1).Return(nil, macherrs.NewNotFound(schema.GroupResource{"batch", "jobs"}, restore.GetJobName(backupName))) diff --git a/operator/database/kinds/databases/managed/adapt_test.go b/operator/database/kinds/databases/managed/adapt_test.go index e36de596ab..2c718191a0 100644 --- a/operator/database/kinds/databases/managed/adapt_test.go +++ b/operator/database/kinds/databases/managed/adapt_test.go @@ -106,31 +106,31 @@ func TestManaged_Adapt1(t *testing.T) { } k8sClient.EXPECT().ApplyService(gomock.Any()).Times(3) - k8sClient.EXPECT().ApplyServiceAccount(gomock.Any()).Times(1) - k8sClient.EXPECT().ApplyRole(gomock.Any()).Times(1) - k8sClient.EXPECT().ApplyClusterRole(gomock.Any()).Times(1) - k8sClient.EXPECT().ApplyRoleBinding(gomock.Any()).Times(1) - k8sClient.EXPECT().ApplyClusterRoleBinding(gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyServiceAccount(gomock.Any()).MinTimes(1).MaxTimes(1) + k8sClient.EXPECT().ApplyRole(gomock.Any()).MinTimes(1).MaxTimes(1) + k8sClient.EXPECT().ApplyClusterRole(gomock.Any()).MinTimes(1).MaxTimes(1) + k8sClient.EXPECT().ApplyRoleBinding(gomock.Any()).MinTimes(1).MaxTimes(1) + k8sClient.EXPECT().ApplyClusterRoleBinding(gomock.Any()).MinTimes(1).MaxTimes(1) //statefulset - k8sClient.EXPECT().ApplyStatefulSet(gomock.Any(), gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyStatefulSet(gomock.Any(), gomock.Any()).MinTimes(1).MaxTimes(1) //running for setup - k8sClient.EXPECT().WaitUntilStatefulsetIsReady(namespace, SfsName, true, false, time.Duration(60)) + k8sClient.EXPECT().WaitUntilStatefulsetIsReady(namespace, SfsName, true, false, time.Duration(60)).MinTimes(1).MaxTimes(1) //not ready for setup - k8sClient.EXPECT().WaitUntilStatefulsetIsReady(namespace, SfsName, true, true, time.Duration(1)) + k8sClient.EXPECT().WaitUntilStatefulsetIsReady(namespace, SfsName, true, true, time.Duration(1)).MinTimes(1).MaxTimes(1) //ready after setup - k8sClient.EXPECT().WaitUntilStatefulsetIsReady(namespace, SfsName, true, true, time.Duration(60)) + k8sClient.EXPECT().WaitUntilStatefulsetIsReady(namespace, SfsName, true, true, time.Duration(60)).MinTimes(1).MaxTimes(1) //client - k8sClient.EXPECT().ListSecrets(namespace, nodeLabels).Times(1).Return(secretList, nil) - dbCurrent.EXPECT().GetCertificate().Times(1).Return(nil) - dbCurrent.EXPECT().GetCertificateKey().Times(1).Return(nil) - k8sClient.EXPECT().ApplySecret(gomock.Any()).Times(1) + k8sClient.EXPECT().ListSecrets(namespace, nodeLabels).MinTimes(1).MaxTimes(1).Return(secretList, nil) + dbCurrent.EXPECT().GetCertificate().MinTimes(1).MaxTimes(1).Return(nil) + dbCurrent.EXPECT().GetCertificateKey().MinTimes(1).MaxTimes(1).Return(nil) + k8sClient.EXPECT().ApplySecret(gomock.Any()).MinTimes(1).MaxTimes(1) //node - k8sClient.EXPECT().ListSecrets(namespace, nodeLabels).Times(1).Return(secretList, nil) - dbCurrent.EXPECT().GetCertificate().Times(1).Return(nil) - dbCurrent.EXPECT().GetCertificateKey().Times(1).Return(nil) - dbCurrent.EXPECT().SetCertificate(gomock.Any()).Times(1) - dbCurrent.EXPECT().SetCertificateKey(gomock.Any()).Times(1) - k8sClient.EXPECT().ApplySecret(gomock.Any()).Times(1) + k8sClient.EXPECT().ListSecrets(namespace, nodeLabels).MinTimes(1).MaxTimes(1).Return(secretList, nil) + dbCurrent.EXPECT().GetCertificate().MinTimes(1).MaxTimes(1).Return(nil) + dbCurrent.EXPECT().GetCertificateKey().MinTimes(1).MaxTimes(1).Return(nil) + dbCurrent.EXPECT().SetCertificate(gomock.Any()).MinTimes(1).MaxTimes(1) + dbCurrent.EXPECT().SetCertificateKey(gomock.Any()).MinTimes(1).MaxTimes(1) + k8sClient.EXPECT().ApplySecret(gomock.Any()).MinTimes(1).MaxTimes(1) query, _, _, err := AdaptFunc(componentLabels, namespace, timestamp, nodeselector, tolerations, version, features)(monitor, desired, &tree.Tree{}) assert.NoError(t, err) @@ -218,31 +218,31 @@ func TestManaged_Adapt2(t *testing.T) { } k8sClient.EXPECT().ApplyService(gomock.Any()).Times(3) - k8sClient.EXPECT().ApplyServiceAccount(gomock.Any()).Times(1) - k8sClient.EXPECT().ApplyRole(gomock.Any()).Times(1) - k8sClient.EXPECT().ApplyClusterRole(gomock.Any()).Times(1) - k8sClient.EXPECT().ApplyRoleBinding(gomock.Any()).Times(1) - k8sClient.EXPECT().ApplyClusterRoleBinding(gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyServiceAccount(gomock.Any()).MinTimes(1).MaxTimes(1) + k8sClient.EXPECT().ApplyRole(gomock.Any()).MinTimes(1).MaxTimes(1) + k8sClient.EXPECT().ApplyClusterRole(gomock.Any()).MinTimes(1).MaxTimes(1) + k8sClient.EXPECT().ApplyRoleBinding(gomock.Any()).MinTimes(1).MaxTimes(1) + k8sClient.EXPECT().ApplyClusterRoleBinding(gomock.Any()).MinTimes(1).MaxTimes(1) //statefulset - k8sClient.EXPECT().ApplyStatefulSet(gomock.Any(), gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyStatefulSet(gomock.Any(), gomock.Any()).MinTimes(1).MaxTimes(1) //running for setup - k8sClient.EXPECT().WaitUntilStatefulsetIsReady(namespace, SfsName, true, false, time.Duration(60)) + k8sClient.EXPECT().WaitUntilStatefulsetIsReady(namespace, SfsName, true, false, time.Duration(60)).MinTimes(1).MaxTimes(1) //not ready for setup - k8sClient.EXPECT().WaitUntilStatefulsetIsReady(namespace, SfsName, true, true, time.Duration(1)) + k8sClient.EXPECT().WaitUntilStatefulsetIsReady(namespace, SfsName, true, true, time.Duration(1)).MinTimes(1).MaxTimes(1) //ready after setup - k8sClient.EXPECT().WaitUntilStatefulsetIsReady(namespace, SfsName, true, true, time.Duration(60)) + k8sClient.EXPECT().WaitUntilStatefulsetIsReady(namespace, SfsName, true, true, time.Duration(60)).MinTimes(1).MaxTimes(1) //client - k8sClient.EXPECT().ListSecrets(namespace, nodeLabels).Times(1).Return(secretList, nil) - dbCurrent.EXPECT().GetCertificate().Times(1).Return(nil) - dbCurrent.EXPECT().GetCertificateKey().Times(1).Return(nil) - k8sClient.EXPECT().ApplySecret(gomock.Any()).Times(1) + k8sClient.EXPECT().ListSecrets(namespace, nodeLabels).MinTimes(1).MaxTimes(1).Return(secretList, nil) + dbCurrent.EXPECT().GetCertificate().MinTimes(1).MaxTimes(1).Return(nil) + dbCurrent.EXPECT().GetCertificateKey().MinTimes(1).MaxTimes(1).Return(nil) + k8sClient.EXPECT().ApplySecret(gomock.Any()).MinTimes(1).MaxTimes(1) //node - k8sClient.EXPECT().ListSecrets(namespace, nodeLabels).Times(1).Return(secretList, nil) - dbCurrent.EXPECT().GetCertificate().Times(1).Return(nil) - dbCurrent.EXPECT().GetCertificateKey().Times(1).Return(nil) - dbCurrent.EXPECT().SetCertificate(gomock.Any()).Times(1) - dbCurrent.EXPECT().SetCertificateKey(gomock.Any()).Times(1) - k8sClient.EXPECT().ApplySecret(gomock.Any()).Times(1) + k8sClient.EXPECT().ListSecrets(namespace, nodeLabels).MinTimes(1).MaxTimes(1).Return(secretList, nil) + dbCurrent.EXPECT().GetCertificate().MinTimes(1).MaxTimes(1).Return(nil) + dbCurrent.EXPECT().GetCertificateKey().MinTimes(1).MaxTimes(1).Return(nil) + dbCurrent.EXPECT().SetCertificate(gomock.Any()).MinTimes(1).MaxTimes(1) + dbCurrent.EXPECT().SetCertificateKey(gomock.Any()).MinTimes(1).MaxTimes(1) + k8sClient.EXPECT().ApplySecret(gomock.Any()).MinTimes(1).MaxTimes(1) query, _, _, err := AdaptFunc(componentLabels, namespace, timestamp, nodeselector, tolerations, version, features)(monitor, desired, &tree.Tree{}) assert.NoError(t, err) diff --git a/operator/zitadel/kinds/iam/zitadel/ambassador/adapt_test.go b/operator/zitadel/kinds/iam/zitadel/ambassador/adapt_test.go index cdadab4f67..7538663458 100644 --- a/operator/zitadel/kinds/iam/zitadel/ambassador/adapt_test.go +++ b/operator/zitadel/kinds/iam/zitadel/ambassador/adapt_test.go @@ -33,7 +33,7 @@ func SetReturnResourceVersion( }, }, } - k8sClient.EXPECT().GetNamespacedCRDResource(group, version, kind, namespace, name).Return(ret, nil) + k8sClient.EXPECT().GetNamespacedCRDResource(group, version, kind, namespace, name).MinTimes(1).MaxTimes(1).Return(ret, nil) } func SetMappingsUI( @@ -43,12 +43,12 @@ func SetMappingsUI( group := "getambassador.io" version := "v2" kind := "Mapping" - k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").Times(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) + k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").MinTimes(1).MaxTimes(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, ui.AccountsName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ui.AccountsName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ui.AccountsName, gomock.Any()).MinTimes(1).MaxTimes(1) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, ui.ConsoleName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ui.ConsoleName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ui.ConsoleName, gomock.Any()).MinTimes(1).MaxTimes(1) } func SetMappingsHTTP( @@ -58,22 +58,22 @@ func SetMappingsHTTP( group := "getambassador.io" version := "v2" kind := "Mapping" - k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").Times(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) + k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").MinTimes(1).MaxTimes(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, http.AdminRName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.AdminRName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.AdminRName, gomock.Any()).MinTimes(1).MaxTimes(1) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, http.AuthorizeName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.AuthorizeName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.AuthorizeName, gomock.Any()).MinTimes(1).MaxTimes(1) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, http.AuthRName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.AuthRName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.AuthRName, gomock.Any()).MinTimes(1).MaxTimes(1) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, http.EndsessionName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.EndsessionName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.EndsessionName, gomock.Any()).MinTimes(1).MaxTimes(1) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, http.IssuerName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.IssuerName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.IssuerName, gomock.Any()).MinTimes(1).MaxTimes(1) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, http.MgmtName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.MgmtName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.MgmtName, gomock.Any()).MinTimes(1).MaxTimes(1) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, http.OauthName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.OauthName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.OauthName, gomock.Any()).MinTimes(1).MaxTimes(1) } func SetMappingsGRPC( @@ -83,14 +83,14 @@ func SetMappingsGRPC( group := "getambassador.io" version := "v2" kind := "Mapping" - k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").Times(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) + k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").MinTimes(1).MaxTimes(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, grpc.AdminMName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, grpc.AdminMName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, grpc.AdminMName, gomock.Any()).MinTimes(1).MaxTimes(1) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, grpc.AuthMName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, grpc.AuthMName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, grpc.AuthMName, gomock.Any()).MinTimes(1).MaxTimes(1) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, grpc.MgmtMName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, grpc.MgmtMName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, grpc.MgmtMName, gomock.Any()).MinTimes(1).MaxTimes(1) } func SetHosts( @@ -100,16 +100,16 @@ func SetHosts( group := "getambassador.io" version := "v2" kind := "Host" - k8sClient.EXPECT().CheckCRD("hosts.getambassador.io").Times(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) + k8sClient.EXPECT().CheckCRD("hosts.getambassador.io").MinTimes(1).MaxTimes(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, hosts.AccountsHostName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, hosts.AccountsHostName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, hosts.AccountsHostName, gomock.Any()).MinTimes(1).MaxTimes(1) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, hosts.ApiHostName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, hosts.ApiHostName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, hosts.ApiHostName, gomock.Any()).MinTimes(1).MaxTimes(1) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, hosts.ConsoleHostName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, hosts.ConsoleHostName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, hosts.ConsoleHostName, gomock.Any()).MinTimes(1).MaxTimes(1) SetReturnResourceVersion(k8sClient, group, version, kind, namespace, hosts.IssuerHostName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, hosts.IssuerHostName, gomock.Any()).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, hosts.IssuerHostName, gomock.Any()).MinTimes(1).MaxTimes(1) } diff --git a/operator/zitadel/kinds/iam/zitadel/ambassador/grpc/adapt_test.go b/operator/zitadel/kinds/iam/zitadel/ambassador/grpc/adapt_test.go index 1a67d5c00a..2c66b066bd 100644 --- a/operator/zitadel/kinds/iam/zitadel/ambassador/grpc/adapt_test.go +++ b/operator/zitadel/kinds/iam/zitadel/ambassador/grpc/adapt_test.go @@ -31,7 +31,7 @@ func SetReturnResourceVersion( }, }, } - k8sClient.EXPECT().GetNamespacedCRDResource(group, version, kind, namespace, name).Return(ret, nil) + k8sClient.EXPECT().GetNamespacedCRDResource(group, version, kind, namespace, name).MinTimes(1).MaxTimes(1).Return(ret, nil) } func TestGrpc_Adapt(t *testing.T) { @@ -53,7 +53,7 @@ func TestGrpc_Adapt(t *testing.T) { k8sClient := kubernetesmock.NewMockClientInt(gomock.NewController(t)) - k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").Times(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) + k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").MinTimes(1).MaxTimes(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) group := "getambassador.io" version := "v2" @@ -90,7 +90,7 @@ func TestGrpc_Adapt(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AdminMName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AdminMName, adminM).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AdminMName, adminM).MinTimes(1).MaxTimes(1) authMName := labels.MustForName(componentLabels, AuthMName) authM := &unstructured.Unstructured{ @@ -115,7 +115,7 @@ func TestGrpc_Adapt(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AuthMName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthMName, authM).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthMName, authM).MinTimes(1).MaxTimes(1) mgmtMName := labels.MustForName(componentLabels, MgmtMName) mgmtM := &unstructured.Unstructured{ @@ -140,7 +140,7 @@ func TestGrpc_Adapt(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, MgmtMName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, MgmtMName, mgmtM).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, MgmtMName, mgmtM).MinTimes(1).MaxTimes(1) query, _, err := AdaptFunc(monitor, componentLabels, namespace, url, dns) assert.NoError(t, err) @@ -169,7 +169,7 @@ func TestGrpc_Adapt2(t *testing.T) { k8sClient := kubernetesmock.NewMockClientInt(gomock.NewController(t)) - k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").Times(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) + k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").MinTimes(1).MaxTimes(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) group := "getambassador.io" version := "v2" @@ -207,7 +207,7 @@ func TestGrpc_Adapt2(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AdminMName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AdminMName, adminM).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AdminMName, adminM).MinTimes(1).MaxTimes(1) authMName := labels.MustForName(componentLabels, AuthMName) authM := &unstructured.Unstructured{ @@ -232,7 +232,7 @@ func TestGrpc_Adapt2(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AuthMName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthMName, authM).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthMName, authM).MinTimes(1).MaxTimes(1) mgmtMName := labels.MustForName(componentLabels, MgmtMName) mgmtM := &unstructured.Unstructured{ @@ -257,7 +257,7 @@ func TestGrpc_Adapt2(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, MgmtMName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, MgmtMName, mgmtM).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, MgmtMName, mgmtM).MinTimes(1).MaxTimes(1) query, _, err := AdaptFunc(monitor, componentLabels, namespace, url, dns) assert.NoError(t, err) diff --git a/operator/zitadel/kinds/iam/zitadel/ambassador/hosts/adapt_test.go b/operator/zitadel/kinds/iam/zitadel/ambassador/hosts/adapt_test.go index b3a7f7b290..406fe0cf79 100644 --- a/operator/zitadel/kinds/iam/zitadel/ambassador/hosts/adapt_test.go +++ b/operator/zitadel/kinds/iam/zitadel/ambassador/hosts/adapt_test.go @@ -30,7 +30,7 @@ func SetReturnResourceVersion( }, }, } - k8sClient.EXPECT().GetNamespacedCRDResource(group, version, kind, namespace, name).Return(ret, nil) + k8sClient.EXPECT().GetNamespacedCRDResource(group, version, kind, namespace, name).MinTimes(1).MaxTimes(1).Return(ret, nil) } func TestHosts_AdaptFunc(t *testing.T) { @@ -52,7 +52,7 @@ func TestHosts_AdaptFunc(t *testing.T) { k8sClient := kubernetesmock.NewMockClientInt(gomock.NewController(t)) - k8sClient.EXPECT().CheckCRD("hosts.getambassador.io").Times(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) + k8sClient.EXPECT().CheckCRD("hosts.getambassador.io").MinTimes(1).MaxTimes(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) group := "getambassador.io" version := "v2" @@ -91,7 +91,7 @@ func TestHosts_AdaptFunc(t *testing.T) { }} SetReturnResourceVersion(k8sClient, group, version, kind, namespace, IssuerHostName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, IssuerHostName, issuerHost).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, IssuerHostName, issuerHost).MinTimes(1).MaxTimes(1) consoleHostName := labels.MustForName(componentLabels, ConsoleHostName) consoleHost := &unstructured.Unstructured{ @@ -126,7 +126,7 @@ func TestHosts_AdaptFunc(t *testing.T) { }} SetReturnResourceVersion(k8sClient, group, version, kind, namespace, ConsoleHostName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ConsoleHostName, consoleHost).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ConsoleHostName, consoleHost).MinTimes(1).MaxTimes(1) apiHostName := labels.MustForName(componentLabels, ApiHostName) apiHost := &unstructured.Unstructured{ @@ -161,7 +161,7 @@ func TestHosts_AdaptFunc(t *testing.T) { }} SetReturnResourceVersion(k8sClient, group, version, kind, namespace, ApiHostName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ApiHostName, apiHost).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ApiHostName, apiHost).MinTimes(1).MaxTimes(1) accountsHostName := labels.MustForName(componentLabels, AccountsHostName) accountsHost := &unstructured.Unstructured{ @@ -196,7 +196,7 @@ func TestHosts_AdaptFunc(t *testing.T) { }} SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AccountsHostName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AccountsHostName, accountsHost).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AccountsHostName, accountsHost).MinTimes(1).MaxTimes(1) query, _, err := AdaptFunc(monitor, componentLabels, namespace, dns) assert.NoError(t, err) @@ -224,7 +224,7 @@ func TestHosts_AdaptFunc2(t *testing.T) { k8sClient := kubernetesmock.NewMockClientInt(gomock.NewController(t)) - k8sClient.EXPECT().CheckCRD("hosts.getambassador.io").Times(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) + k8sClient.EXPECT().CheckCRD("hosts.getambassador.io").MinTimes(1).MaxTimes(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) group := "getambassador.io" version := "v2" @@ -263,7 +263,7 @@ func TestHosts_AdaptFunc2(t *testing.T) { }} SetReturnResourceVersion(k8sClient, group, version, kind, namespace, IssuerHostName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, IssuerHostName, issuerHost).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, IssuerHostName, issuerHost).MinTimes(1).MaxTimes(1) consoleHostName := labels.MustForName(componentLabels, ConsoleHostName) consoleHost := &unstructured.Unstructured{ @@ -298,7 +298,7 @@ func TestHosts_AdaptFunc2(t *testing.T) { }} SetReturnResourceVersion(k8sClient, group, version, kind, namespace, ConsoleHostName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ConsoleHostName, consoleHost).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ConsoleHostName, consoleHost).MinTimes(1).MaxTimes(1) apiHostName := labels.MustForName(componentLabels, ApiHostName) apiHost := &unstructured.Unstructured{ @@ -333,7 +333,7 @@ func TestHosts_AdaptFunc2(t *testing.T) { }} SetReturnResourceVersion(k8sClient, group, version, kind, namespace, ApiHostName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ApiHostName, apiHost).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ApiHostName, apiHost).MinTimes(1).MaxTimes(1) accountsHostName := labels.MustForName(componentLabels, AccountsHostName) accountsHost := &unstructured.Unstructured{ @@ -368,7 +368,7 @@ func TestHosts_AdaptFunc2(t *testing.T) { }} SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AccountsHostName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AccountsHostName, accountsHost).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AccountsHostName, accountsHost).MinTimes(1).MaxTimes(1) query, _, err := AdaptFunc(monitor, componentLabels, namespace, dns) assert.NoError(t, err) diff --git a/operator/zitadel/kinds/iam/zitadel/ambassador/http/adapt_test.go b/operator/zitadel/kinds/iam/zitadel/ambassador/http/adapt_test.go index 20c26de0b4..5776e6b3a6 100644 --- a/operator/zitadel/kinds/iam/zitadel/ambassador/http/adapt_test.go +++ b/operator/zitadel/kinds/iam/zitadel/ambassador/http/adapt_test.go @@ -30,7 +30,7 @@ func SetReturnResourceVersion( }, }, } - k8sClient.EXPECT().GetNamespacedCRDResource(group, version, kind, namespace, name).Return(ret, nil) + k8sClient.EXPECT().GetNamespacedCRDResource(group, version, kind, namespace, name).MinTimes(1).MaxTimes(1).Return(ret, nil) } func TestHttp_Adapt(t *testing.T) { @@ -49,7 +49,7 @@ func TestHttp_Adapt(t *testing.T) { } k8sClient := kubernetesmock.NewMockClientInt(gomock.NewController(t)) - k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").Times(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) + k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").MinTimes(1).MaxTimes(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) group := "getambassador.io" version := "v2" @@ -87,7 +87,7 @@ func TestHttp_Adapt(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, EndsessionName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, EndsessionName, endsession).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, EndsessionName, endsession).MinTimes(1).MaxTimes(1) issuerName := labels.MustForName(componentLabels, IssuerName) issuer := &unstructured.Unstructured{ @@ -111,7 +111,7 @@ func TestHttp_Adapt(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, IssuerName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, IssuerName, issuer).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, IssuerName, issuer).MinTimes(1).MaxTimes(1) authorizeName := labels.MustForName(componentLabels, AuthorizeName) authorize := &unstructured.Unstructured{ @@ -135,7 +135,7 @@ func TestHttp_Adapt(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AuthorizeName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthorizeName, authorize).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthorizeName, authorize).MinTimes(1).MaxTimes(1) oauthName := labels.MustForName(componentLabels, OauthName) oauth := &unstructured.Unstructured{ @@ -159,7 +159,7 @@ func TestHttp_Adapt(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, OauthName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, OauthName, oauth).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, OauthName, oauth).MinTimes(1).MaxTimes(1) mgmtName := labels.MustForName(componentLabels, MgmtName) mgmt := &unstructured.Unstructured{ @@ -183,7 +183,7 @@ func TestHttp_Adapt(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, MgmtName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, MgmtName, mgmt).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, MgmtName, mgmt).MinTimes(1).MaxTimes(1) adminRName := labels.MustForName(componentLabels, AdminRName) adminR := &unstructured.Unstructured{ @@ -207,7 +207,7 @@ func TestHttp_Adapt(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AdminRName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AdminRName, adminR).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AdminRName, adminR).MinTimes(1).MaxTimes(1) authRName := labels.MustForName(componentLabels, AuthRName) authR := &unstructured.Unstructured{ @@ -231,7 +231,7 @@ func TestHttp_Adapt(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AuthRName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthRName, authR).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthRName, authR).MinTimes(1).MaxTimes(1) query, _, err := AdaptFunc(monitor, componentLabels, namespace, url, dns) assert.NoError(t, err) @@ -257,7 +257,7 @@ func TestHttp_Adapt2(t *testing.T) { } k8sClient := kubernetesmock.NewMockClientInt(gomock.NewController(t)) - k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").Times(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) + k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").MinTimes(1).MaxTimes(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) group := "getambassador.io" version := "v2" @@ -296,7 +296,7 @@ func TestHttp_Adapt2(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, EndsessionName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, EndsessionName, endsession).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, EndsessionName, endsession).MinTimes(1).MaxTimes(1) issuerName := labels.MustForName(componentLabels, IssuerName) issuer := &unstructured.Unstructured{ @@ -320,7 +320,7 @@ func TestHttp_Adapt2(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, IssuerName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, IssuerName, issuer).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, IssuerName, issuer).MinTimes(1).MaxTimes(1) authorizeName := labels.MustForName(componentLabels, AuthorizeName) authorize := &unstructured.Unstructured{ @@ -344,7 +344,7 @@ func TestHttp_Adapt2(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AuthorizeName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthorizeName, authorize).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthorizeName, authorize).MinTimes(1).MaxTimes(1) oauthName := labels.MustForName(componentLabels, OauthName) oauth := &unstructured.Unstructured{ @@ -368,7 +368,7 @@ func TestHttp_Adapt2(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, OauthName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, OauthName, oauth).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, OauthName, oauth).MinTimes(1).MaxTimes(1) mgmtName := labels.MustForName(componentLabels, MgmtName) mgmt := &unstructured.Unstructured{ @@ -392,7 +392,7 @@ func TestHttp_Adapt2(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, MgmtName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, MgmtName, mgmt).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, MgmtName, mgmt).MinTimes(1).MaxTimes(1) adminRName := labels.MustForName(componentLabels, AdminRName) adminR := &unstructured.Unstructured{ @@ -416,7 +416,7 @@ func TestHttp_Adapt2(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AdminRName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AdminRName, adminR).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AdminRName, adminR).MinTimes(1).MaxTimes(1) authRName := labels.MustForName(componentLabels, AuthRName) authR := &unstructured.Unstructured{ @@ -440,7 +440,7 @@ func TestHttp_Adapt2(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AuthRName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthRName, authR).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthRName, authR).MinTimes(1).MaxTimes(1) query, _, err := AdaptFunc(monitor, componentLabels, namespace, url, dns) assert.NoError(t, err) diff --git a/operator/zitadel/kinds/iam/zitadel/ambassador/ui/adapt_test.go b/operator/zitadel/kinds/iam/zitadel/ambassador/ui/adapt_test.go index 189955c13b..d9d94e74de 100644 --- a/operator/zitadel/kinds/iam/zitadel/ambassador/ui/adapt_test.go +++ b/operator/zitadel/kinds/iam/zitadel/ambassador/ui/adapt_test.go @@ -30,11 +30,11 @@ func SetReturnResourceVersion( }, }, } - k8sClient.EXPECT().GetNamespacedCRDResource(group, version, kind, namespace, name).Return(ret, nil) + k8sClient.EXPECT().GetNamespacedCRDResource(group, version, kind, namespace, name).MinTimes(1).MaxTimes(1).Return(ret, nil) } func SetCheckCRD(k8sClient *kubernetesmock.MockClientInt) { - k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").Times(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) + k8sClient.EXPECT().CheckCRD("mappings.getambassador.io").MinTimes(1).MaxTimes(1).Return(&apixv1beta1.CustomResourceDefinition{}, nil) } func SetMappingsEmpty( @@ -68,7 +68,7 @@ func SetMappingsEmpty( }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, accountsLabels.Name(), "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, accountsLabels.Name(), accounts).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, accountsLabels.Name(), accounts).MinTimes(1).MaxTimes(1) console := &unstructured.Unstructured{ Object: map[string]interface{}{ @@ -88,7 +88,7 @@ func SetMappingsEmpty( }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, consoleLabels.Name(), "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, consoleLabels.Name(), console).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, consoleLabels.Name(), console).MinTimes(1).MaxTimes(1) } func TestUi_Adapt(t *testing.T) { @@ -171,7 +171,7 @@ func TestUi_Adapt2(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AccountsName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AccountsName, accounts).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AccountsName, accounts).MinTimes(1).MaxTimes(1) consoleName := labels.MustForName(componentLabels, ConsoleName) console := &unstructured.Unstructured{ @@ -192,7 +192,7 @@ func TestUi_Adapt2(t *testing.T) { }, } SetReturnResourceVersion(k8sClient, group, version, kind, namespace, ConsoleName, "") - k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ConsoleName, console).Times(1) + k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, ConsoleName, console).MinTimes(1).MaxTimes(1) query, _, err := AdaptFunc(monitor, componentLabels, namespace, uiURL, dns) assert.NoError(t, err) diff --git a/operator/zitadel/kinds/iam/zitadel/configuration/ready_test.go b/operator/zitadel/kinds/iam/zitadel/configuration/ready_test.go index dc7db0fab8..b1f2df7989 100644 --- a/operator/zitadel/kinds/iam/zitadel/configuration/ready_test.go +++ b/operator/zitadel/kinds/iam/zitadel/configuration/ready_test.go @@ -19,11 +19,11 @@ func TestConfiguration_Ready1(t *testing.T) { cmName := "testCM" consoleCMName := "testConsole" - client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).Times(1).Return(nil) + client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).MinTimes(1).MaxTimes(1).Return(nil) readyFunc := GetReadyFunc(monitor, namespace, secretName, secretVarsName, secretPasswordName, cmName, consoleCMName) assert.NotNil(t, readyFunc) @@ -40,11 +40,11 @@ func TestConfiguration_Ready2(t *testing.T) { cmName := "testCM2" consoleCMName := "testConsole2" - client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).Times(1).Return(nil) + client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).MinTimes(1).MaxTimes(1).Return(nil) readyFunc := GetReadyFunc(monitor, namespace, secretName, secretVarsName, secretPasswordName, cmName, consoleCMName) assert.NotNil(t, readyFunc) @@ -61,11 +61,11 @@ func TestConfiguration_ReadyFail1(t *testing.T) { cmName := "testCM" consoleCMName := "testConsole" - client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).Times(1).Return(errors.New("fail")) - client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).Times(1).Return(nil) + client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).MinTimes(1).MaxTimes(1).Return(errors.New("fail")) + client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).MinTimes(1).MaxTimes(1).Return(nil) readyFunc := GetReadyFunc(monitor, namespace, secretName, secretVarsName, secretPasswordName, cmName, consoleCMName) assert.NotNil(t, readyFunc) @@ -82,11 +82,11 @@ func TestConfiguration_ReadyFail2(t *testing.T) { cmName := "testCM" consoleCMName := "testConsole" - client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).Times(1).Return(errors.New("fail")) - client.EXPECT().WaitForSecret(namespace, secretName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).Times(1).Return(nil) + client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).MinTimes(1).MaxTimes(1).Return(errors.New("fail")) + client.EXPECT().WaitForSecret(namespace, secretName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).MinTimes(1).MaxTimes(1).Return(nil) readyFunc := GetReadyFunc(monitor, namespace, secretName, secretVarsName, secretPasswordName, cmName, consoleCMName) assert.NotNil(t, readyFunc) @@ -103,11 +103,11 @@ func TestConfiguration_ReadyFail3(t *testing.T) { cmName := "testCM" consoleCMName := "testConsole" - client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretName, timeout).Times(1).Return(errors.New("fail")) - client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).Times(1).Return(nil) + client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretName, timeout).MinTimes(1).MaxTimes(1).Return(errors.New("fail")) + client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).MinTimes(1).MaxTimes(1).Return(nil) readyFunc := GetReadyFunc(monitor, namespace, secretName, secretVarsName, secretPasswordName, cmName, consoleCMName) assert.NotNil(t, readyFunc) @@ -124,11 +124,11 @@ func TestConfiguration_ReadyFail4(t *testing.T) { cmName := "testCM" consoleCMName := "testConsole" - client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).Times(1).Return(errors.New("fail")) - client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).Times(1).Return(nil) + client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).MinTimes(1).MaxTimes(1).Return(errors.New("fail")) + client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).MinTimes(1).MaxTimes(1).Return(nil) readyFunc := GetReadyFunc(monitor, namespace, secretName, secretVarsName, secretPasswordName, cmName, consoleCMName) assert.NotNil(t, readyFunc) @@ -145,11 +145,11 @@ func TestConfiguration_ReadyFail5(t *testing.T) { cmName := "testCM" consoleCMName := "testConsole" - client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).Times(1).Return(nil) - client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).Times(1).Return(errors.New("fail")) + client.EXPECT().WaitForConfigMap(namespace, cmName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForConfigMap(namespace, consoleCMName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretVarsName, timeout).MinTimes(1).MaxTimes(1).Return(nil) + client.EXPECT().WaitForSecret(namespace, secretPasswordName, timeout).MinTimes(1).MaxTimes(1).Return(errors.New("fail")) readyFunc := GetReadyFunc(monitor, namespace, secretName, secretVarsName, secretPasswordName, cmName, consoleCMName) assert.NotNil(t, readyFunc) diff --git a/operator/zitadel/kinds/iam/zitadel/database/adapt_test.go b/operator/zitadel/kinds/iam/zitadel/database/adapt_test.go index 62501931d2..5f9df1959c 100644 --- a/operator/zitadel/kinds/iam/zitadel/database/adapt_test.go +++ b/operator/zitadel/kinds/iam/zitadel/database/adapt_test.go @@ -77,8 +77,8 @@ func TestDatabase_AdaptFailConnection(t *testing.T) { monitor := mntr.Monitor{} queried := map[string]interface{}{} - dbClient.EXPECT().GetConnectionInfo(monitor, k8sClient).Return("", "", errors.New("fail")) - dbClient.EXPECT().ListUsers(monitor, k8sClient).Return([]string{"test"}, nil) + dbClient.EXPECT().GetConnectionInfo(monitor, k8sClient).MinTimes(1).MaxTimes(1).Return("", "", errors.New("fail")) + dbClient.EXPECT().ListUsers(monitor, k8sClient).MinTimes(1).MaxTimes(1).Return([]string{"test"}, nil) _, err := GetDatabaseInQueried(queried) assert.Error(t, err) diff --git a/pkg/grpc/management/proto/management.proto b/pkg/grpc/management/proto/management.proto index 7cf1e86332..fd84aec18a 100644 --- a/pkg/grpc/management/proto/management.proto +++ b/pkg/grpc/management/proto/management.proto @@ -2853,6 +2853,7 @@ message ApplicationView { string name = 5; oneof app_config { OIDCConfig oidc_config = 8; + APIConfig api_config = 10; } uint64 sequence = 9;