mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 15:57:32 +00:00
fixes
This commit is contained in:
@@ -19,7 +19,7 @@ type Instance struct {
|
||||
CreatedAt time.Time `json:"createdAt" db:"created_at"`
|
||||
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
|
||||
|
||||
Domains []*InstanceDomain `json:"domains,omitempty" db:"-"`
|
||||
Domains []*InstanceDomain `json:"domains,omitempty" db:"domains"`
|
||||
}
|
||||
|
||||
type instanceCacheIndex uint8
|
||||
|
@@ -22,7 +22,7 @@ type Organization struct {
|
||||
CreatedAt time.Time `json:"createdAt,omitzero" db:"created_at"`
|
||||
UpdatedAt time.Time `json:"updatedAt,omitzero" db:"updated_at"`
|
||||
|
||||
Domains []*OrganizationDomain `json:"domains,omitempty" db:"-"`
|
||||
Domains []*OrganizationDomain `json:"domains,omitempty" db:"domains"`
|
||||
}
|
||||
|
||||
// OrgIdentifierCondition is used to help specify a single Organization,
|
||||
|
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/brianvoe/gofakeit/v6"
|
||||
"github.com/muhlemmer/gu"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -337,6 +338,51 @@ func TestGetInstance(t *testing.T) {
|
||||
},
|
||||
}
|
||||
}(),
|
||||
{
|
||||
name: "happy path including domains",
|
||||
testFunc: func(ctx context.Context, t *testing.T) *domain.Instance {
|
||||
instanceRepo := repository.InstanceRepository(pool)
|
||||
instanceId := gofakeit.Name()
|
||||
instanceName := gofakeit.Name()
|
||||
|
||||
inst := domain.Instance{
|
||||
ID: instanceId,
|
||||
Name: instanceName,
|
||||
DefaultOrgID: "defaultOrgId",
|
||||
IAMProjectID: "iamProject",
|
||||
ConsoleClientID: "consoleCLient",
|
||||
ConsoleAppID: "consoleApp",
|
||||
DefaultLanguage: "defaultLanguage",
|
||||
}
|
||||
|
||||
// create instance
|
||||
err := instanceRepo.Create(ctx, &inst)
|
||||
require.NoError(t, err)
|
||||
|
||||
domainRepo := instanceRepo.Domains(false)
|
||||
d := &domain.AddInstanceDomain{
|
||||
InstanceID: inst.ID,
|
||||
Domain: gofakeit.DomainName(),
|
||||
IsPrimary: gu.Ptr(true),
|
||||
IsGenerated: gu.Ptr(false),
|
||||
Type: domain.DomainTypeCustom,
|
||||
}
|
||||
err = domainRepo.Add(ctx, d)
|
||||
require.NoError(t, err)
|
||||
|
||||
inst.Domains = append(inst.Domains, &domain.InstanceDomain{
|
||||
InstanceID: d.InstanceID,
|
||||
Domain: d.Domain,
|
||||
IsPrimary: d.IsPrimary,
|
||||
IsGenerated: d.IsGenerated,
|
||||
Type: d.Type,
|
||||
CreatedAt: d.CreatedAt,
|
||||
UpdatedAt: d.UpdatedAt,
|
||||
})
|
||||
|
||||
return &inst
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "get non existent instance",
|
||||
testFunc: func(ctx context.Context, t *testing.T) *domain.Instance {
|
||||
|
@@ -471,6 +471,52 @@ func TestGetOrganization(t *testing.T) {
|
||||
orgIdentifierCondition: orgRepo.IDCondition(organizationId),
|
||||
}
|
||||
}(),
|
||||
func() test {
|
||||
organizationId := gofakeit.Name()
|
||||
return test{
|
||||
name: "happy path get using id including domain",
|
||||
testFunc: func(ctx context.Context, t *testing.T) *domain.Organization {
|
||||
organizationName := gofakeit.Name()
|
||||
|
||||
org := domain.Organization{
|
||||
ID: organizationId,
|
||||
Name: organizationName,
|
||||
InstanceID: instanceId,
|
||||
State: domain.OrgStateActive,
|
||||
}
|
||||
|
||||
// create organization
|
||||
err := orgRepo.Create(ctx, &org)
|
||||
require.NoError(t, err)
|
||||
|
||||
d := &domain.AddOrganizationDomain{
|
||||
InstanceID: org.InstanceID,
|
||||
OrgID: org.ID,
|
||||
Domain: gofakeit.DomainName(),
|
||||
IsVerified: true,
|
||||
IsPrimary: true,
|
||||
}
|
||||
err = orgRepo.Domains(false).Add(ctx, d)
|
||||
require.NoError(t, err)
|
||||
|
||||
org.Domains = []*domain.OrganizationDomain{
|
||||
{
|
||||
InstanceID: d.InstanceID,
|
||||
OrgID: d.OrgID,
|
||||
ValidationType: d.ValidationType,
|
||||
Domain: d.Domain,
|
||||
IsPrimary: d.IsPrimary,
|
||||
IsVerified: d.IsVerified,
|
||||
CreatedAt: d.CreatedAt,
|
||||
UpdatedAt: d.UpdatedAt,
|
||||
},
|
||||
}
|
||||
|
||||
return &org
|
||||
},
|
||||
orgIdentifierCondition: orgRepo.IDCondition(organizationId),
|
||||
}
|
||||
}(),
|
||||
func() test {
|
||||
organizationName := gofakeit.Name()
|
||||
return test{
|
||||
|
Reference in New Issue
Block a user