mirror of
https://github.com/zitadel/zitadel.git
synced 2025-02-28 19:47:23 +00:00
fix: join on instanceIDs in queries (#4612)
This commit is contained in:
parent
d721f725fd
commit
441f215513
@ -21,6 +21,7 @@ const (
|
||||
var (
|
||||
actionTable = table{
|
||||
name: projection.ActionTable,
|
||||
instanceIDCol: projection.ActionInstanceIDCol,
|
||||
}
|
||||
ActionColumnID = Column{
|
||||
name: projection.ActionIDCol,
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
var (
|
||||
flowsTriggersTable = table{
|
||||
name: projection.FlowTriggerTable,
|
||||
instanceIDCol: projection.FlowInstanceIDCol,
|
||||
}
|
||||
FlowsTriggersColumnFlowType = Column{
|
||||
name: projection.FlowTypeCol,
|
||||
|
@ -84,6 +84,7 @@ func (q *AppSearchQueries) toQuery(query sq.SelectBuilder) sq.SelectBuilder {
|
||||
var (
|
||||
appsTable = table{
|
||||
name: projection.AppProjectionTable,
|
||||
instanceIDCol: projection.AppColumnInstanceID,
|
||||
}
|
||||
AppColumnID = Column{
|
||||
name: projection.AppColumnID,
|
||||
@ -126,6 +127,7 @@ var (
|
||||
var (
|
||||
appSAMLConfigsTable = table{
|
||||
name: projection.AppSAMLTable,
|
||||
instanceIDCol: projection.AppSAMLConfigColumnInstanceID,
|
||||
}
|
||||
AppSAMLConfigColumnAppID = Column{
|
||||
name: projection.AppSAMLConfigColumnAppID,
|
||||
@ -148,6 +150,7 @@ var (
|
||||
var (
|
||||
appAPIConfigsTable = table{
|
||||
name: projection.AppAPITable,
|
||||
instanceIDCol: projection.AppAPIConfigColumnInstanceID,
|
||||
}
|
||||
AppAPIConfigColumnAppID = Column{
|
||||
name: projection.AppAPIConfigColumnAppID,
|
||||
@ -166,6 +169,7 @@ var (
|
||||
var (
|
||||
appOIDCConfigsTable = table{
|
||||
name: projection.AppOIDCTable,
|
||||
instanceIDCol: projection.AppOIDCConfigColumnInstanceID,
|
||||
}
|
||||
AppOIDCConfigColumnAppID = Column{
|
||||
name: projection.AppOIDCConfigColumnAppID,
|
||||
|
@ -50,9 +50,9 @@ var (
|
||||
` projections.apps3_saml_configs.metadata,` +
|
||||
` projections.apps3_saml_configs.metadata_url` +
|
||||
` FROM projections.apps3` +
|
||||
` LEFT JOIN projections.apps3_api_configs ON projections.apps3.id = projections.apps3_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps3_oidc_configs ON projections.apps3.id = projections.apps3_oidc_configs.app_id` +
|
||||
` LEFT JOIN projections.apps3_saml_configs ON projections.apps3.id = projections.apps3_saml_configs.app_id`)
|
||||
` LEFT JOIN projections.apps3_api_configs ON projections.apps3.id = projections.apps3_api_configs.app_id AND projections.apps3.instance_id = projections.apps3_api_configs.instance_id` +
|
||||
` LEFT JOIN projections.apps3_oidc_configs ON projections.apps3.id = projections.apps3_oidc_configs.app_id AND projections.apps3.instance_id = projections.apps3_oidc_configs.instance_id` +
|
||||
` LEFT JOIN projections.apps3_saml_configs ON projections.apps3.id = projections.apps3_saml_configs.app_id AND projections.apps3.instance_id = projections.apps3_saml_configs.instance_id`)
|
||||
expectedAppsQuery = regexp.QuoteMeta(`SELECT projections.apps3.id,` +
|
||||
` projections.apps3.name,` +
|
||||
` projections.apps3.project_id,` +
|
||||
@ -89,19 +89,19 @@ var (
|
||||
` projections.apps3_saml_configs.metadata_url,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.apps3` +
|
||||
` LEFT JOIN projections.apps3_api_configs ON projections.apps3.id = projections.apps3_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps3_oidc_configs ON projections.apps3.id = projections.apps3_oidc_configs.app_id` +
|
||||
` LEFT JOIN projections.apps3_saml_configs ON projections.apps3.id = projections.apps3_saml_configs.app_id`)
|
||||
` LEFT JOIN projections.apps3_api_configs ON projections.apps3.id = projections.apps3_api_configs.app_id AND projections.apps3.instance_id = projections.apps3_api_configs.instance_id` +
|
||||
` LEFT JOIN projections.apps3_oidc_configs ON projections.apps3.id = projections.apps3_oidc_configs.app_id AND projections.apps3.instance_id = projections.apps3_oidc_configs.instance_id` +
|
||||
` LEFT JOIN projections.apps3_saml_configs ON projections.apps3.id = projections.apps3_saml_configs.app_id AND projections.apps3.instance_id = projections.apps3_saml_configs.instance_id`)
|
||||
expectedAppIDsQuery = regexp.QuoteMeta(`SELECT projections.apps3_api_configs.client_id,` +
|
||||
` projections.apps3_oidc_configs.client_id` +
|
||||
` FROM projections.apps3` +
|
||||
` LEFT JOIN projections.apps3_api_configs ON projections.apps3.id = projections.apps3_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps3_oidc_configs ON projections.apps3.id = projections.apps3_oidc_configs.app_id`)
|
||||
` LEFT JOIN projections.apps3_api_configs ON projections.apps3.id = projections.apps3_api_configs.app_id AND projections.apps3.instance_id = projections.apps3_api_configs.instance_id` +
|
||||
` LEFT JOIN projections.apps3_oidc_configs ON projections.apps3.id = projections.apps3_oidc_configs.app_id AND projections.apps3.instance_id = projections.apps3_oidc_configs.instance_id`)
|
||||
expectedProjectIDByAppQuery = regexp.QuoteMeta(`SELECT projections.apps3.project_id` +
|
||||
` FROM projections.apps3` +
|
||||
` LEFT JOIN projections.apps3_api_configs ON projections.apps3.id = projections.apps3_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps3_oidc_configs ON projections.apps3.id = projections.apps3_oidc_configs.app_id` +
|
||||
` LEFT JOIN projections.apps3_saml_configs ON projections.apps3.id = projections.apps3_saml_configs.app_id`)
|
||||
` LEFT JOIN projections.apps3_api_configs ON projections.apps3.id = projections.apps3_api_configs.app_id AND projections.apps3.instance_id = projections.apps3_api_configs.instance_id` +
|
||||
` LEFT JOIN projections.apps3_oidc_configs ON projections.apps3.id = projections.apps3_oidc_configs.app_id AND projections.apps3.instance_id = projections.apps3_oidc_configs.instance_id` +
|
||||
` LEFT JOIN projections.apps3_saml_configs ON projections.apps3.id = projections.apps3_saml_configs.app_id AND projections.apps3.instance_id = projections.apps3_saml_configs.instance_id`)
|
||||
expectedProjectByAppQuery = regexp.QuoteMeta(`SELECT projections.projects2.id,` +
|
||||
` projections.projects2.creation_date,` +
|
||||
` projections.projects2.change_date,` +
|
||||
@ -114,10 +114,10 @@ var (
|
||||
` projections.projects2.has_project_check,` +
|
||||
` projections.projects2.private_labeling_setting` +
|
||||
` FROM projections.projects2` +
|
||||
` JOIN projections.apps3 ON projections.projects2.id = projections.apps3.project_id` +
|
||||
` LEFT JOIN projections.apps3_api_configs ON projections.apps3.id = projections.apps3_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps3_oidc_configs ON projections.apps3.id = projections.apps3_oidc_configs.app_id` +
|
||||
` LEFT JOIN projections.apps3_saml_configs ON projections.apps3.id = projections.apps3_saml_configs.app_id`)
|
||||
` JOIN projections.apps3 ON projections.projects2.id = projections.apps3.project_id AND projections.projects2.instance_id = projections.apps3.instance_id` +
|
||||
` LEFT JOIN projections.apps3_api_configs ON projections.apps3.id = projections.apps3_api_configs.app_id AND projections.apps3.instance_id = projections.apps3_api_configs.instance_id` +
|
||||
` LEFT JOIN projections.apps3_oidc_configs ON projections.apps3.id = projections.apps3_oidc_configs.app_id AND projections.apps3.instance_id = projections.apps3_oidc_configs.instance_id` +
|
||||
` LEFT JOIN projections.apps3_saml_configs ON projections.apps3.id = projections.apps3_saml_configs.app_id AND projections.apps3.instance_id = projections.apps3_saml_configs.instance_id`)
|
||||
|
||||
appCols = database.StringArray{
|
||||
"id",
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
var (
|
||||
authNKeyTable = table{
|
||||
name: projection.AuthNKeyTable,
|
||||
instanceIDCol: projection.AuthNKeyInstanceIDCol,
|
||||
}
|
||||
AuthNKeyColumnID = Column{
|
||||
name: projection.AuthNKeyIDCol,
|
||||
|
@ -48,6 +48,7 @@ func (c *rsaCertificate) Certificate() []byte {
|
||||
var (
|
||||
certificateTable = table{
|
||||
name: projection.CertificateTable,
|
||||
instanceIDCol: projection.CertificateColumnInstanceID,
|
||||
}
|
||||
CertificateColID = Column{
|
||||
name: projection.CertificateColumnID,
|
||||
|
@ -41,8 +41,8 @@ func Test_CertificatePrepares(t *testing.T) {
|
||||
` projections.keys3_private.key,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.keys3`+
|
||||
` LEFT JOIN projections.keys3_certificate ON projections.keys3.id = projections.keys3_certificate.id`+
|
||||
` LEFT JOIN projections.keys3_private ON projections.keys3.id = projections.keys3_private.id`),
|
||||
` LEFT JOIN projections.keys3_certificate ON projections.keys3.id = projections.keys3_certificate.id AND projections.keys3.instance_id = projections.keys3_certificate.instance_id`+
|
||||
` LEFT JOIN projections.keys3_private ON projections.keys3.id = projections.keys3_private.id AND projections.keys3.instance_id = projections.keys3_private.instance_id`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@ -72,8 +72,8 @@ func Test_CertificatePrepares(t *testing.T) {
|
||||
` projections.keys3_private.key,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.keys3`+
|
||||
` LEFT JOIN projections.keys3_certificate ON projections.keys3.id = projections.keys3_certificate.id`+
|
||||
` LEFT JOIN projections.keys3_private ON projections.keys3.id = projections.keys3_private.id`),
|
||||
` LEFT JOIN projections.keys3_certificate ON projections.keys3.id = projections.keys3_certificate.id AND projections.keys3.instance_id = projections.keys3_certificate.instance_id`+
|
||||
` LEFT JOIN projections.keys3_private ON projections.keys3.id = projections.keys3_private.id AND projections.keys3.instance_id = projections.keys3_private.instance_id`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@ -147,8 +147,8 @@ func Test_CertificatePrepares(t *testing.T) {
|
||||
` projections.keys3_private.key,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.keys3`+
|
||||
` LEFT JOIN projections.keys3_certificate ON projections.keys3.id = projections.keys3_certificate.id`+
|
||||
` LEFT JOIN projections.keys3_private ON projections.keys3.id = projections.keys3_private.id`),
|
||||
` LEFT JOIN projections.keys3_certificate ON projections.keys3.id = projections.keys3_certificate.id AND projections.keys3.instance_id = projections.keys3_certificate.instance_id`+
|
||||
` LEFT JOIN projections.keys3_private ON projections.keys3.id = projections.keys3_private.id AND projections.keys3.instance_id = projections.keys3_private.instance_id`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
@ -250,6 +250,7 @@ func prepareCurrentSequencesQuery() (sq.SelectBuilder, func(*sql.Rows) (*Current
|
||||
var (
|
||||
currentSequencesTable = table{
|
||||
name: projection.CurrentSeqTable,
|
||||
instanceIDCol: "instance_id",
|
||||
}
|
||||
CurrentSequenceColAggregateType = Column{
|
||||
name: "aggregate_type",
|
||||
@ -276,6 +277,7 @@ var (
|
||||
var (
|
||||
locksTable = table{
|
||||
name: projection.LocksTable,
|
||||
instanceIDCol: "instance_id",
|
||||
}
|
||||
LocksColLockerID = Column{
|
||||
name: "locker_id",
|
||||
|
@ -40,6 +40,7 @@ type CustomText struct {
|
||||
var (
|
||||
customTextTable = table{
|
||||
name: projection.CustomTextTable,
|
||||
instanceIDCol: projection.CustomTextInstanceIDCol,
|
||||
}
|
||||
CustomTextColAggregateID = Column{
|
||||
name: projection.CustomTextAggregateIDCol,
|
||||
|
@ -33,6 +33,7 @@ type DomainPolicy struct {
|
||||
var (
|
||||
domainPolicyTable = table{
|
||||
name: projection.DomainPolicyTable,
|
||||
instanceIDCol: projection.DomainPolicyInstanceIDCol,
|
||||
}
|
||||
DomainPolicyColID = Column{
|
||||
name: projection.DomainPolicyIDCol,
|
||||
|
@ -22,6 +22,7 @@ const (
|
||||
var (
|
||||
failedEventsTable = table{
|
||||
name: projection.FailedEventsTable,
|
||||
instanceIDCol: failedEventsColumnInstanceID,
|
||||
}
|
||||
FailedEventsColumnProjectionName = Column{
|
||||
name: failedEventsColumnProjectionName,
|
||||
@ -39,10 +40,6 @@ var (
|
||||
name: failedEventsColumnError,
|
||||
table: failedEventsTable,
|
||||
}
|
||||
FailedEventsColumnInstanceID = Column{
|
||||
name: failedEventsColumnInstanceID,
|
||||
table: failedEventsTable,
|
||||
}
|
||||
)
|
||||
|
||||
type FailedEvents struct {
|
||||
|
@ -16,6 +16,7 @@ var (
|
||||
instanceMemberTable = table{
|
||||
name: projection.InstanceMemberProjectionTable,
|
||||
alias: "members",
|
||||
instanceIDCol: projection.MemberInstanceID,
|
||||
}
|
||||
InstanceMemberUserID = Column{
|
||||
name: projection.MemberUserIDCol,
|
||||
|
@ -29,11 +29,11 @@ var (
|
||||
", COUNT(*) OVER () " +
|
||||
"FROM projections.instance_members2 AS members " +
|
||||
"LEFT JOIN projections.users4_humans " +
|
||||
"ON members.user_id = projections.users4_humans.user_id " +
|
||||
"ON members.user_id = projections.users4_humans.user_id AND members.instance_id = projections.users4_humans.instance_id " +
|
||||
"LEFT JOIN projections.users4_machines " +
|
||||
"ON members.user_id = projections.users4_machines.user_id " +
|
||||
"ON members.user_id = projections.users4_machines.user_id AND members.instance_id = projections.users4_machines.instance_id " +
|
||||
"LEFT JOIN projections.login_names " +
|
||||
"ON members.user_id = projections.login_names.user_id " +
|
||||
"ON members.user_id = projections.login_names.user_id AND members.instance_id = projections.login_names.instance_id " +
|
||||
"WHERE projections.login_names.is_primary = $1")
|
||||
instanceMembersColumns = []string{
|
||||
"creation_date",
|
||||
|
@ -60,6 +60,7 @@ type JWTIDP struct {
|
||||
var (
|
||||
idpTable = table{
|
||||
name: projection.IDPTable,
|
||||
instanceIDCol: projection.IDPInstanceIDCol,
|
||||
}
|
||||
IDPIDCol = Column{
|
||||
name: projection.IDPIDCol,
|
||||
@ -114,6 +115,7 @@ var (
|
||||
var (
|
||||
oidcIDPTable = table{
|
||||
name: projection.IDPOIDCTable,
|
||||
instanceIDCol: projection.OIDCConfigInstanceIDCol,
|
||||
}
|
||||
OIDCIDPColIDPID = Column{
|
||||
name: projection.OIDCConfigIDPIDCol,
|
||||
@ -156,6 +158,7 @@ var (
|
||||
var (
|
||||
jwtIDPTable = table{
|
||||
name: projection.IDPJWTTable,
|
||||
instanceIDCol: projection.JWTConfigInstanceIDCol,
|
||||
}
|
||||
JWTIDPColIDPID = Column{
|
||||
name: projection.JWTConfigIDPIDCol,
|
||||
|
@ -39,6 +39,7 @@ func (q *IDPLoginPolicyLinksSearchQuery) toQuery(query sq.SelectBuilder) sq.Sele
|
||||
var (
|
||||
idpLoginPolicyLinkTable = table{
|
||||
name: projection.IDPLoginPolicyLinkTable,
|
||||
instanceIDCol: projection.IDPLoginPolicyLinkInstanceIDCol,
|
||||
}
|
||||
IDPLoginPolicyLinkIDPIDCol = Column{
|
||||
name: projection.IDPLoginPolicyLinkIDPIDCol,
|
||||
|
@ -14,23 +14,8 @@ import (
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
func Test_IDPPrepares(t *testing.T) {
|
||||
type want struct {
|
||||
sqlExpectations sqlExpectation
|
||||
err checkErr
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
prepare interface{}
|
||||
want want
|
||||
object interface{}
|
||||
}{
|
||||
{
|
||||
name: "prepareIDPByIDQuery no result",
|
||||
prepare: prepareIDPByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.idps2.id,`+
|
||||
var (
|
||||
idpQuery = `SELECT projections.idps2.id,` +
|
||||
` projections.idps2.resource_owner,` +
|
||||
` projections.idps2.creation_date,` +
|
||||
` projections.idps2.change_date,` +
|
||||
@ -55,53 +40,9 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
` projections.idps2_jwt_config.header_name,` +
|
||||
` projections.idps2_jwt_config.endpoint` +
|
||||
` FROM projections.idps2` +
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
if !errs.IsNotFound(err) {
|
||||
return fmt.Errorf("err should be zitadel.NotFoundError got: %w", err), false
|
||||
}
|
||||
return nil, true
|
||||
},
|
||||
},
|
||||
object: (*IDP)(nil),
|
||||
},
|
||||
{
|
||||
name: "prepareIDPByIDQuery oidc idp",
|
||||
prepare: prepareIDPByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.idps2.id,`+
|
||||
` projections.idps2.resource_owner,`+
|
||||
` projections.idps2.creation_date,`+
|
||||
` projections.idps2.change_date,`+
|
||||
` projections.idps2.sequence,`+
|
||||
` projections.idps2.state,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.styling_type,`+
|
||||
` projections.idps2.owner_type,`+
|
||||
` projections.idps2.auto_register,`+
|
||||
` projections.idps2_oidc_config.idp_id,`+
|
||||
` projections.idps2_oidc_config.client_id,`+
|
||||
` projections.idps2_oidc_config.client_secret,`+
|
||||
` projections.idps2_oidc_config.issuer,`+
|
||||
` projections.idps2_oidc_config.scopes,`+
|
||||
` projections.idps2_oidc_config.display_name_mapping,`+
|
||||
` projections.idps2_oidc_config.username_mapping,`+
|
||||
` projections.idps2_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps2_oidc_config.token_endpoint,`+
|
||||
` projections.idps2_jwt_config.idp_id,`+
|
||||
` projections.idps2_jwt_config.issuer,`+
|
||||
` projections.idps2_jwt_config.keys_endpoint,`+
|
||||
` projections.idps2_jwt_config.header_name,`+
|
||||
` projections.idps2_jwt_config.endpoint`+
|
||||
` FROM projections.idps2`+
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id`),
|
||||
[]string{
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id AND projections.idps2.instance_id = projections.idps2_oidc_config.instance_id` +
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id AND projections.idps2.instance_id = projections.idps2_jwt_config.instance_id`
|
||||
idpCols = []string{
|
||||
"id",
|
||||
"resource_owner",
|
||||
"creation_date",
|
||||
@ -128,7 +69,102 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
"keys_endpoint",
|
||||
"header_name",
|
||||
"endpoint",
|
||||
}
|
||||
idpsQuery = `SELECT projections.idps2.id,` +
|
||||
` projections.idps2.resource_owner,` +
|
||||
` projections.idps2.creation_date,` +
|
||||
` projections.idps2.change_date,` +
|
||||
` projections.idps2.sequence,` +
|
||||
` projections.idps2.state,` +
|
||||
` projections.idps2.name,` +
|
||||
` projections.idps2.styling_type,` +
|
||||
` projections.idps2.owner_type,` +
|
||||
` projections.idps2.auto_register,` +
|
||||
` projections.idps2_oidc_config.idp_id,` +
|
||||
` projections.idps2_oidc_config.client_id,` +
|
||||
` projections.idps2_oidc_config.client_secret,` +
|
||||
` projections.idps2_oidc_config.issuer,` +
|
||||
` projections.idps2_oidc_config.scopes,` +
|
||||
` projections.idps2_oidc_config.display_name_mapping,` +
|
||||
` projections.idps2_oidc_config.username_mapping,` +
|
||||
` projections.idps2_oidc_config.authorization_endpoint,` +
|
||||
` projections.idps2_oidc_config.token_endpoint,` +
|
||||
` projections.idps2_jwt_config.idp_id,` +
|
||||
` projections.idps2_jwt_config.issuer,` +
|
||||
` projections.idps2_jwt_config.keys_endpoint,` +
|
||||
` projections.idps2_jwt_config.header_name,` +
|
||||
` projections.idps2_jwt_config.endpoint,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.idps2` +
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id AND projections.idps2.instance_id = projections.idps2_oidc_config.instance_id` +
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id AND projections.idps2.instance_id = projections.idps2_jwt_config.instance_id`
|
||||
idpsCols = []string{
|
||||
"id",
|
||||
"resource_owner",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
"state",
|
||||
"name",
|
||||
"styling_type",
|
||||
"owner_type",
|
||||
"auto_register",
|
||||
// oidc config
|
||||
"idp_id",
|
||||
"client_id",
|
||||
"client_secret",
|
||||
"issuer",
|
||||
"scopes",
|
||||
"display_name_mapping",
|
||||
"username_mapping",
|
||||
"authorization_endpoint",
|
||||
"token_endpoint",
|
||||
// jwt config
|
||||
"idp_id",
|
||||
"issuer",
|
||||
"keys_endpoint",
|
||||
"header_name",
|
||||
"endpoint",
|
||||
"count",
|
||||
}
|
||||
)
|
||||
|
||||
func Test_IDPPrepares(t *testing.T) {
|
||||
type want struct {
|
||||
sqlExpectations sqlExpectation
|
||||
err checkErr
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
prepare interface{}
|
||||
want want
|
||||
object interface{}
|
||||
}{
|
||||
{
|
||||
name: "prepareIDPByIDQuery no result",
|
||||
prepare: prepareIDPByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(idpQuery),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
if !errs.IsNotFound(err) {
|
||||
return fmt.Errorf("err should be zitadel.NotFoundError got: %w", err), false
|
||||
}
|
||||
return nil, true
|
||||
},
|
||||
},
|
||||
object: (*IDP)(nil),
|
||||
},
|
||||
{
|
||||
name: "prepareIDPByIDQuery oidc idp",
|
||||
prepare: prepareIDPByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(idpQuery),
|
||||
idpCols,
|
||||
[]driver.Value{
|
||||
"idp-id",
|
||||
"ro",
|
||||
@ -188,61 +224,8 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.idps2.id,`+
|
||||
` projections.idps2.resource_owner,`+
|
||||
` projections.idps2.creation_date,`+
|
||||
` projections.idps2.change_date,`+
|
||||
` projections.idps2.sequence,`+
|
||||
` projections.idps2.state,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.styling_type,`+
|
||||
` projections.idps2.owner_type,`+
|
||||
` projections.idps2.auto_register,`+
|
||||
` projections.idps2_oidc_config.idp_id,`+
|
||||
` projections.idps2_oidc_config.client_id,`+
|
||||
` projections.idps2_oidc_config.client_secret,`+
|
||||
` projections.idps2_oidc_config.issuer,`+
|
||||
` projections.idps2_oidc_config.scopes,`+
|
||||
` projections.idps2_oidc_config.display_name_mapping,`+
|
||||
` projections.idps2_oidc_config.username_mapping,`+
|
||||
` projections.idps2_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps2_oidc_config.token_endpoint,`+
|
||||
` projections.idps2_jwt_config.idp_id,`+
|
||||
` projections.idps2_jwt_config.issuer,`+
|
||||
` projections.idps2_jwt_config.keys_endpoint,`+
|
||||
` projections.idps2_jwt_config.header_name,`+
|
||||
` projections.idps2_jwt_config.endpoint`+
|
||||
` FROM projections.idps2`+
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id`),
|
||||
[]string{
|
||||
"id",
|
||||
"resource_owner",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
"state",
|
||||
"name",
|
||||
"styling_type",
|
||||
"owner_type",
|
||||
"auto_register",
|
||||
// oidc config
|
||||
"idp_id",
|
||||
"client_id",
|
||||
"client_secret",
|
||||
"issuer",
|
||||
"scopes",
|
||||
"display_name_mapping",
|
||||
"username_mapping",
|
||||
"authorization_endpoint",
|
||||
"token_endpoint",
|
||||
// jwt config
|
||||
"idp_id",
|
||||
"issuer",
|
||||
"keys_endpoint",
|
||||
"header_name",
|
||||
"endpoint",
|
||||
},
|
||||
regexp.QuoteMeta(idpQuery),
|
||||
idpCols,
|
||||
[]driver.Value{
|
||||
"idp-id",
|
||||
"ro",
|
||||
@ -298,61 +281,8 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.idps2.id,`+
|
||||
` projections.idps2.resource_owner,`+
|
||||
` projections.idps2.creation_date,`+
|
||||
` projections.idps2.change_date,`+
|
||||
` projections.idps2.sequence,`+
|
||||
` projections.idps2.state,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.styling_type,`+
|
||||
` projections.idps2.owner_type,`+
|
||||
` projections.idps2.auto_register,`+
|
||||
` projections.idps2_oidc_config.idp_id,`+
|
||||
` projections.idps2_oidc_config.client_id,`+
|
||||
` projections.idps2_oidc_config.client_secret,`+
|
||||
` projections.idps2_oidc_config.issuer,`+
|
||||
` projections.idps2_oidc_config.scopes,`+
|
||||
` projections.idps2_oidc_config.display_name_mapping,`+
|
||||
` projections.idps2_oidc_config.username_mapping,`+
|
||||
` projections.idps2_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps2_oidc_config.token_endpoint,`+
|
||||
` projections.idps2_jwt_config.idp_id,`+
|
||||
` projections.idps2_jwt_config.issuer,`+
|
||||
` projections.idps2_jwt_config.keys_endpoint,`+
|
||||
` projections.idps2_jwt_config.header_name,`+
|
||||
` projections.idps2_jwt_config.endpoint`+
|
||||
` FROM projections.idps2`+
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id`),
|
||||
[]string{
|
||||
"id",
|
||||
"resource_owner",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
"state",
|
||||
"name",
|
||||
"styling_type",
|
||||
"owner_type",
|
||||
"auto_register",
|
||||
// oidc config
|
||||
"idp_id",
|
||||
"client_id",
|
||||
"client_secret",
|
||||
"issuer",
|
||||
"scopes",
|
||||
"display_name_mapping",
|
||||
"username_mapping",
|
||||
"authorization_endpoint",
|
||||
"token_endpoint",
|
||||
// jwt config
|
||||
"idp_id",
|
||||
"issuer",
|
||||
"keys_endpoint",
|
||||
"header_name",
|
||||
"endpoint",
|
||||
},
|
||||
regexp.QuoteMeta(idpQuery),
|
||||
idpCols,
|
||||
[]driver.Value{
|
||||
"idp-id",
|
||||
"ro",
|
||||
@ -401,33 +331,7 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.idps2.id,`+
|
||||
` projections.idps2.resource_owner,`+
|
||||
` projections.idps2.creation_date,`+
|
||||
` projections.idps2.change_date,`+
|
||||
` projections.idps2.sequence,`+
|
||||
` projections.idps2.state,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.styling_type,`+
|
||||
` projections.idps2.owner_type,`+
|
||||
` projections.idps2.auto_register,`+
|
||||
` projections.idps2_oidc_config.idp_id,`+
|
||||
` projections.idps2_oidc_config.client_id,`+
|
||||
` projections.idps2_oidc_config.client_secret,`+
|
||||
` projections.idps2_oidc_config.issuer,`+
|
||||
` projections.idps2_oidc_config.scopes,`+
|
||||
` projections.idps2_oidc_config.display_name_mapping,`+
|
||||
` projections.idps2_oidc_config.username_mapping,`+
|
||||
` projections.idps2_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps2_oidc_config.token_endpoint,`+
|
||||
` projections.idps2_jwt_config.idp_id,`+
|
||||
` projections.idps2_jwt_config.issuer,`+
|
||||
` projections.idps2_jwt_config.keys_endpoint,`+
|
||||
` projections.idps2_jwt_config.header_name,`+
|
||||
` projections.idps2_jwt_config.endpoint`+
|
||||
` FROM projections.idps2`+
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id`),
|
||||
regexp.QuoteMeta(idpQuery),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@ -444,34 +348,7 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.idps2.id,`+
|
||||
` projections.idps2.resource_owner,`+
|
||||
` projections.idps2.creation_date,`+
|
||||
` projections.idps2.change_date,`+
|
||||
` projections.idps2.sequence,`+
|
||||
` projections.idps2.state,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.styling_type,`+
|
||||
` projections.idps2.owner_type,`+
|
||||
` projections.idps2.auto_register,`+
|
||||
` projections.idps2_oidc_config.idp_id,`+
|
||||
` projections.idps2_oidc_config.client_id,`+
|
||||
` projections.idps2_oidc_config.client_secret,`+
|
||||
` projections.idps2_oidc_config.issuer,`+
|
||||
` projections.idps2_oidc_config.scopes,`+
|
||||
` projections.idps2_oidc_config.display_name_mapping,`+
|
||||
` projections.idps2_oidc_config.username_mapping,`+
|
||||
` projections.idps2_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps2_oidc_config.token_endpoint,`+
|
||||
` projections.idps2_jwt_config.idp_id,`+
|
||||
` projections.idps2_jwt_config.issuer,`+
|
||||
` projections.idps2_jwt_config.keys_endpoint,`+
|
||||
` projections.idps2_jwt_config.header_name,`+
|
||||
` projections.idps2_jwt_config.endpoint,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.idps2`+
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id`),
|
||||
regexp.QuoteMeta(idpsQuery),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@ -489,63 +366,8 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.idps2.id,`+
|
||||
` projections.idps2.resource_owner,`+
|
||||
` projections.idps2.creation_date,`+
|
||||
` projections.idps2.change_date,`+
|
||||
` projections.idps2.sequence,`+
|
||||
` projections.idps2.state,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.styling_type,`+
|
||||
` projections.idps2.owner_type,`+
|
||||
` projections.idps2.auto_register,`+
|
||||
` projections.idps2_oidc_config.idp_id,`+
|
||||
` projections.idps2_oidc_config.client_id,`+
|
||||
` projections.idps2_oidc_config.client_secret,`+
|
||||
` projections.idps2_oidc_config.issuer,`+
|
||||
` projections.idps2_oidc_config.scopes,`+
|
||||
` projections.idps2_oidc_config.display_name_mapping,`+
|
||||
` projections.idps2_oidc_config.username_mapping,`+
|
||||
` projections.idps2_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps2_oidc_config.token_endpoint,`+
|
||||
` projections.idps2_jwt_config.idp_id,`+
|
||||
` projections.idps2_jwt_config.issuer,`+
|
||||
` projections.idps2_jwt_config.keys_endpoint,`+
|
||||
` projections.idps2_jwt_config.header_name,`+
|
||||
` projections.idps2_jwt_config.endpoint,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.idps2`+
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id`),
|
||||
[]string{
|
||||
"id",
|
||||
"resource_owner",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
"state",
|
||||
"name",
|
||||
"styling_type",
|
||||
"owner_type",
|
||||
"auto_register",
|
||||
// oidc config
|
||||
"idp_id",
|
||||
"client_id",
|
||||
"client_secret",
|
||||
"issuer",
|
||||
"scopes",
|
||||
"display_name_mapping",
|
||||
"username_mapping",
|
||||
"authorization_endpoint",
|
||||
"token_endpoint",
|
||||
// jwt config
|
||||
"idp_id",
|
||||
"issuer",
|
||||
"keys_endpoint",
|
||||
"header_name",
|
||||
"endpoint",
|
||||
"count",
|
||||
},
|
||||
regexp.QuoteMeta(idpsQuery),
|
||||
idpsCols,
|
||||
[][]driver.Value{
|
||||
{
|
||||
"idp-id",
|
||||
@ -614,62 +436,8 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.idps2.id,`+
|
||||
` projections.idps2.resource_owner,`+
|
||||
` projections.idps2.creation_date,`+
|
||||
` projections.idps2.change_date,`+
|
||||
` projections.idps2.sequence,`+
|
||||
` projections.idps2.state,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.styling_type,`+
|
||||
` projections.idps2.owner_type,`+
|
||||
` projections.idps2.auto_register,`+
|
||||
` projections.idps2_oidc_config.idp_id,`+
|
||||
` projections.idps2_oidc_config.client_id,`+
|
||||
` projections.idps2_oidc_config.client_secret,`+
|
||||
` projections.idps2_oidc_config.issuer,`+
|
||||
` projections.idps2_oidc_config.scopes,`+
|
||||
` projections.idps2_oidc_config.display_name_mapping,`+
|
||||
` projections.idps2_oidc_config.username_mapping,`+
|
||||
` projections.idps2_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps2_oidc_config.token_endpoint,`+
|
||||
` projections.idps2_jwt_config.idp_id,`+
|
||||
` projections.idps2_jwt_config.issuer,`+
|
||||
` projections.idps2_jwt_config.keys_endpoint,`+
|
||||
` projections.idps2_jwt_config.header_name,`+
|
||||
` projections.idps2_jwt_config.endpoint,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.idps2`+
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id`),
|
||||
[]string{
|
||||
"id",
|
||||
"resource_owner",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
"state",
|
||||
"name",
|
||||
"styling_type",
|
||||
"owner_type",
|
||||
"auto_register",
|
||||
// oidc config
|
||||
"idp_id",
|
||||
"client_id",
|
||||
"client_secret",
|
||||
"issuer",
|
||||
"scopes",
|
||||
"display_name_mapping",
|
||||
"username_mapping",
|
||||
"authorization_endpoint",
|
||||
"token_endpoint",
|
||||
"idp_id",
|
||||
"issuer",
|
||||
"keys_endpoint",
|
||||
"header_name",
|
||||
"endpoint",
|
||||
"count",
|
||||
},
|
||||
regexp.QuoteMeta(idpsQuery),
|
||||
idpsCols,
|
||||
[][]driver.Value{
|
||||
{
|
||||
"idp-id",
|
||||
@ -734,62 +502,8 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.idps2.id,`+
|
||||
` projections.idps2.resource_owner,`+
|
||||
` projections.idps2.creation_date,`+
|
||||
` projections.idps2.change_date,`+
|
||||
` projections.idps2.sequence,`+
|
||||
` projections.idps2.state,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.styling_type,`+
|
||||
` projections.idps2.owner_type,`+
|
||||
` projections.idps2.auto_register,`+
|
||||
` projections.idps2_oidc_config.idp_id,`+
|
||||
` projections.idps2_oidc_config.client_id,`+
|
||||
` projections.idps2_oidc_config.client_secret,`+
|
||||
` projections.idps2_oidc_config.issuer,`+
|
||||
` projections.idps2_oidc_config.scopes,`+
|
||||
` projections.idps2_oidc_config.display_name_mapping,`+
|
||||
` projections.idps2_oidc_config.username_mapping,`+
|
||||
` projections.idps2_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps2_oidc_config.token_endpoint,`+
|
||||
` projections.idps2_jwt_config.idp_id,`+
|
||||
` projections.idps2_jwt_config.issuer,`+
|
||||
` projections.idps2_jwt_config.keys_endpoint,`+
|
||||
` projections.idps2_jwt_config.header_name,`+
|
||||
` projections.idps2_jwt_config.endpoint,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.idps2`+
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id`),
|
||||
[]string{
|
||||
"id",
|
||||
"resource_owner",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
"state",
|
||||
"name",
|
||||
"styling_type",
|
||||
"owner_type",
|
||||
"auto_register",
|
||||
// oidc config
|
||||
"idp_id",
|
||||
"client_id",
|
||||
"client_secret",
|
||||
"issuer",
|
||||
"scopes",
|
||||
"display_name_mapping",
|
||||
"username_mapping",
|
||||
"authorization_endpoint",
|
||||
"token_endpoint",
|
||||
"idp_id",
|
||||
"issuer",
|
||||
"keys_endpoint",
|
||||
"header_name",
|
||||
"endpoint",
|
||||
"count",
|
||||
},
|
||||
regexp.QuoteMeta(idpsQuery),
|
||||
idpsCols,
|
||||
[][]driver.Value{
|
||||
{
|
||||
"idp-id",
|
||||
@ -847,62 +561,8 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.idps2.id,`+
|
||||
` projections.idps2.resource_owner,`+
|
||||
` projections.idps2.creation_date,`+
|
||||
` projections.idps2.change_date,`+
|
||||
` projections.idps2.sequence,`+
|
||||
` projections.idps2.state,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.styling_type,`+
|
||||
` projections.idps2.owner_type,`+
|
||||
` projections.idps2.auto_register,`+
|
||||
` projections.idps2_oidc_config.idp_id,`+
|
||||
` projections.idps2_oidc_config.client_id,`+
|
||||
` projections.idps2_oidc_config.client_secret,`+
|
||||
` projections.idps2_oidc_config.issuer,`+
|
||||
` projections.idps2_oidc_config.scopes,`+
|
||||
` projections.idps2_oidc_config.display_name_mapping,`+
|
||||
` projections.idps2_oidc_config.username_mapping,`+
|
||||
` projections.idps2_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps2_oidc_config.token_endpoint,`+
|
||||
` projections.idps2_jwt_config.idp_id,`+
|
||||
` projections.idps2_jwt_config.issuer,`+
|
||||
` projections.idps2_jwt_config.keys_endpoint,`+
|
||||
` projections.idps2_jwt_config.header_name,`+
|
||||
` projections.idps2_jwt_config.endpoint,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.idps2`+
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id`),
|
||||
[]string{
|
||||
"id",
|
||||
"resource_owner",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
"state",
|
||||
"name",
|
||||
"styling_type",
|
||||
"owner_type",
|
||||
"auto_register",
|
||||
// oidc config
|
||||
"idp_id",
|
||||
"client_id",
|
||||
"client_secret",
|
||||
"issuer",
|
||||
"scopes",
|
||||
"display_name_mapping",
|
||||
"username_mapping",
|
||||
"authorization_endpoint",
|
||||
"token_endpoint",
|
||||
"idp_id",
|
||||
"issuer",
|
||||
"keys_endpoint",
|
||||
"header_name",
|
||||
"endpoint",
|
||||
"count",
|
||||
},
|
||||
regexp.QuoteMeta(idpsQuery),
|
||||
idpsCols,
|
||||
[][]driver.Value{
|
||||
{
|
||||
"idp-id-1",
|
||||
@ -1058,34 +718,7 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.idps2.id,`+
|
||||
` projections.idps2.resource_owner,`+
|
||||
` projections.idps2.creation_date,`+
|
||||
` projections.idps2.change_date,`+
|
||||
` projections.idps2.sequence,`+
|
||||
` projections.idps2.state,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.styling_type,`+
|
||||
` projections.idps2.owner_type,`+
|
||||
` projections.idps2.auto_register,`+
|
||||
` projections.idps2_oidc_config.idp_id,`+
|
||||
` projections.idps2_oidc_config.client_id,`+
|
||||
` projections.idps2_oidc_config.client_secret,`+
|
||||
` projections.idps2_oidc_config.issuer,`+
|
||||
` projections.idps2_oidc_config.scopes,`+
|
||||
` projections.idps2_oidc_config.display_name_mapping,`+
|
||||
` projections.idps2_oidc_config.username_mapping,`+
|
||||
` projections.idps2_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps2_oidc_config.token_endpoint,`+
|
||||
` projections.idps2_jwt_config.idp_id,`+
|
||||
` projections.idps2_jwt_config.issuer,`+
|
||||
` projections.idps2_jwt_config.keys_endpoint,`+
|
||||
` projections.idps2_jwt_config.header_name,`+
|
||||
` projections.idps2_jwt_config.endpoint,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.idps2`+
|
||||
` LEFT JOIN projections.idps2_oidc_config ON projections.idps2.id = projections.idps2_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps2_jwt_config ON projections.idps2.id = projections.idps2_jwt_config.idp_id`),
|
||||
regexp.QuoteMeta(idpsQuery),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
@ -43,6 +43,7 @@ func (q *IDPUserLinksSearchQuery) toQuery(query sq.SelectBuilder) sq.SelectBuild
|
||||
var (
|
||||
idpUserLinkTable = table{
|
||||
name: projection.IDPUserLinkTable,
|
||||
instanceIDCol: projection.IDPUserLinkInstanceIDCol,
|
||||
}
|
||||
IDPUserLinkIDPIDCol = Column{
|
||||
name: projection.IDPUserLinkIDPIDCol,
|
||||
|
@ -22,6 +22,7 @@ const (
|
||||
var (
|
||||
instanceTable = table{
|
||||
name: projection.InstanceProjectionTable,
|
||||
instanceIDCol: projection.InstanceColumnID,
|
||||
}
|
||||
InstanceColumnID = Column{
|
||||
name: projection.InstanceColumnID,
|
||||
|
@ -140,6 +140,7 @@ func prepareInstanceDomainsQuery() (sq.SelectBuilder, func(*sql.Rows) (*Instance
|
||||
var (
|
||||
instanceDomainsTable = table{
|
||||
name: projection.InstanceDomainTable,
|
||||
instanceIDCol: projection.InstanceDomainInstanceIDCol,
|
||||
}
|
||||
|
||||
InstanceDomainCreationDateCol = Column{
|
||||
|
@ -14,6 +14,68 @@ import (
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
instanceQuery = `SELECT projections.instances.id,` +
|
||||
` projections.instances.creation_date,` +
|
||||
` projections.instances.change_date,` +
|
||||
` projections.instances.sequence,` +
|
||||
` projections.instances.default_org_id,` +
|
||||
` projections.instances.iam_project_id,` +
|
||||
` projections.instances.console_client_id,` +
|
||||
` projections.instances.console_app_id,` +
|
||||
` projections.instances.default_language` +
|
||||
` FROM projections.instances`
|
||||
instanceCols = []string{
|
||||
"id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
"default_org_id",
|
||||
"iam_project_id",
|
||||
"console_client_id",
|
||||
"console_app_id",
|
||||
"default_language",
|
||||
}
|
||||
instancesQuery = `SELECT f.count, f.id,` +
|
||||
` projections.instances.creation_date,` +
|
||||
` projections.instances.change_date,` +
|
||||
` projections.instances.sequence,` +
|
||||
` projections.instances.name,` +
|
||||
` projections.instances.default_org_id,` +
|
||||
` projections.instances.iam_project_id,` +
|
||||
` projections.instances.console_client_id,` +
|
||||
` projections.instances.console_app_id,` +
|
||||
` projections.instances.default_language,` +
|
||||
` projections.instance_domains.domain,` +
|
||||
` projections.instance_domains.is_primary,` +
|
||||
` projections.instance_domains.is_generated,` +
|
||||
` projections.instance_domains.creation_date,` +
|
||||
` projections.instance_domains.change_date, ` +
|
||||
` projections.instance_domains.sequence` +
|
||||
` FROM (SELECT projections.instances.id, COUNT(*) OVER () FROM projections.instances) AS f` +
|
||||
` LEFT JOIN projections.instances ON f.id = projections.instances.id AND f.id = projections.instances.id` +
|
||||
` LEFT JOIN projections.instance_domains ON f.id = projections.instance_domains.instance_id AND f.id = projections.instance_domains.instance_id`
|
||||
instancesCols = []string{
|
||||
"count",
|
||||
"id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
"name",
|
||||
"default_org_id",
|
||||
"iam_project_id",
|
||||
"console_client_id",
|
||||
"console_app_id",
|
||||
"default_language",
|
||||
"domain",
|
||||
"is_primary",
|
||||
"is_generated",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
}
|
||||
)
|
||||
|
||||
func Test_InstancePrepares(t *testing.T) {
|
||||
type want struct {
|
||||
sqlExpectations sqlExpectation
|
||||
@ -32,16 +94,7 @@ func Test_InstancePrepares(t *testing.T) {
|
||||
},
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.instances.id,`+
|
||||
` projections.instances.creation_date,`+
|
||||
` projections.instances.change_date,`+
|
||||
` projections.instances.sequence,`+
|
||||
` projections.instances.default_org_id,`+
|
||||
` projections.instances.iam_project_id,`+
|
||||
` projections.instances.console_client_id,`+
|
||||
` projections.instances.console_app_id,`+
|
||||
` projections.instances.default_language`+
|
||||
` FROM projections.instances`),
|
||||
regexp.QuoteMeta(instanceQuery),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@ -61,27 +114,8 @@ func Test_InstancePrepares(t *testing.T) {
|
||||
},
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.instances.id,`+
|
||||
` projections.instances.creation_date,`+
|
||||
` projections.instances.change_date,`+
|
||||
` projections.instances.sequence,`+
|
||||
` projections.instances.default_org_id,`+
|
||||
` projections.instances.iam_project_id,`+
|
||||
` projections.instances.console_client_id,`+
|
||||
` projections.instances.console_app_id,`+
|
||||
` projections.instances.default_language`+
|
||||
` FROM projections.instances`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
"default_org_id",
|
||||
"iam_project_id",
|
||||
"console_client_id",
|
||||
"console_app_id",
|
||||
"default_language",
|
||||
},
|
||||
regexp.QuoteMeta(instanceQuery),
|
||||
instanceCols,
|
||||
[]driver.Value{
|
||||
"id",
|
||||
testNow,
|
||||
@ -114,16 +148,7 @@ func Test_InstancePrepares(t *testing.T) {
|
||||
},
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.instances.id,`+
|
||||
` projections.instances.creation_date,`+
|
||||
` projections.instances.change_date,`+
|
||||
` projections.instances.sequence,`+
|
||||
` projections.instances.default_org_id,`+
|
||||
` projections.instances.iam_project_id,`+
|
||||
` projections.instances.console_client_id,`+
|
||||
` projections.instances.console_app_id,`+
|
||||
` projections.instances.default_language`+
|
||||
` FROM projections.instances`),
|
||||
regexp.QuoteMeta(instanceQuery),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@ -143,25 +168,7 @@ func Test_InstancePrepares(t *testing.T) {
|
||||
},
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT f.count, f.id,`+
|
||||
` projections.instances.creation_date,`+
|
||||
` projections.instances.change_date,`+
|
||||
` projections.instances.sequence,`+
|
||||
` projections.instances.name,`+
|
||||
` projections.instances.default_org_id,`+
|
||||
` projections.instances.iam_project_id,`+
|
||||
` projections.instances.console_client_id,`+
|
||||
` projections.instances.console_app_id,`+
|
||||
` projections.instances.default_language,`+
|
||||
` projections.instance_domains.domain,`+
|
||||
` projections.instance_domains.is_primary,`+
|
||||
` projections.instance_domains.is_generated,`+
|
||||
` projections.instance_domains.creation_date,`+
|
||||
` projections.instance_domains.change_date, `+
|
||||
` projections.instance_domains.sequence`+
|
||||
` FROM (SELECT projections.instances.id, COUNT(*) OVER () FROM projections.instances) AS f`+
|
||||
` LEFT JOIN projections.instances ON f.id = projections.instances.id`+
|
||||
` LEFT JOIN projections.instance_domains ON f.id = projections.instance_domains.instance_id`),
|
||||
regexp.QuoteMeta(instancesQuery),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@ -176,44 +183,8 @@ func Test_InstancePrepares(t *testing.T) {
|
||||
},
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT f.count, f.id,`+
|
||||
` projections.instances.creation_date,`+
|
||||
` projections.instances.change_date,`+
|
||||
` projections.instances.sequence,`+
|
||||
` projections.instances.name,`+
|
||||
` projections.instances.default_org_id,`+
|
||||
` projections.instances.iam_project_id,`+
|
||||
` projections.instances.console_client_id,`+
|
||||
` projections.instances.console_app_id,`+
|
||||
` projections.instances.default_language,`+
|
||||
` projections.instance_domains.domain,`+
|
||||
` projections.instance_domains.is_primary,`+
|
||||
` projections.instance_domains.is_generated,`+
|
||||
` projections.instance_domains.creation_date,`+
|
||||
` projections.instance_domains.change_date, `+
|
||||
` projections.instance_domains.sequence`+
|
||||
` FROM (SELECT projections.instances.id, COUNT(*) OVER () FROM projections.instances) AS f`+
|
||||
` LEFT JOIN projections.instances ON f.id = projections.instances.id`+
|
||||
` LEFT JOIN projections.instance_domains ON f.id = projections.instance_domains.instance_id`),
|
||||
[]string{
|
||||
"count",
|
||||
"id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
"name",
|
||||
"default_org_id",
|
||||
"iam_project_id",
|
||||
"console_client_id",
|
||||
"console_app_id",
|
||||
"default_language",
|
||||
"domain",
|
||||
"is_primary",
|
||||
"is_generated",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
},
|
||||
regexp.QuoteMeta(instancesQuery),
|
||||
instancesCols,
|
||||
[][]driver.Value{
|
||||
{
|
||||
"1",
|
||||
@ -276,44 +247,8 @@ func Test_InstancePrepares(t *testing.T) {
|
||||
},
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT f.count, f.id,`+
|
||||
` projections.instances.creation_date,`+
|
||||
` projections.instances.change_date,`+
|
||||
` projections.instances.sequence,`+
|
||||
` projections.instances.name,`+
|
||||
` projections.instances.default_org_id,`+
|
||||
` projections.instances.iam_project_id,`+
|
||||
` projections.instances.console_client_id,`+
|
||||
` projections.instances.console_app_id,`+
|
||||
` projections.instances.default_language,`+
|
||||
` projections.instance_domains.domain,`+
|
||||
` projections.instance_domains.is_primary,`+
|
||||
` projections.instance_domains.is_generated,`+
|
||||
` projections.instance_domains.creation_date,`+
|
||||
` projections.instance_domains.change_date, `+
|
||||
` projections.instance_domains.sequence`+
|
||||
` FROM (SELECT projections.instances.id, COUNT(*) OVER () FROM projections.instances) AS f`+
|
||||
` LEFT JOIN projections.instances ON f.id = projections.instances.id`+
|
||||
` LEFT JOIN projections.instance_domains ON f.id = projections.instance_domains.instance_id`),
|
||||
[]string{
|
||||
"count",
|
||||
"id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
"name",
|
||||
"default_org_id",
|
||||
"iam_project_id",
|
||||
"console_client_id",
|
||||
"console_app_id",
|
||||
"default_language",
|
||||
"domain",
|
||||
"is_primary",
|
||||
"is_generated",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"sequence",
|
||||
},
|
||||
regexp.QuoteMeta(instancesQuery),
|
||||
instancesCols,
|
||||
[][]driver.Value{
|
||||
{
|
||||
2,
|
||||
@ -445,25 +380,7 @@ func Test_InstancePrepares(t *testing.T) {
|
||||
},
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT f.count, f.id,`+
|
||||
` projections.instances.creation_date,`+
|
||||
` projections.instances.change_date,`+
|
||||
` projections.instances.sequence,`+
|
||||
` projections.instances.name,`+
|
||||
` projections.instances.default_org_id,`+
|
||||
` projections.instances.iam_project_id,`+
|
||||
` projections.instances.console_client_id,`+
|
||||
` projections.instances.console_app_id,`+
|
||||
` projections.instances.default_language,`+
|
||||
` projections.instance_domains.domain,`+
|
||||
` projections.instance_domains.is_primary,`+
|
||||
` projections.instance_domains.is_generated,`+
|
||||
` projections.instance_domains.creation_date,`+
|
||||
` projections.instance_domains.change_date, `+
|
||||
` projections.instance_domains.sequence`+
|
||||
` FROM (SELECT projections.instances.id, COUNT(*) OVER () FROM projections.instances) AS f`+
|
||||
` LEFT JOIN projections.instances ON f.id = projections.instances.id`+
|
||||
` LEFT JOIN projections.instance_domains ON f.id = projections.instance_domains.instance_id`),
|
||||
regexp.QuoteMeta(instancesQuery),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
@ -102,6 +102,7 @@ func (r *rsaPublicKey) Key() interface{} {
|
||||
var (
|
||||
keyTable = table{
|
||||
name: projection.KeyProjectionTable,
|
||||
instanceIDCol: projection.KeyColumnInstanceID,
|
||||
}
|
||||
KeyColID = Column{
|
||||
name: projection.KeyColumnID,
|
||||
@ -140,6 +141,7 @@ var (
|
||||
var (
|
||||
keyPrivateTable = table{
|
||||
name: projection.KeyPrivateTable,
|
||||
instanceIDCol: projection.KeyPrivateColumnInstanceID,
|
||||
}
|
||||
KeyPrivateColID = Column{
|
||||
name: projection.KeyPrivateColumnID,
|
||||
@ -158,6 +160,7 @@ var (
|
||||
var (
|
||||
keyPublicTable = table{
|
||||
name: projection.KeyPublicTable,
|
||||
instanceIDCol: projection.KeyPrivateColumnInstanceID,
|
||||
}
|
||||
KeyPublicColID = Column{
|
||||
name: projection.KeyPublicColumnID,
|
||||
|
@ -131,6 +131,7 @@ func (q *Queries) DefaultPreviewLabelPolicy(ctx context.Context) (*LabelPolicy,
|
||||
var (
|
||||
labelPolicyTable = table{
|
||||
name: projection.LabelPolicyTable,
|
||||
instanceIDCol: projection.LabelPolicyInstanceIDCol,
|
||||
}
|
||||
LabelPolicyColCreationDate = Column{
|
||||
name: projection.LabelPolicyCreationDateCol,
|
||||
|
@ -32,6 +32,7 @@ type LockoutPolicy struct {
|
||||
var (
|
||||
lockoutTable = table{
|
||||
name: projection.LockoutPolicyTable,
|
||||
instanceIDCol: projection.LockoutPolicyInstanceIDCol,
|
||||
}
|
||||
LockoutColID = Column{
|
||||
name: projection.LockoutPolicyIDCol,
|
||||
|
@ -5,6 +5,7 @@ import "github.com/zitadel/zitadel/internal/query/projection"
|
||||
var (
|
||||
loginNameTable = table{
|
||||
name: projection.LoginNameProjectionTable,
|
||||
instanceIDCol: projection.LoginNameUserInstanceIDCol,
|
||||
}
|
||||
LoginNameUserIDCol = Column{
|
||||
name: "user_id",
|
||||
|
@ -55,6 +55,7 @@ type MultiFactors struct {
|
||||
var (
|
||||
loginPolicyTable = table{
|
||||
name: projection.LoginPolicyTable,
|
||||
instanceIDCol: projection.LoginPolicyInstanceIDCol,
|
||||
}
|
||||
LoginPolicyColumnOrgID = Column{
|
||||
name: projection.LoginPolicyIDCol,
|
||||
|
@ -14,23 +14,8 @@ import (
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
type want struct {
|
||||
sqlExpectations sqlExpectation
|
||||
err checkErr
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
prepare interface{}
|
||||
want want
|
||||
object interface{}
|
||||
}{
|
||||
{
|
||||
name: "prepareLoginPolicyQuery no result",
|
||||
prepare: prepareLoginPolicyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.login_policies3.aggregate_id,`+
|
||||
var (
|
||||
loginPolicyQuery = `SELECT projections.login_policies3.aggregate_id,` +
|
||||
` projections.login_policies3.creation_date,` +
|
||||
` projections.login_policies3.change_date,` +
|
||||
` projections.login_policies3.sequence,` +
|
||||
@ -59,57 +44,11 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
` FROM projections.login_policies3` +
|
||||
` LEFT JOIN projections.idp_login_policy_links3 ON ` +
|
||||
` projections.login_policies3.aggregate_id = projections.idp_login_policy_links3.aggregate_id` +
|
||||
` AND projections.login_policies3.instance_id = projections.idp_login_policy_links3.instance_id` +
|
||||
` LEFT JOIN projections.idps2 ON` +
|
||||
` projections.idp_login_policy_links3.idp_id = projections.idps2.id`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
if !errs.IsNotFound(err) {
|
||||
return fmt.Errorf("err should be zitadel.NotFoundError got: %w", err), false
|
||||
}
|
||||
return nil, true
|
||||
},
|
||||
},
|
||||
object: (*LoginPolicy)(nil),
|
||||
},
|
||||
{
|
||||
name: "prepareLoginPolicyQuery found",
|
||||
prepare: prepareLoginPolicyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.login_policies3.aggregate_id,`+
|
||||
` projections.login_policies3.creation_date,`+
|
||||
` projections.login_policies3.change_date,`+
|
||||
` projections.login_policies3.sequence,`+
|
||||
` projections.login_policies3.allow_register,`+
|
||||
` projections.login_policies3.allow_username_password,`+
|
||||
` projections.login_policies3.allow_external_idps,`+
|
||||
` projections.login_policies3.force_mfa,`+
|
||||
` projections.login_policies3.second_factors,`+
|
||||
` projections.login_policies3.multi_factors,`+
|
||||
` projections.login_policies3.passwordless_type,`+
|
||||
` projections.login_policies3.is_default,`+
|
||||
` projections.login_policies3.hide_password_reset,`+
|
||||
` projections.login_policies3.ignore_unknown_usernames,`+
|
||||
` projections.login_policies3.allow_domain_discovery,`+
|
||||
` projections.login_policies3.disable_login_with_email,`+
|
||||
` projections.login_policies3.disable_login_with_phone,`+
|
||||
` projections.login_policies3.default_redirect_uri,`+
|
||||
` projections.login_policies3.password_check_lifetime,`+
|
||||
` projections.login_policies3.external_login_check_lifetime,`+
|
||||
` projections.login_policies3.mfa_init_skip_lifetime,`+
|
||||
` projections.login_policies3.second_factor_check_lifetime,`+
|
||||
` projections.login_policies3.multi_factor_check_lifetime,`+
|
||||
` projections.idp_login_policy_links3.idp_id,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.type`+
|
||||
` FROM projections.login_policies3`+
|
||||
` LEFT JOIN projections.idp_login_policy_links3 ON `+
|
||||
` projections.login_policies3.aggregate_id = projections.idp_login_policy_links3.aggregate_id`+
|
||||
` LEFT JOIN projections.idps2 ON`+
|
||||
` projections.idp_login_policy_links3.idp_id = projections.idps2.id`),
|
||||
[]string{
|
||||
` projections.idp_login_policy_links3.idp_id = projections.idps2.id` +
|
||||
` AND projections.idp_login_policy_links3.instance_id = projections.idps2.instance_id`
|
||||
loginPolicyCols = []string{
|
||||
"aggregate_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
@ -136,7 +75,45 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
"idp_id",
|
||||
"name",
|
||||
"type",
|
||||
}
|
||||
)
|
||||
|
||||
func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
type want struct {
|
||||
sqlExpectations sqlExpectation
|
||||
err checkErr
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
prepare interface{}
|
||||
want want
|
||||
object interface{}
|
||||
}{
|
||||
{
|
||||
name: "prepareLoginPolicyQuery no result",
|
||||
prepare: prepareLoginPolicyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(loginPolicyQuery),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
if !errs.IsNotFound(err) {
|
||||
return fmt.Errorf("err should be zitadel.NotFoundError got: %w", err), false
|
||||
}
|
||||
return nil, true
|
||||
},
|
||||
},
|
||||
object: (*LoginPolicy)(nil),
|
||||
},
|
||||
{
|
||||
name: "prepareLoginPolicyQuery found",
|
||||
prepare: prepareLoginPolicyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(loginPolicyQuery),
|
||||
loginPolicyCols,
|
||||
[]driver.Value{
|
||||
"ro",
|
||||
testNow,
|
||||
@ -205,37 +182,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
prepare: prepareLoginPolicyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.login_policies3.aggregate_id,`+
|
||||
` projections.login_policies3.creation_date,`+
|
||||
` projections.login_policies3.change_date,`+
|
||||
` projections.login_policies3.sequence,`+
|
||||
` projections.login_policies3.allow_register,`+
|
||||
` projections.login_policies3.allow_username_password,`+
|
||||
` projections.login_policies3.allow_external_idps,`+
|
||||
` projections.login_policies3.force_mfa,`+
|
||||
` projections.login_policies3.second_factors,`+
|
||||
` projections.login_policies3.multi_factors,`+
|
||||
` projections.login_policies3.passwordless_type,`+
|
||||
` projections.login_policies3.is_default,`+
|
||||
` projections.login_policies3.hide_password_reset,`+
|
||||
` projections.login_policies3.ignore_unknown_usernames,`+
|
||||
` projections.login_policies3.allow_domain_discovery,`+
|
||||
` projections.login_policies3.disable_login_with_email,`+
|
||||
` projections.login_policies3.disable_login_with_phone,`+
|
||||
` projections.login_policies3.default_redirect_uri,`+
|
||||
` projections.login_policies3.password_check_lifetime,`+
|
||||
` projections.login_policies3.external_login_check_lifetime,`+
|
||||
` projections.login_policies3.mfa_init_skip_lifetime,`+
|
||||
` projections.login_policies3.second_factor_check_lifetime,`+
|
||||
` projections.login_policies3.multi_factor_check_lifetime,`+
|
||||
` projections.idp_login_policy_links3.idp_id,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.type`+
|
||||
` FROM projections.login_policies3`+
|
||||
` LEFT JOIN projections.idp_login_policy_links3 ON `+
|
||||
` projections.login_policies3.aggregate_id = projections.idp_login_policy_links3.aggregate_id`+
|
||||
` LEFT JOIN projections.idps2 ON`+
|
||||
` projections.idp_login_policy_links3.idp_id = projections.idps2.id`),
|
||||
regexp.QuoteMeta(loginPolicyQuery),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
@ -28,6 +28,7 @@ type MailTemplate struct {
|
||||
var (
|
||||
mailTemplateTable = table{
|
||||
name: projection.MailTemplateTable,
|
||||
instanceIDCol: projection.MailTemplateInstanceIDCol,
|
||||
}
|
||||
MailTemplateColAggregateID = Column{
|
||||
name: projection.MailTemplateAggregateIDCol,
|
||||
|
@ -66,6 +66,7 @@ var (
|
||||
memberTableAlias = table{
|
||||
name: "members",
|
||||
alias: "members",
|
||||
instanceIDCol: projection.MemberInstanceID,
|
||||
}
|
||||
memberUserID = Column{
|
||||
name: projection.MemberUserIDCol,
|
||||
|
@ -54,6 +54,7 @@ type MessageText struct {
|
||||
var (
|
||||
messageTextTable = table{
|
||||
name: projection.MessageTextTable,
|
||||
instanceIDCol: projection.MessageTextInstanceIDCol,
|
||||
}
|
||||
MessageTextColAggregateID = Column{
|
||||
name: projection.MessageTextAggregateIDCol,
|
||||
|
@ -29,6 +29,7 @@ type DebugNotificationProvider struct {
|
||||
var (
|
||||
notificationProviderTable = table{
|
||||
name: projection.DebugNotificationProviderTable,
|
||||
instanceIDCol: projection.DebugNotificationProviderInstanceIDCol,
|
||||
}
|
||||
NotificationProviderColumnAggID = Column{
|
||||
name: projection.DebugNotificationProviderAggIDCol,
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
var (
|
||||
oidcSettingsTable = table{
|
||||
name: projection.OIDCSettingsProjectionTable,
|
||||
instanceIDCol: projection.OIDCSettingsColumnInstanceID,
|
||||
}
|
||||
OIDCSettingsColumnAggregateID = Column{
|
||||
name: projection.OIDCSettingsColumnAggregateID,
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
var (
|
||||
orgsTable = table{
|
||||
name: projection.OrgProjectionTable,
|
||||
instanceIDCol: projection.OrgColumnInstanceID,
|
||||
}
|
||||
OrgColumnID = Column{
|
||||
name: projection.OrgColumnID,
|
||||
|
@ -126,6 +126,7 @@ func prepareDomainsQuery() (sq.SelectBuilder, func(*sql.Rows) (*Domains, error))
|
||||
var (
|
||||
orgDomainsTable = table{
|
||||
name: projection.OrgDomainTable,
|
||||
instanceIDCol: projection.OrgDomainInstanceIDCol,
|
||||
}
|
||||
|
||||
OrgDomainCreationDateCol = Column{
|
||||
|
@ -15,6 +15,7 @@ var (
|
||||
orgMemberTable = table{
|
||||
name: projection.OrgMemberProjectionTable,
|
||||
alias: "members",
|
||||
instanceIDCol: projection.MemberInstanceID,
|
||||
}
|
||||
OrgMemberUserID = Column{
|
||||
name: projection.MemberUserIDCol,
|
||||
|
@ -30,10 +30,13 @@ var (
|
||||
"FROM projections.org_members2 AS members " +
|
||||
"LEFT JOIN projections.users4_humans " +
|
||||
"ON members.user_id = projections.users4_humans.user_id " +
|
||||
"AND members.instance_id = projections.users4_humans.instance_id " +
|
||||
"LEFT JOIN projections.users4_machines " +
|
||||
"ON members.user_id = projections.users4_machines.user_id " +
|
||||
"AND members.instance_id = projections.users4_machines.instance_id " +
|
||||
"LEFT JOIN projections.login_names " +
|
||||
"ON members.user_id = projections.login_names.user_id " +
|
||||
"AND members.instance_id = projections.login_names.instance_id " +
|
||||
"WHERE projections.login_names.is_primary = $1")
|
||||
orgMembersColumns = []string{
|
||||
"creation_date",
|
||||
|
@ -35,6 +35,7 @@ type OrgMetadataSearchQueries struct {
|
||||
var (
|
||||
orgMetadataTable = table{
|
||||
name: projection.OrgMetadataProjectionTable,
|
||||
instanceIDCol: projection.OrgMetadataColumnInstanceID,
|
||||
}
|
||||
OrgMetadataOrgIDCol = Column{
|
||||
name: projection.OrgMetadataColumnOrgID,
|
||||
|
@ -31,6 +31,7 @@ type PasswordAgePolicy struct {
|
||||
var (
|
||||
passwordAgeTable = table{
|
||||
name: projection.PasswordAgeTable,
|
||||
instanceIDCol: projection.AgePolicyInstanceIDCol,
|
||||
}
|
||||
PasswordAgeColID = Column{
|
||||
name: projection.AgePolicyIDCol,
|
||||
|
@ -84,6 +84,7 @@ func (q *Queries) DefaultPasswordComplexityPolicy(ctx context.Context, shouldTri
|
||||
var (
|
||||
passwordComplexityTable = table{
|
||||
name: projection.PasswordComplexityTable,
|
||||
instanceIDCol: projection.ComplexityPolicyInstanceIDCol,
|
||||
}
|
||||
PasswordComplexityColID = Column{
|
||||
name: projection.ComplexityPolicyIDCol,
|
||||
|
@ -32,6 +32,7 @@ type PrivacyPolicy struct {
|
||||
var (
|
||||
privacyTable = table{
|
||||
name: projection.PrivacyPolicyTable,
|
||||
instanceIDCol: projection.PrivacyPolicyInstanceIDCol,
|
||||
}
|
||||
PrivacyColID = Column{
|
||||
name: projection.PrivacyPolicyIDCol,
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
var (
|
||||
projectsTable = table{
|
||||
name: projection.ProjectProjectionTable,
|
||||
instanceIDCol: projection.ProjectColumnInstanceID,
|
||||
}
|
||||
ProjectColumnID = Column{
|
||||
name: projection.ProjectColumnID,
|
||||
|
@ -24,6 +24,7 @@ const (
|
||||
var (
|
||||
projectGrantsTable = table{
|
||||
name: projection.ProjectGrantProjectionTable,
|
||||
instanceIDCol: projection.ProjectGrantColumnInstanceID,
|
||||
}
|
||||
ProjectGrantColumnCreationDate = Column{
|
||||
name: projection.ProjectGrantColumnCreationDate,
|
||||
|
@ -16,6 +16,7 @@ var (
|
||||
projectGrantMemberTable = table{
|
||||
name: projection.ProjectGrantMemberProjectionTable,
|
||||
alias: "members",
|
||||
instanceIDCol: projection.MemberInstanceID,
|
||||
}
|
||||
ProjectGrantMemberUserID = Column{
|
||||
name: projection.MemberUserIDCol,
|
||||
|
@ -30,12 +30,16 @@ var (
|
||||
"FROM projections.project_grant_members2 AS members " +
|
||||
"LEFT JOIN projections.users4_humans " +
|
||||
"ON members.user_id = projections.users4_humans.user_id " +
|
||||
"AND members.instance_id = projections.users4_humans.instance_id " +
|
||||
"LEFT JOIN projections.users4_machines " +
|
||||
"ON members.user_id = projections.users4_machines.user_id " +
|
||||
"AND members.instance_id = projections.users4_machines.instance_id " +
|
||||
"LEFT JOIN projections.login_names " +
|
||||
"ON members.user_id = projections.login_names.user_id " +
|
||||
"AND members.instance_id = projections.login_names.instance_id " +
|
||||
"LEFT JOIN projections.project_grants2 " +
|
||||
"ON members.grant_id = projections.project_grants2.grant_id " +
|
||||
"AND members.instance_id = projections.project_grants2.instance_id " +
|
||||
"WHERE projections.login_names.is_primary = $1")
|
||||
projectGrantMembersColumns = []string{
|
||||
"creation_date",
|
||||
|
@ -13,6 +13,71 @@ import (
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
projectGrantsQuery = `SELECT projections.project_grants2.project_id,` +
|
||||
` projections.project_grants2.grant_id,` +
|
||||
` projections.project_grants2.creation_date,` +
|
||||
` projections.project_grants2.change_date,` +
|
||||
` projections.project_grants2.resource_owner,` +
|
||||
` projections.project_grants2.state,` +
|
||||
` projections.project_grants2.sequence,` +
|
||||
` projections.projects2.name,` +
|
||||
` projections.project_grants2.granted_org_id,` +
|
||||
` o.name,` +
|
||||
` projections.project_grants2.granted_role_keys,` +
|
||||
` r.name,` +
|
||||
` COUNT(*) OVER () ` +
|
||||
` FROM projections.project_grants2 ` +
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id AND projections.project_grants2.instance_id = projections.projects2.instance_id ` +
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id AND projections.project_grants2.instance_id = r.instance_id` +
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id AND projections.project_grants2.instance_id = o.instance_id`
|
||||
projectGrantsCols = []string{
|
||||
"project_id",
|
||||
"grant_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"state",
|
||||
"sequence",
|
||||
"name",
|
||||
"granted_org_id",
|
||||
"name",
|
||||
"granted_role_keys",
|
||||
"name",
|
||||
"count",
|
||||
}
|
||||
projectGrantQuery = `SELECT projections.project_grants2.project_id,` +
|
||||
` projections.project_grants2.grant_id,` +
|
||||
` projections.project_grants2.creation_date,` +
|
||||
` projections.project_grants2.change_date,` +
|
||||
` projections.project_grants2.resource_owner,` +
|
||||
` projections.project_grants2.state,` +
|
||||
` projections.project_grants2.sequence,` +
|
||||
` projections.projects2.name,` +
|
||||
` projections.project_grants2.granted_org_id,` +
|
||||
` o.name,` +
|
||||
` projections.project_grants2.granted_role_keys,` +
|
||||
` r.name` +
|
||||
` FROM projections.project_grants2 ` +
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id AND projections.project_grants2.instance_id = projections.projects2.instance_id ` +
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id AND projections.project_grants2.instance_id = r.instance_id` +
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id AND projections.project_grants2.instance_id = o.instance_id`
|
||||
projectGrantCols = []string{
|
||||
"project_id",
|
||||
"grant_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"state",
|
||||
"sequence",
|
||||
"name",
|
||||
"granted_org_id",
|
||||
"name",
|
||||
"granted_role_keys",
|
||||
"name",
|
||||
}
|
||||
)
|
||||
|
||||
func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
type want struct {
|
||||
sqlExpectations sqlExpectation
|
||||
@ -29,23 +94,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER () `+
|
||||
` FROM projections.project_grants2 `+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id `+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
regexp.QuoteMeta(projectGrantsQuery),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@ -57,38 +106,8 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.project_grants2`+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id`+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
[]string{
|
||||
"project_id",
|
||||
"grant_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"state",
|
||||
"sequence",
|
||||
"name",
|
||||
"granted_org_id",
|
||||
"name",
|
||||
"granted_role_keys",
|
||||
"name",
|
||||
"count",
|
||||
},
|
||||
regexp.QuoteMeta(projectGrantsQuery),
|
||||
projectGrantsCols,
|
||||
[][]driver.Value{
|
||||
{
|
||||
"project-id",
|
||||
@ -134,38 +153,8 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER () `+
|
||||
` FROM projections.project_grants2 `+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id `+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
[]string{
|
||||
"project_id",
|
||||
"grant_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"state",
|
||||
"sequence",
|
||||
"name",
|
||||
"granted_org_id",
|
||||
"name",
|
||||
"granted_role_keys",
|
||||
"name",
|
||||
"count",
|
||||
},
|
||||
regexp.QuoteMeta(projectGrantsQuery),
|
||||
projectGrantsCols,
|
||||
[][]driver.Value{
|
||||
{
|
||||
"project-id",
|
||||
@ -211,38 +200,8 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER () `+
|
||||
` FROM projections.project_grants2 `+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id `+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
[]string{
|
||||
"project_id",
|
||||
"grant_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"state",
|
||||
"sequence",
|
||||
"name",
|
||||
"granted_org_id",
|
||||
"name",
|
||||
"granted_role_keys",
|
||||
"name",
|
||||
"count",
|
||||
},
|
||||
regexp.QuoteMeta(projectGrantsQuery),
|
||||
projectGrantsCols,
|
||||
[][]driver.Value{
|
||||
{
|
||||
"project-id",
|
||||
@ -288,38 +247,8 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER () `+
|
||||
` FROM projections.project_grants2 `+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id `+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
[]string{
|
||||
"project_id",
|
||||
"grant_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"state",
|
||||
"sequence",
|
||||
"name",
|
||||
"granted_org_id",
|
||||
"name",
|
||||
"granted_role_keys",
|
||||
"name",
|
||||
"count",
|
||||
},
|
||||
regexp.QuoteMeta(projectGrantsQuery),
|
||||
projectGrantsCols,
|
||||
[][]driver.Value{
|
||||
{
|
||||
"project-id",
|
||||
@ -365,38 +294,8 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER () `+
|
||||
` FROM projections.project_grants2 `+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id `+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
[]string{
|
||||
"project_id",
|
||||
"grant_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"state",
|
||||
"sequence",
|
||||
"name",
|
||||
"granted_org_id",
|
||||
"name",
|
||||
"granted_role_keys",
|
||||
"name",
|
||||
"count",
|
||||
},
|
||||
regexp.QuoteMeta(projectGrantsQuery),
|
||||
projectGrantsCols,
|
||||
[][]driver.Value{
|
||||
{
|
||||
"project-id",
|
||||
@ -470,23 +369,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER () `+
|
||||
` FROM projections.project_grants2 `+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id `+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
regexp.QuoteMeta(projectGrantsQuery),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@ -503,22 +386,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name`+
|
||||
` FROM projections.project_grants2 `+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id `+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
regexp.QuoteMeta(projectGrantQuery),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@ -536,36 +404,8 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name`+
|
||||
` FROM projections.project_grants2 `+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id `+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
[]string{
|
||||
"project_id",
|
||||
"grant_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"state",
|
||||
"sequence",
|
||||
"name",
|
||||
"granted_org_id",
|
||||
"name",
|
||||
"granted_role_keys",
|
||||
"name",
|
||||
},
|
||||
regexp.QuoteMeta(projectGrantQuery),
|
||||
projectGrantCols,
|
||||
[]driver.Value{
|
||||
"project-id",
|
||||
"grant-id",
|
||||
@ -602,36 +442,8 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name`+
|
||||
` FROM projections.project_grants2 `+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id `+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
[]string{
|
||||
"project_id",
|
||||
"grant_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"state",
|
||||
"sequence",
|
||||
"name",
|
||||
"granted_org_id",
|
||||
"name",
|
||||
"granted_role_keys",
|
||||
"name",
|
||||
},
|
||||
regexp.QuoteMeta(projectGrantQuery),
|
||||
projectGrantCols,
|
||||
[]driver.Value{
|
||||
"project-id",
|
||||
"grant-id",
|
||||
@ -668,36 +480,8 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name`+
|
||||
` FROM projections.project_grants2 `+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id `+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
[]string{
|
||||
"project_id",
|
||||
"grant_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"state",
|
||||
"sequence",
|
||||
"name",
|
||||
"granted_org_id",
|
||||
"name",
|
||||
"granted_role_keys",
|
||||
"name",
|
||||
},
|
||||
regexp.QuoteMeta(projectGrantQuery),
|
||||
projectGrantCols,
|
||||
[]driver.Value{
|
||||
"project-id",
|
||||
"grant-id",
|
||||
@ -734,36 +518,8 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name`+
|
||||
` FROM projections.project_grants2 `+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id `+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
[]string{
|
||||
"project_id",
|
||||
"grant_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"state",
|
||||
"sequence",
|
||||
"name",
|
||||
"granted_org_id",
|
||||
"name",
|
||||
"granted_role_keys",
|
||||
"name",
|
||||
},
|
||||
regexp.QuoteMeta(projectGrantQuery),
|
||||
projectGrantCols,
|
||||
[]driver.Value{
|
||||
"project-id",
|
||||
"grant-id",
|
||||
@ -800,22 +556,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants2.project_id,`+
|
||||
` projections.project_grants2.grant_id,`+
|
||||
` projections.project_grants2.creation_date,`+
|
||||
` projections.project_grants2.change_date,`+
|
||||
` projections.project_grants2.resource_owner,`+
|
||||
` projections.project_grants2.state,`+
|
||||
` projections.project_grants2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.project_grants2.granted_org_id,`+
|
||||
` o.name,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name`+
|
||||
` FROM projections.project_grants2 `+
|
||||
` LEFT JOIN projections.projects2 ON projections.project_grants2.project_id = projections.projects2.id `+
|
||||
` LEFT JOIN projections.orgs AS r ON projections.project_grants2.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs AS o ON projections.project_grants2.granted_org_id = o.id`),
|
||||
regexp.QuoteMeta(projectGrantQuery),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
@ -16,6 +16,7 @@ var (
|
||||
projectMemberTable = table{
|
||||
name: projection.ProjectMemberProjectionTable,
|
||||
alias: "members",
|
||||
instanceIDCol: projection.MemberInstanceID,
|
||||
}
|
||||
ProjectMemberUserID = Column{
|
||||
name: projection.MemberUserIDCol,
|
||||
|
@ -30,10 +30,13 @@ var (
|
||||
"FROM projections.project_members2 AS members " +
|
||||
"LEFT JOIN projections.users4_humans " +
|
||||
"ON members.user_id = projections.users4_humans.user_id " +
|
||||
"AND members.instance_id = projections.users4_humans.instance_id " +
|
||||
"LEFT JOIN projections.users4_machines " +
|
||||
"ON members.user_id = projections.users4_machines.user_id " +
|
||||
"AND members.instance_id = projections.users4_machines.instance_id " +
|
||||
"LEFT JOIN projections.login_names " +
|
||||
"ON members.user_id = projections.login_names.user_id " +
|
||||
"AND members.instance_id = projections.login_names.instance_id " +
|
||||
"WHERE projections.login_names.is_primary = $1")
|
||||
projectMembersColumns = []string{
|
||||
"creation_date",
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
var (
|
||||
projectRolesTable = table{
|
||||
name: projection.ProjectRoleProjectionTable,
|
||||
instanceIDCol: projection.ProjectRoleColumnInstanceID,
|
||||
}
|
||||
ProjectRoleColumnCreationDate = Column{
|
||||
name: projection.ProjectRoleColumnCreationDate,
|
||||
|
@ -367,6 +367,7 @@ var (
|
||||
type table struct {
|
||||
name string
|
||||
alias string
|
||||
instanceIDCol string
|
||||
}
|
||||
|
||||
func (t table) setAlias(a string) table {
|
||||
@ -385,6 +386,13 @@ func (t table) isZero() bool {
|
||||
return t.name == ""
|
||||
}
|
||||
|
||||
func (t table) InstanceIDIdentifier() string {
|
||||
if t.alias != "" {
|
||||
return t.alias + "." + t.instanceIDCol
|
||||
}
|
||||
return t.name + "." + t.instanceIDCol
|
||||
}
|
||||
|
||||
type Column struct {
|
||||
name string
|
||||
table table
|
||||
@ -418,7 +426,7 @@ func (c Column) isZero() bool {
|
||||
}
|
||||
|
||||
func join(join, from Column) string {
|
||||
return join.table.identifier() + " ON " + from.identifier() + " = " + join.identifier()
|
||||
return join.table.identifier() + " ON " + from.identifier() + " = " + join.identifier() + " AND " + from.table.InstanceIDIdentifier() + " = " + join.table.InstanceIDIdentifier()
|
||||
}
|
||||
|
||||
type listContains struct {
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
)
|
||||
|
||||
@ -13,6 +14,7 @@ var (
|
||||
testTable = table{
|
||||
name: "test_table",
|
||||
alias: "test_table",
|
||||
instanceIDCol: "instance_id",
|
||||
}
|
||||
testCol = Column{
|
||||
name: "test_col",
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
var (
|
||||
secretGeneratorsTable = table{
|
||||
name: projection.SecretGeneratorProjectionTable,
|
||||
instanceIDCol: projection.SecretGeneratorColumnInstanceID,
|
||||
}
|
||||
SecretGeneratorColumnAggregateID = Column{
|
||||
name: projection.SecretGeneratorColumnAggregateID,
|
||||
|
@ -54,6 +54,7 @@ func (q *SMSConfigsSearchQueries) toQuery(query sq.SelectBuilder) sq.SelectBuild
|
||||
var (
|
||||
smsConfigsTable = table{
|
||||
name: projection.SMSConfigProjectionTable,
|
||||
instanceIDCol: projection.SMSColumnInstanceID,
|
||||
}
|
||||
SMSConfigColumnID = Column{
|
||||
name: projection.SMSColumnID,
|
||||
@ -92,6 +93,7 @@ var (
|
||||
var (
|
||||
smsTwilioConfigsTable = table{
|
||||
name: projection.SMSTwilioTable,
|
||||
instanceIDCol: projection.SMSTwilioColumnInstanceID,
|
||||
}
|
||||
SMSTwilioConfigColumnSMSID = Column{
|
||||
name: projection.SMSTwilioConfigColumnSMSID,
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
var (
|
||||
smtpConfigsTable = table{
|
||||
name: projection.SMTPConfigProjectionTable,
|
||||
instanceIDCol: projection.SMTPConfigColumnInstanceID,
|
||||
}
|
||||
SMTPConfigColumnAggregateID = Column{
|
||||
name: projection.SMTPConfigColumnAggregateID,
|
||||
|
@ -123,6 +123,7 @@ type UserSearchQueries struct {
|
||||
var (
|
||||
userTable = table{
|
||||
name: projection.UserTable,
|
||||
instanceIDCol: projection.UserInstanceIDCol,
|
||||
}
|
||||
UserIDCol = Column{
|
||||
name: projection.UserIDCol,
|
||||
@ -180,6 +181,7 @@ var (
|
||||
var (
|
||||
humanTable = table{
|
||||
name: projection.UserHumanTable,
|
||||
instanceIDCol: projection.HumanUserInstanceIDCol,
|
||||
}
|
||||
// profile
|
||||
HumanUserIDCol = Column{
|
||||
@ -244,6 +246,7 @@ var (
|
||||
var (
|
||||
machineTable = table{
|
||||
name: projection.UserMachineTable,
|
||||
instanceIDCol: projection.MachineUserInstanceIDCol,
|
||||
}
|
||||
MachineUserIDCol = Column{
|
||||
name: projection.MachineUserIDCol,
|
||||
@ -263,6 +266,7 @@ var (
|
||||
var (
|
||||
notifyTable = table{
|
||||
name: projection.UserNotifyTable,
|
||||
instanceIDCol: projection.NotifyInstanceIDCol,
|
||||
}
|
||||
NotifyUserIDCol = Column{
|
||||
name: projection.NotifyUserIDCol,
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
var (
|
||||
userAuthMethodTable = table{
|
||||
name: projection.UserAuthMethodTable,
|
||||
instanceIDCol: projection.UserAuthMethodInstanceIDCol,
|
||||
}
|
||||
UserAuthMethodColumnTokenID = Column{
|
||||
name: projection.UserAuthMethodTokenIDCol,
|
||||
|
@ -144,6 +144,7 @@ func NewUserGrantContainsRolesSearchQuery(roles ...string) (SearchQuery, error)
|
||||
var (
|
||||
userGrantTable = table{
|
||||
name: projection.UserGrantProjectionTable,
|
||||
instanceIDCol: projection.UserGrantInstanceID,
|
||||
}
|
||||
UserGrantID = Column{
|
||||
name: projection.UserGrantID,
|
||||
|
@ -38,11 +38,11 @@ var (
|
||||
", projections.user_grants2.project_id" +
|
||||
", projections.projects2.name" +
|
||||
" FROM projections.user_grants2" +
|
||||
" LEFT JOIN projections.users4 ON projections.user_grants2.user_id = projections.users4.id" +
|
||||
" LEFT JOIN projections.users4_humans ON projections.user_grants2.user_id = projections.users4_humans.user_id" +
|
||||
" LEFT JOIN projections.orgs ON projections.user_grants2.resource_owner = projections.orgs.id" +
|
||||
" LEFT JOIN projections.projects2 ON projections.user_grants2.project_id = projections.projects2.id" +
|
||||
" LEFT JOIN projections.login_names ON projections.user_grants2.user_id = projections.login_names.user_id" +
|
||||
" LEFT JOIN projections.users4 ON projections.user_grants2.user_id = projections.users4.id AND projections.user_grants2.instance_id = projections.users4.instance_id" +
|
||||
" LEFT JOIN projections.users4_humans ON projections.user_grants2.user_id = projections.users4_humans.user_id AND projections.user_grants2.instance_id = projections.users4_humans.instance_id" +
|
||||
" LEFT JOIN projections.orgs ON projections.user_grants2.resource_owner = projections.orgs.id AND projections.user_grants2.instance_id = projections.orgs.instance_id" +
|
||||
" LEFT JOIN projections.projects2 ON projections.user_grants2.project_id = projections.projects2.id AND projections.user_grants2.instance_id = projections.projects2.instance_id" +
|
||||
" LEFT JOIN projections.login_names ON projections.user_grants2.user_id = projections.login_names.user_id AND projections.user_grants2.instance_id = projections.login_names.instance_id" +
|
||||
" WHERE projections.login_names.is_primary = $1")
|
||||
userGrantCols = []string{
|
||||
"id",
|
||||
@ -93,11 +93,11 @@ var (
|
||||
", projections.projects2.name" +
|
||||
", COUNT(*) OVER ()" +
|
||||
" FROM projections.user_grants2" +
|
||||
" LEFT JOIN projections.users4 ON projections.user_grants2.user_id = projections.users4.id" +
|
||||
" LEFT JOIN projections.users4_humans ON projections.user_grants2.user_id = projections.users4_humans.user_id" +
|
||||
" LEFT JOIN projections.orgs ON projections.user_grants2.resource_owner = projections.orgs.id" +
|
||||
" LEFT JOIN projections.projects2 ON projections.user_grants2.project_id = projections.projects2.id" +
|
||||
" LEFT JOIN projections.login_names ON projections.user_grants2.user_id = projections.login_names.user_id" +
|
||||
" LEFT JOIN projections.users4 ON projections.user_grants2.user_id = projections.users4.id AND projections.user_grants2.instance_id = projections.users4.instance_id" +
|
||||
" LEFT JOIN projections.users4_humans ON projections.user_grants2.user_id = projections.users4_humans.user_id AND projections.user_grants2.instance_id = projections.users4_humans.instance_id" +
|
||||
" LEFT JOIN projections.orgs ON projections.user_grants2.resource_owner = projections.orgs.id AND projections.user_grants2.instance_id = projections.orgs.instance_id" +
|
||||
" LEFT JOIN projections.projects2 ON projections.user_grants2.project_id = projections.projects2.id AND projections.user_grants2.instance_id = projections.projects2.instance_id" +
|
||||
" LEFT JOIN projections.login_names ON projections.user_grants2.user_id = projections.login_names.user_id AND projections.user_grants2.instance_id = projections.login_names.instance_id" +
|
||||
" WHERE projections.login_names.is_primary = $1")
|
||||
userGrantsCols = append(
|
||||
userGrantCols,
|
||||
|
@ -133,6 +133,7 @@ var (
|
||||
//membershipAlias is a hack to satisfy checks in the queries
|
||||
membershipAlias = table{
|
||||
name: "memberships",
|
||||
instanceIDCol: projection.MemberInstanceID,
|
||||
}
|
||||
membershipUserID = Column{
|
||||
name: projection.MemberUserIDCol,
|
||||
|
@ -80,9 +80,9 @@ var (
|
||||
", members.grant_id" +
|
||||
" FROM projections.project_grant_members2 AS members" +
|
||||
") AS memberships" +
|
||||
" LEFT JOIN projections.projects2 ON memberships.project_id = projections.projects2.id" +
|
||||
" LEFT JOIN projections.orgs ON memberships.org_id = projections.orgs.id" +
|
||||
" LEFT JOIN projections.project_grants2 ON memberships.grant_id = projections.project_grants2.grant_id")
|
||||
" LEFT JOIN projections.projects2 ON memberships.project_id = projections.projects2.id AND memberships.instance_id = projections.projects2.instance_id" +
|
||||
" LEFT JOIN projections.orgs ON memberships.org_id = projections.orgs.id AND memberships.instance_id = projections.orgs.instance_id" +
|
||||
" LEFT JOIN projections.project_grants2 ON memberships.grant_id = projections.project_grants2.grant_id AND memberships.instance_id = projections.project_grants2.instance_id")
|
||||
membershipCols = []string{
|
||||
"user_id",
|
||||
"roles",
|
||||
|
@ -36,6 +36,7 @@ type UserMetadataSearchQueries struct {
|
||||
var (
|
||||
userMetadataTable = table{
|
||||
name: projection.UserMetadataProjectionTable,
|
||||
instanceIDCol: projection.UserMetadataColumnInstanceID,
|
||||
}
|
||||
UserMetadataUserIDCol = Column{
|
||||
name: projection.UserMetadataColumnUserID,
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
var (
|
||||
personalAccessTokensTable = table{
|
||||
name: projection.PersonalAccessTokenProjectionTable,
|
||||
instanceIDCol: projection.PersonalAccessTokenColumnInstanceID,
|
||||
}
|
||||
PersonalAccessTokenColumnID = Column{
|
||||
name: projection.PersonalAccessTokenColumnID,
|
||||
|
@ -44,8 +44,8 @@ var (
|
||||
` projections.users4_machines.description,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.users4` +
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id` +
|
||||
` LEFT JOIN projections.users4_machines ON projections.users4.id = projections.users4_machines.user_id` +
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id AND projections.users4.instance_id = projections.users4_humans.instance_id` +
|
||||
` LEFT JOIN projections.users4_machines ON projections.users4.id = projections.users4_machines.user_id AND projections.users4.instance_id = projections.users4_machines.instance_id` +
|
||||
` LEFT JOIN` +
|
||||
` (SELECT login_names.user_id, ARRAY_AGG(login_names.login_name)::TEXT[] AS loginnames` +
|
||||
` FROM projections.login_names AS login_names` +
|
||||
@ -99,7 +99,7 @@ var (
|
||||
` projections.users4_humans.gender,` +
|
||||
` projections.users4_humans.avatar_key` +
|
||||
` FROM projections.users4` +
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id`
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id AND projections.users4.instance_id = projections.users4_humans.instance_id`
|
||||
profileCols = []string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@ -124,7 +124,7 @@ var (
|
||||
` projections.users4_humans.email,` +
|
||||
` projections.users4_humans.is_email_verified` +
|
||||
` FROM projections.users4` +
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id`
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id AND projections.users4.instance_id = projections.users4_humans.instance_id`
|
||||
emailCols = []string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@ -144,7 +144,7 @@ var (
|
||||
` projections.users4_humans.phone,` +
|
||||
` projections.users4_humans.is_phone_verified` +
|
||||
` FROM projections.users4` +
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id`
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id AND projections.users4.instance_id = projections.users4_humans.instance_id`
|
||||
phoneCols = []string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@ -162,7 +162,7 @@ var (
|
||||
` projections.users4_humans.email,` +
|
||||
` projections.users4_humans.is_email_verified` +
|
||||
` FROM projections.users4` +
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id`
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id AND projections.users4.instance_id = projections.users4_humans.instance_id`
|
||||
userUniqueCols = []string{
|
||||
"id",
|
||||
"state",
|
||||
@ -197,8 +197,8 @@ var (
|
||||
` projections.users4_notifications.password_set,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.users4` +
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id` +
|
||||
` LEFT JOIN projections.users4_notifications ON projections.users4.id = projections.users4_notifications.user_id` +
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id AND projections.users4.instance_id = projections.users4_humans.instance_id` +
|
||||
` LEFT JOIN projections.users4_notifications ON projections.users4.id = projections.users4_notifications.user_id AND projections.users4.instance_id = projections.users4_notifications.instance_id` +
|
||||
` LEFT JOIN` +
|
||||
` (SELECT login_names.user_id, ARRAY_AGG(login_names.login_name) AS loginnames` +
|
||||
` FROM projections.login_names AS login_names` +
|
||||
@ -264,8 +264,8 @@ var (
|
||||
` projections.users4_machines.description,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.users4` +
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id` +
|
||||
` LEFT JOIN projections.users4_machines ON projections.users4.id = projections.users4_machines.user_id` +
|
||||
` LEFT JOIN projections.users4_humans ON projections.users4.id = projections.users4_humans.user_id AND projections.users4.instance_id = projections.users4_humans.instance_id` +
|
||||
` LEFT JOIN projections.users4_machines ON projections.users4.id = projections.users4_machines.user_id AND projections.users4.instance_id = projections.users4_machines.instance_id` +
|
||||
` LEFT JOIN` +
|
||||
` (SELECT login_names.user_id, ARRAY_AGG(login_names.login_name) AS loginnames` +
|
||||
` FROM projections.login_names AS login_names` +
|
||||
|
Loading…
x
Reference in New Issue
Block a user