Skip to content

Commit

Permalink
use default tiers in verification
Browse files Browse the repository at this point in the history
  • Loading branch information
Devtools committed Aug 26, 2024
1 parent 44bcb43 commit 7b98f77
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 58 deletions.
2 changes: 1 addition & 1 deletion test/e2e/no_user_identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestCreationOfUserAndIdentityIsSkipped(t *testing.T) {
Execute(t)
signup := u.UserSignup

VerifyResourcesProvisionedForSignup(t, awaitilities, signup, "deactivate30", "appstudio")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, signup, "deactivate30", "appstudio")

// preexisting user & identity are still there and not modified
// Verify provisioned User
Expand Down
50 changes: 25 additions & 25 deletions test/e2e/parallel/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ func TestE2EFlow(t *testing.T) {
// Confirm the originalSub property has been set during signup
require.Equal(t, originalSubJohnClaim, originalSubJohnSignup.Spec.IdentityClaims.OriginalSub)

VerifyResourcesProvisionedForSignup(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignup(t, awaitilities, targetedJohnSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignup(t, awaitilities, originalSubJohnSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup)
VerifyResourcesProvisionedForSignup(t, awaitilities, targetedJohnSignup)
VerifyResourcesProvisionedForSignup(t, awaitilities, originalSubJohnSignup)

t.Run("try to break UserAccount", func(t *testing.T) {
t.Run("delete user and wait until recreated", func(t *testing.T) {
Expand All @@ -133,8 +133,8 @@ func TestE2EFlow(t *testing.T) {

// then
require.NoError(t, err)
VerifyResourcesProvisionedForSignup(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup)
})

t.Run("delete identity and wait until recreated", func(t *testing.T) {
Expand All @@ -149,8 +149,8 @@ func TestE2EFlow(t *testing.T) {

// then
require.NoError(t, err)
VerifyResourcesProvisionedForSignup(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup)
})

t.Run("delete user mapping and wait until recreated", func(t *testing.T) {
Expand All @@ -165,8 +165,8 @@ func TestE2EFlow(t *testing.T) {

// then
require.NoError(t, err)
VerifyResourcesProvisionedForSignup(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup)
})

t.Run("delete identity mapping and wait until recreated", func(t *testing.T) {
Expand All @@ -182,8 +182,8 @@ func TestE2EFlow(t *testing.T) {

// then
require.NoError(t, err)
VerifyResourcesProvisionedForSignup(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup)
})

t.Run("delete namespaces and wait until recreated", func(t *testing.T) {
Expand All @@ -207,8 +207,8 @@ func TestE2EFlow(t *testing.T) {
_, err := memberAwait.WaitForNamespace(t, johnSignup.Spec.IdentityClaims.PreferredUsername, ref, "base", wait.UntilNamespaceIsActive())
require.NoError(t, err)
}
VerifyResourcesProvisionedForSignup(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup)
})

t.Run("delete useraccount and expect recreation", func(t *testing.T) {
Expand All @@ -230,7 +230,7 @@ func TestE2EFlow(t *testing.T) {
require.NoError(t, err)

// then verify the recreated user account
VerifyResourcesProvisionedForSignup(t, awaitilities, johnSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, johnSignup, "deactivate30", "base")
})
})

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

require.Equal(t, "laracroft", laraSignup.Status.CompliantUsername)

VerifyResourcesProvisionedForSignup(t, awaitilities, laraSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignup(t, awaitilities, laraSignup)

VerifySpaceBinding(t, hostAwait, laraUserName, laraUserName, "admin")

Expand Down Expand Up @@ -361,50 +361,50 @@ func TestE2EFlow(t *testing.T) {
t.Run("namespace role accidentally deleted by user in dev namespace is recreated", func(t *testing.T) {
DeletedRoleAndAwaitRecreation(t, memberAwait, devNs, "exec-pods")
// then the user account should be recreated
VerifyResourcesProvisionedForSignup(t, awaitilities, userSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, userSignup, "deactivate30", "base")
})

t.Run("namespace rolebinding accidentally deleted by user in dev namespace is recreated", func(t *testing.T) {
DeleteRoleBindingAndAwaitRecreation(t, memberAwait, devNs, "crtadmin-pods")
// then the user account should be recreated
VerifyResourcesProvisionedForSignup(t, awaitilities, userSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, userSignup, "deactivate30", "base")
})

t.Run("namespace role accidentally deleted by user in stage namespace is recreated", func(t *testing.T) {
DeletedRoleAndAwaitRecreation(t, memberAwait, stageNs, "exec-pods")
// then the user account should be recreated
VerifyResourcesProvisionedForSignup(t, awaitilities, userSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, userSignup, "deactivate30", "base")
})

t.Run("namespace rolebinding accidentally deleted by user in stage namespace is recreated", func(t *testing.T) {
DeleteRoleBindingAndAwaitRecreation(t, memberAwait, stageNs, "crtadmin-pods")
// then the user account should be recreated
VerifyResourcesProvisionedForSignup(t, awaitilities, userSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, userSignup, "deactivate30", "base")
})

// roles and role bindings defined in the spacerole templates
t.Run("space role accidentally deleted by user in dev namespace is recreated", func(t *testing.T) {
DeletedRoleAndAwaitRecreation(t, memberAwait, devNs, "rbac-edit")
// then the user account should be recreated
VerifyResourcesProvisionedForSignup(t, awaitilities, userSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, userSignup, "deactivate30", "base")
})

t.Run("space rolebinding accidentally deleted by user in dev namespace is recreated", func(t *testing.T) {
DeleteRoleBindingAndAwaitRecreation(t, memberAwait, devNs, "wonderwoman-rbac-edit")
// then the user account should be recreated
VerifyResourcesProvisionedForSignup(t, awaitilities, userSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, userSignup, "deactivate30", "base")
})

t.Run("space role accidentally deleted by user in stage namespace is recreated", func(t *testing.T) {
DeletedRoleAndAwaitRecreation(t, memberAwait, stageNs, "rbac-edit")
// then the user account should be recreated
VerifyResourcesProvisionedForSignup(t, awaitilities, userSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, userSignup, "deactivate30", "base")
})

t.Run("space rolebinding accidentally deleted by user in stage namespace is recreated", func(t *testing.T) {
DeleteRoleBindingAndAwaitRecreation(t, memberAwait, stageNs, "wonderwoman-rbac-edit")
// then the user account should be recreated
VerifyResourcesProvisionedForSignup(t, awaitilities, userSignup, "deactivate30", "base")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, userSignup, "deactivate30", "base")
})
})

Expand Down Expand Up @@ -448,7 +448,7 @@ func TestE2EFlow(t *testing.T) {
require.NoError(t, err, "johnsmith-stage namespace is not deleted")

// also, verify that other user's resource are left intact
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignup(t, awaitilities, johnExtraSignup)
})

t.Run("deactivate UserSignup and ensure that all user and identity resources are deleted", func(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/parallel/nstemplatetier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestNSTemplateTiers(t *testing.T) {
}

// wait for the user to be provisioned for the first time
VerifyResourcesProvisionedForSignup(t, awaitilities, testingtiers, "deactivate30", "base1ns") // deactivate30 is the default UserTier and base is the default SpaceTier
VerifyResourcesProvisionedForSignup(t, awaitilities, testingtiers) // deactivate30 is the default UserTier and base is the default SpaceTier

for _, tierToCheck := range tiersToCheck {
// check that the tier exists, and all its namespace other cluster-scoped resource revisions
Expand All @@ -81,7 +81,7 @@ func TestNSTemplateTiers(t *testing.T) {
tiers.MoveSpaceToTier(t, hostAwait, space.Name, tierToCheck)

// then
VerifyResourcesProvisionedForSignup(t, awaitilities, testingtiers, "deactivate30", tierToCheck) // deactivate30 is the default UserTier
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, testingtiers, "deactivate30", tierToCheck) // deactivate30 is the default UserTier
})
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestResetDeactivatingStateWhenPromotingUser(t *testing.T) {
promotedUserSignup, err := hostAwait.WaitForUserSignup(t, updatedUserSignup.Name)
require.NoError(t, err)
require.False(t, states.Deactivating(promotedUserSignup), "usersignup should not be deactivating")
VerifyResourcesProvisionedForSignup(t, awaitilities, promotedUserSignup, "deactivate90", "base1ns")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, promotedUserSignup, "deactivate90", "base1ns")
})
}

Expand Down Expand Up @@ -225,7 +225,7 @@ func setupAccounts(t *testing.T, awaitilities wait.Awaitilities, tier *tiers.Cus

// let's promote to users the new tier
for i := range userSignups {
VerifyResourcesProvisionedForSignup(t, awaitilities, userSignups[i], "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignup(t, awaitilities, userSignups[i])
username := fmt.Sprintf(nameFmt, i)
tiers.MoveSpaceToTier(t, hostAwait, username, tier.Name)
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/parallel/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ func createAppStudioUser(t *testing.T, awaitilities wait.Awaitilities, user *pro
user.signup = u.UserSignup
user.token = u.Token
tiers.MoveSpaceToTier(t, awaitilities.Host(), u.Space.Name, "appstudio")
VerifyResourcesProvisionedForSignup(t, awaitilities, user.signup, "deactivate30", "appstudio")
VerifyResourcesProvisionedForSignupWithTiers(t, awaitilities, user.signup, "deactivate30", "appstudio")
user.compliantUsername = user.signup.Status.CompliantUsername
_, err := awaitilities.Host().WaitForMasterUserRecord(t, user.compliantUsername, wait.UntilMasterUserRecordHasCondition(wait.Provisioned()))
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/parallel/registration_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func TestSignupOK(t *testing.T) {
require.NoError(t, err)

// Wait for the resources to be provisioned
VerifyResourcesProvisionedForSignup(t, await, userSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignup(t, await, userSignup)

// Call signup endpoint with same valid token to check if status changed to Provisioned now
now := time.Now()
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/parallel/usersignup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ func TestTransformUsernameWithSpaceConflict(t *testing.T) {

// then
userSignup, _ = VerifyUserRelatedResources(t, awaitilities, userSignup, "deactivate30", ExpectAnyUserAccount())
VerifySpaceRelatedResources(t, awaitilities, userSignup, "base")
VerifyResourcesProvisionedForSignup(t, awaitilities, userSignup, "deactivate30", "base")
VerifySpaceRelatedResources(t, awaitilities, userSignup, "base1ns")
VerifyResourcesProvisionedForSignup(t, awaitilities, userSignup)
require.Equal(t, fmt.Sprintf("%s-3", conflictingSpace.Name), userSignup.Status.CompliantUsername)
})
}
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/user_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func (s *userManagementTestSuite) TestUserDeactivation() {
require.NoError(t, err)

// Verify resources still exist
VerifyResourcesProvisionedForSignup(t, s.Awaitilities, userSignupMember1, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignup(t, s.Awaitilities, userSignupMember1)
})

s.T().Run("test full automatic user deactivation lifecycle", func(t *testing.T) {
Expand Down Expand Up @@ -400,7 +400,7 @@ func (s *userManagementTestSuite) TestUserDeactivation() {
require.Less(t, comparison, time.Hour)

// Verify resources have been provisioned
VerifyResourcesProvisionedForSignup(t, s.Awaitilities, userSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignup(t, s.Awaitilities, userSignup)

t.Run("user set to deactivated after deactivating", func(t *testing.T) {
// Set the provisioned time even further back
Expand Down Expand Up @@ -710,7 +710,7 @@ func (s *userManagementTestSuite) TestUserDisabled() {
Execute(s.T())
userSignup := u.UserSignup

VerifyResourcesProvisionedForSignup(s.T(), s.Awaitilities, userSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignup(s.T(), s.Awaitilities, userSignup)

// Disable MUR
mur, err := hostAwait.UpdateMasterUserRecordSpec(s.T(),
Expand Down Expand Up @@ -752,7 +752,7 @@ func (s *userManagementTestSuite) TestUserDisabled() {
})
require.NoError(s.T(), err)

VerifyResourcesProvisionedForSignup(s.T(), s.Awaitilities, userSignup, "deactivate30", "base1ns")
VerifyResourcesProvisionedForSignup(s.T(), s.Awaitilities, userSignup)
})
}

Expand Down
Loading

0 comments on commit 7b98f77

Please sign in to comment.