mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-07 07:16:54 +00:00
chore: move gofakeit integration testing calls (#10684)
# Which Problems Are Solved
Flakiness and conflicts in value from gofakeit.
# How the Problems Are Solved
Move Gofakeit calls to the integration package, to guarantee proper
usage and values for integration testing.
# Additional Changes
None
# Additional Context
None
(cherry picked from commit 492f1826ee)
This commit is contained in:
committed by
Livio Spring
parent
78ded99017
commit
b892fc9b28
@@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/brianvoe/gofakeit/v6"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
@@ -20,7 +19,7 @@ import (
|
||||
|
||||
func TestServer_ListAppKeys(t *testing.T) {
|
||||
// create project
|
||||
prjName := gofakeit.Name()
|
||||
prjName := integration.ProjectName()
|
||||
createPrjRes, err := Instance.Client.Projectv2Beta.CreateProject(IAMOwnerCTX, &project.CreateProjectRequest{
|
||||
Name: prjName,
|
||||
OrganizationId: Instance.DefaultOrg.Id,
|
||||
@@ -31,7 +30,7 @@ func TestServer_ListAppKeys(t *testing.T) {
|
||||
// add app to project
|
||||
createAppjRes, err := Instance.Client.AppV2Beta.CreateApplication(IAMOwnerCTX, &app.CreateApplicationRequest{
|
||||
ProjectId: prjId,
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.ApplicationName(),
|
||||
CreationRequestType: &app.CreateApplicationRequest_ApiRequest{
|
||||
ApiRequest: &app.CreateAPIApplicationRequest{
|
||||
AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
|
||||
@@ -53,7 +52,7 @@ func TestServer_ListAppKeys(t *testing.T) {
|
||||
// add other app to project
|
||||
createOtherAppjRes, err := Instance.Client.AppV2Beta.CreateApplication(IAMOwnerCTX, &app.CreateApplicationRequest{
|
||||
ProjectId: prjId,
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.ApplicationName(),
|
||||
CreationRequestType: &app.CreateApplicationRequest_ApiRequest{
|
||||
ApiRequest: &app.CreateAPIApplicationRequest{
|
||||
AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
|
||||
@@ -89,19 +88,19 @@ func TestServer_ListAppKeys(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(CTX, time.Minute)
|
||||
assert.EventuallyWithT(t, func(ct *assert.CollectT) {
|
||||
expectedKeyIds := tt.expectedKeyIdsFunc()
|
||||
expectedKeyIds := tt.expectedKeyIdsFunc()
|
||||
|
||||
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(CTX, time.Minute)
|
||||
require.EventuallyWithT(t, func(ct *assert.CollectT) {
|
||||
res, err := Client.ListAppKeys(IAMOwnerCTX, &management.ListAppKeysRequest{
|
||||
AppId: appId,
|
||||
ProjectId: prjId,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, len(expectedKeyIds), len(res.GetResult()))
|
||||
require.NoError(ct, err)
|
||||
assert.Equal(ct, len(expectedKeyIds), len(res.GetResult()))
|
||||
|
||||
for _, key := range res.GetResult() {
|
||||
assert.True(t, slices.Contains(expectedKeyIds, key.Id))
|
||||
assert.True(ct, slices.Contains(expectedKeyIds, key.Id))
|
||||
}
|
||||
}, retryDuration, tick)
|
||||
})
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/brianvoe/gofakeit/v6"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
@@ -39,7 +38,7 @@ func TestServer_ListOrgMemberRoles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_ListOrgMembers(t *testing.T) {
|
||||
user := Instance.CreateHumanUserVerified(OrgCTX, Instance.DefaultOrg.Id, gofakeit.Email(), gofakeit.Phone())
|
||||
user := Instance.CreateHumanUserVerified(OrgCTX, Instance.DefaultOrg.Id, integration.Email(), integration.Phone())
|
||||
_, err := Client.AddOrgMember(OrgCTX, &mgmt_pb.AddOrgMemberRequest{
|
||||
UserId: user.GetUserId(),
|
||||
Roles: iamRoles[1:],
|
||||
@@ -120,7 +119,7 @@ func TestServer_ListOrgMembers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_AddOrgMember(t *testing.T) {
|
||||
user := Instance.CreateHumanUserVerified(OrgCTX, Instance.DefaultOrg.Id, gofakeit.Email(), gofakeit.Phone())
|
||||
user := Instance.CreateHumanUserVerified(OrgCTX, Instance.DefaultOrg.Id, integration.Email(), integration.Phone())
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
req *mgmt_pb.AddOrgMemberRequest
|
||||
@@ -194,7 +193,7 @@ func TestServer_AddOrgMember(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_UpdateOrgMember(t *testing.T) {
|
||||
user := Instance.CreateHumanUserVerified(OrgCTX, Instance.DefaultOrg.Id, gofakeit.Email(), gofakeit.Phone())
|
||||
user := Instance.CreateHumanUserVerified(OrgCTX, Instance.DefaultOrg.Id, integration.Email(), integration.Phone())
|
||||
_, err := Client.AddOrgMember(OrgCTX, &mgmt_pb.AddOrgMemberRequest{
|
||||
UserId: user.GetUserId(),
|
||||
Roles: []string{"ORG_OWNER"},
|
||||
@@ -275,7 +274,7 @@ func TestServer_UpdateOrgMember(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServer_RemoveIAMMember(t *testing.T) {
|
||||
user := Instance.CreateHumanUserVerified(OrgCTX, Instance.DefaultOrg.Id, gofakeit.Email(), gofakeit.Phone())
|
||||
user := Instance.CreateHumanUserVerified(OrgCTX, Instance.DefaultOrg.Id, integration.Email(), integration.Phone())
|
||||
_, err := Client.AddOrgMember(OrgCTX, &mgmt_pb.AddOrgMemberRequest{
|
||||
UserId: user.GetUserId(),
|
||||
Roles: []string{"ORG_OWNER"},
|
||||
|
||||
Reference in New Issue
Block a user