diff --git a/pkg/banneduser/banneduser.go b/pkg/banneduser/banneduser.go index 4af498f0..13745a51 100644 --- a/pkg/banneduser/banneduser.go +++ b/pkg/banneduser/banneduser.go @@ -38,8 +38,8 @@ func NewBannedUser(userSignup *toolchainv1alpha1.UserSignup, bannedBy string) (* return bannedUser, nil } -// IsAlreadyBanned checks if the user was already banned -func IsAlreadyBanned(ctx context.Context, userEmailHash string, hostClient client.Client, hostNamespace string) (*toolchainv1alpha1.BannedUser, error) { +// GetBannedUser returns BannedUser with the provided user email hash if found. Otherwise it returns nil. +func GetBannedUser(ctx context.Context, userEmailHash string, hostClient client.Client, hostNamespace string) (*toolchainv1alpha1.BannedUser, error) { emailHashLabelMatch := client.MatchingLabels(map[string]string{ toolchainv1alpha1.BannedUserEmailHashLabelKey: userEmailHash, }) diff --git a/pkg/banneduser/banneduser_test.go b/pkg/banneduser/banneduser_test.go index bbc631dd..d2982652 100644 --- a/pkg/banneduser/banneduser_test.go +++ b/pkg/banneduser/banneduser_test.go @@ -111,7 +111,7 @@ func TestNewBannedUser(t *testing.T) { } } -func TestIsAlreadyBanned(t *testing.T) { +func TestGetBannedUser(t *testing.T) { userSignup1 := commonsignup.NewUserSignup(commonsignup.WithName("johny"), commonsignup.WithEmail("johny@example.com")) userSignup2 := commonsignup.NewUserSignup(commonsignup.WithName("bob"), commonsignup.WithEmail("bob@example.com")) userSignup3 := commonsignup.NewUserSignup(commonsignup.WithName("oliver"), commonsignup.WithEmail("oliver@example.com")) @@ -158,7 +158,7 @@ func TestIsAlreadyBanned(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - gotResult, err := IsAlreadyBanned(ctx, tt.toBan.Labels[toolchainv1alpha1.BannedUserEmailHashLabelKey], tt.fakeClient, test.HostOperatorNs) + gotResult, err := GetBannedUser(ctx, tt.toBan.Labels[toolchainv1alpha1.BannedUserEmailHashLabelKey], tt.fakeClient, test.HostOperatorNs) if tt.wantError { require.Error(t, err)