Skip to content

Commit

Permalink
Merge branch 'master' into createttr
Browse files Browse the repository at this point in the history
# Conflicts:
#	go.mod
#	go.sum
  • Loading branch information
Devtools committed Jan 16, 2025
2 parents 6d72c89 + d844c83 commit 0ebf1df
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
5 changes: 3 additions & 2 deletions controllers/usersignup/usersignup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"errors"
"fmt"
"os"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"strings"
"testing"
"time"

"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

. "github.com/codeready-toolchain/host-operator/pkg/space"

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
Expand Down Expand Up @@ -3135,7 +3136,7 @@ func TestUserSignupBannedWithoutMURAndSpace(t *testing.T) {

func TestUserSignupVerificationRequired(t *testing.T) {
// given
userSignup := commonsignup.NewUserSignup(commonsignup.VerificationRequired(0))
userSignup := commonsignup.NewUserSignup(commonsignup.VerificationRequired())

r, req, _ := prepareReconcile(t, userSignup.Name, userSignup, commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true)), baseNSTemplateTier)
InitializeCounters(t, NewToolchainStatus(
Expand Down
30 changes: 15 additions & 15 deletions controllers/usersignupcleanup/usersignup_cleanup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestUserCleanup(t *testing.T) {
userSignup := commonsignup.NewUserSignup(
commonsignup.ApprovedManuallyAgo(fiveYears),
commonsignup.WithStateLabel(toolchainv1alpha1.UserSignupStateLabelValueApproved),
commonsignup.DeactivatedWithLastTransitionTime(time.Duration(5*time.Minute)),
commonsignup.DeactivatedAgo(5*time.Minute),
commonsignup.CreatedBefore(fiveYears),
)

Expand All @@ -85,7 +85,7 @@ func TestUserCleanup(t *testing.T) {
userSignup := commonsignup.NewUserSignup(
commonsignup.WithStateLabel(toolchainv1alpha1.UserSignupStateLabelValueApproved),
commonsignup.ApprovedManuallyAgo(fiveYears),
commonsignup.DeactivatedWithLastTransitionTime(fiveYears),
commonsignup.DeactivatedAgo(fiveYears),
commonsignup.CreatedBefore(fiveYears),
)

Expand All @@ -111,7 +111,7 @@ func TestUserCleanup(t *testing.T) {

userSignup := commonsignup.NewUserSignup(
commonsignup.CreatedBefore(days(8)),
commonsignup.VerificationRequired(days(8)),
commonsignup.VerificationRequiredAgo(days(8)),
commonsignup.WithActivations("0"),
)

Expand Down Expand Up @@ -142,7 +142,7 @@ func TestUserCleanup(t *testing.T) {
// given
userSignup := commonsignup.NewUserSignup(
commonsignup.CreatedBefore(days(8)),
commonsignup.VerificationRequired(days(8)),
commonsignup.VerificationRequiredAgo(days(8)),
)
r, req, _ := prepareReconcile(t, userSignup.Name, userSignup)
// when
Expand All @@ -167,7 +167,7 @@ func TestUserCleanup(t *testing.T) {
// given
userSignup := commonsignup.NewUserSignup(
commonsignup.CreatedBefore(days(8)),
commonsignup.VerificationRequired(days(8)),
commonsignup.VerificationRequiredAgo(days(8)),
commonsignup.WithAnnotation(toolchainv1alpha1.UserSignupVerificationCodeAnnotationKey, "12345"),
)
r, req, _ := prepareReconcile(t, userSignup.Name, userSignup)
Expand All @@ -194,7 +194,7 @@ func TestUserCleanup(t *testing.T) {
userSignup := commonsignup.NewUserSignup(
commonsignup.CreatedBefore(fiveYears),
commonsignup.ApprovedManuallyAgo(days(40)),
commonsignup.VerificationRequired(days(10)),
commonsignup.VerificationRequiredAgo(days(10)),
commonsignup.WithActivations("1"),
)

Expand All @@ -216,7 +216,7 @@ func TestUserCleanup(t *testing.T) {
userSignup := commonsignup.NewUserSignup(
commonsignup.CreatedBefore(fiveYears),
commonsignup.ApprovedManuallyAgo(days(730+21)),
commonsignup.VerificationRequired(days(730+1)),
commonsignup.VerificationRequiredAgo(days(730+1)),
commonsignup.WithActivations("2"),
)

Expand Down Expand Up @@ -266,43 +266,43 @@ func TestUserCleanup(t *testing.T) {
}{
"test that a UserSignup older than 2 years, with 1 activation and not banned, is deleted": {
userSignup: commonsignup.NewUserSignup(
commonsignup.DeactivatedWithLastTransitionTime(twoYears),
commonsignup.DeactivatedAgo(twoYears),
commonsignup.WithActivations("1")),
expectedError: "",
expectedToBeDeleted: true,
},
"test that a UserSignup older than 2 years, with indeterminate activations and not banned, is deleted": {
userSignup: commonsignup.NewUserSignup(
commonsignup.DeactivatedWithLastTransitionTime(twoYears),
commonsignup.DeactivatedAgo(twoYears),
commonsignup.WithActivations("unknown")),
expectedError: "",
expectedToBeDeleted: true,
},
"test that a UserSignup 1 year old, with 1 activation and not banned, is not deleted": {
userSignup: commonsignup.NewUserSignup(
commonsignup.DeactivatedWithLastTransitionTime(oneYear),
commonsignup.DeactivatedAgo(oneYear),
commonsignup.WithActivations("1")),
expectedError: "",
expectedToBeDeleted: false,
},
"test that a UserSignup older than 2 years, with 2 activations and not banned, is not deleted": {
userSignup: commonsignup.NewUserSignup(
commonsignup.DeactivatedWithLastTransitionTime(twoYears),
commonsignup.DeactivatedAgo(twoYears),
commonsignup.WithActivations("2")),
expectedError: "",
expectedToBeDeleted: false,
},
"test that a UserSignup older than 2 years, with 1 activation but has been banned, is not deleted": {
userSignup: commonsignup.NewUserSignup(
commonsignup.DeactivatedWithLastTransitionTime(twoYears),
commonsignup.DeactivatedAgo(twoYears),
commonsignup.WithActivations("1")),
banned: true,
expectedError: "",
expectedToBeDeleted: false,
},
"test that a banned UserSignup with an invalid email hash returns an error and is not deleted": {
userSignup: commonsignup.NewUserSignup(
commonsignup.DeactivatedWithLastTransitionTime(twoYears),
commonsignup.DeactivatedAgo(twoYears),
commonsignup.WithActivations("1"),
commonsignup.WithName("invalid-email-user"),
commonsignup.WithLabel(toolchainv1alpha1.UserSignupUserEmailHashLabelKey, "INVALID")),
Expand All @@ -312,7 +312,7 @@ func TestUserCleanup(t *testing.T) {
},
"test that a UserSignup without an email address returns an error and is not deleted": {
userSignup: commonsignup.NewUserSignup(
commonsignup.DeactivatedWithLastTransitionTime(twoYears),
commonsignup.DeactivatedAgo(twoYears),
commonsignup.WithActivations("1"),
commonsignup.WithName("without-email-user"),
commonsignup.WithEmail("")),
Expand Down Expand Up @@ -371,7 +371,7 @@ func TestUserCleanup(t *testing.T) {
t.Run("test propagation policy", func(t *testing.T) {
userSignup := commonsignup.NewUserSignup(
commonsignup.CreatedBefore(fiveYears),
commonsignup.VerificationRequired(days(8)),
commonsignup.VerificationRequiredAgo(days(8)),
)

r, req, fakeClient := prepareReconcile(t, userSignup.Name, userSignup)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/codeready-toolchain/host-operator
require (
cloud.google.com/go/recaptchaenterprise/v2 v2.13.0
github.com/codeready-toolchain/api v0.0.0-20241202100321-545317813297
github.com/codeready-toolchain/toolchain-common v0.0.0-20241128143121-e2e3546a35e9
github.com/codeready-toolchain/toolchain-common v0.0.0-20250113092648-1078d683961b
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-bindata/go-bindata v3.1.2+incompatible
github.com/go-logr/logr v1.4.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBS
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/codeready-toolchain/api v0.0.0-20241202100321-545317813297 h1:YsZesoSkP4sxGL7d1DtPHbqLGUe2A9srXVyW2IERKrw=
github.com/codeready-toolchain/api v0.0.0-20241202100321-545317813297/go.mod h1:DUq1ffy9Mbersdgji48i/cm9Y+6NMwAdAQJNlfOrPRo=
github.com/codeready-toolchain/toolchain-common v0.0.0-20241128143121-e2e3546a35e9 h1:urMWj0TK944x2zZhVEvcNklLzPbarWBaxLGhyeXdLi0=
github.com/codeready-toolchain/toolchain-common v0.0.0-20241128143121-e2e3546a35e9/go.mod h1:4MD8PrbljFH7qSF44EjzAs2HVdr1R/vrsii2eO8Im+4=
github.com/codeready-toolchain/toolchain-common v0.0.0-20250113092648-1078d683961b h1:zlLUDN9ddogCX8hzuPrIdS/YpAF8siucA5b56zGUz00=
github.com/codeready-toolchain/toolchain-common v0.0.0-20250113092648-1078d683961b/go.mod h1:wLXGFyEan+RJHZEEMmvTxNa2BrlizIA+4+Lsi1cyuAk=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down

0 comments on commit 0ebf1df

Please sign in to comment.