-
Notifications
You must be signed in to change notification settings - Fork 77
verify that reg-service returns 403 when user is banned #1141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
verify that reg-service returns 403 when user is banned #1141
Conversation
|
s.Run("ban provisioned usersignup", func() { | ||
hostAwait := s.Host() | ||
memberAwait := s.Member1() | ||
hostAwait.UpdateToolchainConfig(s.T(), testconfig.AutomaticApproval().Enabled(false)) | ||
|
||
// Create a new UserSignup and approve it manually | ||
user := NewSignupRequest(s.Awaitilities). | ||
Username("banprovisioned"). | ||
Email("banprovisioned@test.com"). | ||
ManuallyApprove(). | ||
TargetCluster(memberAwait). | ||
RequireConditions(wait.ConditionSet(wait.Default(), wait.ApprovedByAdmin())...). | ||
Execute(s.T()) | ||
userSignup := user.UserSignup | ||
|
||
// Create the BannedUser | ||
CreateBannedUser(s.T(), s.Host(), userSignup.Spec.IdentityClaims.Email) | ||
|
||
// Confirm the user is banned | ||
_, err := hostAwait.WithRetryOptions(wait.TimeoutOption(time.Second*15)).WaitForUserSignup(s.T(), userSignup.Name, | ||
wait.UntilUserSignupHasConditions(wait.ConditionSet(wait.Default(), wait.ApprovedByAdmin(), wait.Banned())...)) | ||
require.NoError(s.T(), err) | ||
|
||
// Confirm that a MasterUserRecord is deleted | ||
_, err = hostAwait.WithRetryOptions(wait.TimeoutOption(time.Second*10)).WaitForMasterUserRecord(s.T(), userSignup.Spec.IdentityClaims.PreferredUsername) | ||
require.Error(s.T(), err) | ||
// confirm usersignup | ||
_, err = hostAwait.WaitForUserSignup(s.T(), userSignup.Name, | ||
wait.UntilUserSignupHasConditions(wait.ConditionSet(wait.Default(), wait.ApprovedByAdmin(), wait.Banned())...), | ||
wait.UntilUserSignupHasStateLabel(toolchainv1alpha1.UserSignupStateLabelValueBanned)) | ||
require.NoError(s.T(), err) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a complete duplication of the first test of "ban provisioned usersignup"
below
s.Run("manually created usersignup with preexisting banneduser", func() { | ||
hostAwait := s.Host() | ||
memberAwait := s.Member1() | ||
hostAwait.UpdateToolchainConfig(s.T(), testconfig.AutomaticApproval().Enabled(true)) | ||
|
||
id := uuid.Must(uuid.NewV4()).String() | ||
email := "testuser" + id + "@test.com" | ||
CreateBannedUser(s.T(), s.Host(), email) | ||
|
||
// For this test, we don't want to create the UserSignup via the registration service (the next test does this) | ||
// Instead, we want to confirm the behaviour when a UserSignup with a banned email address is created manually | ||
userSignup := NewUserSignup(hostAwait.Namespace, "testuser"+id, email) | ||
userSignup.Spec.TargetCluster = memberAwait.ClusterName | ||
|
||
// Create the UserSignup via the Kubernetes API | ||
err := hostAwait.CreateWithCleanup(s.T(), userSignup) | ||
require.NoError(s.T(), err) | ||
s.T().Logf("user signup '%s' created", userSignup.Name) | ||
|
||
// Check the UserSignup is created and confirm that the user is banned | ||
_, err = hostAwait.WaitForUserSignup(s.T(), userSignup.Name, wait.UntilUserSignupHasStateLabel(toolchainv1alpha1.UserSignupStateLabelValueBanned)) | ||
require.NoError(s.T(), err) | ||
|
||
err = hostAwait.WaitUntilSpaceAndSpaceBindingsDeleted(s.T(), "testuser"+id) | ||
require.NoError(s.T(), err) | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this didn't test a real scenario (we don't create UserSignups manually), thus it's better to remove it to not bring any confusion in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
Thanks for the additional cleanup.
/retest |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alexeykazakov, MatousJobanek, metlos, mfrancisc, rajivnathan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
1ae278a
into
codeready-toolchain:master
paired PR codeready-toolchain/registration-service#520
KUBESAW-267