This commit is contained in:
Elio Bischof
2023-07-04 18:14:26 +02:00
parent 209b8bd19c
commit ed5d968d7c
6 changed files with 60 additions and 83 deletions

View File

@@ -1,35 +1,22 @@
Log:
Level: info
Telemetry:
Enabled: true
Endpoints:
- https://httpbin.org/post
ExternalDomain: host.docker.internal
ExternalSecure: false
TLS:
Enabled: false
Database:
cockroach:
# This makes the e2e config reusable with an out-of-docker zitadel process and an /etc/hosts entry
Host: host.docker.internal
TLS:
Enabled: false
FirstInstance:
Org:
Human:
PasswordChangeRequired: false
DefaultInstance:
Org:
Human:
PasswordChangeRequired: false
Password: "Password1!"
LoginPolicy:
MfaInitSkipLifetime: "0"
LogStore:
Access:
Database:
@@ -55,8 +42,10 @@ Projections:
Customizations:
NotificationsQuotas:
RequeueEvery: 1s
Telemetry:
RequeueEvery: 1s
DefaultInstance:
LoginPolicy:
MfaInitSkipLifetime: "0"
SystemAPIUsers:
- cypress:

View File

@@ -1,36 +1,22 @@
Log:
Level: info
Telemetry:
Enabled: true
Endpoints:
# - https://httpbin.org/post
- https://example.com
ExternalDomain: localhost
ExternalSecure: false
TLS:
Enabled: false
Database:
cockroach:
# This makes the e2e config reusable with an out-of-docker zitadel process and an /etc/hosts entry
Host: host.docker.internal
TLS:
Enabled: false
FirstInstance:
Org:
Human:
PasswordChangeRequired: false
DefaultInstance:
Org:
Human:
PasswordChangeRequired: false
Password: "Password1!"
LoginPolicy:
MfaInitSkipLifetime: "0"
LogStore:
Access:
Database:
@@ -56,8 +42,10 @@ Projections:
Customizations:
NotificationsQuotas:
RequeueEvery: 1s
Telemetry:
RequeueEvery: 30s
DefaultInstance:
LoginPolicy:
MfaInitSkipLifetime: "0"
SystemAPIUsers:
- cypress:

View File

@@ -44,6 +44,30 @@ func newClient(cc *grpc.ClientConn) Client {
}
}
func (t *Tester) UseIsolatedInstance(ctx context.Context) (primaryDomain, instanceID string, systemCtx, iamOwnerCtx context.Context) {
systemCtx = t.WithAuthorization(ctx, SystemUser)
primaryDomain = randString(5) + ".integration"
instance, err := t.Client.System.CreateInstance(systemCtx, &system.CreateInstanceRequest{
InstanceName: "testinstance",
CustomDomain: primaryDomain,
Owner: &system.CreateInstanceRequest_Machine_{
Machine: &system.CreateInstanceRequest_Machine{
UserName: "owner",
Name: "owner",
PersonalAccessToken: &system.CreateInstanceRequest_PersonalAccessToken{},
},
},
})
if err != nil {
panic(err)
}
t.createClientConn(ctx, grpc.WithAuthority(primaryDomain))
t.Users[IAMOwner] = User{
Token: instance.GetPat(),
}
return primaryDomain, instance.GetInstanceId(), systemCtx, t.WithAuthorization(ctx, IAMOwner)
}
func (s *Tester) CreateHumanUser(ctx context.Context) *user.AddHumanUserResponse {
resp, err := s.Client.UserV2.AddHumanUser(ctx, &user.AddHumanUserRequest{
Organisation: &object.Organisation{

View File

@@ -8,7 +8,6 @@ import (
_ "embed"
"errors"
"fmt"
"math/rand"
"os"
"strings"
"sync"
@@ -33,13 +32,8 @@ import (
"github.com/zitadel/zitadel/internal/query"
"github.com/zitadel/zitadel/internal/webauthn"
"github.com/zitadel/zitadel/pkg/grpc/admin"
"github.com/zitadel/zitadel/pkg/grpc/system"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
var (
//go:embed config/zitadel.yaml
zitadelYAML []byte
@@ -288,37 +282,3 @@ func Contexts(timeout time.Duration) (ctx, errCtx context.Context, cancel contex
ctx, cancel = context.WithTimeout(context.Background(), timeout)
return ctx, errCtx, cancel
}
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyz")
func randStringRunes(n int) string {
b := make([]rune, n)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
}
return string(b)
}
func (t *Tester) UseIsolatedInstance(ctx context.Context) (primaryDomain, instanceID string, systemCtx, iamOwnerCtx context.Context) {
systemCtx = t.WithAuthorization(ctx, SystemUser)
primaryDomain = randStringRunes(5) + ".integration"
instance, err := t.Client.System.CreateInstance(systemCtx, &system.CreateInstanceRequest{
InstanceName: "testinstance",
CustomDomain: primaryDomain,
Owner: &system.CreateInstanceRequest_Machine_{
Machine: &system.CreateInstanceRequest_Machine{
UserName: "owner",
Name: "owner",
PersonalAccessToken: &system.CreateInstanceRequest_PersonalAccessToken{},
},
},
})
if err != nil {
panic(err)
}
t.createClientConn(ctx, grpc.WithAuthority(primaryDomain))
t.Users[IAMOwner] = User{
Token: instance.GetPat(),
}
return primaryDomain, instance.GetInstanceId(), systemCtx, t.WithAuthorization(ctx, IAMOwner)
}

View File

@@ -0,0 +1,20 @@
package integration
import (
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyz")
func randString(n int) string {
b := make([]rune, n)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
}
return string(b)
}

View File

@@ -8,11 +8,9 @@ import (
"testing"
"time"
"github.com/zitadel/zitadel/pkg/grpc/management"
"github.com/zitadel/zitadel/pkg/grpc/system"
"github.com/zitadel/zitadel/internal/integration"
"github.com/zitadel/zitadel/pkg/grpc/management"
"github.com/zitadel/zitadel/pkg/grpc/system"
)
var (
@@ -27,8 +25,6 @@ func TestMain(m *testing.M) {
ctx, _, cancel := integration.Contexts(5 * time.Minute)
CTX = ctx
defer cancel()
os.Setenv("INTEGRATION_DB_FLAVOR", "postgres")
os.Setenv("ZITADEL_MASTERKEY", "MasterkeyNeedsToHave32Characters")
Tester = integration.NewTester(ctx)
MgmtClient = Tester.Client.Mgmt
SystemClient = Tester.Client.System