mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 16:22:13 +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
@@ -11,7 +11,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/brianvoe/gofakeit/v6"
|
||||
"github.com/crewjam/saml"
|
||||
"github.com/crewjam/saml/samlsp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -71,7 +70,7 @@ func TestServer_ExecutionTarget(t *testing.T) {
|
||||
userID := instance.Users.Get(integration.UserTypeIAMOwner).ID
|
||||
|
||||
// create target for target changes
|
||||
targetCreatedName := gofakeit.Name()
|
||||
targetCreatedName := integration.TargetName()
|
||||
targetCreatedURL := "https://nonexistent"
|
||||
|
||||
targetCreated := instance.CreateTarget(ctx, t, targetCreatedName, targetCreatedURL, target_domain.TargetTypeCall, false)
|
||||
@@ -212,7 +211,7 @@ func TestServer_ExecutionTarget(t *testing.T) {
|
||||
userID := instance.Users.Get(integration.UserTypeIAMOwner).ID
|
||||
|
||||
// create target for target changes
|
||||
targetCreatedName := gofakeit.Name()
|
||||
targetCreatedName := integration.TargetName()
|
||||
targetCreatedURL := "https://nonexistent"
|
||||
|
||||
targetCreated := instance.CreateTarget(ctx, t, targetCreatedName, targetCreatedURL, target_domain.TargetTypeCall, false)
|
||||
@@ -756,8 +755,8 @@ func TestServer_ExecutionTargetPreUserinfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func expectPreUserinfoExecution(ctx context.Context, t *testing.T, instance *integration.Instance, clientID string, req *oidc_pb.CreateCallbackRequest, response *oidc_api.ContextInfoResponse) (string, func()) {
|
||||
userEmail := gofakeit.Email()
|
||||
userPhone := "+41" + gofakeit.Phone()
|
||||
userEmail := integration.Email()
|
||||
userPhone := integration.Phone()
|
||||
userResp := instance.CreateHumanUserVerified(ctx, instance.DefaultOrg.Id, userEmail, userPhone)
|
||||
|
||||
sessionResp := createSession(ctx, t, instance, userResp.GetUserId())
|
||||
@@ -1064,8 +1063,8 @@ func TestServer_ExecutionTargetPreAccessToken(t *testing.T) {
|
||||
}
|
||||
|
||||
func expectPreAccessTokenExecution(ctx context.Context, t *testing.T, instance *integration.Instance, clientID string, req *oidc_pb.CreateCallbackRequest, response *oidc_api.ContextInfoResponse) (string, func()) {
|
||||
userEmail := gofakeit.Email()
|
||||
userPhone := "+41" + gofakeit.Phone()
|
||||
userEmail := integration.Email()
|
||||
userPhone := integration.Phone()
|
||||
userResp := instance.CreateHumanUserVerified(ctx, instance.DefaultOrg.Id, userEmail, userPhone)
|
||||
|
||||
sessionResp := createSession(ctx, t, instance, userResp.GetUserId())
|
||||
@@ -1120,7 +1119,7 @@ func TestServer_ExecutionTargetPreSAMLResponse(t *testing.T) {
|
||||
},
|
||||
req: &saml_pb.CreateResponseRequest{
|
||||
SamlRequestId: func() string {
|
||||
_, samlRequestID, err := instance.CreateSAMLAuthRequest(spMiddlewarePost, instance.Users[integration.UserTypeOrgOwner].ID, acsPost, gofakeit.BitcoinAddress(), saml.HTTPPostBinding)
|
||||
_, samlRequestID, err := instance.CreateSAMLAuthRequest(spMiddlewarePost, instance.Users[integration.UserTypeOrgOwner].ID, acsPost, integration.RelayState(), saml.HTTPPostBinding)
|
||||
require.NoError(t, err)
|
||||
return samlRequestID
|
||||
}(),
|
||||
@@ -1145,7 +1144,7 @@ func TestServer_ExecutionTargetPreSAMLResponse(t *testing.T) {
|
||||
},
|
||||
req: &saml_pb.CreateResponseRequest{
|
||||
SamlRequestId: func() string {
|
||||
_, samlRequestID, err := instance.CreateSAMLAuthRequest(spMiddlewarePost, instance.Users[integration.UserTypeOrgOwner].ID, acsPost, gofakeit.BitcoinAddress(), saml.HTTPPostBinding)
|
||||
_, samlRequestID, err := instance.CreateSAMLAuthRequest(spMiddlewarePost, instance.Users[integration.UserTypeOrgOwner].ID, acsPost, integration.RelayState(), saml.HTTPPostBinding)
|
||||
require.NoError(t, err)
|
||||
return samlRequestID
|
||||
}(),
|
||||
@@ -1177,7 +1176,7 @@ func TestServer_ExecutionTargetPreSAMLResponse(t *testing.T) {
|
||||
},
|
||||
req: &saml_pb.CreateResponseRequest{
|
||||
SamlRequestId: func() string {
|
||||
_, samlRequestID, err := instance.CreateSAMLAuthRequest(spMiddlewarePost, instance.Users[integration.UserTypeOrgOwner].ID, acsPost, gofakeit.BitcoinAddress(), saml.HTTPPostBinding)
|
||||
_, samlRequestID, err := instance.CreateSAMLAuthRequest(spMiddlewarePost, instance.Users[integration.UserTypeOrgOwner].ID, acsPost, integration.RelayState(), saml.HTTPPostBinding)
|
||||
require.NoError(t, err)
|
||||
return samlRequestID
|
||||
}(),
|
||||
@@ -1229,8 +1228,8 @@ func TestServer_ExecutionTargetPreSAMLResponse(t *testing.T) {
|
||||
}
|
||||
|
||||
func expectPreSAMLResponseExecution(ctx context.Context, t *testing.T, instance *integration.Instance, req *saml_pb.CreateResponseRequest, response *saml_api.ContextInfoResponse) (string, func()) {
|
||||
userEmail := gofakeit.Email()
|
||||
userPhone := "+41" + gofakeit.Phone()
|
||||
userEmail := integration.Email()
|
||||
userPhone := integration.Phone()
|
||||
userResp := instance.CreateHumanUserVerified(ctx, instance.DefaultOrg.Id, userEmail, userPhone)
|
||||
|
||||
sessionResp := createSession(ctx, t, instance, userResp.GetUserId())
|
||||
@@ -1251,7 +1250,7 @@ func expectPreSAMLResponseExecution(ctx context.Context, t *testing.T, instance
|
||||
}
|
||||
|
||||
func createSAMLSP(t *testing.T, idpMetadata *saml.EntityDescriptor, binding string) (string, *samlsp.Middleware) {
|
||||
rootURL := "example." + gofakeit.DomainName()
|
||||
rootURL := "example." + integration.DomainName()
|
||||
spMiddleware, err := integration.CreateSAMLSP("https://"+rootURL, idpMetadata, binding)
|
||||
require.NoError(t, err)
|
||||
return rootURL, spMiddleware
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/brianvoe/gofakeit/v6"
|
||||
"github.com/muhlemmer/gu"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
@@ -38,7 +37,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "missing permission",
|
||||
ctx: instance.WithAuthorizationToken(context.Background(), integration.UserTypeOrgOwner),
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
@@ -54,7 +53,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "empty type",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
TargetType: nil,
|
||||
},
|
||||
wantErr: true,
|
||||
@@ -63,7 +62,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "empty webhook url",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
TargetType: &action.CreateTargetRequest_RestWebhook{
|
||||
RestWebhook: &action.RESTWebhook{},
|
||||
},
|
||||
@@ -74,7 +73,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "empty request response url",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
TargetType: &action.CreateTargetRequest_RestCall{
|
||||
RestCall: &action.RESTCall{},
|
||||
},
|
||||
@@ -85,7 +84,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "empty timeout",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
Endpoint: "https://example.com",
|
||||
TargetType: &action.CreateTargetRequest_RestWebhook{
|
||||
RestWebhook: &action.RESTWebhook{},
|
||||
@@ -111,7 +110,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "async, ok",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
Endpoint: "https://example.com",
|
||||
TargetType: &action.CreateTargetRequest_RestAsync{
|
||||
RestAsync: &action.RESTAsync{},
|
||||
@@ -128,7 +127,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "webhook, ok",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
Endpoint: "https://example.com",
|
||||
TargetType: &action.CreateTargetRequest_RestWebhook{
|
||||
RestWebhook: &action.RESTWebhook{
|
||||
@@ -147,7 +146,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "webhook, interrupt on error, ok",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
Endpoint: "https://example.com",
|
||||
TargetType: &action.CreateTargetRequest_RestWebhook{
|
||||
RestWebhook: &action.RESTWebhook{
|
||||
@@ -166,7 +165,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "call, ok",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
Endpoint: "https://example.com",
|
||||
TargetType: &action.CreateTargetRequest_RestCall{
|
||||
RestCall: &action.RESTCall{
|
||||
@@ -186,7 +185,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "call, interruptOnError, ok",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
Endpoint: "https://example.com",
|
||||
TargetType: &action.CreateTargetRequest_RestCall{
|
||||
RestCall: &action.RESTCall{
|
||||
@@ -269,7 +268,7 @@ func TestServer_UpdateTarget(t *testing.T) {
|
||||
args: args{
|
||||
ctx: instance.WithAuthorizationToken(context.Background(), integration.UserTypeOrgOwner),
|
||||
req: &action.UpdateTargetRequest{
|
||||
Name: gu.Ptr(gofakeit.Name()),
|
||||
Name: gu.Ptr(integration.TargetName()),
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
@@ -282,7 +281,7 @@ func TestServer_UpdateTarget(t *testing.T) {
|
||||
args: args{
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.UpdateTargetRequest{
|
||||
Name: gu.Ptr(gofakeit.Name()),
|
||||
Name: gu.Ptr(integration.TargetName()),
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
@@ -314,7 +313,7 @@ func TestServer_UpdateTarget(t *testing.T) {
|
||||
args: args{
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.UpdateTargetRequest{
|
||||
Name: gu.Ptr(gofakeit.Name()),
|
||||
Name: gu.Ptr(integration.TargetName()),
|
||||
},
|
||||
},
|
||||
want: want{
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/brianvoe/gofakeit/v6"
|
||||
"github.com/crewjam/saml"
|
||||
"github.com/crewjam/saml/samlsp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -71,7 +70,7 @@ func TestServer_ExecutionTarget(t *testing.T) {
|
||||
userID := instance.Users.Get(integration.UserTypeIAMOwner).ID
|
||||
|
||||
// create target for target changes
|
||||
targetCreatedName := gofakeit.Name()
|
||||
targetCreatedName := integration.TargetName()
|
||||
targetCreatedURL := "https://nonexistent"
|
||||
|
||||
targetCreated := instance.CreateTarget(ctx, t, targetCreatedName, targetCreatedURL, target_domain.TargetTypeCall, false)
|
||||
@@ -212,7 +211,7 @@ func TestServer_ExecutionTarget(t *testing.T) {
|
||||
userID := instance.Users.Get(integration.UserTypeIAMOwner).ID
|
||||
|
||||
// create target for target changes
|
||||
targetCreatedName := gofakeit.Name()
|
||||
targetCreatedName := integration.TargetName()
|
||||
targetCreatedURL := "https://nonexistent"
|
||||
|
||||
targetCreated := instance.CreateTarget(ctx, t, targetCreatedName, targetCreatedURL, target_domain.TargetTypeCall, false)
|
||||
@@ -547,7 +546,7 @@ func waitForTarget(ctx context.Context, t *testing.T, instance *integration.Inst
|
||||
|
||||
func createTarget(ctx context.Context, t *testing.T, instance *integration.Instance, name, endpoint string, ty target_domain.TargetType, interrupt bool) *action.CreateTargetResponse {
|
||||
if name == "" {
|
||||
name = gofakeit.Name()
|
||||
name = integration.TargetName()
|
||||
}
|
||||
req := &action.CreateTargetRequest{
|
||||
Name: name,
|
||||
@@ -804,8 +803,8 @@ func TestServer_ExecutionTargetPreUserinfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func expectPreUserinfoExecution(ctx context.Context, t *testing.T, instance *integration.Instance, clientID string, req *oidc_pb.CreateCallbackRequest, response *oidc_api.ContextInfoResponse) (string, func()) {
|
||||
userEmail := gofakeit.Email()
|
||||
userPhone := "+41" + gofakeit.Phone()
|
||||
userEmail := integration.Email()
|
||||
userPhone := integration.Phone()
|
||||
userResp := instance.CreateHumanUserVerified(ctx, instance.DefaultOrg.Id, userEmail, userPhone)
|
||||
|
||||
sessionResp := createSession(ctx, t, instance, userResp.GetUserId())
|
||||
@@ -1112,8 +1111,8 @@ func TestServer_ExecutionTargetPreAccessToken(t *testing.T) {
|
||||
}
|
||||
|
||||
func expectPreAccessTokenExecution(ctx context.Context, t *testing.T, instance *integration.Instance, clientID string, req *oidc_pb.CreateCallbackRequest, response *oidc_api.ContextInfoResponse) (string, func()) {
|
||||
userEmail := gofakeit.Email()
|
||||
userPhone := "+41" + gofakeit.Phone()
|
||||
userEmail := integration.Email()
|
||||
userPhone := integration.Phone()
|
||||
userResp := instance.CreateHumanUserVerified(ctx, instance.DefaultOrg.Id, userEmail, userPhone)
|
||||
|
||||
sessionResp := createSession(ctx, t, instance, userResp.GetUserId())
|
||||
@@ -1168,7 +1167,7 @@ func TestServer_ExecutionTargetPreSAMLResponse(t *testing.T) {
|
||||
},
|
||||
req: &saml_pb.CreateResponseRequest{
|
||||
SamlRequestId: func() string {
|
||||
_, samlRequestID, err := instance.CreateSAMLAuthRequest(spMiddlewarePost, instance.Users[integration.UserTypeOrgOwner].ID, acsPost, gofakeit.BitcoinAddress(), saml.HTTPPostBinding)
|
||||
_, samlRequestID, err := instance.CreateSAMLAuthRequest(spMiddlewarePost, instance.Users[integration.UserTypeOrgOwner].ID, acsPost, integration.RelayState(), saml.HTTPPostBinding)
|
||||
require.NoError(t, err)
|
||||
return samlRequestID
|
||||
}(),
|
||||
@@ -1193,7 +1192,7 @@ func TestServer_ExecutionTargetPreSAMLResponse(t *testing.T) {
|
||||
},
|
||||
req: &saml_pb.CreateResponseRequest{
|
||||
SamlRequestId: func() string {
|
||||
_, samlRequestID, err := instance.CreateSAMLAuthRequest(spMiddlewarePost, instance.Users[integration.UserTypeOrgOwner].ID, acsPost, gofakeit.BitcoinAddress(), saml.HTTPPostBinding)
|
||||
_, samlRequestID, err := instance.CreateSAMLAuthRequest(spMiddlewarePost, instance.Users[integration.UserTypeOrgOwner].ID, acsPost, integration.RelayState(), saml.HTTPPostBinding)
|
||||
require.NoError(t, err)
|
||||
return samlRequestID
|
||||
}(),
|
||||
@@ -1225,7 +1224,7 @@ func TestServer_ExecutionTargetPreSAMLResponse(t *testing.T) {
|
||||
},
|
||||
req: &saml_pb.CreateResponseRequest{
|
||||
SamlRequestId: func() string {
|
||||
_, samlRequestID, err := instance.CreateSAMLAuthRequest(spMiddlewarePost, instance.Users[integration.UserTypeOrgOwner].ID, acsPost, gofakeit.BitcoinAddress(), saml.HTTPPostBinding)
|
||||
_, samlRequestID, err := instance.CreateSAMLAuthRequest(spMiddlewarePost, instance.Users[integration.UserTypeOrgOwner].ID, acsPost, integration.RelayState(), saml.HTTPPostBinding)
|
||||
require.NoError(t, err)
|
||||
return samlRequestID
|
||||
}(),
|
||||
@@ -1277,8 +1276,8 @@ func TestServer_ExecutionTargetPreSAMLResponse(t *testing.T) {
|
||||
}
|
||||
|
||||
func expectPreSAMLResponseExecution(ctx context.Context, t *testing.T, instance *integration.Instance, req *saml_pb.CreateResponseRequest, response *saml_api.ContextInfoResponse) (string, func()) {
|
||||
userEmail := gofakeit.Email()
|
||||
userPhone := "+41" + gofakeit.Phone()
|
||||
userEmail := integration.Email()
|
||||
userPhone := integration.Phone()
|
||||
userResp := instance.CreateHumanUserVerified(ctx, instance.DefaultOrg.Id, userEmail, userPhone)
|
||||
|
||||
sessionResp := createSession(ctx, t, instance, userResp.GetUserId())
|
||||
@@ -1299,14 +1298,14 @@ func expectPreSAMLResponseExecution(ctx context.Context, t *testing.T, instance
|
||||
}
|
||||
|
||||
func createSAMLSP(t *testing.T, idpMetadata *saml.EntityDescriptor, binding string) (string, *samlsp.Middleware) {
|
||||
rootURL := "example." + gofakeit.DomainName()
|
||||
rootURL := "example." + integration.DomainName()
|
||||
spMiddleware, err := integration.CreateSAMLSP("https://"+rootURL, idpMetadata, binding)
|
||||
require.NoError(t, err)
|
||||
return rootURL, spMiddleware
|
||||
}
|
||||
|
||||
func createSAMLApplication(ctx context.Context, t *testing.T, instance *integration.Instance, idpMetadata *saml.EntityDescriptor, binding string, projectRoleCheck, hasProjectCheck bool) (string, string, *samlsp.Middleware) {
|
||||
project := instance.CreateProject(ctx, t, instance.DefaultOrg.GetId(), gofakeit.AppName(), projectRoleCheck, hasProjectCheck)
|
||||
project := instance.CreateProject(ctx, t, instance.DefaultOrg.GetId(), integration.ProjectName(), projectRoleCheck, hasProjectCheck)
|
||||
rootURL, sp := createSAMLSP(t, idpMetadata, binding)
|
||||
_, err := instance.CreateSAMLClient(ctx, project.GetId(), sp)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/brianvoe/gofakeit/v6"
|
||||
"github.com/muhlemmer/gu"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -54,7 +53,7 @@ func TestServer_GetTarget(t *testing.T) {
|
||||
args: args{
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
dep: func(ctx context.Context, request *action.GetTargetRequest, response *action.GetTargetResponse) error {
|
||||
name := gofakeit.Name()
|
||||
name := integration.TargetName()
|
||||
resp := instance.CreateTarget(ctx, t, name, "https://example.com", target_domain.TargetTypeWebhook, false)
|
||||
request.Id = resp.GetId()
|
||||
response.Target.Id = resp.GetId()
|
||||
@@ -81,7 +80,7 @@ func TestServer_GetTarget(t *testing.T) {
|
||||
args: args{
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
dep: func(ctx context.Context, request *action.GetTargetRequest, response *action.GetTargetResponse) error {
|
||||
name := gofakeit.Name()
|
||||
name := integration.TargetName()
|
||||
resp := instance.CreateTarget(ctx, t, name, "https://example.com", target_domain.TargetTypeAsync, false)
|
||||
request.Id = resp.GetId()
|
||||
response.Target.Id = resp.GetId()
|
||||
@@ -108,7 +107,7 @@ func TestServer_GetTarget(t *testing.T) {
|
||||
args: args{
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
dep: func(ctx context.Context, request *action.GetTargetRequest, response *action.GetTargetResponse) error {
|
||||
name := gofakeit.Name()
|
||||
name := integration.TargetName()
|
||||
resp := instance.CreateTarget(ctx, t, name, "https://example.com", target_domain.TargetTypeWebhook, true)
|
||||
request.Id = resp.GetId()
|
||||
response.Target.Id = resp.GetId()
|
||||
@@ -137,7 +136,7 @@ func TestServer_GetTarget(t *testing.T) {
|
||||
args: args{
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
dep: func(ctx context.Context, request *action.GetTargetRequest, response *action.GetTargetResponse) error {
|
||||
name := gofakeit.Name()
|
||||
name := integration.TargetName()
|
||||
resp := instance.CreateTarget(ctx, t, name, "https://example.com", target_domain.TargetTypeCall, false)
|
||||
request.Id = resp.GetId()
|
||||
response.Target.Id = resp.GetId()
|
||||
@@ -166,7 +165,7 @@ func TestServer_GetTarget(t *testing.T) {
|
||||
args: args{
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
dep: func(ctx context.Context, request *action.GetTargetRequest, response *action.GetTargetResponse) error {
|
||||
name := gofakeit.Name()
|
||||
name := integration.TargetName()
|
||||
resp := instance.CreateTarget(ctx, t, name, "https://example.com", target_domain.TargetTypeCall, true)
|
||||
request.Id = resp.GetId()
|
||||
response.Target.Id = resp.GetId()
|
||||
@@ -261,7 +260,7 @@ func TestServer_ListTargets(t *testing.T) {
|
||||
args: args{
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
dep: func(ctx context.Context, request *action.ListTargetsRequest, response *action.ListTargetsResponse) {
|
||||
name := gofakeit.Name()
|
||||
name := integration.TargetName()
|
||||
resp := instance.CreateTarget(ctx, t, name, "https://example.com", target_domain.TargetTypeWebhook, false)
|
||||
request.Filters[0].Filter = &action.TargetSearchFilter_InTargetIdsFilter{
|
||||
InTargetIdsFilter: &action.InTargetIDsFilter{
|
||||
@@ -301,7 +300,7 @@ func TestServer_ListTargets(t *testing.T) {
|
||||
args: args{
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
dep: func(ctx context.Context, request *action.ListTargetsRequest, response *action.ListTargetsResponse) {
|
||||
name := gofakeit.Name()
|
||||
name := integration.TargetName()
|
||||
resp := instance.CreateTarget(ctx, t, name, "https://example.com", target_domain.TargetTypeWebhook, false)
|
||||
request.Filters[0].Filter = &action.TargetSearchFilter_TargetNameFilter{
|
||||
TargetNameFilter: &action.TargetNameFilter{
|
||||
@@ -342,9 +341,9 @@ func TestServer_ListTargets(t *testing.T) {
|
||||
args: args{
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
dep: func(ctx context.Context, request *action.ListTargetsRequest, response *action.ListTargetsResponse) {
|
||||
name1 := gofakeit.Name()
|
||||
name2 := gofakeit.Name()
|
||||
name3 := gofakeit.Name()
|
||||
name1 := integration.TargetName()
|
||||
name2 := integration.TargetName()
|
||||
name3 := integration.TargetName()
|
||||
resp1 := instance.CreateTarget(ctx, t, name1, "https://example.com", target_domain.TargetTypeWebhook, false)
|
||||
resp2 := instance.CreateTarget(ctx, t, name2, "https://example.com", target_domain.TargetTypeCall, true)
|
||||
resp3 := instance.CreateTarget(ctx, t, name3, "https://example.com", target_domain.TargetTypeAsync, false)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/brianvoe/gofakeit/v6"
|
||||
"github.com/muhlemmer/gu"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
@@ -25,7 +24,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
creationDate bool
|
||||
signingKey bool
|
||||
}
|
||||
alreadyExistingTargetName := gofakeit.AppName()
|
||||
alreadyExistingTargetName := integration.TargetName()
|
||||
instance.CreateTarget(isolatedIAMOwnerCTX, t, alreadyExistingTargetName, "https://example.com", target_domain.TargetTypeAsync, false)
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -38,7 +37,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "missing permission",
|
||||
ctx: instance.WithAuthorizationToken(context.Background(), integration.UserTypeOrgOwner),
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
@@ -54,7 +53,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "empty type",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
TargetType: nil,
|
||||
},
|
||||
wantErr: true,
|
||||
@@ -63,7 +62,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "empty webhook url",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
TargetType: &action.CreateTargetRequest_RestWebhook{
|
||||
RestWebhook: &action.RESTWebhook{},
|
||||
},
|
||||
@@ -74,7 +73,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "empty request response url",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
TargetType: &action.CreateTargetRequest_RestCall{
|
||||
RestCall: &action.RESTCall{},
|
||||
},
|
||||
@@ -85,7 +84,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "empty timeout",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
Endpoint: "https://example.com",
|
||||
TargetType: &action.CreateTargetRequest_RestWebhook{
|
||||
RestWebhook: &action.RESTWebhook{},
|
||||
@@ -111,7 +110,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "async, ok",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
Endpoint: "https://example.com",
|
||||
TargetType: &action.CreateTargetRequest_RestAsync{
|
||||
RestAsync: &action.RESTAsync{},
|
||||
@@ -128,7 +127,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "webhook, ok",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
Endpoint: "https://example.com",
|
||||
TargetType: &action.CreateTargetRequest_RestWebhook{
|
||||
RestWebhook: &action.RESTWebhook{
|
||||
@@ -147,7 +146,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "webhook, interrupt on error, ok",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
Endpoint: "https://example.com",
|
||||
TargetType: &action.CreateTargetRequest_RestWebhook{
|
||||
RestWebhook: &action.RESTWebhook{
|
||||
@@ -166,7 +165,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "call, ok",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
Endpoint: "https://example.com",
|
||||
TargetType: &action.CreateTargetRequest_RestCall{
|
||||
RestCall: &action.RESTCall{
|
||||
@@ -186,7 +185,7 @@ func TestServer_CreateTarget(t *testing.T) {
|
||||
name: "call, interruptOnError, ok",
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.CreateTargetRequest{
|
||||
Name: gofakeit.Name(),
|
||||
Name: integration.TargetName(),
|
||||
Endpoint: "https://example.com",
|
||||
TargetType: &action.CreateTargetRequest_RestCall{
|
||||
RestCall: &action.RESTCall{
|
||||
@@ -269,7 +268,7 @@ func TestServer_UpdateTarget(t *testing.T) {
|
||||
args: args{
|
||||
ctx: instance.WithAuthorizationToken(context.Background(), integration.UserTypeOrgOwner),
|
||||
req: &action.UpdateTargetRequest{
|
||||
Name: gu.Ptr(gofakeit.Name()),
|
||||
Name: gu.Ptr(integration.TargetName()),
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
@@ -282,7 +281,7 @@ func TestServer_UpdateTarget(t *testing.T) {
|
||||
args: args{
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.UpdateTargetRequest{
|
||||
Name: gu.Ptr(gofakeit.Name()),
|
||||
Name: gu.Ptr(integration.TargetName()),
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
@@ -314,7 +313,7 @@ func TestServer_UpdateTarget(t *testing.T) {
|
||||
args: args{
|
||||
ctx: isolatedIAMOwnerCTX,
|
||||
req: &action.UpdateTargetRequest{
|
||||
Name: gu.Ptr(gofakeit.Name()),
|
||||
Name: gu.Ptr(integration.TargetName()),
|
||||
},
|
||||
},
|
||||
want: want{
|
||||
|
||||
Reference in New Issue
Block a user