mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 07:57:32 +00:00
added first event
This commit is contained in:
@@ -31,7 +31,7 @@ const (
|
||||
|
||||
type IdentityProvider struct {
|
||||
InstanceID string `json:"instanceId,omitempty" db:"instance_id"`
|
||||
OrgID string `json:"orgId,omitempty" db:"org_id"`
|
||||
OrgID *string `json:"orgId,omitempty" db:"org_id"`
|
||||
ID string `json:"id,omitempty" db:"id"`
|
||||
State string `json:"state,omitempty" db:"state"`
|
||||
Name string `json:"name,omitempty" db:"name"`
|
||||
@@ -41,7 +41,7 @@ type IdentityProvider struct {
|
||||
AllowAutoUpdate bool `json:"allowAutoUpdate,omitempty" db:"allow_auto_update"`
|
||||
AllowLinking bool `json:"allowLinking,omitempty" db:"allow_linking"`
|
||||
StylingType int16 `json:"stylingType,omitempty" db:"styling_type"`
|
||||
Payload string `json:"payload,omitempty" db:"payload"`
|
||||
Payload *string `json:"payload,omitempty" db:"payload"`
|
||||
CreatedAt time.Time `json:"createdAt,omitempty" db:"created_at"`
|
||||
UpdatedAt time.Time `json:"updatedAt,omitempty" db:"updated_at"`
|
||||
}
|
||||
@@ -72,7 +72,7 @@ type idProviderColumns interface {
|
||||
|
||||
type idProviderConditions interface {
|
||||
InstanceIDCondition(id string) database.Condition
|
||||
OrgIDCondition(id string) database.Condition
|
||||
OrgIDCondition(id *string) database.Condition
|
||||
IDCondition(id string) IDPIdentifierCondition
|
||||
StateCondition(state IDPState) database.Condition
|
||||
NameCondition(name string) IDPIdentifierCondition
|
||||
|
@@ -16,11 +16,16 @@ func (a *and) Write(builder *StatementBuilder) {
|
||||
builder.WriteString("(")
|
||||
defer builder.WriteString(")")
|
||||
}
|
||||
for i, condition := range a.conditions {
|
||||
if i > 0 {
|
||||
firstCondition := true
|
||||
for _, condition := range a.conditions {
|
||||
if condition == nil {
|
||||
continue
|
||||
}
|
||||
if !firstCondition {
|
||||
builder.WriteString(" AND ")
|
||||
}
|
||||
condition.Write(builder)
|
||||
firstCondition = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,34 +3,31 @@
|
||||
package events_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/brianvoe/gofakeit/v6"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/zitadel/zitadel/backend/v3/domain"
|
||||
"github.com/zitadel/zitadel/backend/v3/storage/database/repository"
|
||||
"github.com/zitadel/zitadel/internal/integration"
|
||||
"github.com/zitadel/zitadel/pkg/grpc/admin"
|
||||
"github.com/zitadel/zitadel/pkg/grpc/idp"
|
||||
v2beta_org "github.com/zitadel/zitadel/pkg/grpc/org/v2beta"
|
||||
idp_grpc "github.com/zitadel/zitadel/pkg/grpc/idp"
|
||||
)
|
||||
|
||||
func TestServer_TestIDProviderReduces(t *testing.T) {
|
||||
// instanceID := Instance.ID()
|
||||
instanceID := Instance.ID()
|
||||
|
||||
t.Run("test org add reduces", func(t *testing.T) {
|
||||
// beforeCreate := time.Now()
|
||||
orgName := gofakeit.Name()
|
||||
|
||||
// create org
|
||||
_, err := OrgClient.CreateOrganization(CTX, &v2beta_org.CreateOrganizationRequest{
|
||||
Name: orgName,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// afterCreate := time.Now()
|
||||
t.Run("test idp add reduces", func(t *testing.T) {
|
||||
name := gofakeit.Name()
|
||||
|
||||
beforeCreate := time.Now()
|
||||
addOCID, err := AdminClient.AddOIDCIDP(CTX, &admin.AddOIDCIDPRequest{
|
||||
Name: gofakeit.Name(),
|
||||
StylingType: idp.IDPStylingType_STYLING_TYPE_GOOGLE,
|
||||
Name: name,
|
||||
StylingType: idp_grpc.IDPStylingType_STYLING_TYPE_GOOGLE,
|
||||
ClientId: "clientID",
|
||||
ClientSecret: "clientSecret",
|
||||
Issuer: "issuer",
|
||||
@@ -39,26 +36,28 @@ func TestServer_TestIDProviderReduces(t *testing.T) {
|
||||
UsernameMapping: idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL,
|
||||
AutoRegister: true,
|
||||
})
|
||||
fmt.Printf("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> addOCID = %+v\n", addOCID)
|
||||
fmt.Printf("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> err = %+v\n", err)
|
||||
require.NoError(t, err)
|
||||
afterCreate := time.Now()
|
||||
|
||||
// idpRepo := repository.IDProviderRepository(pool)
|
||||
idpRepo := repository.IDProviderRepository(pool)
|
||||
|
||||
// retryDuration, tick := integration.WaitForAndTickWithMaxDuration(CTX, time.Minute)
|
||||
// assert.EventuallyWithT(t, func(tt *assert.CollectT) {
|
||||
// organization, err := idpRepo.Get(CTX,
|
||||
// idpRepo.NameCondition(orgName),
|
||||
// instanceID,
|
||||
// )
|
||||
// require.NoError(tt, err)
|
||||
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(CTX, time.Minute)
|
||||
assert.EventuallyWithT(t, func(t *assert.CollectT) {
|
||||
idp, err := idpRepo.Get(CTX,
|
||||
idpRepo.NameCondition(name),
|
||||
instanceID,
|
||||
nil,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
// // event org.added
|
||||
// assert.NotNil(t, organization.ID)
|
||||
// assert.Equal(t, orgName, organization.Name)
|
||||
// assert.NotNil(t, organization.InstanceID)
|
||||
// assert.Equal(t, domain.OrgStateActive.String(), organization.State)
|
||||
// assert.WithinRange(t, organization.CreatedAt, beforeCreate, afterCreate)
|
||||
// assert.WithinRange(t, organization.UpdatedAt, beforeCreate, afterCreate)
|
||||
// }, retryDuration, tick)
|
||||
// event iam.idp.config.added
|
||||
assert.Equal(t, addOCID.IdpId, idp.ID)
|
||||
assert.Equal(t, name, idp.Name)
|
||||
assert.Equal(t, instanceID, idp.InstanceID)
|
||||
assert.Equal(t, domain.OrgStateActive.String(), idp.State)
|
||||
assert.Equal(t, int16(idp_grpc.IDPStylingType_STYLING_TYPE_GOOGLE), idp.StylingType)
|
||||
assert.WithinRange(t, idp.CreatedAt, beforeCreate, afterCreate)
|
||||
assert.WithinRange(t, idp.UpdatedAt, beforeCreate, afterCreate)
|
||||
}, retryDuration, tick)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user