mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-08 15:15:12 +00:00
feat(database): support for postgres (#3998)
* beginning with postgres statements * try pgx * use pgx * database * init works for postgres * arrays working * init for cockroach * init * start tests * tests * TESTS * ch * ch * chore: use go 1.18 * read stmts * fix typo * tests * connection string * add missing error handler * cleanup * start all apis * go mod tidy * old update * switch back to minute * on conflict * replace string slice with `database.StringArray` in db models * fix tests and start * update go version in dockerfile * setup go * clean up * remove notification migration * update * docs: add deploy guide for postgres * fix: revert sonyflake * use `database.StringArray` for daos * use `database.StringArray` every where * new tables * index naming, metadata primary key, project grant role key type * docs(postgres): change to beta * chore: correct compose * fix(defaults): add empty postgres config * refactor: remove unused code * docs: add postgres to self hosted * fix broken link * so? * change title * add mdx to link * fix stmt * update goreleaser in test-code * docs: improve postgres example * update more projections * fix: add beta log for postgres * revert index name change * prerelease * fix: add sequence to v1 "reduce paniced" * log if nil * add logging * fix: log output * fix(import): check if org exists and user * refactor: imports * fix(user): ignore malformed events * refactor: method naming * fix: test * refactor: correct errors.Is call * ci: don't build dev binaries on main * fix(go releaser): update version to 1.11.0 * fix(user): projection should not break * fix(user): handle error properly * docs: correct config example * Update .releaserc.js * Update .releaserc.js Co-authored-by: Livio Amstutz <[email protected]> Co-authored-by: Elio Bischof <[email protected]>
This commit is contained in:
co-authored by
Livio Amstutz
Elio Bischof
parent
d6c9815945
commit
77b4fc5487
@@ -6,7 +6,6 @@ import (
|
||||
"time"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
|
||||
@@ -216,8 +215,8 @@ func prepareFlowQuery(flowType domain.FlowType) (sq.SelectBuilder, func(*sql.Row
|
||||
for rows.Next() {
|
||||
var (
|
||||
actionID sql.NullString
|
||||
actionCreationDate pq.NullTime
|
||||
actionChangeDate pq.NullTime
|
||||
actionCreationDate sql.NullTime
|
||||
actionChangeDate sql.NullTime
|
||||
actionResourceOwner sql.NullString
|
||||
actionState sql.NullInt32
|
||||
actionSequence sql.NullInt64
|
||||
|
||||
@@ -31,14 +31,14 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
},
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script,`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script,`+
|
||||
` projections.flows_triggers.trigger_type,`+
|
||||
` projections.flows_triggers.trigger_sequence,`+
|
||||
` projections.flows_triggers.flow_type,`+
|
||||
@@ -46,7 +46,7 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
` projections.flows_triggers.sequence,`+
|
||||
` projections.flows_triggers.resource_owner`+
|
||||
` FROM projections.flows_triggers`+
|
||||
` LEFT JOIN projections.actions ON projections.flows_triggers.action_id = projections.actions.id`),
|
||||
` LEFT JOIN projections.actions2 ON projections.flows_triggers.action_id = projections.actions2.id`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -63,14 +63,14 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
},
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script,`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script,`+
|
||||
` projections.flows_triggers.trigger_type,`+
|
||||
` projections.flows_triggers.trigger_sequence,`+
|
||||
` projections.flows_triggers.flow_type,`+
|
||||
@@ -78,7 +78,7 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
` projections.flows_triggers.sequence,`+
|
||||
` projections.flows_triggers.resource_owner`+
|
||||
` FROM projections.flows_triggers`+
|
||||
` LEFT JOIN projections.actions ON projections.flows_triggers.action_id = projections.actions.id`),
|
||||
` LEFT JOIN projections.actions2 ON projections.flows_triggers.action_id = projections.actions2.id`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -144,14 +144,14 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
},
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script,`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script,`+
|
||||
` projections.flows_triggers.trigger_type,`+
|
||||
` projections.flows_triggers.trigger_sequence,`+
|
||||
` projections.flows_triggers.flow_type,`+
|
||||
@@ -159,7 +159,7 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
` projections.flows_triggers.sequence,`+
|
||||
` projections.flows_triggers.resource_owner`+
|
||||
` FROM projections.flows_triggers`+
|
||||
` LEFT JOIN projections.actions ON projections.flows_triggers.action_id = projections.actions.id`),
|
||||
` LEFT JOIN projections.actions2 ON projections.flows_triggers.action_id = projections.actions2.id`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -253,14 +253,14 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
},
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script,`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script,`+
|
||||
` projections.flows_triggers.trigger_type,`+
|
||||
` projections.flows_triggers.trigger_sequence,`+
|
||||
` projections.flows_triggers.flow_type,`+
|
||||
@@ -268,7 +268,7 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
` projections.flows_triggers.sequence,`+
|
||||
` projections.flows_triggers.resource_owner`+
|
||||
` FROM projections.flows_triggers`+
|
||||
` LEFT JOIN projections.actions ON projections.flows_triggers.action_id = projections.actions.id`),
|
||||
` LEFT JOIN projections.actions2 ON projections.flows_triggers.action_id = projections.actions2.id`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -321,14 +321,14 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
},
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script,`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script,`+
|
||||
` projections.flows_triggers.trigger_type,`+
|
||||
` projections.flows_triggers.trigger_sequence,`+
|
||||
` projections.flows_triggers.flow_type,`+
|
||||
@@ -336,7 +336,7 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
` projections.flows_triggers.sequence,`+
|
||||
` projections.flows_triggers.resource_owner`+
|
||||
` FROM projections.flows_triggers`+
|
||||
` LEFT JOIN projections.actions ON projections.flows_triggers.action_id = projections.actions.id`),
|
||||
` LEFT JOIN projections.actions2 ON projections.flows_triggers.action_id = projections.actions2.id`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@@ -353,16 +353,16 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
prepare: prepareTriggerActionsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script`+
|
||||
` FROM projections.flows_triggers`+
|
||||
` LEFT JOIN projections.actions ON projections.flows_triggers.action_id = projections.actions.id`),
|
||||
` LEFT JOIN projections.actions2 ON projections.flows_triggers.action_id = projections.actions2.id`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -374,16 +374,16 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
prepare: prepareTriggerActionsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script`+
|
||||
` FROM projections.flows_triggers`+
|
||||
` LEFT JOIN projections.actions ON projections.flows_triggers.action_id = projections.actions.id`),
|
||||
` LEFT JOIN projections.actions2 ON projections.flows_triggers.action_id = projections.actions2.id`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -426,16 +426,16 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
prepare: prepareTriggerActionsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script`+
|
||||
` FROM projections.flows_triggers`+
|
||||
` LEFT JOIN projections.actions ON projections.flows_triggers.action_id = projections.actions.id`),
|
||||
` LEFT JOIN projections.actions2 ON projections.flows_triggers.action_id = projections.actions2.id`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -498,16 +498,16 @@ func Test_FlowPrepares(t *testing.T) {
|
||||
prepare: prepareTriggerActionsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script`+
|
||||
` FROM projections.flows_triggers`+
|
||||
` LEFT JOIN projections.actions ON projections.flows_triggers.action_id = projections.actions.id`),
|
||||
` LEFT JOIN projections.actions2 ON projections.flows_triggers.action_id = projections.actions2.id`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
||||
@@ -29,18 +29,18 @@ func Test_ActionPrepares(t *testing.T) {
|
||||
prepare: prepareActionsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script,`+
|
||||
` projections.actions.timeout,`+
|
||||
` projections.actions.allowed_to_fail,`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script,`+
|
||||
` projections.actions2.timeout,`+
|
||||
` projections.actions2.allowed_to_fail,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.actions`),
|
||||
` FROM projections.actions2`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -52,18 +52,18 @@ func Test_ActionPrepares(t *testing.T) {
|
||||
prepare: prepareActionsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script,`+
|
||||
` projections.actions.timeout,`+
|
||||
` projections.actions.allowed_to_fail,`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script,`+
|
||||
` projections.actions2.timeout,`+
|
||||
` projections.actions2.allowed_to_fail,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.actions`),
|
||||
` FROM projections.actions2`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -118,18 +118,18 @@ func Test_ActionPrepares(t *testing.T) {
|
||||
prepare: prepareActionsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script,`+
|
||||
` projections.actions.timeout,`+
|
||||
` projections.actions.allowed_to_fail,`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script,`+
|
||||
` projections.actions2.timeout,`+
|
||||
` projections.actions2.allowed_to_fail,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.actions`),
|
||||
` FROM projections.actions2`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -208,18 +208,18 @@ func Test_ActionPrepares(t *testing.T) {
|
||||
prepare: prepareActionsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script,`+
|
||||
` projections.actions.timeout,`+
|
||||
` projections.actions.allowed_to_fail,`+
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script,`+
|
||||
` projections.actions2.timeout,`+
|
||||
` projections.actions2.allowed_to_fail,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.actions`),
|
||||
` FROM projections.actions2`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@@ -236,17 +236,17 @@ func Test_ActionPrepares(t *testing.T) {
|
||||
prepare: prepareActionQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script,`+
|
||||
` projections.actions.timeout,`+
|
||||
` projections.actions.allowed_to_fail`+
|
||||
` FROM projections.actions`),
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script,`+
|
||||
` projections.actions2.timeout,`+
|
||||
` projections.actions2.allowed_to_fail`+
|
||||
` FROM projections.actions2`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -264,17 +264,17 @@ func Test_ActionPrepares(t *testing.T) {
|
||||
prepare: prepareActionQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script,`+
|
||||
` projections.actions.timeout,`+
|
||||
` projections.actions.allowed_to_fail`+
|
||||
` FROM projections.actions`),
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script,`+
|
||||
` projections.actions2.timeout,`+
|
||||
` projections.actions2.allowed_to_fail`+
|
||||
` FROM projections.actions2`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -319,17 +319,17 @@ func Test_ActionPrepares(t *testing.T) {
|
||||
prepare: prepareActionQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.actions.id,`+
|
||||
` projections.actions.creation_date,`+
|
||||
` projections.actions.change_date,`+
|
||||
` projections.actions.resource_owner,`+
|
||||
` projections.actions.sequence,`+
|
||||
` projections.actions.action_state,`+
|
||||
` projections.actions.name,`+
|
||||
` projections.actions.script,`+
|
||||
` projections.actions.timeout,`+
|
||||
` projections.actions.allowed_to_fail`+
|
||||
` FROM projections.actions`),
|
||||
regexp.QuoteMeta(`SELECT projections.actions2.id,`+
|
||||
` projections.actions2.creation_date,`+
|
||||
` projections.actions2.change_date,`+
|
||||
` projections.actions2.resource_owner,`+
|
||||
` projections.actions2.sequence,`+
|
||||
` projections.actions2.action_state,`+
|
||||
` projections.actions2.name,`+
|
||||
` projections.actions2.script,`+
|
||||
` projections.actions2.timeout,`+
|
||||
` projections.actions2.allowed_to_fail`+
|
||||
` FROM projections.actions2`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
||||
+17
-35
@@ -7,12 +7,10 @@ import (
|
||||
"time"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/query/projection"
|
||||
@@ -39,23 +37,23 @@ type App struct {
|
||||
}
|
||||
|
||||
type OIDCApp struct {
|
||||
RedirectURIs []string
|
||||
ResponseTypes []domain.OIDCResponseType
|
||||
GrantTypes []domain.OIDCGrantType
|
||||
RedirectURIs database.StringArray
|
||||
ResponseTypes database.EnumArray[domain.OIDCResponseType]
|
||||
GrantTypes database.EnumArray[domain.OIDCGrantType]
|
||||
AppType domain.OIDCApplicationType
|
||||
ClientID string
|
||||
AuthMethodType domain.OIDCAuthMethodType
|
||||
PostLogoutRedirectURIs []string
|
||||
PostLogoutRedirectURIs database.StringArray
|
||||
Version domain.OIDCVersion
|
||||
ComplianceProblems []string
|
||||
ComplianceProblems database.StringArray
|
||||
IsDevMode bool
|
||||
AccessTokenType domain.OIDCTokenType
|
||||
AssertAccessTokenRole bool
|
||||
AssertIDTokenRole bool
|
||||
AssertIDTokenUserinfo bool
|
||||
ClockSkew time.Duration
|
||||
AdditionalOrigins []string
|
||||
AllowedOrigins []string
|
||||
AdditionalOrigins database.StringArray
|
||||
AllowedOrigins database.StringArray
|
||||
}
|
||||
|
||||
type APIApp struct {
|
||||
@@ -613,7 +611,7 @@ func prepareClientIDsQuery() (sq.SelectBuilder, func(*sql.Rows) ([]string, error
|
||||
LeftJoin(join(AppAPIConfigColumnAppID, AppColumnID)).
|
||||
LeftJoin(join(AppOIDCConfigColumnAppID, AppColumnID)).
|
||||
PlaceholderFormat(sq.Dollar), func(rows *sql.Rows) ([]string, error) {
|
||||
ids := []string{}
|
||||
ids := database.StringArray{}
|
||||
|
||||
for rows.Next() {
|
||||
var apiID sql.NullString
|
||||
@@ -639,19 +637,19 @@ type sqlOIDCConfig struct {
|
||||
appID sql.NullString
|
||||
version sql.NullInt32
|
||||
clientID sql.NullString
|
||||
redirectUris pq.StringArray
|
||||
redirectUris database.StringArray
|
||||
applicationType sql.NullInt16
|
||||
authMethodType sql.NullInt16
|
||||
postLogoutRedirectUris pq.StringArray
|
||||
postLogoutRedirectUris database.StringArray
|
||||
devMode sql.NullBool
|
||||
accessTokenType sql.NullInt16
|
||||
accessTokenRoleAssertion sql.NullBool
|
||||
iDTokenRoleAssertion sql.NullBool
|
||||
iDTokenUserinfoAssertion sql.NullBool
|
||||
clockSkew sql.NullInt64
|
||||
additionalOrigins pq.StringArray
|
||||
responseTypes pq.Int32Array
|
||||
grantTypes pq.Int32Array
|
||||
additionalOrigins database.StringArray
|
||||
responseTypes database.EnumArray[domain.OIDCResponseType]
|
||||
grantTypes database.EnumArray[domain.OIDCGrantType]
|
||||
}
|
||||
|
||||
func (c sqlOIDCConfig) set(app *App) {
|
||||
@@ -672,8 +670,8 @@ func (c sqlOIDCConfig) set(app *App) {
|
||||
AssertIDTokenUserinfo: c.iDTokenUserinfoAssertion.Bool,
|
||||
ClockSkew: time.Duration(c.clockSkew.Int64),
|
||||
AdditionalOrigins: c.additionalOrigins,
|
||||
ResponseTypes: oidcResponseTypesToDomain(c.responseTypes),
|
||||
GrantTypes: oidcGrantTypesToDomain(c.grantTypes),
|
||||
ResponseTypes: c.responseTypes,
|
||||
GrantTypes: c.grantTypes,
|
||||
}
|
||||
compliance := domain.GetOIDCCompliance(app.OIDCConfig.Version, app.OIDCConfig.AppType, app.OIDCConfig.GrantTypes, app.OIDCConfig.ResponseTypes, app.OIDCConfig.AuthMethodType, app.OIDCConfig.RedirectURIs)
|
||||
app.OIDCConfig.ComplianceProblems = compliance.Problems
|
||||
@@ -698,19 +696,3 @@ func (c sqlAPIConfig) set(app *App) {
|
||||
AuthMethodType: domain.APIAuthMethodType(c.authMethod.Int16),
|
||||
}
|
||||
}
|
||||
|
||||
func oidcResponseTypesToDomain(t pq.Int32Array) []domain.OIDCResponseType {
|
||||
types := make([]domain.OIDCResponseType, len(t))
|
||||
for i, typ := range t {
|
||||
types[i] = domain.OIDCResponseType(typ)
|
||||
}
|
||||
return types
|
||||
}
|
||||
|
||||
func oidcGrantTypesToDomain(t pq.Int32Array) []domain.OIDCGrantType {
|
||||
types := make([]domain.OIDCGrantType, len(t))
|
||||
for i, typ := range t {
|
||||
types[i] = domain.OIDCGrantType(typ)
|
||||
}
|
||||
return types
|
||||
}
|
||||
|
||||
+210
-211
@@ -9,104 +9,103 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
expectedAppQuery = regexp.QuoteMeta(`SELECT projections.apps.id,` +
|
||||
` projections.apps.name,` +
|
||||
` projections.apps.project_id,` +
|
||||
` projections.apps.creation_date,` +
|
||||
` projections.apps.change_date,` +
|
||||
` projections.apps.resource_owner,` +
|
||||
` projections.apps.state,` +
|
||||
` projections.apps.sequence,` +
|
||||
expectedAppQuery = regexp.QuoteMeta(`SELECT projections.apps2.id,` +
|
||||
` projections.apps2.name,` +
|
||||
` projections.apps2.project_id,` +
|
||||
` projections.apps2.creation_date,` +
|
||||
` projections.apps2.change_date,` +
|
||||
` projections.apps2.resource_owner,` +
|
||||
` projections.apps2.state,` +
|
||||
` projections.apps2.sequence,` +
|
||||
// api config
|
||||
` projections.apps_api_configs.app_id,` +
|
||||
` projections.apps_api_configs.client_id,` +
|
||||
` projections.apps_api_configs.auth_method,` +
|
||||
` projections.apps2_api_configs.app_id,` +
|
||||
` projections.apps2_api_configs.client_id,` +
|
||||
` projections.apps2_api_configs.auth_method,` +
|
||||
// oidc config
|
||||
` projections.apps_oidc_configs.app_id,` +
|
||||
` projections.apps_oidc_configs.version,` +
|
||||
` projections.apps_oidc_configs.client_id,` +
|
||||
` projections.apps_oidc_configs.redirect_uris,` +
|
||||
` projections.apps_oidc_configs.response_types,` +
|
||||
` projections.apps_oidc_configs.grant_types,` +
|
||||
` projections.apps_oidc_configs.application_type,` +
|
||||
` projections.apps_oidc_configs.auth_method_type,` +
|
||||
` projections.apps_oidc_configs.post_logout_redirect_uris,` +
|
||||
` projections.apps_oidc_configs.is_dev_mode,` +
|
||||
` projections.apps_oidc_configs.access_token_type,` +
|
||||
` projections.apps_oidc_configs.access_token_role_assertion,` +
|
||||
` projections.apps_oidc_configs.id_token_role_assertion,` +
|
||||
` projections.apps_oidc_configs.id_token_userinfo_assertion,` +
|
||||
` projections.apps_oidc_configs.clock_skew,` +
|
||||
` projections.apps_oidc_configs.additional_origins` +
|
||||
` FROM projections.apps` +
|
||||
` LEFT JOIN projections.apps_api_configs ON projections.apps.id = projections.apps_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps_oidc_configs ON projections.apps.id = projections.apps_oidc_configs.app_id`)
|
||||
expectedAppsQuery = regexp.QuoteMeta(`SELECT projections.apps.id,` +
|
||||
` projections.apps.name,` +
|
||||
` projections.apps.project_id,` +
|
||||
` projections.apps.creation_date,` +
|
||||
` projections.apps.change_date,` +
|
||||
` projections.apps.resource_owner,` +
|
||||
` projections.apps.state,` +
|
||||
` projections.apps.sequence,` +
|
||||
` projections.apps2_oidc_configs.app_id,` +
|
||||
` projections.apps2_oidc_configs.version,` +
|
||||
` projections.apps2_oidc_configs.client_id,` +
|
||||
` projections.apps2_oidc_configs.redirect_uris,` +
|
||||
` projections.apps2_oidc_configs.response_types,` +
|
||||
` projections.apps2_oidc_configs.grant_types,` +
|
||||
` projections.apps2_oidc_configs.application_type,` +
|
||||
` projections.apps2_oidc_configs.auth_method_type,` +
|
||||
` projections.apps2_oidc_configs.post_logout_redirect_uris,` +
|
||||
` projections.apps2_oidc_configs.is_dev_mode,` +
|
||||
` projections.apps2_oidc_configs.access_token_type,` +
|
||||
` projections.apps2_oidc_configs.access_token_role_assertion,` +
|
||||
` projections.apps2_oidc_configs.id_token_role_assertion,` +
|
||||
` projections.apps2_oidc_configs.id_token_userinfo_assertion,` +
|
||||
` projections.apps2_oidc_configs.clock_skew,` +
|
||||
` projections.apps2_oidc_configs.additional_origins` +
|
||||
` FROM projections.apps2` +
|
||||
` LEFT JOIN projections.apps2_api_configs ON projections.apps2.id = projections.apps2_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps2_oidc_configs ON projections.apps2.id = projections.apps2_oidc_configs.app_id`)
|
||||
expectedAppsQuery = regexp.QuoteMeta(`SELECT projections.apps2.id,` +
|
||||
` projections.apps2.name,` +
|
||||
` projections.apps2.project_id,` +
|
||||
` projections.apps2.creation_date,` +
|
||||
` projections.apps2.change_date,` +
|
||||
` projections.apps2.resource_owner,` +
|
||||
` projections.apps2.state,` +
|
||||
` projections.apps2.sequence,` +
|
||||
// api config
|
||||
` projections.apps_api_configs.app_id,` +
|
||||
` projections.apps_api_configs.client_id,` +
|
||||
` projections.apps_api_configs.auth_method,` +
|
||||
` projections.apps2_api_configs.app_id,` +
|
||||
` projections.apps2_api_configs.client_id,` +
|
||||
` projections.apps2_api_configs.auth_method,` +
|
||||
// oidc config
|
||||
` projections.apps_oidc_configs.app_id,` +
|
||||
` projections.apps_oidc_configs.version,` +
|
||||
` projections.apps_oidc_configs.client_id,` +
|
||||
` projections.apps_oidc_configs.redirect_uris,` +
|
||||
` projections.apps_oidc_configs.response_types,` +
|
||||
` projections.apps_oidc_configs.grant_types,` +
|
||||
` projections.apps_oidc_configs.application_type,` +
|
||||
` projections.apps_oidc_configs.auth_method_type,` +
|
||||
` projections.apps_oidc_configs.post_logout_redirect_uris,` +
|
||||
` projections.apps_oidc_configs.is_dev_mode,` +
|
||||
` projections.apps_oidc_configs.access_token_type,` +
|
||||
` projections.apps_oidc_configs.access_token_role_assertion,` +
|
||||
` projections.apps_oidc_configs.id_token_role_assertion,` +
|
||||
` projections.apps_oidc_configs.id_token_userinfo_assertion,` +
|
||||
` projections.apps_oidc_configs.clock_skew,` +
|
||||
` projections.apps_oidc_configs.additional_origins,` +
|
||||
` projections.apps2_oidc_configs.app_id,` +
|
||||
` projections.apps2_oidc_configs.version,` +
|
||||
` projections.apps2_oidc_configs.client_id,` +
|
||||
` projections.apps2_oidc_configs.redirect_uris,` +
|
||||
` projections.apps2_oidc_configs.response_types,` +
|
||||
` projections.apps2_oidc_configs.grant_types,` +
|
||||
` projections.apps2_oidc_configs.application_type,` +
|
||||
` projections.apps2_oidc_configs.auth_method_type,` +
|
||||
` projections.apps2_oidc_configs.post_logout_redirect_uris,` +
|
||||
` projections.apps2_oidc_configs.is_dev_mode,` +
|
||||
` projections.apps2_oidc_configs.access_token_type,` +
|
||||
` projections.apps2_oidc_configs.access_token_role_assertion,` +
|
||||
` projections.apps2_oidc_configs.id_token_role_assertion,` +
|
||||
` projections.apps2_oidc_configs.id_token_userinfo_assertion,` +
|
||||
` projections.apps2_oidc_configs.clock_skew,` +
|
||||
` projections.apps2_oidc_configs.additional_origins,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.apps` +
|
||||
` LEFT JOIN projections.apps_api_configs ON projections.apps.id = projections.apps_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps_oidc_configs ON projections.apps.id = projections.apps_oidc_configs.app_id`)
|
||||
expectedAppIDsQuery = regexp.QuoteMeta(`SELECT projections.apps_api_configs.client_id,` +
|
||||
` projections.apps_oidc_configs.client_id` +
|
||||
` FROM projections.apps` +
|
||||
` LEFT JOIN projections.apps_api_configs ON projections.apps.id = projections.apps_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps_oidc_configs ON projections.apps.id = projections.apps_oidc_configs.app_id`)
|
||||
expectedProjectIDByAppQuery = regexp.QuoteMeta(`SELECT projections.apps.project_id` +
|
||||
` FROM projections.apps` +
|
||||
` LEFT JOIN projections.apps_api_configs ON projections.apps.id = projections.apps_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps_oidc_configs ON projections.apps.id = projections.apps_oidc_configs.app_id`)
|
||||
expectedProjectByAppQuery = regexp.QuoteMeta(`SELECT projections.projects.id,` +
|
||||
` projections.projects.creation_date,` +
|
||||
` projections.projects.change_date,` +
|
||||
` projections.projects.resource_owner,` +
|
||||
` projections.projects.state,` +
|
||||
` projections.projects.sequence,` +
|
||||
` projections.projects.name,` +
|
||||
` projections.projects.project_role_assertion,` +
|
||||
` projections.projects.project_role_check,` +
|
||||
` projections.projects.has_project_check,` +
|
||||
` projections.projects.private_labeling_setting` +
|
||||
` FROM projections.projects` +
|
||||
` JOIN projections.apps ON projections.projects.id = projections.apps.project_id` +
|
||||
` LEFT JOIN projections.apps_api_configs ON projections.apps.id = projections.apps_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps_oidc_configs ON projections.apps.id = projections.apps_oidc_configs.app_id`)
|
||||
` FROM projections.apps2` +
|
||||
` LEFT JOIN projections.apps2_api_configs ON projections.apps2.id = projections.apps2_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps2_oidc_configs ON projections.apps2.id = projections.apps2_oidc_configs.app_id`)
|
||||
expectedAppIDsQuery = regexp.QuoteMeta(`SELECT projections.apps2_api_configs.client_id,` +
|
||||
` projections.apps2_oidc_configs.client_id` +
|
||||
` FROM projections.apps2` +
|
||||
` LEFT JOIN projections.apps2_api_configs ON projections.apps2.id = projections.apps2_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps2_oidc_configs ON projections.apps2.id = projections.apps2_oidc_configs.app_id`)
|
||||
expectedProjectIDByAppQuery = regexp.QuoteMeta(`SELECT projections.apps2.project_id` +
|
||||
` FROM projections.apps2` +
|
||||
` LEFT JOIN projections.apps2_api_configs ON projections.apps2.id = projections.apps2_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps2_oidc_configs ON projections.apps2.id = projections.apps2_oidc_configs.app_id`)
|
||||
expectedProjectByAppQuery = regexp.QuoteMeta(`SELECT projections.projects2.id,` +
|
||||
` projections.projects2.creation_date,` +
|
||||
` projections.projects2.change_date,` +
|
||||
` projections.projects2.resource_owner,` +
|
||||
` projections.projects2.state,` +
|
||||
` projections.projects2.sequence,` +
|
||||
` projections.projects2.name,` +
|
||||
` projections.projects2.project_role_assertion,` +
|
||||
` projections.projects2.project_role_check,` +
|
||||
` projections.projects2.has_project_check,` +
|
||||
` projections.projects2.private_labeling_setting` +
|
||||
` FROM projections.projects2` +
|
||||
` JOIN projections.apps2 ON projections.projects2.id = projections.apps2.project_id` +
|
||||
` LEFT JOIN projections.apps2_api_configs ON projections.apps2.id = projections.apps2_api_configs.app_id` +
|
||||
` LEFT JOIN projections.apps2_oidc_configs ON projections.apps2.id = projections.apps2_oidc_configs.app_id`)
|
||||
|
||||
appCols = []string{
|
||||
appCols = database.StringArray{
|
||||
"id",
|
||||
"name",
|
||||
"project_id",
|
||||
@@ -312,19 +311,19 @@ func Test_AppsPrepare(t *testing.T) {
|
||||
"app-id",
|
||||
domain.OIDCVersionV1,
|
||||
"oidc-client-id",
|
||||
pq.StringArray{"https://redirect.to/me"},
|
||||
pq.Int32Array{int32(domain.OIDCResponseTypeIDTokenToken)},
|
||||
pq.Int32Array{int32(domain.OIDCGrantTypeImplicit)},
|
||||
database.StringArray{"https://redirect.to/me"},
|
||||
database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
domain.OIDCApplicationTypeUserAgent,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"post.logout.ch"},
|
||||
database.StringArray{"post.logout.ch"},
|
||||
true,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1 * time.Second,
|
||||
pq.StringArray{"additional.origin"},
|
||||
database.StringArray{"additional.origin"},
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -346,21 +345,21 @@ func Test_AppsPrepare(t *testing.T) {
|
||||
OIDCConfig: &OIDCApp{
|
||||
Version: domain.OIDCVersionV1,
|
||||
ClientID: "oidc-client-id",
|
||||
RedirectURIs: []string{"https://redirect.to/me"},
|
||||
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeImplicit},
|
||||
RedirectURIs: database.StringArray{"https://redirect.to/me"},
|
||||
ResponseTypes: database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
AppType: domain.OIDCApplicationTypeUserAgent,
|
||||
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
||||
PostLogoutRedirectURIs: []string{"post.logout.ch"},
|
||||
PostLogoutRedirectURIs: database.StringArray{"post.logout.ch"},
|
||||
IsDevMode: true,
|
||||
AccessTokenType: domain.OIDCTokenTypeJWT,
|
||||
AssertAccessTokenRole: true,
|
||||
AssertIDTokenRole: true,
|
||||
AssertIDTokenUserinfo: true,
|
||||
ClockSkew: 1 * time.Second,
|
||||
AdditionalOrigins: []string{"additional.origin"},
|
||||
AdditionalOrigins: database.StringArray{"additional.origin"},
|
||||
ComplianceProblems: nil,
|
||||
AllowedOrigins: []string{"https://redirect.to", "additional.origin"},
|
||||
AllowedOrigins: database.StringArray{"https://redirect.to", "additional.origin"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -391,19 +390,19 @@ func Test_AppsPrepare(t *testing.T) {
|
||||
"app-id",
|
||||
domain.OIDCVersionV1,
|
||||
"oidc-client-id",
|
||||
pq.StringArray{"https://redirect.to/me"},
|
||||
pq.Int32Array{int32(domain.OIDCResponseTypeIDTokenToken)},
|
||||
pq.Int32Array{int32(domain.OIDCGrantTypeImplicit)},
|
||||
database.StringArray{"https://redirect.to/me"},
|
||||
database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
domain.OIDCApplicationTypeUserAgent,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"post.logout.ch"},
|
||||
database.StringArray{"post.logout.ch"},
|
||||
false,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
1 * time.Second,
|
||||
pq.StringArray{"additional.origin"},
|
||||
database.StringArray{"additional.origin"},
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -425,21 +424,21 @@ func Test_AppsPrepare(t *testing.T) {
|
||||
OIDCConfig: &OIDCApp{
|
||||
Version: domain.OIDCVersionV1,
|
||||
ClientID: "oidc-client-id",
|
||||
RedirectURIs: []string{"https://redirect.to/me"},
|
||||
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeImplicit},
|
||||
RedirectURIs: database.StringArray{"https://redirect.to/me"},
|
||||
ResponseTypes: database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
AppType: domain.OIDCApplicationTypeUserAgent,
|
||||
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
||||
PostLogoutRedirectURIs: []string{"post.logout.ch"},
|
||||
PostLogoutRedirectURIs: database.StringArray{"post.logout.ch"},
|
||||
IsDevMode: false,
|
||||
AccessTokenType: domain.OIDCTokenTypeJWT,
|
||||
AssertAccessTokenRole: false,
|
||||
AssertIDTokenRole: false,
|
||||
AssertIDTokenUserinfo: true,
|
||||
ClockSkew: 1 * time.Second,
|
||||
AdditionalOrigins: []string{"additional.origin"},
|
||||
AdditionalOrigins: database.StringArray{"additional.origin"},
|
||||
ComplianceProblems: nil,
|
||||
AllowedOrigins: []string{"https://redirect.to", "additional.origin"},
|
||||
AllowedOrigins: database.StringArray{"https://redirect.to", "additional.origin"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -470,19 +469,19 @@ func Test_AppsPrepare(t *testing.T) {
|
||||
"app-id",
|
||||
domain.OIDCVersionV1,
|
||||
"oidc-client-id",
|
||||
pq.StringArray{"https://redirect.to/me"},
|
||||
pq.Int32Array{int32(domain.OIDCResponseTypeIDTokenToken)},
|
||||
pq.Int32Array{int32(domain.OIDCGrantTypeImplicit)},
|
||||
database.StringArray{"https://redirect.to/me"},
|
||||
database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
domain.OIDCApplicationTypeUserAgent,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"post.logout.ch"},
|
||||
database.StringArray{"post.logout.ch"},
|
||||
true,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
1 * time.Second,
|
||||
pq.StringArray{"additional.origin"},
|
||||
database.StringArray{"additional.origin"},
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -504,21 +503,21 @@ func Test_AppsPrepare(t *testing.T) {
|
||||
OIDCConfig: &OIDCApp{
|
||||
Version: domain.OIDCVersionV1,
|
||||
ClientID: "oidc-client-id",
|
||||
RedirectURIs: []string{"https://redirect.to/me"},
|
||||
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeImplicit},
|
||||
RedirectURIs: database.StringArray{"https://redirect.to/me"},
|
||||
ResponseTypes: database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
AppType: domain.OIDCApplicationTypeUserAgent,
|
||||
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
||||
PostLogoutRedirectURIs: []string{"post.logout.ch"},
|
||||
PostLogoutRedirectURIs: database.StringArray{"post.logout.ch"},
|
||||
IsDevMode: true,
|
||||
AccessTokenType: domain.OIDCTokenTypeJWT,
|
||||
AssertAccessTokenRole: true,
|
||||
AssertIDTokenRole: false,
|
||||
AssertIDTokenUserinfo: true,
|
||||
ClockSkew: 1 * time.Second,
|
||||
AdditionalOrigins: []string{"additional.origin"},
|
||||
AdditionalOrigins: database.StringArray{"additional.origin"},
|
||||
ComplianceProblems: nil,
|
||||
AllowedOrigins: []string{"https://redirect.to", "additional.origin"},
|
||||
AllowedOrigins: database.StringArray{"https://redirect.to", "additional.origin"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -549,19 +548,19 @@ func Test_AppsPrepare(t *testing.T) {
|
||||
"app-id",
|
||||
domain.OIDCVersionV1,
|
||||
"oidc-client-id",
|
||||
pq.StringArray{"https://redirect.to/me"},
|
||||
pq.Int32Array{int32(domain.OIDCResponseTypeIDTokenToken)},
|
||||
pq.Int32Array{int32(domain.OIDCGrantTypeImplicit)},
|
||||
database.StringArray{"https://redirect.to/me"},
|
||||
database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
domain.OIDCApplicationTypeUserAgent,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"post.logout.ch"},
|
||||
database.StringArray{"post.logout.ch"},
|
||||
false,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
1 * time.Second,
|
||||
pq.StringArray{"additional.origin"},
|
||||
database.StringArray{"additional.origin"},
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -583,21 +582,21 @@ func Test_AppsPrepare(t *testing.T) {
|
||||
OIDCConfig: &OIDCApp{
|
||||
Version: domain.OIDCVersionV1,
|
||||
ClientID: "oidc-client-id",
|
||||
RedirectURIs: []string{"https://redirect.to/me"},
|
||||
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeImplicit},
|
||||
RedirectURIs: database.StringArray{"https://redirect.to/me"},
|
||||
ResponseTypes: database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
AppType: domain.OIDCApplicationTypeUserAgent,
|
||||
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
||||
PostLogoutRedirectURIs: []string{"post.logout.ch"},
|
||||
PostLogoutRedirectURIs: database.StringArray{"post.logout.ch"},
|
||||
IsDevMode: false,
|
||||
AccessTokenType: domain.OIDCTokenTypeJWT,
|
||||
AssertAccessTokenRole: false,
|
||||
AssertIDTokenRole: true,
|
||||
AssertIDTokenUserinfo: true,
|
||||
ClockSkew: 1 * time.Second,
|
||||
AdditionalOrigins: []string{"additional.origin"},
|
||||
AdditionalOrigins: database.StringArray{"additional.origin"},
|
||||
ComplianceProblems: nil,
|
||||
AllowedOrigins: []string{"https://redirect.to", "additional.origin"},
|
||||
AllowedOrigins: database.StringArray{"https://redirect.to", "additional.origin"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -628,19 +627,19 @@ func Test_AppsPrepare(t *testing.T) {
|
||||
"app-id",
|
||||
domain.OIDCVersionV1,
|
||||
"oidc-client-id",
|
||||
pq.StringArray{"https://redirect.to/me"},
|
||||
pq.Int32Array{int32(domain.OIDCResponseTypeIDTokenToken)},
|
||||
pq.Int32Array{int32(domain.OIDCGrantTypeImplicit)},
|
||||
database.StringArray{"https://redirect.to/me"},
|
||||
database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
domain.OIDCApplicationTypeUserAgent,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"post.logout.ch"},
|
||||
database.StringArray{"post.logout.ch"},
|
||||
false,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1 * time.Second,
|
||||
pq.StringArray{"additional.origin"},
|
||||
database.StringArray{"additional.origin"},
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -662,21 +661,21 @@ func Test_AppsPrepare(t *testing.T) {
|
||||
OIDCConfig: &OIDCApp{
|
||||
Version: domain.OIDCVersionV1,
|
||||
ClientID: "oidc-client-id",
|
||||
RedirectURIs: []string{"https://redirect.to/me"},
|
||||
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeImplicit},
|
||||
RedirectURIs: database.StringArray{"https://redirect.to/me"},
|
||||
ResponseTypes: database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
AppType: domain.OIDCApplicationTypeUserAgent,
|
||||
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
||||
PostLogoutRedirectURIs: []string{"post.logout.ch"},
|
||||
PostLogoutRedirectURIs: database.StringArray{"post.logout.ch"},
|
||||
IsDevMode: false,
|
||||
AccessTokenType: domain.OIDCTokenTypeJWT,
|
||||
AssertAccessTokenRole: true,
|
||||
AssertIDTokenRole: true,
|
||||
AssertIDTokenUserinfo: true,
|
||||
ClockSkew: 1 * time.Second,
|
||||
AdditionalOrigins: []string{"additional.origin"},
|
||||
AdditionalOrigins: database.StringArray{"additional.origin"},
|
||||
ComplianceProblems: nil,
|
||||
AllowedOrigins: []string{"https://redirect.to", "additional.origin"},
|
||||
AllowedOrigins: database.StringArray{"https://redirect.to", "additional.origin"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -707,19 +706,19 @@ func Test_AppsPrepare(t *testing.T) {
|
||||
"oidc-app-id",
|
||||
domain.OIDCVersionV1,
|
||||
"oidc-client-id",
|
||||
pq.StringArray{"https://redirect.to/me"},
|
||||
pq.Int32Array{int32(domain.OIDCResponseTypeIDTokenToken)},
|
||||
pq.Int32Array{int32(domain.OIDCGrantTypeImplicit)},
|
||||
database.StringArray{"https://redirect.to/me"},
|
||||
database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
domain.OIDCApplicationTypeUserAgent,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"post.logout.ch"},
|
||||
database.StringArray{"post.logout.ch"},
|
||||
true,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1 * time.Second,
|
||||
pq.StringArray{"additional.origin"},
|
||||
database.StringArray{"additional.origin"},
|
||||
},
|
||||
{
|
||||
"api-app-id",
|
||||
@@ -772,21 +771,21 @@ func Test_AppsPrepare(t *testing.T) {
|
||||
OIDCConfig: &OIDCApp{
|
||||
Version: domain.OIDCVersionV1,
|
||||
ClientID: "oidc-client-id",
|
||||
RedirectURIs: []string{"https://redirect.to/me"},
|
||||
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeImplicit},
|
||||
RedirectURIs: database.StringArray{"https://redirect.to/me"},
|
||||
ResponseTypes: database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
AppType: domain.OIDCApplicationTypeUserAgent,
|
||||
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
||||
PostLogoutRedirectURIs: []string{"post.logout.ch"},
|
||||
PostLogoutRedirectURIs: database.StringArray{"post.logout.ch"},
|
||||
IsDevMode: true,
|
||||
AccessTokenType: domain.OIDCTokenTypeJWT,
|
||||
AssertAccessTokenRole: true,
|
||||
AssertIDTokenRole: true,
|
||||
AssertIDTokenUserinfo: true,
|
||||
ClockSkew: 1 * time.Second,
|
||||
AdditionalOrigins: []string{"additional.origin"},
|
||||
AdditionalOrigins: database.StringArray{"additional.origin"},
|
||||
ComplianceProblems: nil,
|
||||
AllowedOrigins: []string{"https://redirect.to", "additional.origin"},
|
||||
AllowedOrigins: database.StringArray{"https://redirect.to", "additional.origin"},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -993,19 +992,19 @@ func Test_AppPrepare(t *testing.T) {
|
||||
"app-id",
|
||||
domain.OIDCVersionV1,
|
||||
"oidc-client-id",
|
||||
pq.StringArray{"https://redirect.to/me"},
|
||||
pq.Int32Array{int32(domain.OIDCResponseTypeIDTokenToken)},
|
||||
pq.Int32Array{int32(domain.OIDCGrantTypeImplicit)},
|
||||
database.StringArray{"https://redirect.to/me"},
|
||||
database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
domain.OIDCApplicationTypeUserAgent,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"post.logout.ch"},
|
||||
database.StringArray{"post.logout.ch"},
|
||||
true,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1 * time.Second,
|
||||
pq.StringArray{"additional.origin"},
|
||||
database.StringArray{"additional.origin"},
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -1022,21 +1021,21 @@ func Test_AppPrepare(t *testing.T) {
|
||||
OIDCConfig: &OIDCApp{
|
||||
Version: domain.OIDCVersionV1,
|
||||
ClientID: "oidc-client-id",
|
||||
RedirectURIs: []string{"https://redirect.to/me"},
|
||||
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeImplicit},
|
||||
RedirectURIs: database.StringArray{"https://redirect.to/me"},
|
||||
ResponseTypes: database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
AppType: domain.OIDCApplicationTypeUserAgent,
|
||||
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
||||
PostLogoutRedirectURIs: []string{"post.logout.ch"},
|
||||
PostLogoutRedirectURIs: database.StringArray{"post.logout.ch"},
|
||||
IsDevMode: true,
|
||||
AccessTokenType: domain.OIDCTokenTypeJWT,
|
||||
AssertAccessTokenRole: true,
|
||||
AssertIDTokenRole: true,
|
||||
AssertIDTokenUserinfo: true,
|
||||
ClockSkew: 1 * time.Second,
|
||||
AdditionalOrigins: []string{"additional.origin"},
|
||||
AdditionalOrigins: database.StringArray{"additional.origin"},
|
||||
ComplianceProblems: nil,
|
||||
AllowedOrigins: []string{"https://redirect.to", "additional.origin"},
|
||||
AllowedOrigins: database.StringArray{"https://redirect.to", "additional.origin"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1065,19 +1064,19 @@ func Test_AppPrepare(t *testing.T) {
|
||||
"app-id",
|
||||
domain.OIDCVersionV1,
|
||||
"oidc-client-id",
|
||||
pq.StringArray{"https://redirect.to/me"},
|
||||
pq.Int32Array{int32(domain.OIDCResponseTypeIDTokenToken)},
|
||||
pq.Int32Array{int32(domain.OIDCGrantTypeImplicit)},
|
||||
database.StringArray{"https://redirect.to/me"},
|
||||
database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
domain.OIDCApplicationTypeUserAgent,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"post.logout.ch"},
|
||||
database.StringArray{"post.logout.ch"},
|
||||
false,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1 * time.Second,
|
||||
pq.StringArray{"additional.origin"},
|
||||
database.StringArray{"additional.origin"},
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -1094,21 +1093,21 @@ func Test_AppPrepare(t *testing.T) {
|
||||
OIDCConfig: &OIDCApp{
|
||||
Version: domain.OIDCVersionV1,
|
||||
ClientID: "oidc-client-id",
|
||||
RedirectURIs: []string{"https://redirect.to/me"},
|
||||
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeImplicit},
|
||||
RedirectURIs: database.StringArray{"https://redirect.to/me"},
|
||||
ResponseTypes: database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
AppType: domain.OIDCApplicationTypeUserAgent,
|
||||
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
||||
PostLogoutRedirectURIs: []string{"post.logout.ch"},
|
||||
PostLogoutRedirectURIs: database.StringArray{"post.logout.ch"},
|
||||
IsDevMode: false,
|
||||
AccessTokenType: domain.OIDCTokenTypeJWT,
|
||||
AssertAccessTokenRole: true,
|
||||
AssertIDTokenRole: true,
|
||||
AssertIDTokenUserinfo: true,
|
||||
ClockSkew: 1 * time.Second,
|
||||
AdditionalOrigins: []string{"additional.origin"},
|
||||
AdditionalOrigins: database.StringArray{"additional.origin"},
|
||||
ComplianceProblems: nil,
|
||||
AllowedOrigins: []string{"https://redirect.to", "additional.origin"},
|
||||
AllowedOrigins: database.StringArray{"https://redirect.to", "additional.origin"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1137,19 +1136,19 @@ func Test_AppPrepare(t *testing.T) {
|
||||
"app-id",
|
||||
domain.OIDCVersionV1,
|
||||
"oidc-client-id",
|
||||
pq.StringArray{"https://redirect.to/me"},
|
||||
pq.Int32Array{int32(domain.OIDCResponseTypeIDTokenToken)},
|
||||
pq.Int32Array{int32(domain.OIDCGrantTypeImplicit)},
|
||||
database.StringArray{"https://redirect.to/me"},
|
||||
database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
domain.OIDCApplicationTypeUserAgent,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"post.logout.ch"},
|
||||
database.StringArray{"post.logout.ch"},
|
||||
true,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
1 * time.Second,
|
||||
pq.StringArray{"additional.origin"},
|
||||
database.StringArray{"additional.origin"},
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -1166,21 +1165,21 @@ func Test_AppPrepare(t *testing.T) {
|
||||
OIDCConfig: &OIDCApp{
|
||||
Version: domain.OIDCVersionV1,
|
||||
ClientID: "oidc-client-id",
|
||||
RedirectURIs: []string{"https://redirect.to/me"},
|
||||
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeImplicit},
|
||||
RedirectURIs: database.StringArray{"https://redirect.to/me"},
|
||||
ResponseTypes: database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
AppType: domain.OIDCApplicationTypeUserAgent,
|
||||
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
||||
PostLogoutRedirectURIs: []string{"post.logout.ch"},
|
||||
PostLogoutRedirectURIs: database.StringArray{"post.logout.ch"},
|
||||
IsDevMode: true,
|
||||
AccessTokenType: domain.OIDCTokenTypeJWT,
|
||||
AssertAccessTokenRole: false,
|
||||
AssertIDTokenRole: true,
|
||||
AssertIDTokenUserinfo: true,
|
||||
ClockSkew: 1 * time.Second,
|
||||
AdditionalOrigins: []string{"additional.origin"},
|
||||
AdditionalOrigins: database.StringArray{"additional.origin"},
|
||||
ComplianceProblems: nil,
|
||||
AllowedOrigins: []string{"https://redirect.to", "additional.origin"},
|
||||
AllowedOrigins: database.StringArray{"https://redirect.to", "additional.origin"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1209,19 +1208,19 @@ func Test_AppPrepare(t *testing.T) {
|
||||
"app-id",
|
||||
domain.OIDCVersionV1,
|
||||
"oidc-client-id",
|
||||
pq.StringArray{"https://redirect.to/me"},
|
||||
pq.Int32Array{int32(domain.OIDCResponseTypeIDTokenToken)},
|
||||
pq.Int32Array{int32(domain.OIDCGrantTypeImplicit)},
|
||||
database.StringArray{"https://redirect.to/me"},
|
||||
database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
domain.OIDCApplicationTypeUserAgent,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"post.logout.ch"},
|
||||
database.StringArray{"post.logout.ch"},
|
||||
true,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
1 * time.Second,
|
||||
pq.StringArray{"additional.origin"},
|
||||
database.StringArray{"additional.origin"},
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -1238,21 +1237,21 @@ func Test_AppPrepare(t *testing.T) {
|
||||
OIDCConfig: &OIDCApp{
|
||||
Version: domain.OIDCVersionV1,
|
||||
ClientID: "oidc-client-id",
|
||||
RedirectURIs: []string{"https://redirect.to/me"},
|
||||
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeImplicit},
|
||||
RedirectURIs: database.StringArray{"https://redirect.to/me"},
|
||||
ResponseTypes: database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
AppType: domain.OIDCApplicationTypeUserAgent,
|
||||
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
||||
PostLogoutRedirectURIs: []string{"post.logout.ch"},
|
||||
PostLogoutRedirectURIs: database.StringArray{"post.logout.ch"},
|
||||
IsDevMode: true,
|
||||
AccessTokenType: domain.OIDCTokenTypeJWT,
|
||||
AssertAccessTokenRole: true,
|
||||
AssertIDTokenRole: false,
|
||||
AssertIDTokenUserinfo: true,
|
||||
ClockSkew: 1 * time.Second,
|
||||
AdditionalOrigins: []string{"additional.origin"},
|
||||
AdditionalOrigins: database.StringArray{"additional.origin"},
|
||||
ComplianceProblems: nil,
|
||||
AllowedOrigins: []string{"https://redirect.to", "additional.origin"},
|
||||
AllowedOrigins: database.StringArray{"https://redirect.to", "additional.origin"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1281,19 +1280,19 @@ func Test_AppPrepare(t *testing.T) {
|
||||
"app-id",
|
||||
domain.OIDCVersionV1,
|
||||
"oidc-client-id",
|
||||
pq.StringArray{"https://redirect.to/me"},
|
||||
pq.Int32Array{int32(domain.OIDCResponseTypeIDTokenToken)},
|
||||
pq.Int32Array{int32(domain.OIDCGrantTypeImplicit)},
|
||||
database.StringArray{"https://redirect.to/me"},
|
||||
database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
domain.OIDCApplicationTypeUserAgent,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"post.logout.ch"},
|
||||
database.StringArray{"post.logout.ch"},
|
||||
true,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
1 * time.Second,
|
||||
pq.StringArray{"additional.origin"},
|
||||
database.StringArray{"additional.origin"},
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -1310,21 +1309,21 @@ func Test_AppPrepare(t *testing.T) {
|
||||
OIDCConfig: &OIDCApp{
|
||||
Version: domain.OIDCVersionV1,
|
||||
ClientID: "oidc-client-id",
|
||||
RedirectURIs: []string{"https://redirect.to/me"},
|
||||
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeImplicit},
|
||||
RedirectURIs: database.StringArray{"https://redirect.to/me"},
|
||||
ResponseTypes: database.EnumArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
|
||||
GrantTypes: database.EnumArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
|
||||
AppType: domain.OIDCApplicationTypeUserAgent,
|
||||
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
||||
PostLogoutRedirectURIs: []string{"post.logout.ch"},
|
||||
PostLogoutRedirectURIs: database.StringArray{"post.logout.ch"},
|
||||
IsDevMode: true,
|
||||
AccessTokenType: domain.OIDCTokenTypeJWT,
|
||||
AssertAccessTokenRole: true,
|
||||
AssertIDTokenRole: true,
|
||||
AssertIDTokenUserinfo: false,
|
||||
ClockSkew: 1 * time.Second,
|
||||
AdditionalOrigins: []string{"additional.origin"},
|
||||
AdditionalOrigins: database.StringArray{"additional.origin"},
|
||||
ComplianceProblems: nil,
|
||||
AllowedOrigins: []string{"https://redirect.to", "additional.origin"},
|
||||
AllowedOrigins: database.StringArray{"https://redirect.to", "additional.origin"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1382,7 +1381,7 @@ func Test_AppIDsPrepare(t *testing.T) {
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
expectedAppIDsQuery,
|
||||
[]string{"client_id", "client_id"},
|
||||
database.StringArray{"client_id", "client_id"},
|
||||
[][]driver.Value{
|
||||
{
|
||||
"app-id",
|
||||
@@ -1399,7 +1398,7 @@ func Test_AppIDsPrepare(t *testing.T) {
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
expectedAppIDsQuery,
|
||||
[]string{"client_id", "client_id"},
|
||||
database.StringArray{"client_id", "client_id"},
|
||||
[][]driver.Value{
|
||||
{
|
||||
nil,
|
||||
@@ -1474,7 +1473,7 @@ func Test_ProjectIDByAppPrepare(t *testing.T) {
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
expectedProjectIDByAppQuery,
|
||||
[]string{"project_id"},
|
||||
database.StringArray{"project_id"},
|
||||
[]driver.Value{"project-id"},
|
||||
),
|
||||
},
|
||||
|
||||
@@ -194,7 +194,7 @@ func prepareLatestSequence() (sq.SelectBuilder, func(*sql.Row) (*LatestSequence,
|
||||
return sq.Select(
|
||||
CurrentSequenceColCurrentSequence.identifier(),
|
||||
CurrentSequenceColTimestamp.identifier()).
|
||||
From(currentSequencesTable.identifier() + " AS OF SYSTEM TIME '-1ms'").PlaceholderFormat(sq.Dollar),
|
||||
From(currentSequencesTable.identifier()).PlaceholderFormat(sq.Dollar),
|
||||
func(row *sql.Row) (*LatestSequence, error) {
|
||||
seq := new(LatestSequence)
|
||||
err := row.Scan(
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"database/sql"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
|
||||
@@ -117,7 +116,6 @@ func prepareInstanceMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Members,
|
||||
|
||||
for rows.Next() {
|
||||
member := new(Member)
|
||||
roles := pq.StringArray{}
|
||||
|
||||
var (
|
||||
preferredLoginName = sql.NullString{}
|
||||
@@ -135,7 +133,7 @@ func prepareInstanceMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Members,
|
||||
&member.Sequence,
|
||||
&member.ResourceOwner,
|
||||
&member.UserID,
|
||||
&roles,
|
||||
&member.Roles,
|
||||
&preferredLoginName,
|
||||
&email,
|
||||
&firstName,
|
||||
@@ -151,7 +149,6 @@ func prepareInstanceMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Members,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
member.Roles = roles
|
||||
member.PreferredLoginName = preferredLoginName.String
|
||||
member.Email = email.String
|
||||
member.FirstName = firstName.String
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -20,18 +20,18 @@ var (
|
||||
", members.user_id" +
|
||||
", members.roles" +
|
||||
", projections.login_names.login_name" +
|
||||
", projections.users2_humans.email" +
|
||||
", projections.users2_humans.first_name" +
|
||||
", projections.users2_humans.last_name" +
|
||||
", projections.users2_humans.display_name" +
|
||||
", projections.users2_machines.name" +
|
||||
", projections.users2_humans.avatar_key" +
|
||||
", projections.users3_humans.email" +
|
||||
", projections.users3_humans.first_name" +
|
||||
", projections.users3_humans.last_name" +
|
||||
", projections.users3_humans.display_name" +
|
||||
", projections.users3_machines.name" +
|
||||
", projections.users3_humans.avatar_key" +
|
||||
", COUNT(*) OVER () " +
|
||||
"FROM projections.instance_members as members " +
|
||||
"LEFT JOIN projections.users2_humans " +
|
||||
"ON members.user_id = projections.users2_humans.user_id " +
|
||||
"LEFT JOIN projections.users2_machines " +
|
||||
"ON members.user_id = projections.users2_machines.user_id " +
|
||||
"FROM projections.instance_members2 AS members " +
|
||||
"LEFT JOIN projections.users3_humans " +
|
||||
"ON members.user_id = projections.users3_humans.user_id " +
|
||||
"LEFT JOIN projections.users3_machines " +
|
||||
"ON members.user_id = projections.users3_machines.user_id " +
|
||||
"LEFT JOIN projections.login_names " +
|
||||
"ON members.user_id = projections.login_names.user_id " +
|
||||
"WHERE projections.login_names.is_primary = $1")
|
||||
@@ -92,7 +92,7 @@ func Test_IAMMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"first-name",
|
||||
@@ -115,7 +115,7 @@ func Test_IAMMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "[email protected]",
|
||||
FirstName: "first-name",
|
||||
@@ -140,7 +140,7 @@ func Test_IAMMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
nil,
|
||||
nil,
|
||||
@@ -163,7 +163,7 @@ func Test_IAMMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "",
|
||||
FirstName: "",
|
||||
@@ -188,7 +188,7 @@ func Test_IAMMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id-1",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"first-name",
|
||||
@@ -203,7 +203,7 @@ func Test_IAMMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id-2",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
nil,
|
||||
nil,
|
||||
@@ -226,7 +226,7 @@ func Test_IAMMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id-1",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "[email protected]",
|
||||
FirstName: "first-name",
|
||||
@@ -240,7 +240,7 @@ func Test_IAMMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id-2",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "",
|
||||
FirstName: "",
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"time"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
@@ -42,7 +42,7 @@ type OIDCIDP struct {
|
||||
ClientID string
|
||||
ClientSecret *crypto.CryptoValue
|
||||
Issuer string
|
||||
Scopes []string
|
||||
Scopes database.StringArray
|
||||
DisplayNameMapping domain.OIDCMappingField
|
||||
UsernameMapping domain.OIDCMappingField
|
||||
AuthorizationEndpoint string
|
||||
@@ -307,7 +307,7 @@ func prepareIDPByIDQuery() (sq.SelectBuilder, func(*sql.Row) (*IDP, error)) {
|
||||
oidcClientID := sql.NullString{}
|
||||
oidcClientSecret := new(crypto.CryptoValue)
|
||||
oidcIssuer := sql.NullString{}
|
||||
oidcScopes := pq.StringArray{}
|
||||
oidcScopes := database.StringArray{}
|
||||
oidcDisplayNameMapping := sql.NullInt32{}
|
||||
oidcUsernameMapping := sql.NullInt32{}
|
||||
oidcAuthorizationEndpoint := sql.NullString{}
|
||||
@@ -419,7 +419,7 @@ func prepareIDPsQuery() (sq.SelectBuilder, func(*sql.Rows) (*IDPs, error)) {
|
||||
oidcClientID := sql.NullString{}
|
||||
oidcClientSecret := new(crypto.CryptoValue)
|
||||
oidcIssuer := sql.NullString{}
|
||||
oidcScopes := pq.StringArray{}
|
||||
oidcScopes := database.StringArray{}
|
||||
oidcDisplayNameMapping := sql.NullInt32{}
|
||||
oidcUsernameMapping := sql.NullInt32{}
|
||||
oidcAuthorizationEndpoint := sql.NullString{}
|
||||
|
||||
@@ -12,12 +12,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
loginPolicyIDPLinksQuery = regexp.QuoteMeta(`SELECT projections.idp_login_policy_links.idp_id,` +
|
||||
` projections.idps.name,` +
|
||||
` projections.idps.type,` +
|
||||
loginPolicyIDPLinksQuery = regexp.QuoteMeta(`SELECT projections.idp_login_policy_links2.idp_id,` +
|
||||
` projections.idps2.name,` +
|
||||
` projections.idps2.type,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.idp_login_policy_links` +
|
||||
` LEFT JOIN projections.idps ON projections.idp_login_policy_links.idp_id = projections.idps.id`)
|
||||
` FROM projections.idp_login_policy_links2` +
|
||||
` LEFT JOIN projections.idps2 ON projections.idp_login_policy_links2.idp_id = projections.idps2.id`)
|
||||
loginPolicyIDPLinksCols = []string{
|
||||
"idp_id",
|
||||
"name",
|
||||
|
||||
+304
-305
@@ -8,9 +8,8 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
@@ -31,33 +30,33 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.idps.id,`+
|
||||
` projections.idps.resource_owner,`+
|
||||
` projections.idps.creation_date,`+
|
||||
` projections.idps.change_date,`+
|
||||
` projections.idps.sequence,`+
|
||||
` projections.idps.state,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.styling_type,`+
|
||||
` projections.idps.owner_type,`+
|
||||
` projections.idps.auto_register,`+
|
||||
` projections.idps_oidc_config.idp_id,`+
|
||||
` projections.idps_oidc_config.client_id,`+
|
||||
` projections.idps_oidc_config.client_secret,`+
|
||||
` projections.idps_oidc_config.issuer,`+
|
||||
` projections.idps_oidc_config.scopes,`+
|
||||
` projections.idps_oidc_config.display_name_mapping,`+
|
||||
` projections.idps_oidc_config.username_mapping,`+
|
||||
` projections.idps_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps_oidc_config.token_endpoint,`+
|
||||
` projections.idps_jwt_config.idp_id,`+
|
||||
` projections.idps_jwt_config.issuer,`+
|
||||
` projections.idps_jwt_config.keys_endpoint,`+
|
||||
` projections.idps_jwt_config.header_name,`+
|
||||
` projections.idps_jwt_config.endpoint`+
|
||||
` FROM projections.idps`+
|
||||
` LEFT JOIN projections.idps_oidc_config ON projections.idps.id = projections.idps_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps_jwt_config ON projections.idps.id = projections.idps_jwt_config.idp_id`),
|
||||
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`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -75,33 +74,33 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.idps.id,`+
|
||||
` projections.idps.resource_owner,`+
|
||||
` projections.idps.creation_date,`+
|
||||
` projections.idps.change_date,`+
|
||||
` projections.idps.sequence,`+
|
||||
` projections.idps.state,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.styling_type,`+
|
||||
` projections.idps.owner_type,`+
|
||||
` projections.idps.auto_register,`+
|
||||
` projections.idps_oidc_config.idp_id,`+
|
||||
` projections.idps_oidc_config.client_id,`+
|
||||
` projections.idps_oidc_config.client_secret,`+
|
||||
` projections.idps_oidc_config.issuer,`+
|
||||
` projections.idps_oidc_config.scopes,`+
|
||||
` projections.idps_oidc_config.display_name_mapping,`+
|
||||
` projections.idps_oidc_config.username_mapping,`+
|
||||
` projections.idps_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps_oidc_config.token_endpoint,`+
|
||||
` projections.idps_jwt_config.idp_id,`+
|
||||
` projections.idps_jwt_config.issuer,`+
|
||||
` projections.idps_jwt_config.keys_endpoint,`+
|
||||
` projections.idps_jwt_config.header_name,`+
|
||||
` projections.idps_jwt_config.endpoint`+
|
||||
` FROM projections.idps`+
|
||||
` LEFT JOIN projections.idps_oidc_config ON projections.idps.id = projections.idps_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps_jwt_config ON projections.idps.id = projections.idps_jwt_config.idp_id`),
|
||||
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",
|
||||
@@ -146,7 +145,7 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
"oidc-client-id",
|
||||
nil,
|
||||
"oidc-issuer",
|
||||
pq.StringArray{"scope"},
|
||||
database.StringArray{"scope"},
|
||||
domain.OIDCMappingFieldEmail,
|
||||
domain.OIDCMappingFieldPreferredLoginName,
|
||||
"auth.endpoint.ch",
|
||||
@@ -176,7 +175,7 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
ClientID: "oidc-client-id",
|
||||
ClientSecret: &crypto.CryptoValue{},
|
||||
Issuer: "oidc-issuer",
|
||||
Scopes: []string{"scope"},
|
||||
Scopes: database.StringArray{"scope"},
|
||||
DisplayNameMapping: domain.OIDCMappingFieldEmail,
|
||||
UsernameMapping: domain.OIDCMappingFieldPreferredLoginName,
|
||||
AuthorizationEndpoint: "auth.endpoint.ch",
|
||||
@@ -189,33 +188,33 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.idps.id,`+
|
||||
` projections.idps.resource_owner,`+
|
||||
` projections.idps.creation_date,`+
|
||||
` projections.idps.change_date,`+
|
||||
` projections.idps.sequence,`+
|
||||
` projections.idps.state,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.styling_type,`+
|
||||
` projections.idps.owner_type,`+
|
||||
` projections.idps.auto_register,`+
|
||||
` projections.idps_oidc_config.idp_id,`+
|
||||
` projections.idps_oidc_config.client_id,`+
|
||||
` projections.idps_oidc_config.client_secret,`+
|
||||
` projections.idps_oidc_config.issuer,`+
|
||||
` projections.idps_oidc_config.scopes,`+
|
||||
` projections.idps_oidc_config.display_name_mapping,`+
|
||||
` projections.idps_oidc_config.username_mapping,`+
|
||||
` projections.idps_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps_oidc_config.token_endpoint,`+
|
||||
` projections.idps_jwt_config.idp_id,`+
|
||||
` projections.idps_jwt_config.issuer,`+
|
||||
` projections.idps_jwt_config.keys_endpoint,`+
|
||||
` projections.idps_jwt_config.header_name,`+
|
||||
` projections.idps_jwt_config.endpoint`+
|
||||
` FROM projections.idps`+
|
||||
` LEFT JOIN projections.idps_oidc_config ON projections.idps.id = projections.idps_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps_jwt_config ON projections.idps.id = projections.idps_jwt_config.idp_id`),
|
||||
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",
|
||||
@@ -299,33 +298,33 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.idps.id,`+
|
||||
` projections.idps.resource_owner,`+
|
||||
` projections.idps.creation_date,`+
|
||||
` projections.idps.change_date,`+
|
||||
` projections.idps.sequence,`+
|
||||
` projections.idps.state,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.styling_type,`+
|
||||
` projections.idps.owner_type,`+
|
||||
` projections.idps.auto_register,`+
|
||||
` projections.idps_oidc_config.idp_id,`+
|
||||
` projections.idps_oidc_config.client_id,`+
|
||||
` projections.idps_oidc_config.client_secret,`+
|
||||
` projections.idps_oidc_config.issuer,`+
|
||||
` projections.idps_oidc_config.scopes,`+
|
||||
` projections.idps_oidc_config.display_name_mapping,`+
|
||||
` projections.idps_oidc_config.username_mapping,`+
|
||||
` projections.idps_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps_oidc_config.token_endpoint,`+
|
||||
` projections.idps_jwt_config.idp_id,`+
|
||||
` projections.idps_jwt_config.issuer,`+
|
||||
` projections.idps_jwt_config.keys_endpoint,`+
|
||||
` projections.idps_jwt_config.header_name,`+
|
||||
` projections.idps_jwt_config.endpoint`+
|
||||
` FROM projections.idps`+
|
||||
` LEFT JOIN projections.idps_oidc_config ON projections.idps.id = projections.idps_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps_jwt_config ON projections.idps.id = projections.idps_jwt_config.idp_id`),
|
||||
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",
|
||||
@@ -402,33 +401,33 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPByIDQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.idps.id,`+
|
||||
` projections.idps.resource_owner,`+
|
||||
` projections.idps.creation_date,`+
|
||||
` projections.idps.change_date,`+
|
||||
` projections.idps.sequence,`+
|
||||
` projections.idps.state,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.styling_type,`+
|
||||
` projections.idps.owner_type,`+
|
||||
` projections.idps.auto_register,`+
|
||||
` projections.idps_oidc_config.idp_id,`+
|
||||
` projections.idps_oidc_config.client_id,`+
|
||||
` projections.idps_oidc_config.client_secret,`+
|
||||
` projections.idps_oidc_config.issuer,`+
|
||||
` projections.idps_oidc_config.scopes,`+
|
||||
` projections.idps_oidc_config.display_name_mapping,`+
|
||||
` projections.idps_oidc_config.username_mapping,`+
|
||||
` projections.idps_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps_oidc_config.token_endpoint,`+
|
||||
` projections.idps_jwt_config.idp_id,`+
|
||||
` projections.idps_jwt_config.issuer,`+
|
||||
` projections.idps_jwt_config.keys_endpoint,`+
|
||||
` projections.idps_jwt_config.header_name,`+
|
||||
` projections.idps_jwt_config.endpoint`+
|
||||
` FROM projections.idps`+
|
||||
` LEFT JOIN projections.idps_oidc_config ON projections.idps.id = projections.idps_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps_jwt_config ON projections.idps.id = projections.idps_jwt_config.idp_id`),
|
||||
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`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@@ -445,34 +444,34 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.idps.id,`+
|
||||
` projections.idps.resource_owner,`+
|
||||
` projections.idps.creation_date,`+
|
||||
` projections.idps.change_date,`+
|
||||
` projections.idps.sequence,`+
|
||||
` projections.idps.state,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.styling_type,`+
|
||||
` projections.idps.owner_type,`+
|
||||
` projections.idps.auto_register,`+
|
||||
` projections.idps_oidc_config.idp_id,`+
|
||||
` projections.idps_oidc_config.client_id,`+
|
||||
` projections.idps_oidc_config.client_secret,`+
|
||||
` projections.idps_oidc_config.issuer,`+
|
||||
` projections.idps_oidc_config.scopes,`+
|
||||
` projections.idps_oidc_config.display_name_mapping,`+
|
||||
` projections.idps_oidc_config.username_mapping,`+
|
||||
` projections.idps_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps_oidc_config.token_endpoint,`+
|
||||
` projections.idps_jwt_config.idp_id,`+
|
||||
` projections.idps_jwt_config.issuer,`+
|
||||
` projections.idps_jwt_config.keys_endpoint,`+
|
||||
` projections.idps_jwt_config.header_name,`+
|
||||
` projections.idps_jwt_config.endpoint,`+
|
||||
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.idps`+
|
||||
` LEFT JOIN projections.idps_oidc_config ON projections.idps.id = projections.idps_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps_jwt_config ON projections.idps.id = projections.idps_jwt_config.idp_id`),
|
||||
` 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,
|
||||
),
|
||||
@@ -490,34 +489,34 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.idps.id,`+
|
||||
` projections.idps.resource_owner,`+
|
||||
` projections.idps.creation_date,`+
|
||||
` projections.idps.change_date,`+
|
||||
` projections.idps.sequence,`+
|
||||
` projections.idps.state,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.styling_type,`+
|
||||
` projections.idps.owner_type,`+
|
||||
` projections.idps.auto_register,`+
|
||||
` projections.idps_oidc_config.idp_id,`+
|
||||
` projections.idps_oidc_config.client_id,`+
|
||||
` projections.idps_oidc_config.client_secret,`+
|
||||
` projections.idps_oidc_config.issuer,`+
|
||||
` projections.idps_oidc_config.scopes,`+
|
||||
` projections.idps_oidc_config.display_name_mapping,`+
|
||||
` projections.idps_oidc_config.username_mapping,`+
|
||||
` projections.idps_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps_oidc_config.token_endpoint,`+
|
||||
` projections.idps_jwt_config.idp_id,`+
|
||||
` projections.idps_jwt_config.issuer,`+
|
||||
` projections.idps_jwt_config.keys_endpoint,`+
|
||||
` projections.idps_jwt_config.header_name,`+
|
||||
` projections.idps_jwt_config.endpoint,`+
|
||||
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.idps`+
|
||||
` LEFT JOIN projections.idps_oidc_config ON projections.idps.id = projections.idps_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps_jwt_config ON projections.idps.id = projections.idps_jwt_config.idp_id`),
|
||||
` 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",
|
||||
@@ -564,7 +563,7 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
"oidc-client-id",
|
||||
nil,
|
||||
"oidc-issuer",
|
||||
pq.StringArray{"scope"},
|
||||
database.StringArray{"scope"},
|
||||
domain.OIDCMappingFieldEmail,
|
||||
domain.OIDCMappingFieldPreferredLoginName,
|
||||
"auth.endpoint.ch",
|
||||
@@ -600,7 +599,7 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
ClientID: "oidc-client-id",
|
||||
ClientSecret: &crypto.CryptoValue{},
|
||||
Issuer: "oidc-issuer",
|
||||
Scopes: []string{"scope"},
|
||||
Scopes: database.StringArray{"scope"},
|
||||
DisplayNameMapping: domain.OIDCMappingFieldEmail,
|
||||
UsernameMapping: domain.OIDCMappingFieldPreferredLoginName,
|
||||
AuthorizationEndpoint: "auth.endpoint.ch",
|
||||
@@ -615,34 +614,34 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.idps.id,`+
|
||||
` projections.idps.resource_owner,`+
|
||||
` projections.idps.creation_date,`+
|
||||
` projections.idps.change_date,`+
|
||||
` projections.idps.sequence,`+
|
||||
` projections.idps.state,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.styling_type,`+
|
||||
` projections.idps.owner_type,`+
|
||||
` projections.idps.auto_register,`+
|
||||
` projections.idps_oidc_config.idp_id,`+
|
||||
` projections.idps_oidc_config.client_id,`+
|
||||
` projections.idps_oidc_config.client_secret,`+
|
||||
` projections.idps_oidc_config.issuer,`+
|
||||
` projections.idps_oidc_config.scopes,`+
|
||||
` projections.idps_oidc_config.display_name_mapping,`+
|
||||
` projections.idps_oidc_config.username_mapping,`+
|
||||
` projections.idps_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps_oidc_config.token_endpoint,`+
|
||||
` projections.idps_jwt_config.idp_id,`+
|
||||
` projections.idps_jwt_config.issuer,`+
|
||||
` projections.idps_jwt_config.keys_endpoint,`+
|
||||
` projections.idps_jwt_config.header_name,`+
|
||||
` projections.idps_jwt_config.endpoint,`+
|
||||
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.idps`+
|
||||
` LEFT JOIN projections.idps_oidc_config ON projections.idps.id = projections.idps_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps_jwt_config ON projections.idps.id = projections.idps_jwt_config.idp_id`),
|
||||
` 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",
|
||||
@@ -735,34 +734,34 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.idps.id,`+
|
||||
` projections.idps.resource_owner,`+
|
||||
` projections.idps.creation_date,`+
|
||||
` projections.idps.change_date,`+
|
||||
` projections.idps.sequence,`+
|
||||
` projections.idps.state,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.styling_type,`+
|
||||
` projections.idps.owner_type,`+
|
||||
` projections.idps.auto_register,`+
|
||||
` projections.idps_oidc_config.idp_id,`+
|
||||
` projections.idps_oidc_config.client_id,`+
|
||||
` projections.idps_oidc_config.client_secret,`+
|
||||
` projections.idps_oidc_config.issuer,`+
|
||||
` projections.idps_oidc_config.scopes,`+
|
||||
` projections.idps_oidc_config.display_name_mapping,`+
|
||||
` projections.idps_oidc_config.username_mapping,`+
|
||||
` projections.idps_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps_oidc_config.token_endpoint,`+
|
||||
` projections.idps_jwt_config.idp_id,`+
|
||||
` projections.idps_jwt_config.issuer,`+
|
||||
` projections.idps_jwt_config.keys_endpoint,`+
|
||||
` projections.idps_jwt_config.header_name,`+
|
||||
` projections.idps_jwt_config.endpoint,`+
|
||||
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.idps`+
|
||||
` LEFT JOIN projections.idps_oidc_config ON projections.idps.id = projections.idps_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps_jwt_config ON projections.idps.id = projections.idps_jwt_config.idp_id`),
|
||||
` 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",
|
||||
@@ -848,34 +847,34 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.idps.id,`+
|
||||
` projections.idps.resource_owner,`+
|
||||
` projections.idps.creation_date,`+
|
||||
` projections.idps.change_date,`+
|
||||
` projections.idps.sequence,`+
|
||||
` projections.idps.state,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.styling_type,`+
|
||||
` projections.idps.owner_type,`+
|
||||
` projections.idps.auto_register,`+
|
||||
` projections.idps_oidc_config.idp_id,`+
|
||||
` projections.idps_oidc_config.client_id,`+
|
||||
` projections.idps_oidc_config.client_secret,`+
|
||||
` projections.idps_oidc_config.issuer,`+
|
||||
` projections.idps_oidc_config.scopes,`+
|
||||
` projections.idps_oidc_config.display_name_mapping,`+
|
||||
` projections.idps_oidc_config.username_mapping,`+
|
||||
` projections.idps_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps_oidc_config.token_endpoint,`+
|
||||
` projections.idps_jwt_config.idp_id,`+
|
||||
` projections.idps_jwt_config.issuer,`+
|
||||
` projections.idps_jwt_config.keys_endpoint,`+
|
||||
` projections.idps_jwt_config.header_name,`+
|
||||
` projections.idps_jwt_config.endpoint,`+
|
||||
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.idps`+
|
||||
` LEFT JOIN projections.idps_oidc_config ON projections.idps.id = projections.idps_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps_jwt_config ON projections.idps.id = projections.idps_jwt_config.idp_id`),
|
||||
` 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",
|
||||
@@ -949,7 +948,7 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
"oidc-client-id",
|
||||
nil,
|
||||
"oidc-issuer",
|
||||
pq.StringArray{"scope"},
|
||||
database.StringArray{"scope"},
|
||||
domain.OIDCMappingFieldEmail,
|
||||
domain.OIDCMappingFieldPreferredLoginName,
|
||||
"auth.endpoint.ch",
|
||||
@@ -1025,7 +1024,7 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
ClientID: "oidc-client-id",
|
||||
ClientSecret: &crypto.CryptoValue{},
|
||||
Issuer: "oidc-issuer",
|
||||
Scopes: []string{"scope"},
|
||||
Scopes: database.StringArray{"scope"},
|
||||
DisplayNameMapping: domain.OIDCMappingFieldEmail,
|
||||
UsernameMapping: domain.OIDCMappingFieldPreferredLoginName,
|
||||
AuthorizationEndpoint: "auth.endpoint.ch",
|
||||
@@ -1059,34 +1058,34 @@ func Test_IDPPrepares(t *testing.T) {
|
||||
prepare: prepareIDPsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.idps.id,`+
|
||||
` projections.idps.resource_owner,`+
|
||||
` projections.idps.creation_date,`+
|
||||
` projections.idps.change_date,`+
|
||||
` projections.idps.sequence,`+
|
||||
` projections.idps.state,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.styling_type,`+
|
||||
` projections.idps.owner_type,`+
|
||||
` projections.idps.auto_register,`+
|
||||
` projections.idps_oidc_config.idp_id,`+
|
||||
` projections.idps_oidc_config.client_id,`+
|
||||
` projections.idps_oidc_config.client_secret,`+
|
||||
` projections.idps_oidc_config.issuer,`+
|
||||
` projections.idps_oidc_config.scopes,`+
|
||||
` projections.idps_oidc_config.display_name_mapping,`+
|
||||
` projections.idps_oidc_config.username_mapping,`+
|
||||
` projections.idps_oidc_config.authorization_endpoint,`+
|
||||
` projections.idps_oidc_config.token_endpoint,`+
|
||||
` projections.idps_jwt_config.idp_id,`+
|
||||
` projections.idps_jwt_config.issuer,`+
|
||||
` projections.idps_jwt_config.keys_endpoint,`+
|
||||
` projections.idps_jwt_config.header_name,`+
|
||||
` projections.idps_jwt_config.endpoint,`+
|
||||
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.idps`+
|
||||
` LEFT JOIN projections.idps_oidc_config ON projections.idps.id = projections.idps_oidc_config.idp_id`+
|
||||
` LEFT JOIN projections.idps_jwt_config ON projections.idps.id = projections.idps_jwt_config.idp_id`),
|
||||
` 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`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
||||
@@ -12,16 +12,16 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
idpUserLinksQuery = regexp.QuoteMeta(`SELECT projections.idp_user_links.idp_id,` +
|
||||
` projections.idp_user_links.user_id,` +
|
||||
` projections.idps.name,` +
|
||||
` projections.idp_user_links.external_user_id,` +
|
||||
` projections.idp_user_links.display_name,` +
|
||||
` projections.idps.type,` +
|
||||
` projections.idp_user_links.resource_owner,` +
|
||||
idpUserLinksQuery = regexp.QuoteMeta(`SELECT projections.idp_user_links2.idp_id,` +
|
||||
` projections.idp_user_links2.user_id,` +
|
||||
` projections.idps2.name,` +
|
||||
` projections.idp_user_links2.external_user_id,` +
|
||||
` projections.idp_user_links2.display_name,` +
|
||||
` projections.idps2.type,` +
|
||||
` projections.idp_user_links2.resource_owner,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.idp_user_links` +
|
||||
` LEFT JOIN projections.idps ON projections.idp_user_links.idp_id = projections.idps.id`)
|
||||
` FROM projections.idp_user_links2` +
|
||||
` LEFT JOIN projections.idps2 ON projections.idp_user_links2.idp_id = projections.idps2.id`)
|
||||
idpUserLinksCols = []string{
|
||||
"idp_id",
|
||||
"user_id",
|
||||
|
||||
+66
-66
@@ -31,18 +31,18 @@ func Test_KeyPrepares(t *testing.T) {
|
||||
prepare: preparePublicKeysQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.keys.id,`+
|
||||
` projections.keys.creation_date,`+
|
||||
` projections.keys.change_date,`+
|
||||
` projections.keys.sequence,`+
|
||||
` projections.keys.resource_owner,`+
|
||||
` projections.keys.algorithm,`+
|
||||
` projections.keys.use,`+
|
||||
` projections.keys_public.expiry,`+
|
||||
` projections.keys_public.key,`+
|
||||
regexp.QuoteMeta(`SELECT projections.keys2.id,`+
|
||||
` projections.keys2.creation_date,`+
|
||||
` projections.keys2.change_date,`+
|
||||
` projections.keys2.sequence,`+
|
||||
` projections.keys2.resource_owner,`+
|
||||
` projections.keys2.algorithm,`+
|
||||
` projections.keys2.use,`+
|
||||
` projections.keys2_public.expiry,`+
|
||||
` projections.keys2_public.key,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.keys`+
|
||||
` LEFT JOIN projections.keys_public ON projections.keys.id = projections.keys_public.id`),
|
||||
` FROM projections.keys2`+
|
||||
` LEFT JOIN projections.keys2_public ON projections.keys2.id = projections.keys2_public.id`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -60,18 +60,18 @@ func Test_KeyPrepares(t *testing.T) {
|
||||
prepare: preparePublicKeysQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.keys.id,`+
|
||||
` projections.keys.creation_date,`+
|
||||
` projections.keys.change_date,`+
|
||||
` projections.keys.sequence,`+
|
||||
` projections.keys.resource_owner,`+
|
||||
` projections.keys.algorithm,`+
|
||||
` projections.keys.use,`+
|
||||
` projections.keys_public.expiry,`+
|
||||
` projections.keys_public.key,`+
|
||||
regexp.QuoteMeta(`SELECT projections.keys2.id,`+
|
||||
` projections.keys2.creation_date,`+
|
||||
` projections.keys2.change_date,`+
|
||||
` projections.keys2.sequence,`+
|
||||
` projections.keys2.resource_owner,`+
|
||||
` projections.keys2.algorithm,`+
|
||||
` projections.keys2.use,`+
|
||||
` projections.keys2_public.expiry,`+
|
||||
` projections.keys2_public.key,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.keys`+
|
||||
` LEFT JOIN projections.keys_public ON projections.keys.id = projections.keys_public.id`),
|
||||
` FROM projections.keys2`+
|
||||
` LEFT JOIN projections.keys2_public ON projections.keys2.id = projections.keys2_public.id`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -128,18 +128,18 @@ func Test_KeyPrepares(t *testing.T) {
|
||||
prepare: preparePublicKeysQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.keys.id,`+
|
||||
` projections.keys.creation_date,`+
|
||||
` projections.keys.change_date,`+
|
||||
` projections.keys.sequence,`+
|
||||
` projections.keys.resource_owner,`+
|
||||
` projections.keys.algorithm,`+
|
||||
` projections.keys.use,`+
|
||||
` projections.keys_public.expiry,`+
|
||||
` projections.keys_public.key,`+
|
||||
regexp.QuoteMeta(`SELECT projections.keys2.id,`+
|
||||
` projections.keys2.creation_date,`+
|
||||
` projections.keys2.change_date,`+
|
||||
` projections.keys2.sequence,`+
|
||||
` projections.keys2.resource_owner,`+
|
||||
` projections.keys2.algorithm,`+
|
||||
` projections.keys2.use,`+
|
||||
` projections.keys2_public.expiry,`+
|
||||
` projections.keys2_public.key,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.keys`+
|
||||
` LEFT JOIN projections.keys_public ON projections.keys.id = projections.keys_public.id`),
|
||||
` FROM projections.keys2`+
|
||||
` LEFT JOIN projections.keys2_public ON projections.keys2.id = projections.keys2_public.id`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@@ -156,18 +156,18 @@ func Test_KeyPrepares(t *testing.T) {
|
||||
prepare: preparePrivateKeysQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.keys.id,`+
|
||||
` projections.keys.creation_date,`+
|
||||
` projections.keys.change_date,`+
|
||||
` projections.keys.sequence,`+
|
||||
` projections.keys.resource_owner,`+
|
||||
` projections.keys.algorithm,`+
|
||||
` projections.keys.use,`+
|
||||
` projections.keys_private.expiry,`+
|
||||
` projections.keys_private.key,`+
|
||||
regexp.QuoteMeta(`SELECT projections.keys2.id,`+
|
||||
` projections.keys2.creation_date,`+
|
||||
` projections.keys2.change_date,`+
|
||||
` projections.keys2.sequence,`+
|
||||
` projections.keys2.resource_owner,`+
|
||||
` projections.keys2.algorithm,`+
|
||||
` projections.keys2.use,`+
|
||||
` projections.keys2_private.expiry,`+
|
||||
` projections.keys2_private.key,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.keys`+
|
||||
` LEFT JOIN projections.keys_private ON projections.keys.id = projections.keys_private.id`),
|
||||
` FROM projections.keys2`+
|
||||
` LEFT JOIN projections.keys2_private ON projections.keys2.id = projections.keys2_private.id`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -185,18 +185,18 @@ func Test_KeyPrepares(t *testing.T) {
|
||||
prepare: preparePrivateKeysQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.keys.id,`+
|
||||
` projections.keys.creation_date,`+
|
||||
` projections.keys.change_date,`+
|
||||
` projections.keys.sequence,`+
|
||||
` projections.keys.resource_owner,`+
|
||||
` projections.keys.algorithm,`+
|
||||
` projections.keys.use,`+
|
||||
` projections.keys_private.expiry,`+
|
||||
` projections.keys_private.key,`+
|
||||
regexp.QuoteMeta(`SELECT projections.keys2.id,`+
|
||||
` projections.keys2.creation_date,`+
|
||||
` projections.keys2.change_date,`+
|
||||
` projections.keys2.sequence,`+
|
||||
` projections.keys2.resource_owner,`+
|
||||
` projections.keys2.algorithm,`+
|
||||
` projections.keys2.use,`+
|
||||
` projections.keys2_private.expiry,`+
|
||||
` projections.keys2_private.key,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.keys`+
|
||||
` LEFT JOIN projections.keys_private ON projections.keys.id = projections.keys_private.id`),
|
||||
` FROM projections.keys2`+
|
||||
` LEFT JOIN projections.keys2_private ON projections.keys2.id = projections.keys2_private.id`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -255,18 +255,18 @@ func Test_KeyPrepares(t *testing.T) {
|
||||
prepare: preparePrivateKeysQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.keys.id,`+
|
||||
` projections.keys.creation_date,`+
|
||||
` projections.keys.change_date,`+
|
||||
` projections.keys.sequence,`+
|
||||
` projections.keys.resource_owner,`+
|
||||
` projections.keys.algorithm,`+
|
||||
` projections.keys.use,`+
|
||||
` projections.keys_private.expiry,`+
|
||||
` projections.keys_private.key,`+
|
||||
regexp.QuoteMeta(`SELECT projections.keys2.id,`+
|
||||
` projections.keys2.creation_date,`+
|
||||
` projections.keys2.change_date,`+
|
||||
` projections.keys2.sequence,`+
|
||||
` projections.keys2.resource_owner,`+
|
||||
` projections.keys2.algorithm,`+
|
||||
` projections.keys2.use,`+
|
||||
` projections.keys2_private.expiry,`+
|
||||
` projections.keys2_private.key,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.keys`+
|
||||
` LEFT JOIN projections.keys_private ON projections.keys.id = projections.keys_private.id`),
|
||||
` FROM projections.keys2`+
|
||||
` LEFT JOIN projections.keys2_private ON projections.keys2.id = projections.keys2_private.id`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"time"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/query/projection"
|
||||
@@ -24,8 +24,8 @@ type LoginPolicy struct {
|
||||
AllowUsernamePassword bool
|
||||
AllowExternalIDPs bool
|
||||
ForceMFA bool
|
||||
SecondFactors []domain.SecondFactorType
|
||||
MultiFactors []domain.MultiFactorType
|
||||
SecondFactors database.EnumArray[domain.SecondFactorType]
|
||||
MultiFactors database.EnumArray[domain.MultiFactorType]
|
||||
PasswordlessType domain.PasswordlessType
|
||||
IsDefault bool
|
||||
HidePasswordReset bool
|
||||
@@ -41,12 +41,12 @@ type LoginPolicy struct {
|
||||
|
||||
type SecondFactors struct {
|
||||
SearchResponse
|
||||
Factors []domain.SecondFactorType
|
||||
Factors database.EnumArray[domain.SecondFactorType]
|
||||
}
|
||||
|
||||
type MultiFactors struct {
|
||||
SearchResponse
|
||||
Factors []domain.MultiFactorType
|
||||
Factors database.EnumArray[domain.MultiFactorType]
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -320,8 +320,6 @@ func prepareLoginPolicyQuery() (sq.SelectBuilder, func(*sql.Rows) (*LoginPolicy,
|
||||
PlaceholderFormat(sq.Dollar),
|
||||
func(rows *sql.Rows) (*LoginPolicy, error) {
|
||||
p := new(LoginPolicy)
|
||||
secondFactors := pq.Int32Array{}
|
||||
multiFactors := pq.Int32Array{}
|
||||
defaultRedirectURI := sql.NullString{}
|
||||
links := make([]*IDPLoginPolicyLink, 0)
|
||||
for rows.Next() {
|
||||
@@ -339,8 +337,8 @@ func prepareLoginPolicyQuery() (sq.SelectBuilder, func(*sql.Rows) (*LoginPolicy,
|
||||
&p.AllowUsernamePassword,
|
||||
&p.AllowExternalIDPs,
|
||||
&p.ForceMFA,
|
||||
&secondFactors,
|
||||
&multiFactors,
|
||||
&p.SecondFactors,
|
||||
&p.MultiFactors,
|
||||
&p.PasswordlessType,
|
||||
&p.IsDefault,
|
||||
&p.HidePasswordReset,
|
||||
@@ -376,14 +374,6 @@ func prepareLoginPolicyQuery() (sq.SelectBuilder, func(*sql.Rows) (*LoginPolicy,
|
||||
return nil, errors.ThrowNotFound(nil, "QUERY-QsUBJ", "Errors.LoginPolicy.NotFound")
|
||||
}
|
||||
p.DefaultRedirectURI = defaultRedirectURI.String
|
||||
p.MultiFactors = make([]domain.MultiFactorType, len(multiFactors))
|
||||
for i, mfa := range multiFactors {
|
||||
p.MultiFactors[i] = domain.MultiFactorType(mfa)
|
||||
}
|
||||
p.SecondFactors = make([]domain.SecondFactorType, len(secondFactors))
|
||||
for i, mfa := range secondFactors {
|
||||
p.SecondFactors[i] = domain.SecondFactorType(mfa)
|
||||
}
|
||||
p.IDPLinks = links
|
||||
return p, nil
|
||||
}
|
||||
@@ -395,9 +385,8 @@ func prepareLoginPolicy2FAsQuery() (sq.SelectBuilder, func(*sql.Row) (*SecondFac
|
||||
).From(loginPolicyTable.identifier()).PlaceholderFormat(sq.Dollar),
|
||||
func(row *sql.Row) (*SecondFactors, error) {
|
||||
p := new(SecondFactors)
|
||||
secondFactors := pq.Int32Array{}
|
||||
err := row.Scan(
|
||||
&secondFactors,
|
||||
&p.Factors,
|
||||
)
|
||||
if err != nil {
|
||||
if errs.Is(err, sql.ErrNoRows) {
|
||||
@@ -406,11 +395,7 @@ func prepareLoginPolicy2FAsQuery() (sq.SelectBuilder, func(*sql.Row) (*SecondFac
|
||||
return nil, errors.ThrowInternal(err, "QUERY-Mr6H3", "Errors.Internal")
|
||||
}
|
||||
|
||||
p.Factors = make([]domain.SecondFactorType, len(secondFactors))
|
||||
p.Count = uint64(len(secondFactors))
|
||||
for i, mfa := range secondFactors {
|
||||
p.Factors[i] = domain.SecondFactorType(mfa)
|
||||
}
|
||||
p.Count = uint64(len(p.Factors))
|
||||
return p, nil
|
||||
}
|
||||
}
|
||||
@@ -421,9 +406,8 @@ func prepareLoginPolicyMFAsQuery() (sq.SelectBuilder, func(*sql.Row) (*MultiFact
|
||||
).From(loginPolicyTable.identifier()).PlaceholderFormat(sq.Dollar),
|
||||
func(row *sql.Row) (*MultiFactors, error) {
|
||||
p := new(MultiFactors)
|
||||
multiFactors := pq.Int32Array{}
|
||||
err := row.Scan(
|
||||
&multiFactors,
|
||||
&p.Factors,
|
||||
)
|
||||
if err != nil {
|
||||
if errs.Is(err, sql.ErrNoRows) {
|
||||
@@ -432,11 +416,7 @@ func prepareLoginPolicyMFAsQuery() (sq.SelectBuilder, func(*sql.Row) (*MultiFact
|
||||
return nil, errors.ThrowInternal(err, "QUERY-Mr6H3", "Errors.Internal")
|
||||
}
|
||||
|
||||
p.Factors = make([]domain.MultiFactorType, len(multiFactors))
|
||||
p.Count = uint64(len(multiFactors))
|
||||
for i, mfa := range multiFactors {
|
||||
p.Factors[i] = domain.MultiFactorType(mfa)
|
||||
}
|
||||
p.Count = uint64(len(p.Factors))
|
||||
return p, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
@@ -51,14 +50,14 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
` projections.login_policies.mfa_init_skip_lifetime,`+
|
||||
` projections.login_policies.second_factor_check_lifetime,`+
|
||||
` projections.login_policies.multi_factor_check_lifetime,`+
|
||||
` projections.idp_login_policy_links.idp_id,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.type`+
|
||||
` projections.idp_login_policy_links2.idp_id,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.type`+
|
||||
` FROM projections.login_policies`+
|
||||
` LEFT JOIN projections.idp_login_policy_links ON `+
|
||||
` projections.login_policies.aggregate_id = projections.idp_login_policy_links.aggregate_id`+
|
||||
` LEFT JOIN projections.idps ON`+
|
||||
` projections.idp_login_policy_links.idp_id = projections.idps.id`),
|
||||
` LEFT JOIN projections.idp_login_policy_links2 ON `+
|
||||
` projections.login_policies.aggregate_id = projections.idp_login_policy_links2.aggregate_id`+
|
||||
` LEFT JOIN projections.idps2 ON`+
|
||||
` projections.idp_login_policy_links2.idp_id = projections.idps2.id`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -96,14 +95,14 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
` projections.login_policies.mfa_init_skip_lifetime,`+
|
||||
` projections.login_policies.second_factor_check_lifetime,`+
|
||||
` projections.login_policies.multi_factor_check_lifetime,`+
|
||||
` projections.idp_login_policy_links.idp_id,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.type`+
|
||||
` projections.idp_login_policy_links2.idp_id,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.type`+
|
||||
` FROM projections.login_policies`+
|
||||
` LEFT JOIN projections.idp_login_policy_links ON `+
|
||||
` projections.login_policies.aggregate_id = projections.idp_login_policy_links.aggregate_id`+
|
||||
` LEFT JOIN projections.idps ON`+
|
||||
` projections.idp_login_policy_links.idp_id = projections.idps.id`),
|
||||
` LEFT JOIN projections.idp_login_policy_links2 ON `+
|
||||
` projections.login_policies.aggregate_id = projections.idp_login_policy_links2.aggregate_id`+
|
||||
` LEFT JOIN projections.idps2 ON`+
|
||||
` projections.idp_login_policy_links2.idp_id = projections.idps2.id`),
|
||||
[]string{
|
||||
"aggregate_id",
|
||||
"creation_date",
|
||||
@@ -138,8 +137,8 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
pq.Int32Array{int32(domain.SecondFactorTypeOTP)},
|
||||
pq.Int32Array{int32(domain.MultiFactorTypeU2FWithPIN)},
|
||||
database.EnumArray[domain.SecondFactorType]{domain.SecondFactorTypeOTP},
|
||||
database.EnumArray[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
|
||||
domain.PasswordlessTypeAllowed,
|
||||
true,
|
||||
true,
|
||||
@@ -165,8 +164,8 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
AllowUsernamePassword: true,
|
||||
AllowExternalIDPs: true,
|
||||
ForceMFA: true,
|
||||
SecondFactors: []domain.SecondFactorType{domain.SecondFactorTypeOTP},
|
||||
MultiFactors: []domain.MultiFactorType{domain.MultiFactorTypeU2FWithPIN},
|
||||
SecondFactors: database.EnumArray[domain.SecondFactorType]{domain.SecondFactorTypeOTP},
|
||||
MultiFactors: database.EnumArray[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
|
||||
PasswordlessType: domain.PasswordlessTypeAllowed,
|
||||
IsDefault: true,
|
||||
HidePasswordReset: true,
|
||||
@@ -211,14 +210,14 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
` projections.login_policies.mfa_init_skip_lifetime,`+
|
||||
` projections.login_policies.second_factor_check_lifetime,`+
|
||||
` projections.login_policies.multi_factor_check_lifetime,`+
|
||||
` projections.idp_login_policy_links.idp_id,`+
|
||||
` projections.idps.name,`+
|
||||
` projections.idps.type`+
|
||||
` projections.idp_login_policy_links2.idp_id,`+
|
||||
` projections.idps2.name,`+
|
||||
` projections.idps2.type`+
|
||||
` FROM projections.login_policies`+
|
||||
` LEFT JOIN projections.idp_login_policy_links ON `+
|
||||
` projections.login_policies.aggregate_id = projections.idp_login_policy_links.aggregate_id`+
|
||||
` LEFT JOIN projections.idps ON`+
|
||||
` projections.idp_login_policy_links.idp_id = projections.idps.id`),
|
||||
` LEFT JOIN projections.idp_login_policy_links2 ON `+
|
||||
` projections.login_policies.aggregate_id = projections.idp_login_policy_links2.aggregate_id`+
|
||||
` LEFT JOIN projections.idps2 ON`+
|
||||
` projections.idp_login_policy_links2.idp_id = projections.idps2.id`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@@ -262,7 +261,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
"second_factors",
|
||||
},
|
||||
[]driver.Value{
|
||||
pq.Int32Array{int32(domain.SecondFactorTypeOTP)},
|
||||
database.EnumArray[domain.SecondFactorType]{domain.SecondFactorTypeOTP},
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -270,7 +269,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
SearchResponse: SearchResponse{
|
||||
Count: 1,
|
||||
},
|
||||
Factors: []domain.SecondFactorType{domain.SecondFactorTypeOTP},
|
||||
Factors: database.EnumArray[domain.SecondFactorType]{domain.SecondFactorTypeOTP},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -284,11 +283,11 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
"second_factors",
|
||||
},
|
||||
[]driver.Value{
|
||||
pq.Int32Array{},
|
||||
database.EnumArray[domain.SecondFactorType]{},
|
||||
},
|
||||
),
|
||||
},
|
||||
object: &SecondFactors{Factors: []domain.SecondFactorType{}},
|
||||
object: &SecondFactors{Factors: database.EnumArray[domain.SecondFactorType]{}},
|
||||
},
|
||||
{
|
||||
name: "prepareLoginPolicy2FAsQuery sql err",
|
||||
@@ -308,7 +307,6 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
},
|
||||
object: nil,
|
||||
},
|
||||
|
||||
{
|
||||
name: "prepareLoginPolicyMFAsQuery no result",
|
||||
prepare: prepareLoginPolicyMFAsQuery,
|
||||
@@ -341,7 +339,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
"multi_factors",
|
||||
},
|
||||
[]driver.Value{
|
||||
pq.Int32Array{int32(domain.MultiFactorTypeU2FWithPIN)},
|
||||
database.EnumArray[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -349,7 +347,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
SearchResponse: SearchResponse{
|
||||
Count: 1,
|
||||
},
|
||||
Factors: []domain.MultiFactorType{domain.MultiFactorTypeU2FWithPIN},
|
||||
Factors: database.EnumArray[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -363,11 +361,11 @@ func Test_LoginPolicyPrepares(t *testing.T) {
|
||||
"multi_factors",
|
||||
},
|
||||
[]driver.Value{
|
||||
pq.Int32Array{},
|
||||
database.EnumArray[domain.MultiFactorType]{},
|
||||
},
|
||||
),
|
||||
},
|
||||
object: &MultiFactors{Factors: []domain.MultiFactorType{}},
|
||||
object: &MultiFactors{Factors: database.EnumArray[domain.MultiFactorType]{}},
|
||||
},
|
||||
{
|
||||
name: "prepareLoginPolicyMFAsQuery sql err",
|
||||
|
||||
@@ -3,6 +3,7 @@ package query
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/query/projection"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
@@ -52,7 +53,7 @@ type Member struct {
|
||||
ResourceOwner string
|
||||
|
||||
UserID string
|
||||
Roles []string
|
||||
Roles database.StringArray
|
||||
PreferredLoginName string
|
||||
Email string
|
||||
FirstName string
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/query/projection"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -120,7 +119,6 @@ func prepareOrgMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Members, erro
|
||||
member := new(Member)
|
||||
|
||||
var (
|
||||
roles = pq.StringArray{}
|
||||
preferredLoginName = sql.NullString{}
|
||||
email = sql.NullString{}
|
||||
firstName = sql.NullString{}
|
||||
@@ -136,7 +134,7 @@ func prepareOrgMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Members, erro
|
||||
&member.Sequence,
|
||||
&member.ResourceOwner,
|
||||
&member.UserID,
|
||||
&roles,
|
||||
&member.Roles,
|
||||
&preferredLoginName,
|
||||
&email,
|
||||
&firstName,
|
||||
@@ -152,7 +150,6 @@ func prepareOrgMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Members, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
member.Roles = roles
|
||||
member.PreferredLoginName = preferredLoginName.String
|
||||
member.Email = email.String
|
||||
member.FirstName = firstName.String
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -20,18 +20,18 @@ var (
|
||||
", members.user_id" +
|
||||
", members.roles" +
|
||||
", projections.login_names.login_name" +
|
||||
", projections.users2_humans.email" +
|
||||
", projections.users2_humans.first_name" +
|
||||
", projections.users2_humans.last_name" +
|
||||
", projections.users2_humans.display_name" +
|
||||
", projections.users2_machines.name" +
|
||||
", projections.users2_humans.avatar_key" +
|
||||
", projections.users3_humans.email" +
|
||||
", projections.users3_humans.first_name" +
|
||||
", projections.users3_humans.last_name" +
|
||||
", projections.users3_humans.display_name" +
|
||||
", projections.users3_machines.name" +
|
||||
", projections.users3_humans.avatar_key" +
|
||||
", COUNT(*) OVER () " +
|
||||
"FROM projections.org_members as members " +
|
||||
"LEFT JOIN projections.users2_humans " +
|
||||
"ON members.user_id = projections.users2_humans.user_id " +
|
||||
"LEFT JOIN projections.users2_machines " +
|
||||
"ON members.user_id = projections.users2_machines.user_id " +
|
||||
"FROM projections.org_members2 AS members " +
|
||||
"LEFT JOIN projections.users3_humans " +
|
||||
"ON members.user_id = projections.users3_humans.user_id " +
|
||||
"LEFT JOIN projections.users3_machines " +
|
||||
"ON members.user_id = projections.users3_machines.user_id " +
|
||||
"LEFT JOIN projections.login_names " +
|
||||
"ON members.user_id = projections.login_names.user_id " +
|
||||
"WHERE projections.login_names.is_primary = $1")
|
||||
@@ -92,7 +92,7 @@ func Test_OrgMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"first-name",
|
||||
@@ -115,7 +115,7 @@ func Test_OrgMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "[email protected]",
|
||||
FirstName: "first-name",
|
||||
@@ -140,7 +140,7 @@ func Test_OrgMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
nil,
|
||||
nil,
|
||||
@@ -163,7 +163,7 @@ func Test_OrgMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "",
|
||||
FirstName: "",
|
||||
@@ -188,7 +188,7 @@ func Test_OrgMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id-1",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"first-name",
|
||||
@@ -203,7 +203,7 @@ func Test_OrgMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id-2",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
nil,
|
||||
nil,
|
||||
@@ -226,7 +226,7 @@ func Test_OrgMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id-1",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "[email protected]",
|
||||
FirstName: "first-name",
|
||||
@@ -240,7 +240,7 @@ func Test_OrgMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id-2",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "",
|
||||
FirstName: "",
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"time"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/query/projection"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
@@ -92,7 +92,7 @@ type ProjectGrant struct {
|
||||
ProjectName string
|
||||
GrantedOrgID string
|
||||
OrgName string
|
||||
GrantedRoleKeys pq.StringArray
|
||||
GrantedRoleKeys database.StringArray
|
||||
ResourceOwnerName string
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"database/sql"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
|
||||
@@ -133,7 +132,6 @@ func prepareProjectGrantMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Memb
|
||||
|
||||
for rows.Next() {
|
||||
member := new(Member)
|
||||
roles := pq.StringArray{}
|
||||
|
||||
var (
|
||||
preferredLoginName = sql.NullString{}
|
||||
@@ -151,7 +149,7 @@ func prepareProjectGrantMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Memb
|
||||
&member.Sequence,
|
||||
&member.ResourceOwner,
|
||||
&member.UserID,
|
||||
&roles,
|
||||
&member.Roles,
|
||||
&preferredLoginName,
|
||||
&email,
|
||||
&firstName,
|
||||
@@ -167,7 +165,6 @@ func prepareProjectGrantMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Memb
|
||||
return nil, err
|
||||
}
|
||||
|
||||
member.Roles = roles
|
||||
member.PreferredLoginName = preferredLoginName.String
|
||||
member.Email = email.String
|
||||
member.FirstName = firstName.String
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -20,22 +20,22 @@ var (
|
||||
", members.user_id" +
|
||||
", members.roles" +
|
||||
", projections.login_names.login_name" +
|
||||
", projections.users2_humans.email" +
|
||||
", projections.users2_humans.first_name" +
|
||||
", projections.users2_humans.last_name" +
|
||||
", projections.users2_humans.display_name" +
|
||||
", projections.users2_machines.name" +
|
||||
", projections.users2_humans.avatar_key" +
|
||||
", projections.users3_humans.email" +
|
||||
", projections.users3_humans.first_name" +
|
||||
", projections.users3_humans.last_name" +
|
||||
", projections.users3_humans.display_name" +
|
||||
", projections.users3_machines.name" +
|
||||
", projections.users3_humans.avatar_key" +
|
||||
", COUNT(*) OVER () " +
|
||||
"FROM projections.project_grant_members as members " +
|
||||
"LEFT JOIN projections.users2_humans " +
|
||||
"ON members.user_id = projections.users2_humans.user_id " +
|
||||
"LEFT JOIN projections.users2_machines " +
|
||||
"ON members.user_id = projections.users2_machines.user_id " +
|
||||
"FROM projections.project_grant_members2 AS members " +
|
||||
"LEFT JOIN projections.users3_humans " +
|
||||
"ON members.user_id = projections.users3_humans.user_id " +
|
||||
"LEFT JOIN projections.users3_machines " +
|
||||
"ON members.user_id = projections.users3_machines.user_id " +
|
||||
"LEFT JOIN projections.login_names " +
|
||||
"ON members.user_id = projections.login_names.user_id " +
|
||||
"LEFT JOIN projections.project_grants " +
|
||||
"ON members.grant_id = projections.project_grants.grant_id " +
|
||||
"LEFT JOIN projections.project_grants2 " +
|
||||
"ON members.grant_id = projections.project_grants2.grant_id " +
|
||||
"WHERE projections.login_names.is_primary = $1")
|
||||
projectGrantMembersColumns = []string{
|
||||
"creation_date",
|
||||
@@ -94,7 +94,7 @@ func Test_ProjectGrantMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"first-name",
|
||||
@@ -117,7 +117,7 @@ func Test_ProjectGrantMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "[email protected]",
|
||||
FirstName: "first-name",
|
||||
@@ -142,7 +142,7 @@ func Test_ProjectGrantMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
nil,
|
||||
nil,
|
||||
@@ -165,7 +165,7 @@ func Test_ProjectGrantMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "",
|
||||
FirstName: "",
|
||||
@@ -190,7 +190,7 @@ func Test_ProjectGrantMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id-1",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"first-name",
|
||||
@@ -205,7 +205,7 @@ func Test_ProjectGrantMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id-2",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
nil,
|
||||
nil,
|
||||
@@ -228,7 +228,7 @@ func Test_ProjectGrantMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id-1",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "[email protected]",
|
||||
FirstName: "first-name",
|
||||
@@ -242,7 +242,7 @@ func Test_ProjectGrantMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id-2",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "",
|
||||
FirstName: "",
|
||||
|
||||
@@ -8,8 +8,7 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
@@ -30,23 +29,23 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER () `+
|
||||
` FROM projections.project_grants `+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id `+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -58,23 +57,23 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.project_grants`+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id`+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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",
|
||||
@@ -102,7 +101,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
"project-name",
|
||||
"org-id",
|
||||
"org-name",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
"ro-name",
|
||||
},
|
||||
},
|
||||
@@ -124,7 +123,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
ProjectName: "project-name",
|
||||
GrantedOrgID: "org-id",
|
||||
OrgName: "org-name",
|
||||
GrantedRoleKeys: pq.StringArray{"role-key"},
|
||||
GrantedRoleKeys: database.StringArray{"role-key"},
|
||||
ResourceOwnerName: "ro-name",
|
||||
},
|
||||
},
|
||||
@@ -135,23 +134,23 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER () `+
|
||||
` FROM projections.project_grants `+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id `+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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",
|
||||
@@ -179,7 +178,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
nil,
|
||||
"org-id",
|
||||
"org-name",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
"ro-name",
|
||||
},
|
||||
},
|
||||
@@ -201,7 +200,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
ProjectName: "",
|
||||
GrantedOrgID: "org-id",
|
||||
OrgName: "org-name",
|
||||
GrantedRoleKeys: pq.StringArray{"role-key"},
|
||||
GrantedRoleKeys: database.StringArray{"role-key"},
|
||||
ResourceOwnerName: "ro-name",
|
||||
},
|
||||
},
|
||||
@@ -212,23 +211,23 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER () `+
|
||||
` FROM projections.project_grants `+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id `+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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",
|
||||
@@ -256,7 +255,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
"project-name",
|
||||
"org-id",
|
||||
nil,
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
"ro-name",
|
||||
},
|
||||
},
|
||||
@@ -278,7 +277,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
ProjectName: "project-name",
|
||||
GrantedOrgID: "org-id",
|
||||
OrgName: "",
|
||||
GrantedRoleKeys: pq.StringArray{"role-key"},
|
||||
GrantedRoleKeys: database.StringArray{"role-key"},
|
||||
ResourceOwnerName: "ro-name",
|
||||
},
|
||||
},
|
||||
@@ -289,23 +288,23 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER () `+
|
||||
` FROM projections.project_grants `+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id `+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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",
|
||||
@@ -333,7 +332,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
"project-name",
|
||||
"org-id",
|
||||
"org-name",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
nil,
|
||||
},
|
||||
},
|
||||
@@ -355,7 +354,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
ProjectName: "project-name",
|
||||
GrantedOrgID: "org-id",
|
||||
OrgName: "org-name",
|
||||
GrantedRoleKeys: pq.StringArray{"role-key"},
|
||||
GrantedRoleKeys: database.StringArray{"role-key"},
|
||||
ResourceOwnerName: "",
|
||||
},
|
||||
},
|
||||
@@ -366,23 +365,23 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER () `+
|
||||
` FROM projections.project_grants `+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id `+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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",
|
||||
@@ -410,7 +409,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
"project-name",
|
||||
"org-id",
|
||||
"org-name",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
"ro-name",
|
||||
},
|
||||
{
|
||||
@@ -424,7 +423,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
"project-name",
|
||||
"org-id",
|
||||
"org-name",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
"ro-name",
|
||||
},
|
||||
},
|
||||
@@ -446,7 +445,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
ProjectName: "project-name",
|
||||
GrantedOrgID: "org-id",
|
||||
OrgName: "org-name",
|
||||
GrantedRoleKeys: pq.StringArray{"role-key"},
|
||||
GrantedRoleKeys: database.StringArray{"role-key"},
|
||||
ResourceOwnerName: "ro-name",
|
||||
},
|
||||
{
|
||||
@@ -460,7 +459,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
ProjectName: "project-name",
|
||||
GrantedOrgID: "org-id",
|
||||
OrgName: "org-name",
|
||||
GrantedRoleKeys: pq.StringArray{"role-key"},
|
||||
GrantedRoleKeys: database.StringArray{"role-key"},
|
||||
ResourceOwnerName: "ro-name",
|
||||
},
|
||||
},
|
||||
@@ -471,23 +470,23 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name,`+
|
||||
` COUNT(*) OVER () `+
|
||||
` FROM projections.project_grants `+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id `+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@@ -504,22 +503,22 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name`+
|
||||
` FROM projections.project_grants `+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id `+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -537,22 +536,22 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name`+
|
||||
` FROM projections.project_grants `+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id `+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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",
|
||||
@@ -578,7 +577,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
"project-name",
|
||||
"org-id",
|
||||
"org-name",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
"ro-name",
|
||||
},
|
||||
),
|
||||
@@ -594,7 +593,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
ProjectName: "project-name",
|
||||
GrantedOrgID: "org-id",
|
||||
OrgName: "org-name",
|
||||
GrantedRoleKeys: pq.StringArray{"role-key"},
|
||||
GrantedRoleKeys: database.StringArray{"role-key"},
|
||||
ResourceOwnerName: "ro-name",
|
||||
},
|
||||
},
|
||||
@@ -603,22 +602,22 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name`+
|
||||
` FROM projections.project_grants `+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id `+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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",
|
||||
@@ -644,7 +643,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
"project-name",
|
||||
"org-id",
|
||||
nil,
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
"ro-name",
|
||||
},
|
||||
),
|
||||
@@ -660,7 +659,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
ProjectName: "project-name",
|
||||
GrantedOrgID: "org-id",
|
||||
OrgName: "",
|
||||
GrantedRoleKeys: pq.StringArray{"role-key"},
|
||||
GrantedRoleKeys: database.StringArray{"role-key"},
|
||||
ResourceOwnerName: "ro-name",
|
||||
},
|
||||
},
|
||||
@@ -669,22 +668,22 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name`+
|
||||
` FROM projections.project_grants `+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id `+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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",
|
||||
@@ -710,7 +709,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
"project-name",
|
||||
"org-id",
|
||||
"org-name",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
nil,
|
||||
},
|
||||
),
|
||||
@@ -726,7 +725,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
ProjectName: "project-name",
|
||||
GrantedOrgID: "org-id",
|
||||
OrgName: "org-name",
|
||||
GrantedRoleKeys: pq.StringArray{"role-key"},
|
||||
GrantedRoleKeys: database.StringArray{"role-key"},
|
||||
ResourceOwnerName: "",
|
||||
},
|
||||
},
|
||||
@@ -735,22 +734,22 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name`+
|
||||
` FROM projections.project_grants `+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id `+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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",
|
||||
@@ -776,7 +775,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
nil,
|
||||
"org-id",
|
||||
"org-name",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
"ro-name",
|
||||
},
|
||||
),
|
||||
@@ -792,7 +791,7 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
ProjectName: "",
|
||||
GrantedOrgID: "org-id",
|
||||
OrgName: "org-name",
|
||||
GrantedRoleKeys: pq.StringArray{"role-key"},
|
||||
GrantedRoleKeys: database.StringArray{"role-key"},
|
||||
ResourceOwnerName: "ro-name",
|
||||
},
|
||||
},
|
||||
@@ -801,22 +800,22 @@ func Test_ProjectGrantPrepares(t *testing.T) {
|
||||
prepare: prepareProjectGrantQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(` SELECT projections.project_grants.project_id,`+
|
||||
` projections.project_grants.grant_id,`+
|
||||
` projections.project_grants.creation_date,`+
|
||||
` projections.project_grants.change_date,`+
|
||||
` projections.project_grants.resource_owner,`+
|
||||
` projections.project_grants.state,`+
|
||||
` projections.project_grants.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.project_grants.granted_org_id,`+
|
||||
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_grants.granted_role_keys,`+
|
||||
` projections.project_grants2.granted_role_keys,`+
|
||||
` r.name`+
|
||||
` FROM projections.project_grants `+
|
||||
` LEFT JOIN projections.projects ON projections.project_grants.project_id = projections.projects.id `+
|
||||
` LEFT JOIN projections.orgs as r ON projections.project_grants.resource_owner = r.id`+
|
||||
` LEFT JOIN projections.orgs as o ON projections.project_grants.granted_org_id = o.id`),
|
||||
` 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`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"database/sql"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
|
||||
@@ -119,7 +118,6 @@ func prepareProjectMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Members,
|
||||
|
||||
for rows.Next() {
|
||||
member := new(Member)
|
||||
roles := pq.StringArray{}
|
||||
|
||||
var (
|
||||
preferredLoginName = sql.NullString{}
|
||||
@@ -137,7 +135,7 @@ func prepareProjectMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Members,
|
||||
&member.Sequence,
|
||||
&member.ResourceOwner,
|
||||
&member.UserID,
|
||||
&roles,
|
||||
&member.Roles,
|
||||
&preferredLoginName,
|
||||
&email,
|
||||
&firstName,
|
||||
@@ -153,7 +151,6 @@ func prepareProjectMembersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Members,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
member.Roles = roles
|
||||
member.PreferredLoginName = preferredLoginName.String
|
||||
member.Email = email.String
|
||||
member.FirstName = firstName.String
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -20,18 +20,18 @@ var (
|
||||
", members.user_id" +
|
||||
", members.roles" +
|
||||
", projections.login_names.login_name" +
|
||||
", projections.users2_humans.email" +
|
||||
", projections.users2_humans.first_name" +
|
||||
", projections.users2_humans.last_name" +
|
||||
", projections.users2_humans.display_name" +
|
||||
", projections.users2_machines.name" +
|
||||
", projections.users2_humans.avatar_key" +
|
||||
", projections.users3_humans.email" +
|
||||
", projections.users3_humans.first_name" +
|
||||
", projections.users3_humans.last_name" +
|
||||
", projections.users3_humans.display_name" +
|
||||
", projections.users3_machines.name" +
|
||||
", projections.users3_humans.avatar_key" +
|
||||
", COUNT(*) OVER () " +
|
||||
"FROM projections.project_members as members " +
|
||||
"LEFT JOIN projections.users2_humans " +
|
||||
"ON members.user_id = projections.users2_humans.user_id " +
|
||||
"LEFT JOIN projections.users2_machines " +
|
||||
"ON members.user_id = projections.users2_machines.user_id " +
|
||||
"FROM projections.project_members2 AS members " +
|
||||
"LEFT JOIN projections.users3_humans " +
|
||||
"ON members.user_id = projections.users3_humans.user_id " +
|
||||
"LEFT JOIN projections.users3_machines " +
|
||||
"ON members.user_id = projections.users3_machines.user_id " +
|
||||
"LEFT JOIN projections.login_names " +
|
||||
"ON members.user_id = projections.login_names.user_id " +
|
||||
"WHERE projections.login_names.is_primary = $1")
|
||||
@@ -92,7 +92,7 @@ func Test_ProjectMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"first-name",
|
||||
@@ -115,7 +115,7 @@ func Test_ProjectMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "[email protected]",
|
||||
FirstName: "first-name",
|
||||
@@ -140,7 +140,7 @@ func Test_ProjectMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
nil,
|
||||
nil,
|
||||
@@ -163,7 +163,7 @@ func Test_ProjectMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "",
|
||||
FirstName: "",
|
||||
@@ -188,7 +188,7 @@ func Test_ProjectMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id-1",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"first-name",
|
||||
@@ -203,7 +203,7 @@ func Test_ProjectMemberPrepares(t *testing.T) {
|
||||
uint64(20211206),
|
||||
"ro",
|
||||
"user-id-2",
|
||||
pq.StringArray{"role-1", "role-2"},
|
||||
database.StringArray{"role-1", "role-2"},
|
||||
"[email protected]",
|
||||
nil,
|
||||
nil,
|
||||
@@ -226,7 +226,7 @@ func Test_ProjectMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id-1",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "[email protected]",
|
||||
FirstName: "first-name",
|
||||
@@ -240,7 +240,7 @@ func Test_ProjectMemberPrepares(t *testing.T) {
|
||||
Sequence: 20211206,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user-id-2",
|
||||
Roles: []string{"role-1", "role-2"},
|
||||
Roles: database.StringArray{"role-1", "role-2"},
|
||||
PreferredLoginName: "[email protected]",
|
||||
Email: "",
|
||||
FirstName: "",
|
||||
|
||||
@@ -44,19 +44,19 @@ func Test_ProjectPrepares(t *testing.T) {
|
||||
prepare: prepareProjectsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.projects.id,`+
|
||||
` projections.projects.creation_date,`+
|
||||
` projections.projects.change_date,`+
|
||||
` projections.projects.resource_owner,`+
|
||||
` projections.projects.state,`+
|
||||
` projections.projects.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.projects.project_role_assertion,`+
|
||||
` projections.projects.project_role_check,`+
|
||||
` projections.projects.has_project_check,`+
|
||||
` projections.projects.private_labeling_setting,`+
|
||||
regexp.QuoteMeta(`SELECT projections.projects2.id,`+
|
||||
` projections.projects2.creation_date,`+
|
||||
` projections.projects2.change_date,`+
|
||||
` projections.projects2.resource_owner,`+
|
||||
` projections.projects2.state,`+
|
||||
` projections.projects2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.projects2.project_role_assertion,`+
|
||||
` projections.projects2.project_role_check,`+
|
||||
` projections.projects2.has_project_check,`+
|
||||
` projections.projects2.private_labeling_setting,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.projects`),
|
||||
` FROM projections.projects2`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -68,19 +68,19 @@ func Test_ProjectPrepares(t *testing.T) {
|
||||
prepare: prepareProjectsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.projects.id,`+
|
||||
` projections.projects.creation_date,`+
|
||||
` projections.projects.change_date,`+
|
||||
` projections.projects.resource_owner,`+
|
||||
` projections.projects.state,`+
|
||||
` projections.projects.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.projects.project_role_assertion,`+
|
||||
` projections.projects.project_role_check,`+
|
||||
` projections.projects.has_project_check,`+
|
||||
` projections.projects.private_labeling_setting,`+
|
||||
regexp.QuoteMeta(`SELECT projections.projects2.id,`+
|
||||
` projections.projects2.creation_date,`+
|
||||
` projections.projects2.change_date,`+
|
||||
` projections.projects2.resource_owner,`+
|
||||
` projections.projects2.state,`+
|
||||
` projections.projects2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.projects2.project_role_assertion,`+
|
||||
` projections.projects2.project_role_check,`+
|
||||
` projections.projects2.has_project_check,`+
|
||||
` projections.projects2.private_labeling_setting,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.projects`),
|
||||
` FROM projections.projects2`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -138,19 +138,19 @@ func Test_ProjectPrepares(t *testing.T) {
|
||||
prepare: prepareProjectsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.projects.id,`+
|
||||
` projections.projects.creation_date,`+
|
||||
` projections.projects.change_date,`+
|
||||
` projections.projects.resource_owner,`+
|
||||
` projections.projects.state,`+
|
||||
` projections.projects.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.projects.project_role_assertion,`+
|
||||
` projections.projects.project_role_check,`+
|
||||
` projections.projects.has_project_check,`+
|
||||
` projections.projects.private_labeling_setting,`+
|
||||
regexp.QuoteMeta(`SELECT projections.projects2.id,`+
|
||||
` projections.projects2.creation_date,`+
|
||||
` projections.projects2.change_date,`+
|
||||
` projections.projects2.resource_owner,`+
|
||||
` projections.projects2.state,`+
|
||||
` projections.projects2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.projects2.project_role_assertion,`+
|
||||
` projections.projects2.project_role_check,`+
|
||||
` projections.projects2.has_project_check,`+
|
||||
` projections.projects2.private_labeling_setting,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.projects`),
|
||||
` FROM projections.projects2`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -234,19 +234,19 @@ func Test_ProjectPrepares(t *testing.T) {
|
||||
prepare: prepareProjectsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.projects.id,`+
|
||||
` projections.projects.creation_date,`+
|
||||
` projections.projects.change_date,`+
|
||||
` projections.projects.resource_owner,`+
|
||||
` projections.projects.state,`+
|
||||
` projections.projects.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.projects.project_role_assertion,`+
|
||||
` projections.projects.project_role_check,`+
|
||||
` projections.projects.has_project_check,`+
|
||||
` projections.projects.private_labeling_setting,`+
|
||||
regexp.QuoteMeta(`SELECT projections.projects2.id,`+
|
||||
` projections.projects2.creation_date,`+
|
||||
` projections.projects2.change_date,`+
|
||||
` projections.projects2.resource_owner,`+
|
||||
` projections.projects2.state,`+
|
||||
` projections.projects2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.projects2.project_role_assertion,`+
|
||||
` projections.projects2.project_role_check,`+
|
||||
` projections.projects2.has_project_check,`+
|
||||
` projections.projects2.private_labeling_setting,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.projects`),
|
||||
` FROM projections.projects2`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@@ -263,18 +263,18 @@ func Test_ProjectPrepares(t *testing.T) {
|
||||
prepare: prepareProjectQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
`SELECT projections.projects.id,`+
|
||||
` projections.projects.creation_date,`+
|
||||
` projections.projects.change_date,`+
|
||||
` projections.projects.resource_owner,`+
|
||||
` projections.projects.state,`+
|
||||
` projections.projects.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.projects.project_role_assertion,`+
|
||||
` projections.projects.project_role_check,`+
|
||||
` projections.projects.has_project_check,`+
|
||||
` projections.projects.private_labeling_setting`+
|
||||
` FROM projections.projects`,
|
||||
`SELECT projections.projects2.id,`+
|
||||
` projections.projects2.creation_date,`+
|
||||
` projections.projects2.change_date,`+
|
||||
` projections.projects2.resource_owner,`+
|
||||
` projections.projects2.state,`+
|
||||
` projections.projects2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.projects2.project_role_assertion,`+
|
||||
` projections.projects2.project_role_check,`+
|
||||
` projections.projects2.has_project_check,`+
|
||||
` projections.projects2.private_labeling_setting`+
|
||||
` FROM projections.projects2`,
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -292,18 +292,18 @@ func Test_ProjectPrepares(t *testing.T) {
|
||||
prepare: prepareProjectQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.projects.id,`+
|
||||
` projections.projects.creation_date,`+
|
||||
` projections.projects.change_date,`+
|
||||
` projections.projects.resource_owner,`+
|
||||
` projections.projects.state,`+
|
||||
` projections.projects.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.projects.project_role_assertion,`+
|
||||
` projections.projects.project_role_check,`+
|
||||
` projections.projects.has_project_check,`+
|
||||
` projections.projects.private_labeling_setting`+
|
||||
` FROM projections.projects`),
|
||||
regexp.QuoteMeta(`SELECT projections.projects2.id,`+
|
||||
` projections.projects2.creation_date,`+
|
||||
` projections.projects2.change_date,`+
|
||||
` projections.projects2.resource_owner,`+
|
||||
` projections.projects2.state,`+
|
||||
` projections.projects2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.projects2.project_role_assertion,`+
|
||||
` projections.projects2.project_role_check,`+
|
||||
` projections.projects2.has_project_check,`+
|
||||
` projections.projects2.private_labeling_setting`+
|
||||
` FROM projections.projects2`),
|
||||
[]string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -351,18 +351,18 @@ func Test_ProjectPrepares(t *testing.T) {
|
||||
prepare: prepareProjectQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.projects.id,`+
|
||||
` projections.projects.creation_date,`+
|
||||
` projections.projects.change_date,`+
|
||||
` projections.projects.resource_owner,`+
|
||||
` projections.projects.state,`+
|
||||
` projections.projects.sequence,`+
|
||||
` projections.projects.name,`+
|
||||
` projections.projects.project_role_assertion,`+
|
||||
` projections.projects.project_role_check,`+
|
||||
` projections.projects.has_project_check,`+
|
||||
` projections.projects.private_labeling_setting`+
|
||||
` FROM projections.projects`),
|
||||
regexp.QuoteMeta(`SELECT projections.projects2.id,`+
|
||||
` projections.projects2.creation_date,`+
|
||||
` projections.projects2.change_date,`+
|
||||
` projections.projects2.resource_owner,`+
|
||||
` projections.projects2.state,`+
|
||||
` projections.projects2.sequence,`+
|
||||
` projections.projects2.name,`+
|
||||
` projections.projects2.project_role_assertion,`+
|
||||
` projections.projects2.project_role_check,`+
|
||||
` projections.projects2.has_project_check,`+
|
||||
` projections.projects2.private_labeling_setting`+
|
||||
` FROM projections.projects2`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ActionTable = "projections.actions"
|
||||
ActionTable = "projections.actions2"
|
||||
ActionIDCol = "id"
|
||||
ActionCreationDateCol = "creation_date"
|
||||
ActionChangeDateCol = "change_date"
|
||||
@@ -49,7 +49,7 @@ func newActionProjection(ctx context.Context, config crdb.StatementHandlerConfig
|
||||
crdb.NewColumn(ActionAllowedToFailCol, crdb.ColumnTypeBool, crdb.Default(false)),
|
||||
},
|
||||
crdb.NewPrimaryKey(ActionInstanceIDCol, ActionIDCol),
|
||||
crdb.WithIndex(crdb.NewIndex("ro_idx", []string{ActionResourceOwnerCol})),
|
||||
crdb.WithIndex(crdb.NewIndex("actions_ro_idx", []string{ActionResourceOwnerCol})),
|
||||
),
|
||||
)
|
||||
p.StatementHandler = crdb.NewStatementHandler(ctx, config)
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestActionProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.actions (id, creation_date, change_date, resource_owner, instance_id, sequence, name, script, timeout, allowed_to_fail, action_state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedStmt: "INSERT INTO projections.actions2 (id, creation_date, change_date, resource_owner, instance_id, sequence, name, script, timeout, allowed_to_fail, action_state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -77,7 +77,7 @@ func TestActionProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.actions SET (change_date, sequence, name, script) = ($1, $2, $3, $4) WHERE (id = $5)",
|
||||
expectedStmt: "UPDATE projections.actions2 SET (change_date, sequence, name, script) = ($1, $2, $3, $4) WHERE (id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -108,7 +108,7 @@ func TestActionProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.actions SET (change_date, sequence, action_state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.actions2 SET (change_date, sequence, action_state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -138,7 +138,7 @@ func TestActionProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.actions SET (change_date, sequence, action_state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.actions2 SET (change_date, sequence, action_state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -168,7 +168,7 @@ func TestActionProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.actions WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.actions2 WHERE (id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
|
||||
@@ -3,8 +3,7 @@ package projection
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
@@ -14,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
AppProjectionTable = "projections.apps"
|
||||
AppProjectionTable = "projections.apps2"
|
||||
AppAPITable = AppProjectionTable + "_" + appAPITableSuffix
|
||||
AppOIDCTable = AppProjectionTable + "_" + appOIDCTableSuffix
|
||||
|
||||
@@ -76,9 +75,9 @@ func newAppProjection(ctx context.Context, config crdb.StatementHandlerConfig) *
|
||||
crdb.NewColumn(AppColumnState, crdb.ColumnTypeEnum),
|
||||
crdb.NewColumn(AppColumnSequence, crdb.ColumnTypeInt64),
|
||||
},
|
||||
crdb.NewPrimaryKey(AppColumnID, AppColumnInstanceID),
|
||||
crdb.WithIndex(crdb.NewIndex("project_id_idx", []string{AppColumnProjectID})),
|
||||
crdb.WithConstraint(crdb.NewConstraint("id_unique", []string{AppColumnID})),
|
||||
crdb.NewPrimaryKey(AppColumnInstanceID, AppColumnID),
|
||||
crdb.WithIndex(crdb.NewIndex("app_project_id_idx", []string{AppColumnProjectID})),
|
||||
crdb.WithConstraint(crdb.NewConstraint("app_id_unique", []string{AppColumnID})),
|
||||
),
|
||||
crdb.NewSuffixedTable([]*crdb.Column{
|
||||
crdb.NewColumn(AppAPIConfigColumnAppID, crdb.ColumnTypeText),
|
||||
@@ -87,15 +86,15 @@ func newAppProjection(ctx context.Context, config crdb.StatementHandlerConfig) *
|
||||
crdb.NewColumn(AppAPIConfigColumnClientSecret, crdb.ColumnTypeJSONB, crdb.Nullable()),
|
||||
crdb.NewColumn(AppAPIConfigColumnAuthMethod, crdb.ColumnTypeEnum),
|
||||
},
|
||||
crdb.NewPrimaryKey(AppAPIConfigColumnAppID, AppAPIConfigColumnInstanceID),
|
||||
crdb.NewPrimaryKey(AppAPIConfigColumnInstanceID, AppAPIConfigColumnAppID),
|
||||
appAPITableSuffix,
|
||||
crdb.WithForeignKey(crdb.NewForeignKeyOfPublicKeys("fk_api_ref_apps")),
|
||||
crdb.WithIndex(crdb.NewIndex("client_id_idx", []string{AppAPIConfigColumnClientID})),
|
||||
crdb.WithIndex(crdb.NewIndex("api_client_id_idx", []string{AppAPIConfigColumnClientID})),
|
||||
),
|
||||
crdb.NewSuffixedTable([]*crdb.Column{
|
||||
crdb.NewColumn(AppOIDCConfigColumnAppID, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(AppOIDCConfigColumnInstanceID, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(AppOIDCConfigColumnVersion, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(AppOIDCConfigColumnVersion, crdb.ColumnTypeEnum),
|
||||
crdb.NewColumn(AppOIDCConfigColumnClientID, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(AppOIDCConfigColumnClientSecret, crdb.ColumnTypeJSONB, crdb.Nullable()),
|
||||
crdb.NewColumn(AppOIDCConfigColumnRedirectUris, crdb.ColumnTypeTextArray, crdb.Nullable()),
|
||||
@@ -112,10 +111,10 @@ func newAppProjection(ctx context.Context, config crdb.StatementHandlerConfig) *
|
||||
crdb.NewColumn(AppOIDCConfigColumnClockSkew, crdb.ColumnTypeInt64, crdb.Default(0)),
|
||||
crdb.NewColumn(AppOIDCConfigColumnAdditionalOrigins, crdb.ColumnTypeTextArray, crdb.Nullable()),
|
||||
},
|
||||
crdb.NewPrimaryKey(AppOIDCConfigColumnAppID, AppOIDCConfigColumnInstanceID),
|
||||
crdb.NewPrimaryKey(AppOIDCConfigColumnInstanceID, AppOIDCConfigColumnAppID),
|
||||
appOIDCTableSuffix,
|
||||
crdb.WithForeignKey(crdb.NewForeignKeyOfPublicKeys("fk_oidc_ref_apps")),
|
||||
crdb.WithIndex(crdb.NewIndex("client_id_idx", []string{AppOIDCConfigColumnClientID})),
|
||||
crdb.WithIndex(crdb.NewIndex("oidc_client_id_idx", []string{AppOIDCConfigColumnClientID})),
|
||||
),
|
||||
)
|
||||
p.StatementHandler = crdb.NewStatementHandler(ctx, config)
|
||||
@@ -401,19 +400,19 @@ func (p *appProjection) reduceOIDCConfigAdded(event eventstore.Event) (*handler.
|
||||
handler.NewCol(AppOIDCConfigColumnVersion, e.Version),
|
||||
handler.NewCol(AppOIDCConfigColumnClientID, e.ClientID),
|
||||
handler.NewCol(AppOIDCConfigColumnClientSecret, e.ClientSecret),
|
||||
handler.NewCol(AppOIDCConfigColumnRedirectUris, pq.StringArray(e.RedirectUris)),
|
||||
handler.NewCol(AppOIDCConfigColumnResponseTypes, pq.Array(e.ResponseTypes)),
|
||||
handler.NewCol(AppOIDCConfigColumnGrantTypes, pq.Array(e.GrantTypes)),
|
||||
handler.NewCol(AppOIDCConfigColumnRedirectUris, database.StringArray(e.RedirectUris)),
|
||||
handler.NewCol(AppOIDCConfigColumnResponseTypes, database.EnumArray[domain.OIDCResponseType](e.ResponseTypes)),
|
||||
handler.NewCol(AppOIDCConfigColumnGrantTypes, database.EnumArray[domain.OIDCGrantType](e.GrantTypes)),
|
||||
handler.NewCol(AppOIDCConfigColumnApplicationType, e.ApplicationType),
|
||||
handler.NewCol(AppOIDCConfigColumnAuthMethodType, e.AuthMethodType),
|
||||
handler.NewCol(AppOIDCConfigColumnPostLogoutRedirectUris, pq.StringArray(e.PostLogoutRedirectUris)),
|
||||
handler.NewCol(AppOIDCConfigColumnPostLogoutRedirectUris, database.StringArray(e.PostLogoutRedirectUris)),
|
||||
handler.NewCol(AppOIDCConfigColumnDevMode, e.DevMode),
|
||||
handler.NewCol(AppOIDCConfigColumnAccessTokenType, e.AccessTokenType),
|
||||
handler.NewCol(AppOIDCConfigColumnAccessTokenRoleAssertion, e.AccessTokenRoleAssertion),
|
||||
handler.NewCol(AppOIDCConfigColumnIDTokenRoleAssertion, e.IDTokenRoleAssertion),
|
||||
handler.NewCol(AppOIDCConfigColumnIDTokenUserinfoAssertion, e.IDTokenUserinfoAssertion),
|
||||
handler.NewCol(AppOIDCConfigColumnClockSkew, e.ClockSkew),
|
||||
handler.NewCol(AppOIDCConfigColumnAdditionalOrigins, pq.StringArray(e.AdditionalOrigins)),
|
||||
handler.NewCol(AppOIDCConfigColumnAdditionalOrigins, database.StringArray(e.AdditionalOrigins)),
|
||||
},
|
||||
crdb.WithTableSuffix(appOIDCTableSuffix),
|
||||
),
|
||||
@@ -441,13 +440,13 @@ func (p *appProjection) reduceOIDCConfigChanged(event eventstore.Event) (*handle
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnVersion, *e.Version))
|
||||
}
|
||||
if e.RedirectUris != nil {
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnRedirectUris, pq.StringArray(*e.RedirectUris)))
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnRedirectUris, database.StringArray(*e.RedirectUris)))
|
||||
}
|
||||
if e.ResponseTypes != nil {
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnResponseTypes, pq.Array(*e.ResponseTypes)))
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnResponseTypes, database.EnumArray[domain.OIDCResponseType](*e.ResponseTypes)))
|
||||
}
|
||||
if e.GrantTypes != nil {
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnGrantTypes, pq.Array(*e.GrantTypes)))
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnGrantTypes, database.EnumArray[domain.OIDCGrantType](*e.GrantTypes)))
|
||||
}
|
||||
if e.ApplicationType != nil {
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnApplicationType, *e.ApplicationType))
|
||||
@@ -456,7 +455,7 @@ func (p *appProjection) reduceOIDCConfigChanged(event eventstore.Event) (*handle
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnAuthMethodType, *e.AuthMethodType))
|
||||
}
|
||||
if e.PostLogoutRedirectUris != nil {
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnPostLogoutRedirectUris, pq.StringArray(*e.PostLogoutRedirectUris)))
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnPostLogoutRedirectUris, database.StringArray(*e.PostLogoutRedirectUris)))
|
||||
}
|
||||
if e.DevMode != nil {
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnDevMode, *e.DevMode))
|
||||
@@ -477,7 +476,7 @@ func (p *appProjection) reduceOIDCConfigChanged(event eventstore.Event) (*handle
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnClockSkew, *e.ClockSkew))
|
||||
}
|
||||
if e.AdditionalOrigins != nil {
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnAdditionalOrigins, pq.StringArray(*e.AdditionalOrigins)))
|
||||
cols = append(cols, handler.NewCol(AppOIDCConfigColumnAdditionalOrigins, database.StringArray(*e.AdditionalOrigins)))
|
||||
}
|
||||
|
||||
if len(cols) == 0 {
|
||||
|
||||
@@ -4,8 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
@@ -45,7 +44,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.apps (id, name, project_id, creation_date, change_date, resource_owner, instance_id, state, sequence) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.apps2 (id, name, project_id, creation_date, change_date, resource_owner, instance_id, state, sequence) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"app-id",
|
||||
"my-app",
|
||||
@@ -83,7 +82,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps SET (name, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.apps2 SET (name, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"my-app",
|
||||
anyArg{},
|
||||
@@ -116,7 +115,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps SET (state, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.apps2 SET (state, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.AppStateInactive,
|
||||
anyArg{},
|
||||
@@ -149,7 +148,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps SET (state, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.apps2 SET (state, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.AppStateActive,
|
||||
anyArg{},
|
||||
@@ -182,7 +181,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.apps WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.apps2 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"app-id",
|
||||
"instance-id",
|
||||
@@ -210,7 +209,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.apps WHERE (project_id = $1) AND (instance_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.apps2 WHERE (project_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -243,7 +242,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.apps_api_configs (app_id, instance_id, client_id, client_secret, auth_method) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.apps2_api_configs (app_id, instance_id, client_id, client_secret, auth_method) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"app-id",
|
||||
"instance-id",
|
||||
@@ -253,7 +252,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.apps2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -288,7 +287,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps_api_configs SET (client_secret, auth_method) = ($1, $2) WHERE (app_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.apps2_api_configs SET (client_secret, auth_method) = ($1, $2) WHERE (app_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.APIAuthMethodTypePrivateKeyJWT,
|
||||
@@ -297,7 +296,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.apps2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -352,7 +351,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps_api_configs SET (client_secret) = ($1) WHERE (app_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.apps2_api_configs SET (client_secret) = ($1) WHERE (app_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
"app-id",
|
||||
@@ -360,7 +359,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.apps2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -408,30 +407,30 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.apps_oidc_configs (app_id, instance_id, version, client_id, client_secret, redirect_uris, response_types, grant_types, application_type, auth_method_type, post_logout_redirect_uris, is_dev_mode, access_token_type, access_token_role_assertion, id_token_role_assertion, id_token_userinfo_assertion, clock_skew, additional_origins) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18)",
|
||||
expectedStmt: "INSERT INTO projections.apps2_oidc_configs (app_id, instance_id, version, client_id, client_secret, redirect_uris, response_types, grant_types, application_type, auth_method_type, post_logout_redirect_uris, is_dev_mode, access_token_type, access_token_role_assertion, id_token_role_assertion, id_token_userinfo_assertion, clock_skew, additional_origins) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18)",
|
||||
expectedArgs: []interface{}{
|
||||
"app-id",
|
||||
"instance-id",
|
||||
domain.OIDCVersionV1,
|
||||
"client-id",
|
||||
anyArg{},
|
||||
pq.StringArray{"redirect.one.ch", "redirect.two.ch"},
|
||||
pq.Array([]domain.OIDCResponseType{1, 2}),
|
||||
pq.Array([]domain.OIDCGrantType{1, 2}),
|
||||
database.StringArray{"redirect.one.ch", "redirect.two.ch"},
|
||||
database.EnumArray[domain.OIDCResponseType]{1, 2},
|
||||
database.EnumArray[domain.OIDCGrantType]{1, 2},
|
||||
domain.OIDCApplicationTypeNative,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"logout.one.ch", "logout.two.ch"},
|
||||
database.StringArray{"logout.one.ch", "logout.two.ch"},
|
||||
true,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1 * time.Microsecond,
|
||||
pq.StringArray{"origin.one.ch", "origin.two.ch"},
|
||||
database.StringArray{"origin.one.ch", "origin.two.ch"},
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.apps2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -477,28 +476,28 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps_oidc_configs SET (version, redirect_uris, response_types, grant_types, application_type, auth_method_type, post_logout_redirect_uris, is_dev_mode, access_token_type, access_token_role_assertion, id_token_role_assertion, id_token_userinfo_assertion, clock_skew, additional_origins) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) WHERE (app_id = $15) AND (instance_id = $16)",
|
||||
expectedStmt: "UPDATE projections.apps2_oidc_configs SET (version, redirect_uris, response_types, grant_types, application_type, auth_method_type, post_logout_redirect_uris, is_dev_mode, access_token_type, access_token_role_assertion, id_token_role_assertion, id_token_userinfo_assertion, clock_skew, additional_origins) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) WHERE (app_id = $15) AND (instance_id = $16)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.OIDCVersionV1,
|
||||
pq.StringArray{"redirect.one.ch", "redirect.two.ch"},
|
||||
pq.Array([]domain.OIDCResponseType{1, 2}),
|
||||
pq.Array([]domain.OIDCGrantType{1, 2}),
|
||||
database.StringArray{"redirect.one.ch", "redirect.two.ch"},
|
||||
database.EnumArray[domain.OIDCResponseType]{1, 2},
|
||||
database.EnumArray[domain.OIDCGrantType]{1, 2},
|
||||
domain.OIDCApplicationTypeNative,
|
||||
domain.OIDCAuthMethodTypeNone,
|
||||
pq.StringArray{"logout.one.ch", "logout.two.ch"},
|
||||
database.StringArray{"logout.one.ch", "logout.two.ch"},
|
||||
true,
|
||||
domain.OIDCTokenTypeJWT,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1 * time.Microsecond,
|
||||
pq.StringArray{"origin.one.ch", "origin.two.ch"},
|
||||
database.StringArray{"origin.one.ch", "origin.two.ch"},
|
||||
"app-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.apps2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -553,7 +552,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps_oidc_configs SET (client_secret) = ($1) WHERE (app_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.apps2_oidc_configs SET (client_secret) = ($1) WHERE (app_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
"app-id",
|
||||
@@ -561,7 +560,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.apps SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.apps2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
|
||||
@@ -109,6 +109,13 @@ func (p *customTextProjection) reduceSet(event eventstore.Event) (*handler.State
|
||||
}
|
||||
return crdb.NewUpsertStatement(
|
||||
&customTextEvent,
|
||||
[]handler.Column{
|
||||
handler.NewCol(CustomTextInstanceIDCol, nil),
|
||||
handler.NewCol(CustomTextAggregateIDCol, nil),
|
||||
handler.NewCol(CustomTextTemplateCol, nil),
|
||||
handler.NewCol(CustomTextKeyCol, nil),
|
||||
handler.NewCol(CustomTextLanguageCol, nil),
|
||||
},
|
||||
[]handler.Column{
|
||||
handler.NewCol(CustomTextAggregateIDCol, customTextEvent.Aggregate().ID),
|
||||
handler.NewCol(CustomTextInstanceIDCol, customTextEvent.Aggregate().InstanceID),
|
||||
|
||||
@@ -44,7 +44,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.custom_texts (aggregate_id, instance_id, creation_date, change_date, sequence, is_default, template, language, key, text) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.custom_texts (aggregate_id, instance_id, creation_date, change_date, sequence, is_default, template, language, key, text) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ON CONFLICT (instance_id, aggregate_id, template, key, language) DO UPDATE SET (creation_date, change_date, sequence, is_default, text) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.is_default, EXCLUDED.text)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -152,7 +152,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.custom_texts (aggregate_id, instance_id, creation_date, change_date, sequence, is_default, template, language, key, text) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.custom_texts (aggregate_id, instance_id, creation_date, change_date, sequence, is_default, template, language, key, text) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ON CONFLICT (instance_id, aggregate_id, template, key, language) DO UPDATE SET (creation_date, change_date, sequence, is_default, text) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.is_default, EXCLUDED.text)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package projection
|
||||
|
||||
const (
|
||||
FailedEventsColumnProjectionName = "projection_name"
|
||||
FailedEventsColumnFailedSequence = "failed_sequence"
|
||||
FailedEventsColumnFailureCount = "failure_count"
|
||||
FailedEventsColumnError = "error"
|
||||
)
|
||||
@@ -3,8 +3,7 @@ package projection
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
@@ -16,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
IDPTable = "projections.idps"
|
||||
IDPTable = "projections.idps2"
|
||||
IDPOIDCTable = IDPTable + "_" + IDPOIDCSuffix
|
||||
IDPJWTTable = IDPTable + "_" + IDPJWTSuffix
|
||||
|
||||
@@ -78,9 +77,9 @@ func newIDPProjection(ctx context.Context, config crdb.StatementHandlerConfig) *
|
||||
crdb.NewColumn(IDPAutoRegisterCol, crdb.ColumnTypeBool, crdb.Default(false)),
|
||||
crdb.NewColumn(IDPTypeCol, crdb.ColumnTypeEnum, crdb.Nullable()),
|
||||
},
|
||||
crdb.NewPrimaryKey(IDPIDCol, IDPInstanceIDCol),
|
||||
crdb.WithIndex(crdb.NewIndex("ro_idx", []string{IDPResourceOwnerCol})),
|
||||
crdb.WithConstraint(crdb.NewConstraint("id_unique", []string{IDPIDCol})),
|
||||
crdb.NewPrimaryKey(IDPInstanceIDCol, IDPIDCol),
|
||||
crdb.WithIndex(crdb.NewIndex("idp_ro_idx", []string{IDPResourceOwnerCol})),
|
||||
crdb.WithConstraint(crdb.NewConstraint("idp_id_unique", []string{IDPIDCol})),
|
||||
),
|
||||
crdb.NewSuffixedTable([]*crdb.Column{
|
||||
crdb.NewColumn(OIDCConfigIDPIDCol, crdb.ColumnTypeText),
|
||||
@@ -94,7 +93,7 @@ func newIDPProjection(ctx context.Context, config crdb.StatementHandlerConfig) *
|
||||
crdb.NewColumn(OIDCConfigAuthorizationEndpointCol, crdb.ColumnTypeText, crdb.Nullable()),
|
||||
crdb.NewColumn(OIDCConfigTokenEndpointCol, crdb.ColumnTypeText, crdb.Nullable()),
|
||||
},
|
||||
crdb.NewPrimaryKey(OIDCConfigIDPIDCol, OIDCConfigInstanceIDCol),
|
||||
crdb.NewPrimaryKey(OIDCConfigInstanceIDCol, OIDCConfigIDPIDCol),
|
||||
IDPOIDCSuffix,
|
||||
crdb.WithForeignKey(crdb.NewForeignKeyOfPublicKeys("fk_oidc_ref_idp")),
|
||||
),
|
||||
@@ -106,7 +105,7 @@ func newIDPProjection(ctx context.Context, config crdb.StatementHandlerConfig) *
|
||||
crdb.NewColumn(JWTConfigHeaderNameCol, crdb.ColumnTypeText, crdb.Nullable()),
|
||||
crdb.NewColumn(JWTConfigEndpointCol, crdb.ColumnTypeText, crdb.Nullable()),
|
||||
},
|
||||
crdb.NewPrimaryKey(JWTConfigIDPIDCol, JWTConfigInstanceIDCol),
|
||||
crdb.NewPrimaryKey(JWTConfigInstanceIDCol, JWTConfigIDPIDCol),
|
||||
IDPJWTSuffix,
|
||||
crdb.WithForeignKey(crdb.NewForeignKeyOfPublicKeys("fk_jwt_ref_idp")),
|
||||
),
|
||||
@@ -374,7 +373,7 @@ func (p *idpProjection) reduceOIDCConfigAdded(event eventstore.Event) (*handler.
|
||||
handler.NewCol(OIDCConfigClientIDCol, idpEvent.ClientID),
|
||||
handler.NewCol(OIDCConfigClientSecretCol, idpEvent.ClientSecret),
|
||||
handler.NewCol(OIDCConfigIssuerCol, idpEvent.Issuer),
|
||||
handler.NewCol(OIDCConfigScopesCol, pq.StringArray(idpEvent.Scopes)),
|
||||
handler.NewCol(OIDCConfigScopesCol, database.StringArray(idpEvent.Scopes)),
|
||||
handler.NewCol(OIDCConfigDisplayNameMappingCol, idpEvent.IDPDisplayNameMapping),
|
||||
handler.NewCol(OIDCConfigUsernameMappingCol, idpEvent.UserNameMapping),
|
||||
handler.NewCol(OIDCConfigAuthorizationEndpointCol, idpEvent.AuthorizationEndpoint),
|
||||
@@ -414,7 +413,7 @@ func (p *idpProjection) reduceOIDCConfigChanged(event eventstore.Event) (*handle
|
||||
cols = append(cols, handler.NewCol(OIDCConfigTokenEndpointCol, *idpEvent.TokenEndpoint))
|
||||
}
|
||||
if idpEvent.Scopes != nil {
|
||||
cols = append(cols, handler.NewCol(OIDCConfigScopesCol, pq.StringArray(idpEvent.Scopes)))
|
||||
cols = append(cols, handler.NewCol(OIDCConfigScopesCol, database.StringArray(idpEvent.Scopes)))
|
||||
}
|
||||
if idpEvent.IDPDisplayNameMapping != nil {
|
||||
cols = append(cols, handler.NewCol(OIDCConfigDisplayNameMappingCol, *idpEvent.IDPDisplayNameMapping))
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
IDPLoginPolicyLinkTable = "projections.idp_login_policy_links"
|
||||
IDPLoginPolicyLinkTable = "projections.idp_login_policy_links2"
|
||||
|
||||
IDPLoginPolicyLinkIDPIDCol = "idp_id"
|
||||
IDPLoginPolicyLinkAggregateIDCol = "aggregate_id"
|
||||
@@ -46,7 +46,7 @@ func newIDPLoginPolicyLinkProjection(ctx context.Context, config crdb.StatementH
|
||||
crdb.NewColumn(IDPLoginPolicyLinkProviderTypeCol, crdb.ColumnTypeText),
|
||||
},
|
||||
crdb.NewPrimaryKey(IDPLoginPolicyLinkInstanceIDCol, IDPLoginPolicyLinkAggregateIDCol, IDPLoginPolicyLinkIDPIDCol),
|
||||
crdb.WithIndex(crdb.NewIndex("ro_idx", []string{IDPLoginPolicyLinkResourceOwnerCol})),
|
||||
crdb.WithIndex(crdb.NewIndex("link_ro_idx", []string{IDPLoginPolicyLinkResourceOwnerCol})),
|
||||
),
|
||||
)
|
||||
p.StatementHandler = crdb.NewStatementHandler(ctx, config)
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.idp_login_policy_links (idp_id, aggregate_id, creation_date, change_date, sequence, resource_owner, instance_id, provider_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedStmt: "INSERT INTO projections.idp_login_policy_links2 (idp_id, aggregate_id, creation_date, change_date, sequence, resource_owner, instance_id, provider_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
@@ -80,7 +80,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links WHERE (idp_id = $1) AND (aggregate_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (aggregate_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
@@ -111,7 +111,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links WHERE (idp_id = $1) AND (aggregate_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (aggregate_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
@@ -142,7 +142,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.idp_login_policy_links (idp_id, aggregate_id, creation_date, change_date, sequence, resource_owner, instance_id, provider_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedStmt: "INSERT INTO projections.idp_login_policy_links2 (idp_id, aggregate_id, creation_date, change_date, sequence, resource_owner, instance_id, provider_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
@@ -179,7 +179,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links WHERE (idp_id = $1) AND (aggregate_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (aggregate_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
@@ -210,7 +210,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links WHERE (idp_id = $1) AND (aggregate_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (aggregate_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
@@ -238,7 +238,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links WHERE (resource_owner = $1)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (resource_owner = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -267,7 +267,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links WHERE (idp_id = $1) AND (resource_owner = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (resource_owner = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"ro-id",
|
||||
@@ -297,7 +297,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links WHERE (idp_id = $1) AND (resource_owner = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (resource_owner = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"ro-id",
|
||||
|
||||
@@ -3,8 +3,7 @@ package projection
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
@@ -48,7 +47,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.idps (id, creation_date, change_date, sequence, resource_owner, instance_id, state, name, styling_type, auto_register, owner_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedStmt: "INSERT INTO projections.idps2 (id, creation_date, change_date, sequence, resource_owner, instance_id, state, name, styling_type, auto_register, owner_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
anyArg{},
|
||||
@@ -90,7 +89,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (name, styling_type, auto_register, change_date, sequence) = ($1, $2, $3, $4, $5) WHERE (id = $6) AND (instance_id = $7)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (name, styling_type, auto_register, change_date, sequence) = ($1, $2, $3, $4, $5) WHERE (id = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
"custom-zitadel-instance",
|
||||
domain.IDPConfigStylingTypeGoogle,
|
||||
@@ -125,7 +124,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (state, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (state, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.IDPConfigStateInactive,
|
||||
anyArg{},
|
||||
@@ -158,7 +157,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (state, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (state, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.IDPConfigStateActive,
|
||||
anyArg{},
|
||||
@@ -191,7 +190,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idps WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idps2 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"instance-id",
|
||||
@@ -233,7 +232,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (change_date, sequence, type) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (change_date, sequence, type) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -243,14 +242,14 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.idps_oidc_config (idp_id, instance_id, client_id, client_secret, issuer, scopes, display_name_mapping, username_mapping, authorization_endpoint, token_endpoint) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.idps2_oidc_config (idp_id, instance_id, client_id, client_secret, issuer, scopes, display_name_mapping, username_mapping, authorization_endpoint, token_endpoint) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"instance-id",
|
||||
"client-id",
|
||||
anyArg{},
|
||||
"issuer",
|
||||
pq.StringArray{"profile"},
|
||||
database.StringArray{"profile"},
|
||||
domain.OIDCMappingFieldUnspecified,
|
||||
domain.OIDCMappingFieldPreferredLoginName,
|
||||
"https://api.zitadel.ch/authorize",
|
||||
@@ -293,7 +292,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -302,14 +301,14 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps_oidc_config SET (client_id, client_secret, issuer, authorization_endpoint, token_endpoint, scopes, display_name_mapping, username_mapping) = ($1, $2, $3, $4, $5, $6, $7, $8) WHERE (idp_id = $9) AND (instance_id = $10)",
|
||||
expectedStmt: "UPDATE projections.idps2_oidc_config SET (client_id, client_secret, issuer, authorization_endpoint, token_endpoint, scopes, display_name_mapping, username_mapping) = ($1, $2, $3, $4, $5, $6, $7, $8) WHERE (idp_id = $9) AND (instance_id = $10)",
|
||||
expectedArgs: []interface{}{
|
||||
"client-id",
|
||||
anyArg{},
|
||||
"issuer",
|
||||
"https://api.zitadel.ch/authorize",
|
||||
"https://api.zitadel.ch/token",
|
||||
pq.StringArray{"profile"},
|
||||
database.StringArray{"profile"},
|
||||
domain.OIDCMappingFieldUnspecified,
|
||||
domain.OIDCMappingFieldPreferredLoginName,
|
||||
"idp-config-id",
|
||||
@@ -364,7 +363,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (change_date, sequence, type) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (change_date, sequence, type) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -374,7 +373,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.idps_jwt_config (idp_id, instance_id, endpoint, issuer, keys_endpoint, header_name) VALUES ($1, $2, $3, $4, $5, $6)",
|
||||
expectedStmt: "INSERT INTO projections.idps2_jwt_config (idp_id, instance_id, endpoint, issuer, keys_endpoint, header_name) VALUES ($1, $2, $3, $4, $5, $6)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"instance-id",
|
||||
@@ -412,7 +411,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -421,7 +420,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps_jwt_config SET (endpoint, issuer, keys_endpoint, header_name) = ($1, $2, $3, $4) WHERE (idp_id = $5) AND (instance_id = $6)",
|
||||
expectedStmt: "UPDATE projections.idps2_jwt_config SET (endpoint, issuer, keys_endpoint, header_name) = ($1, $2, $3, $4) WHERE (idp_id = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
"https://api.zitadel.ch/jwt",
|
||||
"issuer",
|
||||
@@ -479,7 +478,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.idps (id, creation_date, change_date, sequence, resource_owner, instance_id, state, name, styling_type, auto_register, owner_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedStmt: "INSERT INTO projections.idps2 (id, creation_date, change_date, sequence, resource_owner, instance_id, state, name, styling_type, auto_register, owner_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
anyArg{},
|
||||
@@ -521,7 +520,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (name, styling_type, auto_register, change_date, sequence) = ($1, $2, $3, $4, $5) WHERE (id = $6) AND (instance_id = $7)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (name, styling_type, auto_register, change_date, sequence) = ($1, $2, $3, $4, $5) WHERE (id = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
"custom-zitadel-instance",
|
||||
domain.IDPConfigStylingTypeGoogle,
|
||||
@@ -556,7 +555,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (state, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (state, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.IDPConfigStateInactive,
|
||||
anyArg{},
|
||||
@@ -589,7 +588,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (state, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (state, change_date, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.IDPConfigStateActive,
|
||||
anyArg{},
|
||||
@@ -622,7 +621,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idps WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idps2 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"instance-id",
|
||||
@@ -664,7 +663,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (change_date, sequence, type) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (change_date, sequence, type) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -674,14 +673,14 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.idps_oidc_config (idp_id, instance_id, client_id, client_secret, issuer, scopes, display_name_mapping, username_mapping, authorization_endpoint, token_endpoint) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.idps2_oidc_config (idp_id, instance_id, client_id, client_secret, issuer, scopes, display_name_mapping, username_mapping, authorization_endpoint, token_endpoint) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"instance-id",
|
||||
"client-id",
|
||||
anyArg{},
|
||||
"issuer",
|
||||
pq.StringArray{"profile"},
|
||||
database.StringArray{"profile"},
|
||||
domain.OIDCMappingFieldUnspecified,
|
||||
domain.OIDCMappingFieldPreferredLoginName,
|
||||
"https://api.zitadel.ch/authorize",
|
||||
@@ -724,7 +723,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -733,14 +732,14 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps_oidc_config SET (client_id, client_secret, issuer, authorization_endpoint, token_endpoint, scopes, display_name_mapping, username_mapping) = ($1, $2, $3, $4, $5, $6, $7, $8) WHERE (idp_id = $9) AND (instance_id = $10)",
|
||||
expectedStmt: "UPDATE projections.idps2_oidc_config SET (client_id, client_secret, issuer, authorization_endpoint, token_endpoint, scopes, display_name_mapping, username_mapping) = ($1, $2, $3, $4, $5, $6, $7, $8) WHERE (idp_id = $9) AND (instance_id = $10)",
|
||||
expectedArgs: []interface{}{
|
||||
"client-id",
|
||||
anyArg{},
|
||||
"issuer",
|
||||
"https://api.zitadel.ch/authorize",
|
||||
"https://api.zitadel.ch/token",
|
||||
pq.StringArray{"profile"},
|
||||
database.StringArray{"profile"},
|
||||
domain.OIDCMappingFieldUnspecified,
|
||||
domain.OIDCMappingFieldPreferredLoginName,
|
||||
"idp-config-id",
|
||||
@@ -795,7 +794,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (change_date, sequence, type) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (change_date, sequence, type) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -805,7 +804,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.idps_jwt_config (idp_id, instance_id, endpoint, issuer, keys_endpoint, header_name) VALUES ($1, $2, $3, $4, $5, $6)",
|
||||
expectedStmt: "INSERT INTO projections.idps2_jwt_config (idp_id, instance_id, endpoint, issuer, keys_endpoint, header_name) VALUES ($1, $2, $3, $4, $5, $6)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"instance-id",
|
||||
@@ -843,7 +842,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.idps2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -852,7 +851,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.idps_jwt_config SET (endpoint, issuer, keys_endpoint, header_name) = ($1, $2, $3, $4) WHERE (idp_id = $5) AND (instance_id = $6)",
|
||||
expectedStmt: "UPDATE projections.idps2_jwt_config SET (endpoint, issuer, keys_endpoint, header_name) = ($1, $2, $3, $4) WHERE (idp_id = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
"https://api.zitadel.ch/jwt",
|
||||
"issuer",
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
IDPUserLinkTable = "projections.idp_user_links"
|
||||
IDPUserLinkTable = "projections.idp_user_links2"
|
||||
IDPUserLinkIDPIDCol = "idp_id"
|
||||
IDPUserLinkUserIDCol = "user_id"
|
||||
IDPUserLinkExternalUserIDCol = "external_user_id"
|
||||
@@ -46,7 +46,7 @@ func newIDPUserLinkProjection(ctx context.Context, config crdb.StatementHandlerC
|
||||
crdb.NewColumn(IDPUserLinkDisplayNameCol, crdb.ColumnTypeText),
|
||||
},
|
||||
crdb.NewPrimaryKey(IDPUserLinkInstanceIDCol, IDPUserLinkIDPIDCol, IDPUserLinkExternalUserIDCol),
|
||||
crdb.WithIndex(crdb.NewIndex("user_idx", []string{IDPUserLinkUserIDCol})),
|
||||
crdb.WithIndex(crdb.NewIndex("idp_user_idx", []string{IDPUserLinkUserIDCol})),
|
||||
),
|
||||
)
|
||||
p.StatementHandler = crdb.NewStatementHandler(ctx, config)
|
||||
|
||||
@@ -44,7 +44,7 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.idp_user_links (idp_id, user_id, external_user_id, creation_date, change_date, sequence, resource_owner, instance_id, display_name) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.idp_user_links2 (idp_id, user_id, external_user_id, creation_date, change_date, sequence, resource_owner, instance_id, display_name) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
@@ -82,7 +82,7 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links WHERE (idp_id = $1) AND (user_id = $2) AND (external_user_id = $3)",
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (idp_id = $1) AND (user_id = $2) AND (external_user_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
@@ -114,7 +114,7 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links WHERE (idp_id = $1) AND (user_id = $2) AND (external_user_id = $3)",
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (idp_id = $1) AND (user_id = $2) AND (external_user_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
@@ -143,7 +143,7 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links WHERE (resource_owner = $1)",
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (resource_owner = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -170,7 +170,7 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -199,7 +199,7 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links WHERE (idp_id = $1) AND (resource_owner = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (idp_id = $1) AND (resource_owner = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"ro-id",
|
||||
@@ -229,7 +229,7 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links WHERE (idp_id = $1) AND (resource_owner = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (idp_id = $1) AND (resource_owner = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"ro-id",
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
InstanceMemberProjectionTable = "projections.instance_members"
|
||||
InstanceMemberProjectionTable = "projections.instance_members2"
|
||||
|
||||
InstanceMemberIAMIDCol = "id"
|
||||
)
|
||||
@@ -29,7 +29,7 @@ func newInstanceMemberProjection(ctx context.Context, config crdb.StatementHandl
|
||||
crdb.NewTable(
|
||||
append(memberColumns, crdb.NewColumn(InstanceColumnID, crdb.ColumnTypeText)),
|
||||
crdb.NewPrimaryKey(MemberInstanceID, InstanceColumnID, MemberUserIDCol),
|
||||
crdb.WithIndex(crdb.NewIndex("user_idx", []string{MemberUserIDCol})),
|
||||
crdb.WithIndex(crdb.NewIndex("inst_memb_user_idx", []string{MemberUserIDCol})),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@ package projection
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
@@ -44,10 +43,10 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.instance_members (user_id, roles, creation_date, change_date, sequence, resource_owner, instance_id, id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedStmt: "INSERT INTO projections.instance_members2 (user_id, roles, creation_date, change_date, sequence, resource_owner, instance_id, id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedArgs: []interface{}{
|
||||
"user-id",
|
||||
pq.StringArray{"role"},
|
||||
database.StringArray{"role"},
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -81,9 +80,9 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.instance_members SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (user_id = $4)",
|
||||
expectedStmt: "UPDATE projections.instance_members2 SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (user_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
pq.StringArray{"role", "changed"},
|
||||
database.StringArray{"role", "changed"},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"user-id",
|
||||
@@ -113,7 +112,7 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.instance_members WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.instance_members2 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"user-id",
|
||||
},
|
||||
@@ -142,7 +141,7 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.instance_members WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.instance_members2 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"user-id",
|
||||
},
|
||||
@@ -169,7 +168,7 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.instance_members WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.instance_members2 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
KeyProjectionTable = "projections.keys"
|
||||
KeyProjectionTable = "projections.keys2"
|
||||
KeyPrivateTable = KeyProjectionTable + "_" + privateKeyTableSuffix
|
||||
KeyPublicTable = KeyProjectionTable + "_" + publicKeyTableSuffix
|
||||
|
||||
@@ -59,8 +59,8 @@ func newKeyProjection(ctx context.Context, config crdb.StatementHandlerConfig, k
|
||||
crdb.NewColumn(KeyColumnAlgorithm, crdb.ColumnTypeText, crdb.Default("")),
|
||||
crdb.NewColumn(KeyColumnUse, crdb.ColumnTypeEnum, crdb.Default(0)),
|
||||
},
|
||||
crdb.NewPrimaryKey(KeyColumnID, KeyColumnInstanceID),
|
||||
crdb.WithConstraint(crdb.NewConstraint("id_unique", []string{KeyColumnID})),
|
||||
crdb.NewPrimaryKey(KeyColumnInstanceID, KeyColumnID),
|
||||
crdb.WithConstraint(crdb.NewConstraint("key_id_unique", []string{KeyColumnID})),
|
||||
),
|
||||
crdb.NewSuffixedTable([]*crdb.Column{
|
||||
crdb.NewColumn(KeyPrivateColumnID, crdb.ColumnTypeText),
|
||||
@@ -68,7 +68,7 @@ func newKeyProjection(ctx context.Context, config crdb.StatementHandlerConfig, k
|
||||
crdb.NewColumn(KeyPrivateColumnExpiry, crdb.ColumnTypeTimestamp),
|
||||
crdb.NewColumn(KeyPrivateColumnKey, crdb.ColumnTypeJSONB),
|
||||
},
|
||||
crdb.NewPrimaryKey(KeyPrivateColumnID, KeyPrivateColumnInstanceID),
|
||||
crdb.NewPrimaryKey(KeyPrivateColumnInstanceID, KeyPrivateColumnID),
|
||||
privateKeyTableSuffix,
|
||||
crdb.WithForeignKey(crdb.NewForeignKeyOfPublicKeys("fk_private_ref_keys")),
|
||||
),
|
||||
@@ -78,7 +78,7 @@ func newKeyProjection(ctx context.Context, config crdb.StatementHandlerConfig, k
|
||||
crdb.NewColumn(KeyPublicColumnExpiry, crdb.ColumnTypeTimestamp),
|
||||
crdb.NewColumn(KeyPublicColumnKey, crdb.ColumnTypeBytes),
|
||||
},
|
||||
crdb.NewPrimaryKey(KeyPublicColumnID, KeyPublicColumnInstanceID),
|
||||
crdb.NewPrimaryKey(KeyPublicColumnInstanceID, KeyPublicColumnID),
|
||||
publicKeyTableSuffix,
|
||||
crdb.WithForeignKey(crdb.NewForeignKeyOfPublicKeys("fk_public_ref_keys")),
|
||||
),
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestKeyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.keys (id, creation_date, change_date, resource_owner, instance_id, sequence, algorithm, use) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedStmt: "INSERT INTO projections.keys2 (id, creation_date, change_date, resource_owner, instance_id, sequence, algorithm, use) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -56,7 +56,7 @@ func TestKeyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.keys_private (id, instance_id, expiry, key) VALUES ($1, $2, $3, $4)",
|
||||
expectedStmt: "INSERT INTO projections.keys2_private (id, instance_id, expiry, key) VALUES ($1, $2, $3, $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -70,7 +70,7 @@ func TestKeyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.keys_public (id, instance_id, expiry, key) VALUES ($1, $2, $3, $4)",
|
||||
expectedStmt: "INSERT INTO projections.keys2_public (id, instance_id, expiry, key) VALUES ($1, $2, $3, $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
|
||||
@@ -332,6 +332,11 @@ func (p *labelPolicyProjection) reduceActivated(event eventstore.Event) (*handle
|
||||
}
|
||||
return crdb.NewCopyStatement(
|
||||
event,
|
||||
[]handler.Column{
|
||||
handler.NewCol(LabelPolicyInstanceIDCol, nil),
|
||||
handler.NewCol(LabelPolicyIDCol, nil),
|
||||
handler.NewCol(LabelPolicyStateCol, nil),
|
||||
},
|
||||
[]handler.Column{
|
||||
handler.NewCol(LabelPolicyChangeDateCol, event.CreationDate()),
|
||||
handler.NewCol(LabelPolicySequenceCol, event.Sequence()),
|
||||
|
||||
@@ -146,7 +146,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.label_policies (change_date, sequence, state, creation_date, resource_owner, instance_id, id, is_default, hide_login_name_suffix, font_url, watermark_disabled, should_error_popup, light_primary_color, light_warn_color, light_background_color, light_font_color, light_logo_url, light_icon_url, dark_primary_color, dark_warn_color, dark_background_color, dark_font_color, dark_logo_url, dark_icon_url) SELECT $1, $2, $3, creation_date, resource_owner, instance_id, id, is_default, hide_login_name_suffix, font_url, watermark_disabled, should_error_popup, light_primary_color, light_warn_color, light_background_color, light_font_color, light_logo_url, light_icon_url, dark_primary_color, dark_warn_color, dark_background_color, dark_font_color, dark_logo_url, dark_icon_url FROM projections.label_policies AS copy_table WHERE copy_table.id = $4 AND copy_table.state = $5 AND copy_table.instance_id = $6",
|
||||
expectedStmt: "INSERT INTO projections.label_policies (change_date, sequence, state, creation_date, resource_owner, instance_id, id, is_default, hide_login_name_suffix, font_url, watermark_disabled, should_error_popup, light_primary_color, light_warn_color, light_background_color, light_font_color, light_logo_url, light_icon_url, dark_primary_color, dark_warn_color, dark_background_color, dark_font_color, dark_logo_url, dark_icon_url) SELECT $1, $2, $3, creation_date, resource_owner, instance_id, id, is_default, hide_login_name_suffix, font_url, watermark_disabled, should_error_popup, light_primary_color, light_warn_color, light_background_color, light_font_color, light_logo_url, light_icon_url, dark_primary_color, dark_warn_color, dark_background_color, dark_font_color, dark_logo_url, dark_icon_url FROM projections.label_policies AS copy_table WHERE copy_table.id = $4 AND copy_table.state = $5 AND copy_table.instance_id = $6 ON CONFLICT (instance_id, id, state) DO UPDATE SET (change_date, sequence, state, creation_date, resource_owner, instance_id, id, is_default, hide_login_name_suffix, font_url, watermark_disabled, should_error_popup, light_primary_color, light_warn_color, light_background_color, light_font_color, light_logo_url, light_icon_url, dark_primary_color, dark_warn_color, dark_background_color, dark_font_color, dark_logo_url, dark_icon_url) = ($1, $2, $3, EXCLUDED.creation_date, EXCLUDED.resource_owner, EXCLUDED.instance_id, EXCLUDED.id, EXCLUDED.is_default, EXCLUDED.hide_login_name_suffix, EXCLUDED.font_url, EXCLUDED.watermark_disabled, EXCLUDED.should_error_popup, EXCLUDED.light_primary_color, EXCLUDED.light_warn_color, EXCLUDED.light_background_color, EXCLUDED.light_font_color, EXCLUDED.light_logo_url, EXCLUDED.light_icon_url, EXCLUDED.dark_primary_color, EXCLUDED.dark_warn_color, EXCLUDED.dark_background_color, EXCLUDED.dark_font_color, EXCLUDED.dark_logo_url, EXCLUDED.dark_icon_url)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -609,7 +609,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.label_policies (change_date, sequence, state, creation_date, resource_owner, instance_id, id, is_default, hide_login_name_suffix, font_url, watermark_disabled, should_error_popup, light_primary_color, light_warn_color, light_background_color, light_font_color, light_logo_url, light_icon_url, dark_primary_color, dark_warn_color, dark_background_color, dark_font_color, dark_logo_url, dark_icon_url) SELECT $1, $2, $3, creation_date, resource_owner, instance_id, id, is_default, hide_login_name_suffix, font_url, watermark_disabled, should_error_popup, light_primary_color, light_warn_color, light_background_color, light_font_color, light_logo_url, light_icon_url, dark_primary_color, dark_warn_color, dark_background_color, dark_font_color, dark_logo_url, dark_icon_url FROM projections.label_policies AS copy_table WHERE copy_table.id = $4 AND copy_table.state = $5 AND copy_table.instance_id = $6",
|
||||
expectedStmt: "INSERT INTO projections.label_policies (change_date, sequence, state, creation_date, resource_owner, instance_id, id, is_default, hide_login_name_suffix, font_url, watermark_disabled, should_error_popup, light_primary_color, light_warn_color, light_background_color, light_font_color, light_logo_url, light_icon_url, dark_primary_color, dark_warn_color, dark_background_color, dark_font_color, dark_logo_url, dark_icon_url) SELECT $1, $2, $3, creation_date, resource_owner, instance_id, id, is_default, hide_login_name_suffix, font_url, watermark_disabled, should_error_popup, light_primary_color, light_warn_color, light_background_color, light_font_color, light_logo_url, light_icon_url, dark_primary_color, dark_warn_color, dark_background_color, dark_font_color, dark_logo_url, dark_icon_url FROM projections.label_policies AS copy_table WHERE copy_table.id = $4 AND copy_table.state = $5 AND copy_table.instance_id = $6 ON CONFLICT (instance_id, id, state) DO UPDATE SET (change_date, sequence, state, creation_date, resource_owner, instance_id, id, is_default, hide_login_name_suffix, font_url, watermark_disabled, should_error_popup, light_primary_color, light_warn_color, light_background_color, light_font_color, light_logo_url, light_icon_url, dark_primary_color, dark_warn_color, dark_background_color, dark_font_color, dark_logo_url, dark_icon_url) = ($1, $2, $3, EXCLUDED.creation_date, EXCLUDED.resource_owner, EXCLUDED.instance_id, EXCLUDED.id, EXCLUDED.is_default, EXCLUDED.hide_login_name_suffix, EXCLUDED.font_url, EXCLUDED.watermark_disabled, EXCLUDED.should_error_popup, EXCLUDED.light_primary_color, EXCLUDED.light_warn_color, EXCLUDED.light_background_color, EXCLUDED.light_font_color, EXCLUDED.light_logo_url, EXCLUDED.light_icon_url, EXCLUDED.dark_primary_color, EXCLUDED.dark_warn_color, EXCLUDED.dark_background_color, EXCLUDED.dark_font_color, EXCLUDED.dark_logo_url, EXCLUDED.dark_icon_url)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
|
||||
@@ -44,8 +44,8 @@ const (
|
||||
var (
|
||||
viewStmt = fmt.Sprintf("SELECT"+
|
||||
" user_id"+
|
||||
" , IF(%[1]s, CONCAT(%[2]s, '@', domain), %[2]s) AS login_name"+
|
||||
" , IFNULL(%[3]s, true) AS %[3]s"+
|
||||
" , (CASE WHEN %[1]s THEN CONCAT(%[2]s, '@', domain) ELSE %[2]s END) AS login_name"+
|
||||
" , COALESCE(%[3]s, true) AS %[3]s"+
|
||||
" , %[4]s"+
|
||||
" FROM ("+
|
||||
" SELECT"+
|
||||
@@ -62,12 +62,12 @@ var (
|
||||
" , users.%[2]s"+
|
||||
" , users.%[4]s"+
|
||||
" , users.%[5]s"+
|
||||
" , IFNULL(policy_custom.%[1]s, policy_default.%[1]s) AS %[1]s"+
|
||||
" , COALESCE(policy_custom.%[1]s, policy_default.%[1]s) AS %[1]s"+
|
||||
" FROM %[7]s users"+
|
||||
" LEFT JOIN %[8]s policy_custom on policy_custom.%[9]s = users.%[5]s AND policy_custom.%[10]s = users.%[4]s"+
|
||||
" LEFT JOIN %[8]s policy_default on policy_default.%[11]s = true AND policy_default.%[10]s = users.%[4]s) policy_users"+
|
||||
" LEFT JOIN %[12]s domains ON policy_users.%[1]s AND policy_users.%[5]s = domains.%[13]s AND policy_users.%[10]s = domains.%[14]s"+
|
||||
");",
|
||||
") AS login_names;",
|
||||
LoginNamePoliciesMustBeDomainCol,
|
||||
LoginNameUserUserNameCol,
|
||||
LoginNameDomainIsPrimaryCol,
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package projection
|
||||
|
||||
import (
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler/crdb"
|
||||
@@ -57,7 +56,7 @@ func reduceMemberAdded(e member.MemberAddedEvent, opts ...reduceMemberOpt) (*han
|
||||
config := reduceMemberConfig{
|
||||
cols: []handler.Column{
|
||||
handler.NewCol(MemberUserIDCol, e.UserID),
|
||||
handler.NewCol(MemberRolesCol, pq.StringArray(e.Roles)),
|
||||
handler.NewCol(MemberRolesCol, database.StringArray(e.Roles)),
|
||||
handler.NewCol(MemberCreationDate, e.CreationDate()),
|
||||
handler.NewCol(MemberChangeDate, e.CreationDate()),
|
||||
handler.NewCol(MemberSequence, e.Sequence()),
|
||||
@@ -75,7 +74,7 @@ func reduceMemberAdded(e member.MemberAddedEvent, opts ...reduceMemberOpt) (*han
|
||||
func reduceMemberChanged(e member.MemberChangedEvent, opts ...reduceMemberOpt) (*handler.Statement, error) {
|
||||
config := reduceMemberConfig{
|
||||
cols: []handler.Column{
|
||||
handler.NewCol(MemberRolesCol, pq.StringArray(e.Roles)),
|
||||
handler.NewCol(MemberRolesCol, database.StringArray(e.Roles)),
|
||||
handler.NewCol(MemberChangeDate, e.CreationDate()),
|
||||
handler.NewCol(MemberSequence, e.Sequence()),
|
||||
},
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, title) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, title) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (instance_id, aggregate_id, type, language) DO UPDATE SET (creation_date, change_date, sequence, state, title) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.state, EXCLUDED.title)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -85,7 +85,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, pre_header) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, pre_header) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (instance_id, aggregate_id, type, language) DO UPDATE SET (creation_date, change_date, sequence, state, pre_header) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.state, EXCLUDED.pre_header)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -125,7 +125,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, subject) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, subject) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (instance_id, aggregate_id, type, language) DO UPDATE SET (creation_date, change_date, sequence, state, subject) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.state, EXCLUDED.subject)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -165,7 +165,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, greeting) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, greeting) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (instance_id, aggregate_id, type, language) DO UPDATE SET (creation_date, change_date, sequence, state, greeting) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.state, EXCLUDED.greeting)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -205,7 +205,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, text) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, text) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (instance_id, aggregate_id, type, language) DO UPDATE SET (creation_date, change_date, sequence, state, text) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.state, EXCLUDED.text)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -245,7 +245,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, button_text) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, button_text) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (instance_id, aggregate_id, type, language) DO UPDATE SET (creation_date, change_date, sequence, state, button_text) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.state, EXCLUDED.button_text)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -285,7 +285,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, footer_text) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, footer_text) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (instance_id, aggregate_id, type, language) DO UPDATE SET (creation_date, change_date, sequence, state, footer_text) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.state, EXCLUDED.footer_text)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -610,7 +610,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, title) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.message_texts (aggregate_id, instance_id, creation_date, change_date, sequence, state, type, language, title) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) ON CONFLICT (instance_id, aggregate_id, type, language) DO UPDATE SET (creation_date, change_date, sequence, state, title) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.state, EXCLUDED.title)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
|
||||
@@ -152,7 +152,14 @@ func (p *messageTextProjection) reduceAdded(event eventstore.Event) (*handler.St
|
||||
}
|
||||
return crdb.NewUpsertStatement(
|
||||
&templateEvent,
|
||||
cols), nil
|
||||
[]handler.Column{
|
||||
handler.NewCol(MessageTextInstanceIDCol, nil),
|
||||
handler.NewCol(MessageTextAggregateIDCol, nil),
|
||||
handler.NewCol(MessageTextTypeCol, nil),
|
||||
handler.NewCol(MessageTextLanguageCol, nil),
|
||||
},
|
||||
cols,
|
||||
), nil
|
||||
}
|
||||
|
||||
func (p *messageTextProjection) reduceRemoved(event eventstore.Event) (*handler.Statement, error) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
OrgMemberProjectionTable = "projections.org_members"
|
||||
OrgMemberProjectionTable = "projections.org_members2"
|
||||
OrgMemberOrgIDCol = "org_id"
|
||||
)
|
||||
|
||||
@@ -28,7 +28,7 @@ func newOrgMemberProjection(ctx context.Context, config crdb.StatementHandlerCon
|
||||
crdb.NewTable(
|
||||
append(memberColumns, crdb.NewColumn(OrgMemberOrgIDCol, crdb.ColumnTypeText)),
|
||||
crdb.NewPrimaryKey(MemberInstanceID, OrgMemberOrgIDCol, MemberUserIDCol),
|
||||
crdb.WithIndex(crdb.NewIndex("user_idx", []string{MemberUserIDCol})),
|
||||
crdb.WithIndex(crdb.NewIndex("org_memb_user_idx", []string{MemberUserIDCol})),
|
||||
),
|
||||
)
|
||||
p.StatementHandler = crdb.NewStatementHandler(ctx, config)
|
||||
|
||||
@@ -3,8 +3,7 @@ package projection
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
@@ -44,10 +43,10 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.org_members (user_id, roles, creation_date, change_date, sequence, resource_owner, instance_id, org_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedStmt: "INSERT INTO projections.org_members2 (user_id, roles, creation_date, change_date, sequence, resource_owner, instance_id, org_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedArgs: []interface{}{
|
||||
"user-id",
|
||||
pq.StringArray{"role"},
|
||||
database.StringArray{"role"},
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -81,9 +80,9 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.org_members SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (user_id = $4) AND (org_id = $5)",
|
||||
expectedStmt: "UPDATE projections.org_members2 SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (user_id = $4) AND (org_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
pq.StringArray{"role", "changed"},
|
||||
database.StringArray{"role", "changed"},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"user-id",
|
||||
@@ -114,7 +113,7 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.org_members WHERE (user_id = $1) AND (org_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.org_members2 WHERE (user_id = $1) AND (org_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"user-id",
|
||||
"agg-id",
|
||||
@@ -144,7 +143,7 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.org_members WHERE (user_id = $1) AND (org_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.org_members2 WHERE (user_id = $1) AND (org_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"user-id",
|
||||
"agg-id",
|
||||
@@ -172,7 +171,7 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.org_members WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.org_members2 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -199,7 +198,7 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.org_members WHERE (org_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.org_members2 WHERE (org_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ProjectProjectionTable = "projections.projects"
|
||||
ProjectProjectionTable = "projections.projects2"
|
||||
|
||||
ProjectColumnID = "id"
|
||||
ProjectColumnCreationDate = "creation_date"
|
||||
@@ -52,7 +52,7 @@ func newProjectProjection(ctx context.Context, config crdb.StatementHandlerConfi
|
||||
crdb.NewColumn(ProjectColumnPrivateLabelingSetting, crdb.ColumnTypeEnum),
|
||||
},
|
||||
crdb.NewPrimaryKey(ProjectColumnInstanceID, ProjectColumnID),
|
||||
crdb.WithIndex(crdb.NewIndex("ro_idx", []string{ProjectColumnResourceOwner})),
|
||||
crdb.WithIndex(crdb.NewIndex("project_ro_idx", []string{ProjectColumnResourceOwner})),
|
||||
),
|
||||
)
|
||||
p.StatementHandler = crdb.NewStatementHandler(ctx, config)
|
||||
|
||||
@@ -3,8 +3,7 @@ package projection
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
@@ -14,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ProjectGrantProjectionTable = "projections.project_grants"
|
||||
ProjectGrantProjectionTable = "projections.project_grants2"
|
||||
|
||||
ProjectGrantColumnGrantID = "grant_id"
|
||||
ProjectGrantColumnCreationDate = "creation_date"
|
||||
@@ -50,7 +49,7 @@ func newProjectGrantProjection(ctx context.Context, config crdb.StatementHandler
|
||||
crdb.NewColumn(ProjectGrantColumnRoleKeys, crdb.ColumnTypeTextArray, crdb.Nullable()),
|
||||
},
|
||||
crdb.NewPrimaryKey(ProjectGrantColumnInstanceID, ProjectGrantColumnGrantID),
|
||||
crdb.WithIndex(crdb.NewIndex("ro_idx", []string{ProjectGrantColumnResourceOwner})),
|
||||
crdb.WithIndex(crdb.NewIndex("pg_ro_idx", []string{ProjectGrantColumnResourceOwner})),
|
||||
crdb.WithIndex(crdb.NewIndex("granted_org_idx", []string{ProjectGrantColumnGrantedOrgID})),
|
||||
),
|
||||
)
|
||||
@@ -113,7 +112,7 @@ func (p *projectGrantProjection) reduceProjectGrantAdded(event eventstore.Event)
|
||||
handler.NewCol(ProjectGrantColumnState, domain.ProjectGrantStateActive),
|
||||
handler.NewCol(ProjectGrantColumnSequence, e.Sequence()),
|
||||
handler.NewCol(ProjectGrantColumnGrantedOrgID, e.GrantedOrgID),
|
||||
handler.NewCol(ProjectGrantColumnRoleKeys, pq.StringArray(e.RoleKeys)),
|
||||
handler.NewCol(ProjectGrantColumnRoleKeys, database.StringArray(e.RoleKeys)),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@@ -128,7 +127,7 @@ func (p *projectGrantProjection) reduceProjectGrantChanged(event eventstore.Even
|
||||
[]handler.Column{
|
||||
handler.NewCol(ProjectColumnChangeDate, e.CreationDate()),
|
||||
handler.NewCol(ProjectGrantColumnSequence, e.Sequence()),
|
||||
handler.NewCol(ProjectGrantColumnRoleKeys, pq.StringArray(e.RoleKeys)),
|
||||
handler.NewCol(ProjectGrantColumnRoleKeys, database.StringArray(e.RoleKeys)),
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectGrantColumnGrantID, e.GrantID),
|
||||
@@ -147,7 +146,7 @@ func (p *projectGrantProjection) reduceProjectGrantCascadeChanged(event eventsto
|
||||
[]handler.Column{
|
||||
handler.NewCol(ProjectGrantColumnChangeDate, e.CreationDate()),
|
||||
handler.NewCol(ProjectGrantColumnSequence, e.Sequence()),
|
||||
handler.NewCol(ProjectGrantColumnRoleKeys, pq.StringArray(e.RoleKeys)),
|
||||
handler.NewCol(ProjectGrantColumnRoleKeys, database.StringArray(e.RoleKeys)),
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectGrantColumnGrantID, e.GrantID),
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ProjectGrantMemberProjectionTable = "projections.project_grant_members"
|
||||
ProjectGrantMemberProjectionTable = "projections.project_grant_members2"
|
||||
ProjectGrantMemberProjectIDCol = "project_id"
|
||||
ProjectGrantMemberGrantIDCol = "grant_id"
|
||||
)
|
||||
@@ -34,7 +34,7 @@ func newProjectGrantMemberProjection(ctx context.Context, config crdb.StatementH
|
||||
crdb.NewColumn(ProjectGrantMemberGrantIDCol, crdb.ColumnTypeText),
|
||||
),
|
||||
crdb.NewPrimaryKey(MemberInstanceID, ProjectGrantMemberProjectIDCol, ProjectGrantMemberGrantIDCol, MemberUserIDCol),
|
||||
crdb.WithIndex(crdb.NewIndex("user_idx", []string{MemberUserIDCol})),
|
||||
crdb.WithIndex(crdb.NewIndex("proj_grant_memb_user_idx", []string{MemberUserIDCol})),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@ package projection
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
@@ -46,10 +45,10 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.project_grant_members (user_id, roles, creation_date, change_date, sequence, resource_owner, instance_id, project_id, grant_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.project_grant_members2 (user_id, roles, creation_date, change_date, sequence, resource_owner, instance_id, project_id, grant_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"user-id",
|
||||
pq.StringArray{"role"},
|
||||
database.StringArray{"role"},
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -85,9 +84,9 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_grant_members SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (user_id = $4) AND (project_id = $5) AND (grant_id = $6)",
|
||||
expectedStmt: "UPDATE projections.project_grant_members2 SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (user_id = $4) AND (project_id = $5) AND (grant_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
pq.StringArray{"role", "changed"},
|
||||
database.StringArray{"role", "changed"},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"user-id",
|
||||
@@ -120,7 +119,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members WHERE (user_id = $1) AND (project_id = $2) AND (grant_id = $3)",
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (user_id = $1) AND (project_id = $2) AND (grant_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"user-id",
|
||||
"agg-id",
|
||||
@@ -152,7 +151,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members WHERE (user_id = $1) AND (project_id = $2) AND (grant_id = $3)",
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (user_id = $1) AND (project_id = $2) AND (grant_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"user-id",
|
||||
"agg-id",
|
||||
@@ -181,7 +180,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -208,7 +207,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members WHERE (resource_owner = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (resource_owner = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -235,7 +234,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members WHERE (project_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (project_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -262,7 +261,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members WHERE (grant_id = $1) AND (project_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (grant_id = $1) AND (project_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"grant-id",
|
||||
"agg-id",
|
||||
|
||||
@@ -3,8 +3,7 @@ package projection
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
@@ -41,7 +40,7 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grants WHERE (project_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_grants2 WHERE (project_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -68,7 +67,7 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grants WHERE (grant_id = $1) AND (project_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.project_grants2 WHERE (grant_id = $1) AND (project_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"grant-id",
|
||||
"agg-id",
|
||||
@@ -96,7 +95,7 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_grants SET (change_date, sequence, state) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5)",
|
||||
expectedStmt: "UPDATE projections.project_grants2 SET (change_date, sequence, state) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -127,7 +126,7 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_grants SET (change_date, sequence, state) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5)",
|
||||
expectedStmt: "UPDATE projections.project_grants2 SET (change_date, sequence, state) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -158,11 +157,11 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_grants SET (change_date, sequence, granted_role_keys) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5)",
|
||||
expectedStmt: "UPDATE projections.project_grants2 SET (change_date, sequence, granted_role_keys) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
pq.StringArray{"admin", "user"},
|
||||
database.StringArray{"admin", "user"},
|
||||
"grant-id",
|
||||
"agg-id",
|
||||
},
|
||||
@@ -189,11 +188,11 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_grants SET (change_date, sequence, granted_role_keys) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5)",
|
||||
expectedStmt: "UPDATE projections.project_grants2 SET (change_date, sequence, granted_role_keys) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
pq.StringArray{"admin", "user"},
|
||||
database.StringArray{"admin", "user"},
|
||||
"grant-id",
|
||||
"agg-id",
|
||||
},
|
||||
@@ -220,7 +219,7 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.project_grants (grant_id, project_id, creation_date, change_date, resource_owner, instance_id, state, sequence, granted_org_id, granted_role_keys) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.project_grants2 (grant_id, project_id, creation_date, change_date, resource_owner, instance_id, state, sequence, granted_org_id, granted_role_keys) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedArgs: []interface{}{
|
||||
"grant-id",
|
||||
"agg-id",
|
||||
@@ -231,7 +230,7 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
domain.ProjectGrantStateActive,
|
||||
uint64(15),
|
||||
"granted-org-id",
|
||||
pq.StringArray{"admin", "user"},
|
||||
database.StringArray{"admin", "user"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ProjectMemberProjectionTable = "projections.project_members"
|
||||
ProjectMemberProjectionTable = "projections.project_members2"
|
||||
ProjectMemberProjectIDCol = "project_id"
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ func newProjectMemberProjection(ctx context.Context, config crdb.StatementHandle
|
||||
crdb.NewColumn(ProjectMemberProjectIDCol, crdb.ColumnTypeText),
|
||||
),
|
||||
crdb.NewPrimaryKey(MemberInstanceID, ProjectMemberProjectIDCol, MemberUserIDCol),
|
||||
crdb.WithIndex(crdb.NewIndex("user_idx", []string{MemberUserIDCol})),
|
||||
crdb.WithIndex(crdb.NewIndex("proj_memb_user_idx", []string{MemberUserIDCol})),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@ package projection
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
@@ -45,10 +44,10 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.project_members (user_id, roles, creation_date, change_date, sequence, resource_owner, instance_id, project_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedStmt: "INSERT INTO projections.project_members2 (user_id, roles, creation_date, change_date, sequence, resource_owner, instance_id, project_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedArgs: []interface{}{
|
||||
"user-id",
|
||||
pq.StringArray{"role"},
|
||||
database.StringArray{"role"},
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -82,9 +81,9 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_members SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (user_id = $4) AND (project_id = $5)",
|
||||
expectedStmt: "UPDATE projections.project_members2 SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (user_id = $4) AND (project_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
pq.StringArray{"role", "changed"},
|
||||
database.StringArray{"role", "changed"},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"user-id",
|
||||
@@ -115,7 +114,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_members WHERE (user_id = $1) AND (project_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (user_id = $1) AND (project_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"user-id",
|
||||
"agg-id",
|
||||
@@ -145,7 +144,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_members WHERE (user_id = $1) AND (project_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (user_id = $1) AND (project_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"user-id",
|
||||
"agg-id",
|
||||
@@ -173,7 +172,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_members WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -200,7 +199,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_members WHERE (resource_owner = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (resource_owner = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -227,7 +226,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_members WHERE (project_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (project_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
|
||||
@@ -39,7 +39,7 @@ func TestProjectProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.projects WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.projects2 WHERE (id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -66,7 +66,7 @@ func TestProjectProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.projects SET (change_date, sequence, state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.projects2 SET (change_date, sequence, state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -96,7 +96,7 @@ func TestProjectProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.projects SET (change_date, sequence, state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.projects2 SET (change_date, sequence, state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -126,7 +126,7 @@ func TestProjectProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.projects SET (change_date, sequence, name, project_role_assertion, project_role_check, has_project_check, private_labeling_setting) = ($1, $2, $3, $4, $5, $6, $7) WHERE (id = $8)",
|
||||
expectedStmt: "UPDATE projections.projects2 SET (change_date, sequence, name, project_role_assertion, project_role_check, has_project_check, private_labeling_setting) = ($1, $2, $3, $4, $5, $6, $7) WHERE (id = $8)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -178,7 +178,7 @@ func TestProjectProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.projects (id, creation_date, change_date, resource_owner, instance_id, sequence, name, project_role_assertion, project_role_check, has_project_check, private_labeling_setting, state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)",
|
||||
expectedStmt: "INSERT INTO projections.projects2 (id, creation_date, change_date, resource_owner, instance_id, sequence, name, project_role_assertion, project_role_check, has_project_check, private_labeling_setting, state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
SecretGeneratorProjectionTable = "projections.secret_generators"
|
||||
SecretGeneratorProjectionTable = "projections.secret_generators2"
|
||||
|
||||
SecretGeneratorColumnGeneratorType = "generator_type"
|
||||
SecretGeneratorColumnAggregateID = "aggregate_id"
|
||||
@@ -38,7 +38,7 @@ func newSecretGeneratorProjection(ctx context.Context, config crdb.StatementHand
|
||||
config.Reducers = p.reducers()
|
||||
config.InitCheck = crdb.NewTableCheck(
|
||||
crdb.NewTable([]*crdb.Column{
|
||||
crdb.NewColumn(SecretGeneratorColumnGeneratorType, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(SecretGeneratorColumnGeneratorType, crdb.ColumnTypeEnum),
|
||||
crdb.NewColumn(SecretGeneratorColumnAggregateID, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(SecretGeneratorColumnCreationDate, crdb.ColumnTypeTimestamp),
|
||||
crdb.NewColumn(SecretGeneratorColumnChangeDate, crdb.ColumnTypeTimestamp),
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestSecretGeneratorProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.secret_generators WHERE (aggregate_id = $1) AND (generator_type = $2)",
|
||||
expectedStmt: "DELETE FROM projections.secret_generators2 WHERE (aggregate_id = $1) AND (generator_type = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
domain.SecretGeneratorTypeInitCode,
|
||||
@@ -68,7 +68,7 @@ func TestSecretGeneratorProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.secret_generators SET (change_date, sequence, length, expiry, include_lower_letters, include_upper_letters, include_digits, include_symbols) = ($1, $2, $3, $4, $5, $6, $7, $8) WHERE (aggregate_id = $9) AND (generator_type = $10)",
|
||||
expectedStmt: "UPDATE projections.secret_generators2 SET (change_date, sequence, length, expiry, include_lower_letters, include_upper_letters, include_digits, include_symbols) = ($1, $2, $3, $4, $5, $6, $7, $8) WHERE (aggregate_id = $9) AND (generator_type = $10)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -104,7 +104,7 @@ func TestSecretGeneratorProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.secret_generators (aggregate_id, generator_type, creation_date, change_date, resource_owner, instance_id, sequence, length, expiry, include_lower_letters, include_upper_letters, include_digits, include_symbols) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)",
|
||||
expectedStmt: "INSERT INTO projections.secret_generators2 (aggregate_id, generator_type, creation_date, change_date, resource_owner, instance_id, sequence, length, expiry, include_lower_letters, include_upper_letters, include_digits, include_symbols) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
domain.SecretGeneratorTypeInitCode,
|
||||
|
||||
@@ -17,7 +17,7 @@ type userProjection struct {
|
||||
}
|
||||
|
||||
const (
|
||||
UserTable = "projections.users2"
|
||||
UserTable = "projections.users3"
|
||||
UserHumanTable = UserTable + "_" + UserHumanSuffix
|
||||
UserMachineTable = UserTable + "_" + UserMachineSuffix
|
||||
UserNotifyTable = UserTable + "_" + UserNotifySuffix
|
||||
@@ -89,8 +89,8 @@ func newUserProjection(ctx context.Context, config crdb.StatementHandlerConfig)
|
||||
},
|
||||
crdb.NewPrimaryKey(UserIDCol, UserInstanceIDCol),
|
||||
crdb.WithIndex(crdb.NewIndex("username_idx", []string{UserUsernameCol})),
|
||||
crdb.WithIndex(crdb.NewIndex("ro_idx", []string{UserResourceOwnerCol})),
|
||||
crdb.WithConstraint(crdb.NewConstraint("id_unique", []string{UserIDCol})),
|
||||
crdb.WithIndex(crdb.NewIndex("user_ro_idx", []string{UserResourceOwnerCol})),
|
||||
crdb.WithConstraint(crdb.NewConstraint("user_id_unique", []string{UserIDCol})),
|
||||
),
|
||||
crdb.NewSuffixedTable([]*crdb.Column{
|
||||
crdb.NewColumn(HumanUserIDCol, crdb.ColumnTypeText),
|
||||
@@ -709,6 +709,10 @@ func (p *userProjection) reduceHumanPhoneVerified(event eventstore.Event) (*hand
|
||||
crdb.WithTableSuffix(UserHumanSuffix),
|
||||
),
|
||||
crdb.AddCopyStatement(
|
||||
[]handler.Column{
|
||||
handler.NewCol(NotifyUserIDCol, nil),
|
||||
handler.NewCol(NotifyInstanceIDCol, nil),
|
||||
},
|
||||
[]handler.Column{
|
||||
handler.NewCol(NotifyUserIDCol, nil),
|
||||
handler.NewCol(NotifyInstanceIDCol, nil),
|
||||
@@ -799,6 +803,10 @@ func (p *userProjection) reduceHumanEmailVerified(event eventstore.Event) (*hand
|
||||
crdb.WithTableSuffix(UserHumanSuffix),
|
||||
),
|
||||
crdb.AddCopyStatement(
|
||||
[]handler.Column{
|
||||
handler.NewCol(NotifyUserIDCol, nil),
|
||||
handler.NewCol(NotifyInstanceIDCol, nil),
|
||||
},
|
||||
[]handler.Column{
|
||||
handler.NewCol(NotifyUserIDCol, nil),
|
||||
handler.NewCol(NotifyInstanceIDCol, nil),
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
UserAuthMethodTable = "projections.user_auth_methods"
|
||||
UserAuthMethodTable = "projections.user_auth_methods2"
|
||||
|
||||
UserAuthMethodUserIDCol = "user_id"
|
||||
UserAuthMethodTypeCol = "method_type"
|
||||
@@ -48,7 +48,7 @@ func newUserAuthMethodProjection(ctx context.Context, config crdb.StatementHandl
|
||||
crdb.NewColumn(UserAuthMethodNameCol, crdb.ColumnTypeText),
|
||||
},
|
||||
crdb.NewPrimaryKey(UserAuthMethodInstanceIDCol, UserAuthMethodUserIDCol, UserAuthMethodTypeCol, UserAuthMethodTokenIDCol),
|
||||
crdb.WithIndex(crdb.NewIndex("ro_idx", []string{UserAuthMethodResourceOwnerCol})),
|
||||
crdb.WithIndex(crdb.NewIndex("auth_meth_ro_idx", []string{UserAuthMethodResourceOwnerCol})),
|
||||
),
|
||||
)
|
||||
p.StatementHandler = crdb.NewStatementHandler(ctx, config)
|
||||
@@ -119,6 +119,12 @@ func (p *userAuthMethodProjection) reduceInitAuthMethod(event eventstore.Event)
|
||||
|
||||
return crdb.NewUpsertStatement(
|
||||
event,
|
||||
[]handler.Column{
|
||||
handler.NewCol(UserAuthMethodInstanceIDCol, nil),
|
||||
handler.NewCol(UserAuthMethodUserIDCol, nil),
|
||||
handler.NewCol(UserAuthMethodTypeCol, nil),
|
||||
handler.NewCol(UserAuthMethodTokenIDCol, nil),
|
||||
},
|
||||
[]handler.Column{
|
||||
handler.NewCol(UserAuthMethodTokenIDCol, tokenID),
|
||||
handler.NewCol(UserAuthMethodCreationDateCol, event.CreationDate()),
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.user_auth_methods (token_id, creation_date, change_date, resource_owner, instance_id, user_id, sequence, state, method_type, name) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.user_auth_methods2 (token_id, creation_date, change_date, resource_owner, instance_id, user_id, sequence, state, method_type, name) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ON CONFLICT (instance_id, user_id, method_type, token_id) DO UPDATE SET (creation_date, change_date, resource_owner, sequence, state, name) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.resource_owner, EXCLUDED.sequence, EXCLUDED.state, EXCLUDED.name)",
|
||||
expectedArgs: []interface{}{
|
||||
"token-id",
|
||||
anyArg{},
|
||||
@@ -79,7 +79,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.user_auth_methods (token_id, creation_date, change_date, resource_owner, instance_id, user_id, sequence, state, method_type, name) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.user_auth_methods2 (token_id, creation_date, change_date, resource_owner, instance_id, user_id, sequence, state, method_type, name) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ON CONFLICT (instance_id, user_id, method_type, token_id) DO UPDATE SET (creation_date, change_date, resource_owner, sequence, state, name) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.resource_owner, EXCLUDED.sequence, EXCLUDED.state, EXCLUDED.name)",
|
||||
expectedArgs: []interface{}{
|
||||
"token-id",
|
||||
anyArg{},
|
||||
@@ -116,7 +116,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.user_auth_methods (token_id, creation_date, change_date, resource_owner, instance_id, user_id, sequence, state, method_type, name) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.user_auth_methods2 (token_id, creation_date, change_date, resource_owner, instance_id, user_id, sequence, state, method_type, name) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ON CONFLICT (instance_id, user_id, method_type, token_id) DO UPDATE SET (creation_date, change_date, resource_owner, sequence, state, name) = (EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.resource_owner, EXCLUDED.sequence, EXCLUDED.state, EXCLUDED.name)",
|
||||
expectedArgs: []interface{}{
|
||||
"",
|
||||
anyArg{},
|
||||
@@ -155,7 +155,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_auth_methods SET (change_date, sequence, name, state) = ($1, $2, $3, $4) WHERE (user_id = $5) AND (method_type = $6) AND (resource_owner = $7) AND (token_id = $8)",
|
||||
expectedStmt: "UPDATE projections.user_auth_methods2 SET (change_date, sequence, name, state) = ($1, $2, $3, $4) WHERE (user_id = $5) AND (method_type = $6) AND (resource_owner = $7) AND (token_id = $8)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -192,7 +192,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_auth_methods SET (change_date, sequence, name, state) = ($1, $2, $3, $4) WHERE (user_id = $5) AND (method_type = $6) AND (resource_owner = $7) AND (token_id = $8)",
|
||||
expectedStmt: "UPDATE projections.user_auth_methods2 SET (change_date, sequence, name, state) = ($1, $2, $3, $4) WHERE (user_id = $5) AND (method_type = $6) AND (resource_owner = $7) AND (token_id = $8)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -227,7 +227,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_auth_methods SET (change_date, sequence, name, state) = ($1, $2, $3, $4) WHERE (user_id = $5) AND (method_type = $6) AND (resource_owner = $7) AND (token_id = $8)",
|
||||
expectedStmt: "UPDATE projections.user_auth_methods2 SET (change_date, sequence, name, state) = ($1, $2, $3, $4) WHERE (user_id = $5) AND (method_type = $6) AND (resource_owner = $7) AND (token_id = $8)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
|
||||
@@ -3,8 +3,7 @@ package projection
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
@@ -16,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
UserGrantProjectionTable = "projections.user_grants"
|
||||
UserGrantProjectionTable = "projections.user_grants2"
|
||||
|
||||
UserGrantID = "id"
|
||||
UserGrantCreationDate = "creation_date"
|
||||
@@ -54,8 +53,8 @@ func newUserGrantProjection(ctx context.Context, config crdb.StatementHandlerCon
|
||||
crdb.NewColumn(UserGrantRoles, crdb.ColumnTypeTextArray, crdb.Nullable()),
|
||||
},
|
||||
crdb.NewPrimaryKey(UserGrantInstanceID, UserGrantID),
|
||||
crdb.WithIndex(crdb.NewIndex("user_idx", []string{UserGrantUserID})),
|
||||
crdb.WithIndex(crdb.NewIndex("ro_idx", []string{UserGrantResourceOwner})),
|
||||
crdb.WithIndex(crdb.NewIndex("user_grant_user_idx", []string{UserGrantUserID})),
|
||||
crdb.WithIndex(crdb.NewIndex("user_grant_ro_idx", []string{UserGrantResourceOwner})),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -152,14 +151,14 @@ func (p *userGrantProjection) reduceAdded(event eventstore.Event) (*handler.Stat
|
||||
handler.NewCol(UserGrantUserID, e.UserID),
|
||||
handler.NewCol(UserGrantProjectID, e.ProjectID),
|
||||
handler.NewCol(UserGrantGrantID, e.ProjectGrantID),
|
||||
handler.NewCol(UserGrantRoles, pq.StringArray(e.RoleKeys)),
|
||||
handler.NewCol(UserGrantRoles, database.StringArray(e.RoleKeys)),
|
||||
handler.NewCol(UserGrantState, domain.UserGrantStateActive),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
||||
func (p *userGrantProjection) reduceChanged(event eventstore.Event) (*handler.Statement, error) {
|
||||
var roles pq.StringArray
|
||||
var roles database.StringArray
|
||||
|
||||
switch e := event.(type) {
|
||||
case *usergrant.UserGrantChangedEvent:
|
||||
@@ -309,7 +308,7 @@ func (p *userGrantProjection) reduceProjectGrantChanged(event eventstore.Event)
|
||||
return crdb.NewUpdateStatement(
|
||||
event,
|
||||
[]handler.Column{
|
||||
crdb.NewArrayIntersectCol(UserGrantRoles, pq.StringArray(keys)),
|
||||
crdb.NewArrayIntersectCol(UserGrantRoles, database.StringArray(keys)),
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(UserGrantGrantID, grantID),
|
||||
|
||||
@@ -3,8 +3,7 @@ package projection
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
@@ -47,7 +46,7 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.user_grants (id, resource_owner, instance_id, creation_date, change_date, sequence, user_id, project_id, grant_id, roles, state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedStmt: "INSERT INTO projections.user_grants2 (id, resource_owner, instance_id, creation_date, change_date, sequence, user_id, project_id, grant_id, roles, state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"ro-id",
|
||||
@@ -58,7 +57,7 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
"user-id",
|
||||
"project-id",
|
||||
"",
|
||||
pq.StringArray{"role"},
|
||||
database.StringArray{"role"},
|
||||
domain.UserGrantStateActive,
|
||||
},
|
||||
},
|
||||
@@ -86,10 +85,10 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_grants SET (change_date, roles, sequence) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (change_date, roles, sequence) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
pq.StringArray{"role"},
|
||||
database.StringArray{"role"},
|
||||
uint64(15),
|
||||
"agg-id",
|
||||
},
|
||||
@@ -118,10 +117,10 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_grants SET (change_date, roles, sequence) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (change_date, roles, sequence) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
pq.StringArray{"role"},
|
||||
database.StringArray{"role"},
|
||||
uint64(15),
|
||||
"agg-id",
|
||||
},
|
||||
@@ -148,7 +147,7 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_grants WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
},
|
||||
@@ -175,7 +174,7 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_grants WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
},
|
||||
@@ -202,7 +201,7 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_grants SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.UserGrantStateInactive,
|
||||
@@ -232,7 +231,7 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_grants SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.UserGrantStateActive,
|
||||
@@ -262,7 +261,7 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_grants WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
},
|
||||
@@ -289,7 +288,7 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_grants WHERE (project_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (project_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
},
|
||||
@@ -316,7 +315,7 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_grants WHERE (grant_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (grant_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"grantID",
|
||||
},
|
||||
@@ -343,7 +342,7 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_grants SET (roles) = (array_remove(roles, $1)) WHERE (project_id = $2)",
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (roles) = (array_remove(roles, $1)) WHERE (project_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"key",
|
||||
"agg-id",
|
||||
@@ -371,9 +370,9 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_grants SET (roles) = (SELECT ARRAY( SELECT UNNEST(roles) INTERSECT SELECT UNNEST ($1::STRING[]))) WHERE (grant_id = $2)",
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (roles) = (SELECT ARRAY( SELECT UNNEST(roles) INTERSECT SELECT UNNEST ($1::TEXT[]))) WHERE (grant_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
pq.StringArray{"key"},
|
||||
database.StringArray{"key"},
|
||||
"grantID",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
UserMetadataProjectionTable = "projections.user_metadata2"
|
||||
UserMetadataProjectionTable = "projections.user_metadata3"
|
||||
|
||||
UserMetadataColumnUserID = "user_id"
|
||||
UserMetadataColumnCreationDate = "creation_date"
|
||||
@@ -43,7 +43,7 @@ func newUserMetadataProjection(ctx context.Context, config crdb.StatementHandler
|
||||
crdb.NewColumn(UserMetadataColumnValue, crdb.ColumnTypeBytes, crdb.Nullable()),
|
||||
},
|
||||
crdb.NewPrimaryKey(UserMetadataColumnInstanceID, UserMetadataColumnUserID, UserMetadataColumnKey),
|
||||
crdb.WithIndex(crdb.NewIndex("ro_idx", []string{UserGrantResourceOwner})),
|
||||
crdb.WithIndex(crdb.NewIndex("usr_md_ro_idx", []string{UserGrantResourceOwner})),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -85,13 +85,18 @@ func (p *userMetadataProjection) reduceMetadataSet(event eventstore.Event) (*han
|
||||
return crdb.NewUpsertStatement(
|
||||
e,
|
||||
[]handler.Column{
|
||||
handler.NewCol(UserMetadataColumnUserID, e.Aggregate().ID),
|
||||
handler.NewCol(UserMetadataColumnResourceOwner, e.Aggregate().ResourceOwner),
|
||||
handler.NewCol(UserMetadataColumnInstanceID, nil),
|
||||
handler.NewCol(UserMetadataColumnUserID, nil),
|
||||
handler.NewCol(UserMetadataColumnKey, e.Key),
|
||||
},
|
||||
[]handler.Column{
|
||||
handler.NewCol(UserMetadataColumnInstanceID, e.Aggregate().InstanceID),
|
||||
handler.NewCol(UserMetadataColumnUserID, e.Aggregate().ID),
|
||||
handler.NewCol(UserMetadataColumnKey, e.Key),
|
||||
handler.NewCol(UserMetadataColumnResourceOwner, e.Aggregate().ResourceOwner),
|
||||
handler.NewCol(UserMetadataColumnCreationDate, e.CreationDate()),
|
||||
handler.NewCol(UserMetadataColumnChangeDate, e.CreationDate()),
|
||||
handler.NewCol(UserMetadataColumnSequence, e.Sequence()),
|
||||
handler.NewCol(UserMetadataColumnKey, e.Key),
|
||||
handler.NewCol(UserMetadataColumnValue, e.Value),
|
||||
},
|
||||
), nil
|
||||
|
||||
@@ -41,15 +41,15 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.user_metadata2 (user_id, resource_owner, instance_id, creation_date, change_date, sequence, key, value) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedStmt: "INSERT INTO projections.user_metadata3 (instance_id, user_id, key, resource_owner, creation_date, change_date, sequence, value) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT (instance_id, user_id, key) DO UPDATE SET (resource_owner, creation_date, change_date, sequence, value) = (EXCLUDED.resource_owner, EXCLUDED.creation_date, EXCLUDED.change_date, EXCLUDED.sequence, EXCLUDED.value)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
"agg-id",
|
||||
"key",
|
||||
"ro-id",
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"key",
|
||||
[]byte("value"),
|
||||
},
|
||||
},
|
||||
@@ -77,7 +77,7 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_metadata2 WHERE (user_id = $1) AND (key = $2)",
|
||||
expectedStmt: "DELETE FROM projections.user_metadata3 WHERE (user_id = $1) AND (key = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"key",
|
||||
@@ -105,7 +105,7 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_metadata2 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_metadata3 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@@ -132,7 +132,7 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_metadata2 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_metadata3 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
|
||||
@@ -3,8 +3,7 @@ package projection
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
@@ -13,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
PersonalAccessTokenProjectionTable = "projections.personal_access_tokens"
|
||||
PersonalAccessTokenProjectionTable = "projections.personal_access_tokens2"
|
||||
|
||||
PersonalAccessTokenColumnID = "id"
|
||||
PersonalAccessTokenColumnCreationDate = "creation_date"
|
||||
@@ -47,8 +46,8 @@ func newPersonalAccessTokenProjection(ctx context.Context, config crdb.Statement
|
||||
crdb.NewColumn(PersonalAccessTokenColumnScopes, crdb.ColumnTypeTextArray, crdb.Nullable()),
|
||||
},
|
||||
crdb.NewPrimaryKey(PersonalAccessTokenColumnInstanceID, PersonalAccessTokenColumnID),
|
||||
crdb.WithIndex(crdb.NewIndex("user_idx", []string{PersonalAccessTokenColumnUserID})),
|
||||
crdb.WithIndex(crdb.NewIndex("ro_idx", []string{PersonalAccessTokenColumnResourceOwner})),
|
||||
crdb.WithIndex(crdb.NewIndex("pat_user_idx", []string{PersonalAccessTokenColumnUserID})),
|
||||
crdb.WithIndex(crdb.NewIndex("pat_ro_idx", []string{PersonalAccessTokenColumnResourceOwner})),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -94,7 +93,7 @@ func (p *personalAccessTokenProjection) reducePersonalAccessTokenAdded(event eve
|
||||
handler.NewCol(PersonalAccessTokenColumnSequence, e.Sequence()),
|
||||
handler.NewCol(PersonalAccessTokenColumnUserID, e.Aggregate().ID),
|
||||
handler.NewCol(PersonalAccessTokenColumnExpiration, e.Expiration),
|
||||
handler.NewCol(PersonalAccessTokenColumnScopes, pq.StringArray(e.Scopes)),
|
||||
handler.NewCol(PersonalAccessTokenColumnScopes, database.StringArray(e.Scopes)),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
@@ -41,7 +40,7 @@ func TestPersonalAccessTokenProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.personal_access_tokens (id, creation_date, change_date, resource_owner, instance_id, sequence, user_id, expiration, scopes) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.personal_access_tokens2 (id, creation_date, change_date, resource_owner, instance_id, sequence, user_id, expiration, scopes) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"tokenID",
|
||||
anyArg{},
|
||||
@@ -51,7 +50,7 @@ func TestPersonalAccessTokenProjection_reduces(t *testing.T) {
|
||||
uint64(15),
|
||||
"agg-id",
|
||||
time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC),
|
||||
pq.StringArray{"openid"},
|
||||
database.StringArray{"openid"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -76,7 +75,7 @@ func TestPersonalAccessTokenProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.personal_access_tokens WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.personal_access_tokens2 WHERE (id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"tokenID",
|
||||
},
|
||||
@@ -103,7 +102,7 @@ func TestPersonalAccessTokenProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.personal_access_tokens WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.personal_access_tokens2 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
|
||||
@@ -50,7 +50,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users3 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -64,7 +64,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.users3_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -79,7 +79,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users3_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -120,7 +120,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users3 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -134,7 +134,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.users3_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -149,7 +149,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users3_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -185,7 +185,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users3 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -199,7 +199,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.users3_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -214,7 +214,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users3_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -255,7 +255,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users3 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -269,7 +269,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.users3_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -284,7 +284,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users3_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -325,7 +325,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users3 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -339,7 +339,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.users3_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -354,7 +354,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users3_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -390,7 +390,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users3 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -404,7 +404,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedStmt: "INSERT INTO projections.users3_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -419,7 +419,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users3_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -450,7 +450,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (state) = ($1) WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (state) = ($1) WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.UserStateInitial,
|
||||
"agg-id",
|
||||
@@ -479,7 +479,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (state) = ($1) WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (state) = ($1) WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.UserStateInitial,
|
||||
"agg-id",
|
||||
@@ -508,7 +508,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (state) = ($1) WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (state) = ($1) WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.UserStateActive,
|
||||
"agg-id",
|
||||
@@ -537,7 +537,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (state) = ($1) WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (state) = ($1) WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.UserStateActive,
|
||||
"agg-id",
|
||||
@@ -566,7 +566,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.UserStateLocked,
|
||||
@@ -597,7 +597,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.UserStateActive,
|
||||
@@ -628,7 +628,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.UserStateInactive,
|
||||
@@ -659,7 +659,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.UserStateActive,
|
||||
@@ -690,7 +690,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.users2 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.users3 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -720,7 +720,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, username, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, username, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
"username",
|
||||
@@ -753,7 +753,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, username, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, username, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
"[email protected]",
|
||||
@@ -791,7 +791,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -800,7 +800,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (first_name, last_name, nick_name, display_name, preferred_language, gender) = ($1, $2, $3, $4, $5, $6) WHERE (user_id = $7) AND (instance_id = $8)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (first_name, last_name, nick_name, display_name, preferred_language, gender) = ($1, $2, $3, $4, $5, $6) WHERE (user_id = $7) AND (instance_id = $8)",
|
||||
expectedArgs: []interface{}{
|
||||
"first-name",
|
||||
"last-name",
|
||||
@@ -841,7 +841,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -850,7 +850,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (first_name, last_name, nick_name, display_name, preferred_language, gender) = ($1, $2, $3, $4, $5, $6) WHERE (user_id = $7) AND (instance_id = $8)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (first_name, last_name, nick_name, display_name, preferred_language, gender) = ($1, $2, $3, $4, $5, $6) WHERE (user_id = $7) AND (instance_id = $8)",
|
||||
expectedArgs: []interface{}{
|
||||
"first-name",
|
||||
"last-name",
|
||||
@@ -886,7 +886,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -895,7 +895,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"+41 00 000 00 00",
|
||||
false,
|
||||
@@ -904,7 +904,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_notifications SET (last_phone) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3_notifications SET (last_phone) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
&sql.NullString{String: "+41 00 000 00 00", Valid: true},
|
||||
"agg-id",
|
||||
@@ -935,7 +935,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -944,7 +944,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"+41 00 000 00 00",
|
||||
false,
|
||||
@@ -953,7 +953,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_notifications SET (last_phone) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3_notifications SET (last_phone) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
&sql.NullString{String: "+41 00 000 00 00", Valid: true},
|
||||
"agg-id",
|
||||
@@ -982,7 +982,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -991,7 +991,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
nil,
|
||||
nil,
|
||||
@@ -1000,7 +1000,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_notifications SET (last_phone, verified_phone) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3_notifications SET (last_phone, verified_phone) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
nil,
|
||||
nil,
|
||||
@@ -1030,7 +1030,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1039,7 +1039,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
nil,
|
||||
nil,
|
||||
@@ -1048,7 +1048,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_notifications SET (last_phone, verified_phone) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3_notifications SET (last_phone, verified_phone) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
nil,
|
||||
nil,
|
||||
@@ -1078,7 +1078,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1087,7 +1087,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (is_phone_verified) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (is_phone_verified) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"agg-id",
|
||||
@@ -1095,7 +1095,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.users2_notifications (user_id, instance_id, verified_phone) SELECT user_id, instance_id, last_phone FROM projections.users2_notifications AS copy_table WHERE copy_table.user_id = $1 AND copy_table.instance_id = $2",
|
||||
expectedStmt: "INSERT INTO projections.users3_notifications (user_id, instance_id, verified_phone) SELECT user_id, instance_id, last_phone FROM projections.users3_notifications AS copy_table WHERE copy_table.user_id = $1 AND copy_table.instance_id = $2 ON CONFLICT (user_id, instance_id) DO UPDATE SET (user_id, instance_id, verified_phone) = (EXCLUDED.user_id, EXCLUDED.instance_id, EXCLUDED.last_phone)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -1123,7 +1123,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1132,7 +1132,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (is_phone_verified) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (is_phone_verified) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"agg-id",
|
||||
@@ -1140,7 +1140,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.users2_notifications (user_id, instance_id, verified_phone) SELECT user_id, instance_id, last_phone FROM projections.users2_notifications AS copy_table WHERE copy_table.user_id = $1 AND copy_table.instance_id = $2",
|
||||
expectedStmt: "INSERT INTO projections.users3_notifications (user_id, instance_id, verified_phone) SELECT user_id, instance_id, last_phone FROM projections.users3_notifications AS copy_table WHERE copy_table.user_id = $1 AND copy_table.instance_id = $2 ON CONFLICT (user_id, instance_id) DO UPDATE SET (user_id, instance_id, verified_phone) = (EXCLUDED.user_id, EXCLUDED.instance_id, EXCLUDED.last_phone)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -1170,7 +1170,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1179,7 +1179,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (email, is_email_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (email, is_email_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"[email protected]",
|
||||
false,
|
||||
@@ -1188,7 +1188,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_notifications SET (last_email) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3_notifications SET (last_email) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
&sql.NullString{String: "[email protected]", Valid: true},
|
||||
"agg-id",
|
||||
@@ -1219,7 +1219,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1228,7 +1228,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (email, is_email_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (email, is_email_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"[email protected]",
|
||||
false,
|
||||
@@ -1237,7 +1237,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_notifications SET (last_email) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3_notifications SET (last_email) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
&sql.NullString{String: "[email protected]", Valid: true},
|
||||
"agg-id",
|
||||
@@ -1266,7 +1266,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1275,7 +1275,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (is_email_verified) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (is_email_verified) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"agg-id",
|
||||
@@ -1283,7 +1283,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.users2_notifications (user_id, instance_id, verified_email) SELECT user_id, instance_id, last_email FROM projections.users2_notifications AS copy_table WHERE copy_table.user_id = $1 AND copy_table.instance_id = $2",
|
||||
expectedStmt: "INSERT INTO projections.users3_notifications (user_id, instance_id, verified_email) SELECT user_id, instance_id, last_email FROM projections.users3_notifications AS copy_table WHERE copy_table.user_id = $1 AND copy_table.instance_id = $2 ON CONFLICT (user_id, instance_id) DO UPDATE SET (user_id, instance_id, verified_email) = (EXCLUDED.user_id, EXCLUDED.instance_id, EXCLUDED.last_email)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -1311,7 +1311,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1320,7 +1320,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (is_email_verified) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (is_email_verified) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"agg-id",
|
||||
@@ -1328,7 +1328,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.users2_notifications (user_id, instance_id, verified_email) SELECT user_id, instance_id, last_email FROM projections.users2_notifications AS copy_table WHERE copy_table.user_id = $1 AND copy_table.instance_id = $2",
|
||||
expectedStmt: "INSERT INTO projections.users3_notifications (user_id, instance_id, verified_email) SELECT user_id, instance_id, last_email FROM projections.users3_notifications AS copy_table WHERE copy_table.user_id = $1 AND copy_table.instance_id = $2 ON CONFLICT (user_id, instance_id) DO UPDATE SET (user_id, instance_id, verified_email) = (EXCLUDED.user_id, EXCLUDED.instance_id, EXCLUDED.last_email)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -1358,7 +1358,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1367,7 +1367,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (avatar_key) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (avatar_key) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"users/agg-id/avatar",
|
||||
"agg-id",
|
||||
@@ -1396,7 +1396,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1405,7 +1405,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_humans SET (avatar_key) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3_humans SET (avatar_key) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
nil,
|
||||
"agg-id",
|
||||
@@ -1437,7 +1437,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users3 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -1451,7 +1451,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_machines (user_id, instance_id, name, description) VALUES ($1, $2, $3, $4)",
|
||||
expectedStmt: "INSERT INTO projections.users3_machines (user_id, instance_id, name, description) VALUES ($1, $2, $3, $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -1485,7 +1485,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users3 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -1499,7 +1499,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users2_machines (user_id, instance_id, name, description) VALUES ($1, $2, $3, $4)",
|
||||
expectedStmt: "INSERT INTO projections.users3_machines (user_id, instance_id, name, description) VALUES ($1, $2, $3, $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -1532,7 +1532,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1541,7 +1541,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_machines SET (name, description) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3_machines SET (name, description) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"machine-name",
|
||||
"description",
|
||||
@@ -1573,7 +1573,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1582,7 +1582,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_machines SET (name) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3_machines SET (name) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"machine-name",
|
||||
"agg-id",
|
||||
@@ -1613,7 +1613,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users3 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1622,7 +1622,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users2_machines SET (description) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users3_machines SET (description) = ($1) WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"description",
|
||||
"agg-id",
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"reflect"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
)
|
||||
@@ -139,7 +138,7 @@ func (s *TextQuery) comp() sq.Sqlizer {
|
||||
case TextContainsIgnoreCase:
|
||||
return sq.ILike{s.Column.identifier(): "%" + s.Text + "%"}
|
||||
case TextListContains:
|
||||
return &listContains{col: s.Column, args: []interface{}{pq.StringArray{s.Text}}}
|
||||
return &listContains{col: s.Column, args: []interface{}{s.Text}}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -228,7 +227,7 @@ func (s *NumberQuery) comp() sq.Sqlizer {
|
||||
case NumberGreater:
|
||||
return sq.Gt{s.Column.identifier(): s.Number}
|
||||
case NumberListContains:
|
||||
return &listContains{col: s.Column, args: []interface{}{pq.GenericArray{s.Number}}}
|
||||
return &listContains{col: s.Column, args: []interface{}{s.Number}}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -379,7 +378,7 @@ func (t table) identifier() string {
|
||||
if t.alias == "" {
|
||||
return t.name
|
||||
}
|
||||
return t.name + " as " + t.alias
|
||||
return t.name + " AS " + t.alias
|
||||
}
|
||||
|
||||
func (t table) isZero() bool {
|
||||
@@ -424,9 +423,9 @@ func join(join, from Column) string {
|
||||
|
||||
type listContains struct {
|
||||
col Column
|
||||
args []interface{}
|
||||
args interface{}
|
||||
}
|
||||
|
||||
func (q *listContains) ToSql() (string, []interface{}, error) {
|
||||
return q.col.identifier() + " @> ? ", q.args, nil
|
||||
return q.col.identifier() + " @> ? ", []interface{}{q.args}, nil
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"testing"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
)
|
||||
|
||||
@@ -339,7 +338,7 @@ func TestTextQuery_comp(t *testing.T) {
|
||||
want: want{
|
||||
query: &listContains{
|
||||
col: testCol,
|
||||
args: []interface{}{pq.StringArray{"Hurst"}},
|
||||
args: []interface{}{"Hurst"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -643,7 +642,7 @@ func TestNumberQuery_comp(t *testing.T) {
|
||||
want: want{
|
||||
query: &listContains{
|
||||
col: testCol,
|
||||
args: []interface{}{pq.GenericArray{42}},
|
||||
args: []interface{}{42},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -29,20 +29,20 @@ func Test_SecretGeneratorsPrepares(t *testing.T) {
|
||||
prepare: prepareSecretGeneratorsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.secret_generators.aggregate_id,`+
|
||||
` projections.secret_generators.generator_type,`+
|
||||
` projections.secret_generators.creation_date,`+
|
||||
` projections.secret_generators.change_date,`+
|
||||
` projections.secret_generators.resource_owner,`+
|
||||
` projections.secret_generators.sequence,`+
|
||||
` projections.secret_generators.length,`+
|
||||
` projections.secret_generators.expiry,`+
|
||||
` projections.secret_generators.include_lower_letters,`+
|
||||
` projections.secret_generators.include_upper_letters,`+
|
||||
` projections.secret_generators.include_digits,`+
|
||||
` projections.secret_generators.include_symbols,`+
|
||||
regexp.QuoteMeta(`SELECT projections.secret_generators2.aggregate_id,`+
|
||||
` projections.secret_generators2.generator_type,`+
|
||||
` projections.secret_generators2.creation_date,`+
|
||||
` projections.secret_generators2.change_date,`+
|
||||
` projections.secret_generators2.resource_owner,`+
|
||||
` projections.secret_generators2.sequence,`+
|
||||
` projections.secret_generators2.length,`+
|
||||
` projections.secret_generators2.expiry,`+
|
||||
` projections.secret_generators2.include_lower_letters,`+
|
||||
` projections.secret_generators2.include_upper_letters,`+
|
||||
` projections.secret_generators2.include_digits,`+
|
||||
` projections.secret_generators2.include_symbols,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.secret_generators`),
|
||||
` FROM projections.secret_generators2`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -54,20 +54,20 @@ func Test_SecretGeneratorsPrepares(t *testing.T) {
|
||||
prepare: prepareSecretGeneratorsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.secret_generators.aggregate_id,`+
|
||||
` projections.secret_generators.generator_type,`+
|
||||
` projections.secret_generators.creation_date,`+
|
||||
` projections.secret_generators.change_date,`+
|
||||
` projections.secret_generators.resource_owner,`+
|
||||
` projections.secret_generators.sequence,`+
|
||||
` projections.secret_generators.length,`+
|
||||
` projections.secret_generators.expiry,`+
|
||||
` projections.secret_generators.include_lower_letters,`+
|
||||
` projections.secret_generators.include_upper_letters,`+
|
||||
` projections.secret_generators.include_digits,`+
|
||||
` projections.secret_generators.include_symbols,`+
|
||||
regexp.QuoteMeta(`SELECT projections.secret_generators2.aggregate_id,`+
|
||||
` projections.secret_generators2.generator_type,`+
|
||||
` projections.secret_generators2.creation_date,`+
|
||||
` projections.secret_generators2.change_date,`+
|
||||
` projections.secret_generators2.resource_owner,`+
|
||||
` projections.secret_generators2.sequence,`+
|
||||
` projections.secret_generators2.length,`+
|
||||
` projections.secret_generators2.expiry,`+
|
||||
` projections.secret_generators2.include_lower_letters,`+
|
||||
` projections.secret_generators2.include_upper_letters,`+
|
||||
` projections.secret_generators2.include_digits,`+
|
||||
` projections.secret_generators2.include_symbols,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.secret_generators`),
|
||||
` FROM projections.secret_generators2`),
|
||||
[]string{
|
||||
"aggregate_id",
|
||||
"generator_type",
|
||||
@@ -128,20 +128,20 @@ func Test_SecretGeneratorsPrepares(t *testing.T) {
|
||||
prepare: prepareSecretGeneratorsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.secret_generators.aggregate_id,`+
|
||||
` projections.secret_generators.generator_type,`+
|
||||
` projections.secret_generators.creation_date,`+
|
||||
` projections.secret_generators.change_date,`+
|
||||
` projections.secret_generators.resource_owner,`+
|
||||
` projections.secret_generators.sequence,`+
|
||||
` projections.secret_generators.length,`+
|
||||
` projections.secret_generators.expiry,`+
|
||||
` projections.secret_generators.include_lower_letters,`+
|
||||
` projections.secret_generators.include_upper_letters,`+
|
||||
` projections.secret_generators.include_digits,`+
|
||||
` projections.secret_generators.include_symbols,`+
|
||||
regexp.QuoteMeta(`SELECT projections.secret_generators2.aggregate_id,`+
|
||||
` projections.secret_generators2.generator_type,`+
|
||||
` projections.secret_generators2.creation_date,`+
|
||||
` projections.secret_generators2.change_date,`+
|
||||
` projections.secret_generators2.resource_owner,`+
|
||||
` projections.secret_generators2.sequence,`+
|
||||
` projections.secret_generators2.length,`+
|
||||
` projections.secret_generators2.expiry,`+
|
||||
` projections.secret_generators2.include_lower_letters,`+
|
||||
` projections.secret_generators2.include_upper_letters,`+
|
||||
` projections.secret_generators2.include_digits,`+
|
||||
` projections.secret_generators2.include_symbols,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.secret_generators`),
|
||||
` FROM projections.secret_generators2`),
|
||||
[]string{
|
||||
"aggregate_id",
|
||||
"generator_type",
|
||||
@@ -230,20 +230,20 @@ func Test_SecretGeneratorsPrepares(t *testing.T) {
|
||||
prepare: prepareSecretGeneratorsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.secret_generators.aggregate_id,`+
|
||||
` projections.secret_generators.generator_type,`+
|
||||
` projections.secret_generators.creation_date,`+
|
||||
` projections.secret_generators.change_date,`+
|
||||
` projections.secret_generators.resource_owner,`+
|
||||
` projections.secret_generators.sequence,`+
|
||||
` projections.secret_generators.length,`+
|
||||
` projections.secret_generators.expiry,`+
|
||||
` projections.secret_generators.include_lower_letters,`+
|
||||
` projections.secret_generators.include_upper_letters,`+
|
||||
` projections.secret_generators.include_digits,`+
|
||||
` projections.secret_generators.include_symbols,`+
|
||||
regexp.QuoteMeta(`SELECT projections.secret_generators2.aggregate_id,`+
|
||||
` projections.secret_generators2.generator_type,`+
|
||||
` projections.secret_generators2.creation_date,`+
|
||||
` projections.secret_generators2.change_date,`+
|
||||
` projections.secret_generators2.resource_owner,`+
|
||||
` projections.secret_generators2.sequence,`+
|
||||
` projections.secret_generators2.length,`+
|
||||
` projections.secret_generators2.expiry,`+
|
||||
` projections.secret_generators2.include_lower_letters,`+
|
||||
` projections.secret_generators2.include_upper_letters,`+
|
||||
` projections.secret_generators2.include_digits,`+
|
||||
` projections.secret_generators2.include_symbols,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.secret_generators`),
|
||||
` FROM projections.secret_generators2`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@@ -260,19 +260,19 @@ func Test_SecretGeneratorsPrepares(t *testing.T) {
|
||||
prepare: prepareSecretGeneratorQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
`SELECT projections.secret_generators.aggregate_id,`+
|
||||
` projections.secret_generators.generator_type,`+
|
||||
` projections.secret_generators.creation_date,`+
|
||||
` projections.secret_generators.change_date,`+
|
||||
` projections.secret_generators.resource_owner,`+
|
||||
` projections.secret_generators.sequence,`+
|
||||
` projections.secret_generators.length,`+
|
||||
` projections.secret_generators.expiry,`+
|
||||
` projections.secret_generators.include_lower_letters,`+
|
||||
` projections.secret_generators.include_upper_letters,`+
|
||||
` projections.secret_generators.include_digits,`+
|
||||
` projections.secret_generators.include_symbols`+
|
||||
` FROM projections.secret_generators`,
|
||||
`SELECT projections.secret_generators2.aggregate_id,`+
|
||||
` projections.secret_generators2.generator_type,`+
|
||||
` projections.secret_generators2.creation_date,`+
|
||||
` projections.secret_generators2.change_date,`+
|
||||
` projections.secret_generators2.resource_owner,`+
|
||||
` projections.secret_generators2.sequence,`+
|
||||
` projections.secret_generators2.length,`+
|
||||
` projections.secret_generators2.expiry,`+
|
||||
` projections.secret_generators2.include_lower_letters,`+
|
||||
` projections.secret_generators2.include_upper_letters,`+
|
||||
` projections.secret_generators2.include_digits,`+
|
||||
` projections.secret_generators2.include_symbols`+
|
||||
` FROM projections.secret_generators2`,
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -290,19 +290,19 @@ func Test_SecretGeneratorsPrepares(t *testing.T) {
|
||||
prepare: prepareSecretGeneratorQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.secret_generators.aggregate_id,`+
|
||||
` projections.secret_generators.generator_type,`+
|
||||
` projections.secret_generators.creation_date,`+
|
||||
` projections.secret_generators.change_date,`+
|
||||
` projections.secret_generators.resource_owner,`+
|
||||
` projections.secret_generators.sequence,`+
|
||||
` projections.secret_generators.length,`+
|
||||
` projections.secret_generators.expiry,`+
|
||||
` projections.secret_generators.include_lower_letters,`+
|
||||
` projections.secret_generators.include_upper_letters,`+
|
||||
` projections.secret_generators.include_digits,`+
|
||||
` projections.secret_generators.include_symbols`+
|
||||
` FROM projections.secret_generators`),
|
||||
regexp.QuoteMeta(`SELECT projections.secret_generators2.aggregate_id,`+
|
||||
` projections.secret_generators2.generator_type,`+
|
||||
` projections.secret_generators2.creation_date,`+
|
||||
` projections.secret_generators2.change_date,`+
|
||||
` projections.secret_generators2.resource_owner,`+
|
||||
` projections.secret_generators2.sequence,`+
|
||||
` projections.secret_generators2.length,`+
|
||||
` projections.secret_generators2.expiry,`+
|
||||
` projections.secret_generators2.include_lower_letters,`+
|
||||
` projections.secret_generators2.include_upper_letters,`+
|
||||
` projections.secret_generators2.include_digits,`+
|
||||
` projections.secret_generators2.include_symbols`+
|
||||
` FROM projections.secret_generators2`),
|
||||
[]string{
|
||||
"aggregate_id",
|
||||
"generator_type",
|
||||
@@ -353,19 +353,19 @@ func Test_SecretGeneratorsPrepares(t *testing.T) {
|
||||
prepare: prepareSecretGeneratorQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.secret_generators.aggregate_id,`+
|
||||
` projections.secret_generators.generator_type,`+
|
||||
` projections.secret_generators.creation_date,`+
|
||||
` projections.secret_generators.change_date,`+
|
||||
` projections.secret_generators.resource_owner,`+
|
||||
` projections.secret_generators.sequence,`+
|
||||
` projections.secret_generators.length,`+
|
||||
` projections.secret_generators.expiry,`+
|
||||
` projections.secret_generators.include_lower_letters,`+
|
||||
` projections.secret_generators.include_upper_letters,`+
|
||||
` projections.secret_generators.include_digits,`+
|
||||
` projections.secret_generators.include_symbols`+
|
||||
` FROM projections.secret_generators`),
|
||||
regexp.QuoteMeta(`SELECT projections.secret_generators2.aggregate_id,`+
|
||||
` projections.secret_generators2.generator_type,`+
|
||||
` projections.secret_generators2.creation_date,`+
|
||||
` projections.secret_generators2.change_date,`+
|
||||
` projections.secret_generators2.resource_owner,`+
|
||||
` projections.secret_generators2.sequence,`+
|
||||
` projections.secret_generators2.length,`+
|
||||
` projections.secret_generators2.expiry,`+
|
||||
` projections.secret_generators2.include_lower_letters,`+
|
||||
` projections.secret_generators2.include_upper_letters,`+
|
||||
` projections.secret_generators2.include_digits,`+
|
||||
` projections.secret_generators2.include_symbols`+
|
||||
` FROM projections.secret_generators2`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
||||
+17
-20
@@ -7,10 +7,10 @@ import (
|
||||
"time"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/query/projection"
|
||||
@@ -30,7 +30,7 @@ type User struct {
|
||||
State domain.UserState
|
||||
Type domain.UserType
|
||||
Username string
|
||||
LoginNames []string
|
||||
LoginNames database.StringArray
|
||||
PreferredLoginName string
|
||||
Human *Human
|
||||
Machine *Machine
|
||||
@@ -99,7 +99,7 @@ type NotifyUser struct {
|
||||
State domain.UserState
|
||||
Type domain.UserType
|
||||
Username string
|
||||
LoginNames []string
|
||||
LoginNames database.StringArray
|
||||
PreferredLoginName string
|
||||
FirstName string
|
||||
LastName string
|
||||
@@ -534,7 +534,7 @@ func NewUserLoginNamesSearchQuery(value string) (SearchQuery, error) {
|
||||
func prepareUserQuery(instanceID string) (sq.SelectBuilder, func(*sql.Row) (*User, error)) {
|
||||
loginNamesQuery, loginNamesArgs, err := sq.Select(
|
||||
userLoginNamesUserIDCol.identifier(),
|
||||
"ARRAY_AGG("+userLoginNamesNameCol.identifier()+") as "+userLoginNamesListCol.name).
|
||||
"ARRAY_AGG("+userLoginNamesNameCol.identifier()+")::TEXT[] AS "+userLoginNamesListCol.name).
|
||||
From(userLoginNamesTable.identifier()).
|
||||
GroupBy(userLoginNamesUserIDCol.identifier()).
|
||||
Where(sq.Eq{
|
||||
@@ -584,12 +584,11 @@ func prepareUserQuery(instanceID string) (sq.SelectBuilder, func(*sql.Row) (*Use
|
||||
From(userTable.identifier()).
|
||||
LeftJoin(join(HumanUserIDCol, UserIDCol)).
|
||||
LeftJoin(join(MachineUserIDCol, UserIDCol)).
|
||||
LeftJoin("("+loginNamesQuery+") as "+userLoginNamesTable.alias+" on "+userLoginNamesUserIDCol.identifier()+" = "+UserIDCol.identifier(), loginNamesArgs...).
|
||||
LeftJoin("("+preferredLoginNameQuery+") as "+userPreferredLoginNameTable.alias+" on "+userPreferredLoginNameUserIDCol.identifier()+" = "+UserIDCol.identifier(), preferredLoginNameArgs...).
|
||||
LeftJoin("("+loginNamesQuery+") AS "+userLoginNamesTable.alias+" ON "+userLoginNamesUserIDCol.identifier()+" = "+UserIDCol.identifier(), loginNamesArgs...).
|
||||
LeftJoin("("+preferredLoginNameQuery+") AS "+userPreferredLoginNameTable.alias+" ON "+userPreferredLoginNameUserIDCol.identifier()+" = "+UserIDCol.identifier(), preferredLoginNameArgs...).
|
||||
PlaceholderFormat(sq.Dollar),
|
||||
func(row *sql.Row) (*User, error) {
|
||||
u := new(User)
|
||||
loginNames := pq.StringArray{}
|
||||
preferredLoginName := sql.NullString{}
|
||||
|
||||
humanID := sql.NullString{}
|
||||
@@ -618,7 +617,7 @@ func prepareUserQuery(instanceID string) (sq.SelectBuilder, func(*sql.Row) (*Use
|
||||
&u.State,
|
||||
&u.Type,
|
||||
&u.Username,
|
||||
&loginNames,
|
||||
&u.LoginNames,
|
||||
&preferredLoginName,
|
||||
&humanID,
|
||||
&firstName,
|
||||
@@ -644,10 +643,8 @@ func prepareUserQuery(instanceID string) (sq.SelectBuilder, func(*sql.Row) (*Use
|
||||
return nil, errors.ThrowInternal(err, "QUERY-Bgah2", "Errors.Internal")
|
||||
}
|
||||
|
||||
u.LoginNames = loginNames
|
||||
if preferredLoginName.Valid {
|
||||
u.PreferredLoginName = preferredLoginName.String
|
||||
}
|
||||
u.PreferredLoginName = preferredLoginName.String
|
||||
|
||||
if humanID.Valid {
|
||||
u.Human = &Human{
|
||||
FirstName: firstName.String,
|
||||
@@ -835,7 +832,7 @@ func preparePhoneQuery() (sq.SelectBuilder, func(*sql.Row) (*Phone, error)) {
|
||||
func prepareNotifyUserQuery(instanceID string) (sq.SelectBuilder, func(*sql.Row) (*NotifyUser, error)) {
|
||||
loginNamesQuery, loginNamesArgs, err := sq.Select(
|
||||
userLoginNamesUserIDCol.identifier(),
|
||||
"ARRAY_AGG("+userLoginNamesNameCol.identifier()+") as "+userLoginNamesListCol.name).
|
||||
"ARRAY_AGG("+userLoginNamesNameCol.identifier()+") AS "+userLoginNamesListCol.name).
|
||||
From(userLoginNamesTable.identifier()).
|
||||
GroupBy(userLoginNamesUserIDCol.identifier()).
|
||||
Where(sq.Eq{
|
||||
@@ -884,12 +881,12 @@ func prepareNotifyUserQuery(instanceID string) (sq.SelectBuilder, func(*sql.Row)
|
||||
From(userTable.identifier()).
|
||||
LeftJoin(join(HumanUserIDCol, UserIDCol)).
|
||||
LeftJoin(join(NotifyUserIDCol, UserIDCol)).
|
||||
LeftJoin("("+loginNamesQuery+") as "+userLoginNamesTable.alias+" on "+userLoginNamesUserIDCol.identifier()+" = "+UserIDCol.identifier(), loginNamesArgs...).
|
||||
LeftJoin("("+preferredLoginNameQuery+") as "+userPreferredLoginNameTable.alias+" on "+userPreferredLoginNameUserIDCol.identifier()+" = "+UserIDCol.identifier(), preferredLoginNameArgs...).
|
||||
LeftJoin("("+loginNamesQuery+") AS "+userLoginNamesTable.alias+" ON "+userLoginNamesUserIDCol.identifier()+" = "+UserIDCol.identifier(), loginNamesArgs...).
|
||||
LeftJoin("("+preferredLoginNameQuery+") AS "+userPreferredLoginNameTable.alias+" ON "+userPreferredLoginNameUserIDCol.identifier()+" = "+UserIDCol.identifier(), preferredLoginNameArgs...).
|
||||
PlaceholderFormat(sq.Dollar),
|
||||
func(row *sql.Row) (*NotifyUser, error) {
|
||||
u := new(NotifyUser)
|
||||
loginNames := pq.StringArray{}
|
||||
loginNames := database.StringArray{}
|
||||
preferredLoginName := sql.NullString{}
|
||||
|
||||
humanID := sql.NullString{}
|
||||
@@ -1009,7 +1006,7 @@ func prepareUserUniqueQuery() (sq.SelectBuilder, func(*sql.Row) (bool, error)) {
|
||||
func prepareUsersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Users, error)) {
|
||||
loginNamesQuery, _, err := sq.Select(
|
||||
userLoginNamesUserIDCol.identifier(),
|
||||
"ARRAY_AGG("+userLoginNamesNameCol.identifier()+") as "+userLoginNamesListCol.name).
|
||||
"ARRAY_AGG("+userLoginNamesNameCol.identifier()+") AS "+userLoginNamesListCol.name).
|
||||
From(userLoginNamesTable.identifier()).
|
||||
GroupBy(userLoginNamesUserIDCol.identifier()).
|
||||
ToSql()
|
||||
@@ -1057,15 +1054,15 @@ func prepareUsersQuery() (sq.SelectBuilder, func(*sql.Rows) (*Users, error)) {
|
||||
From(userTable.identifier()).
|
||||
LeftJoin(join(HumanUserIDCol, UserIDCol)).
|
||||
LeftJoin(join(MachineUserIDCol, UserIDCol)).
|
||||
LeftJoin("("+loginNamesQuery+") as "+userLoginNamesTable.alias+" on "+userLoginNamesUserIDCol.identifier()+" = "+UserIDCol.identifier()).
|
||||
LeftJoin("("+preferredLoginNameQuery+") as "+userPreferredLoginNameTable.alias+" on "+userPreferredLoginNameUserIDCol.identifier()+" = "+UserIDCol.identifier(), preferredLoginNameArgs...).
|
||||
LeftJoin("("+loginNamesQuery+") AS "+userLoginNamesTable.alias+" ON "+userLoginNamesUserIDCol.identifier()+" = "+UserIDCol.identifier()).
|
||||
LeftJoin("("+preferredLoginNameQuery+") AS "+userPreferredLoginNameTable.alias+" ON "+userPreferredLoginNameUserIDCol.identifier()+" = "+UserIDCol.identifier(), preferredLoginNameArgs...).
|
||||
PlaceholderFormat(sq.Dollar),
|
||||
func(rows *sql.Rows) (*Users, error) {
|
||||
users := make([]*User, 0)
|
||||
var count uint64
|
||||
for rows.Next() {
|
||||
u := new(User)
|
||||
loginNames := pq.StringArray{}
|
||||
loginNames := database.StringArray{}
|
||||
preferredLoginName := sql.NullString{}
|
||||
|
||||
humanID := sql.NullString{}
|
||||
|
||||
@@ -27,17 +27,17 @@ func Test_UserAuthMethodPrepares(t *testing.T) {
|
||||
prepare: prepareUserAuthMethodsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.user_auth_methods.token_id,`+
|
||||
` projections.user_auth_methods.creation_date,`+
|
||||
` projections.user_auth_methods.change_date,`+
|
||||
` projections.user_auth_methods.resource_owner,`+
|
||||
` projections.user_auth_methods.user_id,`+
|
||||
` projections.user_auth_methods.sequence,`+
|
||||
` projections.user_auth_methods.name,`+
|
||||
` projections.user_auth_methods.state,`+
|
||||
` projections.user_auth_methods.method_type,`+
|
||||
regexp.QuoteMeta(`SELECT projections.user_auth_methods2.token_id,`+
|
||||
` projections.user_auth_methods2.creation_date,`+
|
||||
` projections.user_auth_methods2.change_date,`+
|
||||
` projections.user_auth_methods2.resource_owner,`+
|
||||
` projections.user_auth_methods2.user_id,`+
|
||||
` projections.user_auth_methods2.sequence,`+
|
||||
` projections.user_auth_methods2.name,`+
|
||||
` projections.user_auth_methods2.state,`+
|
||||
` projections.user_auth_methods2.method_type,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.user_auth_methods`),
|
||||
` FROM projections.user_auth_methods2`),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -49,17 +49,17 @@ func Test_UserAuthMethodPrepares(t *testing.T) {
|
||||
prepare: prepareUserAuthMethodsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.user_auth_methods.token_id,`+
|
||||
` projections.user_auth_methods.creation_date,`+
|
||||
` projections.user_auth_methods.change_date,`+
|
||||
` projections.user_auth_methods.resource_owner,`+
|
||||
` projections.user_auth_methods.user_id,`+
|
||||
` projections.user_auth_methods.sequence,`+
|
||||
` projections.user_auth_methods.name,`+
|
||||
` projections.user_auth_methods.state,`+
|
||||
` projections.user_auth_methods.method_type,`+
|
||||
regexp.QuoteMeta(`SELECT projections.user_auth_methods2.token_id,`+
|
||||
` projections.user_auth_methods2.creation_date,`+
|
||||
` projections.user_auth_methods2.change_date,`+
|
||||
` projections.user_auth_methods2.resource_owner,`+
|
||||
` projections.user_auth_methods2.user_id,`+
|
||||
` projections.user_auth_methods2.sequence,`+
|
||||
` projections.user_auth_methods2.name,`+
|
||||
` projections.user_auth_methods2.state,`+
|
||||
` projections.user_auth_methods2.method_type,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.user_auth_methods`),
|
||||
` FROM projections.user_auth_methods2`),
|
||||
[]string{
|
||||
"token_id",
|
||||
"creation_date",
|
||||
@@ -111,17 +111,17 @@ func Test_UserAuthMethodPrepares(t *testing.T) {
|
||||
prepare: prepareUserAuthMethodsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.user_auth_methods.token_id,`+
|
||||
` projections.user_auth_methods.creation_date,`+
|
||||
` projections.user_auth_methods.change_date,`+
|
||||
` projections.user_auth_methods.resource_owner,`+
|
||||
` projections.user_auth_methods.user_id,`+
|
||||
` projections.user_auth_methods.sequence,`+
|
||||
` projections.user_auth_methods.name,`+
|
||||
` projections.user_auth_methods.state,`+
|
||||
` projections.user_auth_methods.method_type,`+
|
||||
regexp.QuoteMeta(`SELECT projections.user_auth_methods2.token_id,`+
|
||||
` projections.user_auth_methods2.creation_date,`+
|
||||
` projections.user_auth_methods2.change_date,`+
|
||||
` projections.user_auth_methods2.resource_owner,`+
|
||||
` projections.user_auth_methods2.user_id,`+
|
||||
` projections.user_auth_methods2.sequence,`+
|
||||
` projections.user_auth_methods2.name,`+
|
||||
` projections.user_auth_methods2.state,`+
|
||||
` projections.user_auth_methods2.method_type,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.user_auth_methods`),
|
||||
` FROM projections.user_auth_methods2`),
|
||||
[]string{
|
||||
"token_id",
|
||||
"creation_date",
|
||||
@@ -195,17 +195,17 @@ func Test_UserAuthMethodPrepares(t *testing.T) {
|
||||
prepare: prepareUserAuthMethodsQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.user_auth_methods.token_id,`+
|
||||
` projections.user_auth_methods.creation_date,`+
|
||||
` projections.user_auth_methods.change_date,`+
|
||||
` projections.user_auth_methods.resource_owner,`+
|
||||
` projections.user_auth_methods.user_id,`+
|
||||
` projections.user_auth_methods.sequence,`+
|
||||
` projections.user_auth_methods.name,`+
|
||||
` projections.user_auth_methods.state,`+
|
||||
` projections.user_auth_methods.method_type,`+
|
||||
regexp.QuoteMeta(`SELECT projections.user_auth_methods2.token_id,`+
|
||||
` projections.user_auth_methods2.creation_date,`+
|
||||
` projections.user_auth_methods2.change_date,`+
|
||||
` projections.user_auth_methods2.resource_owner,`+
|
||||
` projections.user_auth_methods2.user_id,`+
|
||||
` projections.user_auth_methods2.sequence,`+
|
||||
` projections.user_auth_methods2.name,`+
|
||||
` projections.user_auth_methods2.state,`+
|
||||
` projections.user_auth_methods2.method_type,`+
|
||||
` COUNT(*) OVER ()`+
|
||||
` FROM projections.user_auth_methods`),
|
||||
` FROM projections.user_auth_methods2`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"time"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/query/projection"
|
||||
@@ -20,7 +20,7 @@ type UserGrant struct {
|
||||
CreationDate time.Time
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
Roles []string
|
||||
Roles database.StringArray
|
||||
GrantID string
|
||||
State domain.UserGrantState
|
||||
|
||||
@@ -281,7 +281,6 @@ func prepareUserGrantQuery() (sq.SelectBuilder, func(*sql.Row) (*UserGrant, erro
|
||||
g := new(UserGrant)
|
||||
|
||||
var (
|
||||
roles = pq.StringArray{}
|
||||
username sql.NullString
|
||||
firstName sql.NullString
|
||||
userType sql.NullInt32
|
||||
@@ -304,7 +303,7 @@ func prepareUserGrantQuery() (sq.SelectBuilder, func(*sql.Row) (*UserGrant, erro
|
||||
&g.ChangeDate,
|
||||
&g.Sequence,
|
||||
&g.GrantID,
|
||||
&roles,
|
||||
&g.Roles,
|
||||
&g.State,
|
||||
|
||||
&g.UserID,
|
||||
@@ -332,7 +331,6 @@ func prepareUserGrantQuery() (sq.SelectBuilder, func(*sql.Row) (*UserGrant, erro
|
||||
return nil, errors.ThrowInternal(err, "QUERY-oQPcP", "Errors.Internal")
|
||||
}
|
||||
|
||||
g.Roles = roles
|
||||
g.Username = username.String
|
||||
g.UserType = domain.UserType(userType.Int32)
|
||||
g.UserResourceOwner = userOwner.String
|
||||
@@ -396,7 +394,6 @@ func prepareUserGrantsQuery() (sq.SelectBuilder, func(*sql.Rows) (*UserGrants, e
|
||||
g := new(UserGrant)
|
||||
|
||||
var (
|
||||
roles = pq.StringArray{}
|
||||
username sql.NullString
|
||||
userType sql.NullInt32
|
||||
userOwner sql.NullString
|
||||
@@ -419,7 +416,7 @@ func prepareUserGrantsQuery() (sq.SelectBuilder, func(*sql.Rows) (*UserGrants, e
|
||||
&g.ChangeDate,
|
||||
&g.Sequence,
|
||||
&g.GrantID,
|
||||
&roles,
|
||||
&g.Roles,
|
||||
&g.State,
|
||||
|
||||
&g.UserID,
|
||||
@@ -446,7 +443,6 @@ func prepareUserGrantsQuery() (sq.SelectBuilder, func(*sql.Rows) (*UserGrants, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
g.Roles = roles
|
||||
g.Username = username.String
|
||||
g.UserType = domain.UserType(userType.Int32)
|
||||
g.UserResourceOwner = userOwner.String
|
||||
|
||||
@@ -8,42 +8,41 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
userGrantStmt = regexp.QuoteMeta(
|
||||
"SELECT projections.user_grants.id" +
|
||||
", projections.user_grants.creation_date" +
|
||||
", projections.user_grants.change_date" +
|
||||
", projections.user_grants.sequence" +
|
||||
", projections.user_grants.grant_id" +
|
||||
", projections.user_grants.roles" +
|
||||
", projections.user_grants.state" +
|
||||
", projections.user_grants.user_id" +
|
||||
", projections.users2.username" +
|
||||
", projections.users2.type" +
|
||||
", projections.users2.resource_owner" +
|
||||
", projections.users2_humans.first_name" +
|
||||
", projections.users2_humans.last_name" +
|
||||
", projections.users2_humans.email" +
|
||||
", projections.users2_humans.display_name" +
|
||||
", projections.users2_humans.avatar_key" +
|
||||
"SELECT projections.user_grants2.id" +
|
||||
", projections.user_grants2.creation_date" +
|
||||
", projections.user_grants2.change_date" +
|
||||
", projections.user_grants2.sequence" +
|
||||
", projections.user_grants2.grant_id" +
|
||||
", projections.user_grants2.roles" +
|
||||
", projections.user_grants2.state" +
|
||||
", projections.user_grants2.user_id" +
|
||||
", projections.users3.username" +
|
||||
", projections.users3.type" +
|
||||
", projections.users3.resource_owner" +
|
||||
", projections.users3_humans.first_name" +
|
||||
", projections.users3_humans.last_name" +
|
||||
", projections.users3_humans.email" +
|
||||
", projections.users3_humans.display_name" +
|
||||
", projections.users3_humans.avatar_key" +
|
||||
", projections.login_names.login_name" +
|
||||
", projections.user_grants.resource_owner" +
|
||||
", projections.user_grants2.resource_owner" +
|
||||
", projections.orgs.name" +
|
||||
", projections.orgs.primary_domain" +
|
||||
", projections.user_grants.project_id" +
|
||||
", projections.projects.name" +
|
||||
" FROM projections.user_grants" +
|
||||
" LEFT JOIN projections.users2 ON projections.user_grants.user_id = projections.users2.id" +
|
||||
" LEFT JOIN projections.users2_humans ON projections.user_grants.user_id = projections.users2_humans.user_id" +
|
||||
" LEFT JOIN projections.orgs ON projections.user_grants.resource_owner = projections.orgs.id" +
|
||||
" LEFT JOIN projections.projects ON projections.user_grants.project_id = projections.projects.id" +
|
||||
" LEFT JOIN projections.login_names ON projections.user_grants.user_id = projections.login_names.user_id" +
|
||||
", projections.user_grants2.project_id" +
|
||||
", projections.projects2.name" +
|
||||
" FROM projections.user_grants2" +
|
||||
" LEFT JOIN projections.users3 ON projections.user_grants2.user_id = projections.users3.id" +
|
||||
" LEFT JOIN projections.users3_humans ON projections.user_grants2.user_id = projections.users3_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" +
|
||||
" WHERE projections.login_names.is_primary = $1")
|
||||
userGrantCols = []string{
|
||||
"id",
|
||||
@@ -70,35 +69,35 @@ var (
|
||||
"name", //project name
|
||||
}
|
||||
userGrantsStmt = regexp.QuoteMeta(
|
||||
"SELECT projections.user_grants.id" +
|
||||
", projections.user_grants.creation_date" +
|
||||
", projections.user_grants.change_date" +
|
||||
", projections.user_grants.sequence" +
|
||||
", projections.user_grants.grant_id" +
|
||||
", projections.user_grants.roles" +
|
||||
", projections.user_grants.state" +
|
||||
", projections.user_grants.user_id" +
|
||||
", projections.users2.username" +
|
||||
", projections.users2.type" +
|
||||
", projections.users2.resource_owner" +
|
||||
", projections.users2_humans.first_name" +
|
||||
", projections.users2_humans.last_name" +
|
||||
", projections.users2_humans.email" +
|
||||
", projections.users2_humans.display_name" +
|
||||
", projections.users2_humans.avatar_key" +
|
||||
"SELECT projections.user_grants2.id" +
|
||||
", projections.user_grants2.creation_date" +
|
||||
", projections.user_grants2.change_date" +
|
||||
", projections.user_grants2.sequence" +
|
||||
", projections.user_grants2.grant_id" +
|
||||
", projections.user_grants2.roles" +
|
||||
", projections.user_grants2.state" +
|
||||
", projections.user_grants2.user_id" +
|
||||
", projections.users3.username" +
|
||||
", projections.users3.type" +
|
||||
", projections.users3.resource_owner" +
|
||||
", projections.users3_humans.first_name" +
|
||||
", projections.users3_humans.last_name" +
|
||||
", projections.users3_humans.email" +
|
||||
", projections.users3_humans.display_name" +
|
||||
", projections.users3_humans.avatar_key" +
|
||||
", projections.login_names.login_name" +
|
||||
", projections.user_grants.resource_owner" +
|
||||
", projections.user_grants2.resource_owner" +
|
||||
", projections.orgs.name" +
|
||||
", projections.orgs.primary_domain" +
|
||||
", projections.user_grants.project_id" +
|
||||
", projections.projects.name" +
|
||||
", projections.user_grants2.project_id" +
|
||||
", projections.projects2.name" +
|
||||
", COUNT(*) OVER ()" +
|
||||
" FROM projections.user_grants" +
|
||||
" LEFT JOIN projections.users2 ON projections.user_grants.user_id = projections.users2.id" +
|
||||
" LEFT JOIN projections.users2_humans ON projections.user_grants.user_id = projections.users2_humans.user_id" +
|
||||
" LEFT JOIN projections.orgs ON projections.user_grants.resource_owner = projections.orgs.id" +
|
||||
" LEFT JOIN projections.projects ON projections.user_grants.project_id = projections.projects.id" +
|
||||
" LEFT JOIN projections.login_names ON projections.user_grants.user_id = projections.login_names.user_id" +
|
||||
" FROM projections.user_grants2" +
|
||||
" LEFT JOIN projections.users3 ON projections.user_grants2.user_id = projections.users3.id" +
|
||||
" LEFT JOIN projections.users3_humans ON projections.user_grants2.user_id = projections.users3_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" +
|
||||
" WHERE projections.login_names.is_primary = $1")
|
||||
userGrantsCols = append(
|
||||
userGrantCols,
|
||||
@@ -148,7 +147,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
testNow,
|
||||
20211111,
|
||||
"grant-id",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
domain.UserGrantStateActive,
|
||||
"user-id",
|
||||
"username",
|
||||
@@ -173,7 +172,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211111,
|
||||
Roles: []string{"role-key"},
|
||||
Roles: database.StringArray{"role-key"},
|
||||
GrantID: "grant-id",
|
||||
State: domain.UserGrantStateActive,
|
||||
UserID: "user-id",
|
||||
@@ -206,7 +205,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
testNow,
|
||||
20211111,
|
||||
"grant-id",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
domain.UserGrantStateActive,
|
||||
"user-id",
|
||||
"username",
|
||||
@@ -231,7 +230,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211111,
|
||||
Roles: []string{"role-key"},
|
||||
Roles: database.StringArray{"role-key"},
|
||||
GrantID: "grant-id",
|
||||
State: domain.UserGrantStateActive,
|
||||
UserID: "user-id",
|
||||
@@ -264,7 +263,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
testNow,
|
||||
20211111,
|
||||
"grant-id",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
domain.UserGrantStateActive,
|
||||
"user-id",
|
||||
"username",
|
||||
@@ -289,7 +288,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211111,
|
||||
Roles: []string{"role-key"},
|
||||
Roles: database.StringArray{"role-key"},
|
||||
GrantID: "grant-id",
|
||||
State: domain.UserGrantStateActive,
|
||||
UserID: "user-id",
|
||||
@@ -322,7 +321,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
testNow,
|
||||
20211111,
|
||||
"grant-id",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
domain.UserGrantStateActive,
|
||||
"user-id",
|
||||
"username",
|
||||
@@ -347,7 +346,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211111,
|
||||
Roles: []string{"role-key"},
|
||||
Roles: database.StringArray{"role-key"},
|
||||
GrantID: "grant-id",
|
||||
State: domain.UserGrantStateActive,
|
||||
UserID: "user-id",
|
||||
@@ -380,7 +379,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
testNow,
|
||||
20211111,
|
||||
"grant-id",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
domain.UserGrantStateActive,
|
||||
"user-id",
|
||||
"username",
|
||||
@@ -405,7 +404,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211111,
|
||||
Roles: []string{"role-key"},
|
||||
Roles: database.StringArray{"role-key"},
|
||||
GrantID: "grant-id",
|
||||
State: domain.UserGrantStateActive,
|
||||
UserID: "user-id",
|
||||
@@ -468,7 +467,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
testNow,
|
||||
20211111,
|
||||
"grant-id",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
domain.UserGrantStateActive,
|
||||
"user-id",
|
||||
"username",
|
||||
@@ -499,7 +498,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211111,
|
||||
Roles: []string{"role-key"},
|
||||
Roles: database.StringArray{"role-key"},
|
||||
GrantID: "grant-id",
|
||||
State: domain.UserGrantStateActive,
|
||||
UserID: "user-id",
|
||||
@@ -535,7 +534,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
testNow,
|
||||
20211111,
|
||||
"grant-id",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
domain.UserGrantStateActive,
|
||||
"user-id",
|
||||
"username",
|
||||
@@ -566,7 +565,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211111,
|
||||
Roles: []string{"role-key"},
|
||||
Roles: database.StringArray{"role-key"},
|
||||
GrantID: "grant-id",
|
||||
State: domain.UserGrantStateActive,
|
||||
UserID: "user-id",
|
||||
@@ -602,7 +601,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
testNow,
|
||||
20211111,
|
||||
"grant-id",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
domain.UserGrantStateActive,
|
||||
"user-id",
|
||||
"username",
|
||||
@@ -633,7 +632,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211111,
|
||||
Roles: []string{"role-key"},
|
||||
Roles: database.StringArray{"role-key"},
|
||||
GrantID: "grant-id",
|
||||
State: domain.UserGrantStateActive,
|
||||
UserID: "user-id",
|
||||
@@ -669,7 +668,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
testNow,
|
||||
20211111,
|
||||
"grant-id",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
domain.UserGrantStateActive,
|
||||
"user-id",
|
||||
"username",
|
||||
@@ -700,7 +699,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211111,
|
||||
Roles: []string{"role-key"},
|
||||
Roles: database.StringArray{"role-key"},
|
||||
GrantID: "grant-id",
|
||||
State: domain.UserGrantStateActive,
|
||||
UserID: "user-id",
|
||||
@@ -736,7 +735,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
testNow,
|
||||
20211111,
|
||||
"grant-id",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
domain.UserGrantStateActive,
|
||||
"user-id",
|
||||
"username",
|
||||
@@ -767,7 +766,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211111,
|
||||
Roles: []string{"role-key"},
|
||||
Roles: database.StringArray{"role-key"},
|
||||
GrantID: "grant-id",
|
||||
State: domain.UserGrantStateActive,
|
||||
UserID: "user-id",
|
||||
@@ -803,7 +802,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
testNow,
|
||||
20211111,
|
||||
"grant-id",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
domain.UserGrantStateActive,
|
||||
"user-id",
|
||||
"username",
|
||||
@@ -827,7 +826,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
testNow,
|
||||
20211111,
|
||||
"grant-id",
|
||||
pq.StringArray{"role-key"},
|
||||
database.StringArray{"role-key"},
|
||||
domain.UserGrantStateActive,
|
||||
"user-id",
|
||||
"username",
|
||||
@@ -858,7 +857,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211111,
|
||||
Roles: []string{"role-key"},
|
||||
Roles: database.StringArray{"role-key"},
|
||||
GrantID: "grant-id",
|
||||
State: domain.UserGrantStateActive,
|
||||
UserID: "user-id",
|
||||
@@ -882,7 +881,7 @@ func Test_UserGrantPrepares(t *testing.T) {
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211111,
|
||||
Roles: []string{"role-key"},
|
||||
Roles: database.StringArray{"role-key"},
|
||||
GrantID: "grant-id",
|
||||
State: domain.UserGrantStateActive,
|
||||
UserID: "user-id",
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"time"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/query/projection"
|
||||
)
|
||||
@@ -20,7 +20,7 @@ type Memberships struct {
|
||||
|
||||
type Membership struct {
|
||||
UserID string
|
||||
Roles []string
|
||||
Roles database.StringArray
|
||||
CreationDate time.Time
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
@@ -227,14 +227,13 @@ func prepareMembershipsQuery() (sq.SelectBuilder, func(*sql.Rows) (*Memberships,
|
||||
projectID = sql.NullString{}
|
||||
grantID = sql.NullString{}
|
||||
grantedOrgID = sql.NullString{}
|
||||
roles = pq.StringArray{}
|
||||
projectName = sql.NullString{}
|
||||
orgName = sql.NullString{}
|
||||
)
|
||||
|
||||
err := rows.Scan(
|
||||
&membership.UserID,
|
||||
&roles,
|
||||
&membership.Roles,
|
||||
&membership.CreationDate,
|
||||
&membership.ChangeDate,
|
||||
&membership.Sequence,
|
||||
@@ -253,8 +252,6 @@ func prepareMembershipsQuery() (sq.SelectBuilder, func(*sql.Rows) (*Memberships,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
membership.Roles = roles
|
||||
|
||||
if orgID.Valid {
|
||||
membership.Org = &OrgMembership{
|
||||
OrgID: orgID.String,
|
||||
@@ -305,9 +302,9 @@ func prepareOrgMember() string {
|
||||
OrgMemberResourceOwner.identifier(),
|
||||
OrgMemberInstanceID.identifier(),
|
||||
OrgMemberOrgID.identifier(),
|
||||
"NULL::STRING AS "+membershipIAMID.name,
|
||||
"NULL::STRING AS "+membershipProjectID.name,
|
||||
"NULL::STRING AS "+membershipGrantID.name,
|
||||
"NULL::TEXT AS "+membershipIAMID.name,
|
||||
"NULL::TEXT AS "+membershipProjectID.name,
|
||||
"NULL::TEXT AS "+membershipGrantID.name,
|
||||
).From(orgMemberTable.identifier()).MustSql()
|
||||
return stmt
|
||||
}
|
||||
@@ -321,10 +318,10 @@ func prepareIAMMember() string {
|
||||
InstanceMemberSequence.identifier(),
|
||||
InstanceMemberResourceOwner.identifier(),
|
||||
InstanceMemberInstanceID.identifier(),
|
||||
"NULL::STRING AS "+membershipOrgID.name,
|
||||
"NULL::TEXT AS "+membershipOrgID.name,
|
||||
InstanceMemberIAMID.identifier(),
|
||||
"NULL::STRING AS "+membershipProjectID.name,
|
||||
"NULL::STRING AS "+membershipGrantID.name,
|
||||
"NULL::TEXT AS "+membershipProjectID.name,
|
||||
"NULL::TEXT AS "+membershipGrantID.name,
|
||||
).From(instanceMemberTable.identifier()).MustSql()
|
||||
return stmt
|
||||
}
|
||||
@@ -338,10 +335,10 @@ func prepareProjectMember() string {
|
||||
ProjectMemberSequence.identifier(),
|
||||
ProjectMemberResourceOwner.identifier(),
|
||||
ProjectMemberInstanceID.identifier(),
|
||||
"NULL::STRING AS "+membershipOrgID.name,
|
||||
"NULL::STRING AS "+membershipIAMID.name,
|
||||
"NULL::TEXT AS "+membershipOrgID.name,
|
||||
"NULL::TEXT AS "+membershipIAMID.name,
|
||||
ProjectMemberProjectID.identifier(),
|
||||
"NULL::STRING AS "+membershipGrantID.name,
|
||||
"NULL::TEXT AS "+membershipGrantID.name,
|
||||
).From(projectMemberTable.identifier()).MustSql()
|
||||
|
||||
return stmt
|
||||
@@ -356,8 +353,8 @@ func prepareProjectGrantMember() string {
|
||||
ProjectGrantMemberSequence.identifier(),
|
||||
ProjectGrantMemberResourceOwner.identifier(),
|
||||
ProjectGrantMemberInstanceID.identifier(),
|
||||
"NULL::STRING AS "+membershipOrgID.name,
|
||||
"NULL::STRING AS "+membershipIAMID.name,
|
||||
"NULL::TEXT AS "+membershipOrgID.name,
|
||||
"NULL::TEXT AS "+membershipIAMID.name,
|
||||
ProjectGrantMemberProjectID.identifier(),
|
||||
ProjectGrantMemberGrantID.identifier(),
|
||||
).From(projectGrantMemberTable.identifier()).
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -23,8 +23,8 @@ var (
|
||||
", memberships.id" +
|
||||
", memberships.project_id" +
|
||||
", memberships.grant_id" +
|
||||
", projections.project_grants.granted_org_id" +
|
||||
", projections.projects.name" +
|
||||
", projections.project_grants2.granted_org_id" +
|
||||
", projections.projects2.name" +
|
||||
", projections.orgs.name" +
|
||||
", COUNT(*) OVER ()" +
|
||||
" FROM (" +
|
||||
@@ -36,10 +36,10 @@ var (
|
||||
", members.resource_owner" +
|
||||
", members.instance_id" +
|
||||
", members.org_id" +
|
||||
", NULL::STRING AS id" +
|
||||
", NULL::STRING AS project_id" +
|
||||
", NULL::STRING AS grant_id" +
|
||||
" FROM projections.org_members as members" +
|
||||
", NULL::TEXT AS id" +
|
||||
", NULL::TEXT AS project_id" +
|
||||
", NULL::TEXT AS grant_id" +
|
||||
" FROM projections.org_members2 AS members" +
|
||||
" UNION ALL " +
|
||||
"SELECT members.user_id" +
|
||||
", members.roles" +
|
||||
@@ -48,11 +48,11 @@ var (
|
||||
", members.sequence" +
|
||||
", members.resource_owner" +
|
||||
", members.instance_id" +
|
||||
", NULL::STRING AS org_id" +
|
||||
", NULL::TEXT AS org_id" +
|
||||
", members.id" +
|
||||
", NULL::STRING AS project_id" +
|
||||
", NULL::STRING AS grant_id" +
|
||||
" FROM projections.instance_members as members" +
|
||||
", NULL::TEXT AS project_id" +
|
||||
", NULL::TEXT AS grant_id" +
|
||||
" FROM projections.instance_members2 AS members" +
|
||||
" UNION ALL " +
|
||||
"SELECT members.user_id" +
|
||||
", members.roles" +
|
||||
@@ -61,11 +61,11 @@ var (
|
||||
", members.sequence" +
|
||||
", members.resource_owner" +
|
||||
", members.instance_id" +
|
||||
", NULL::STRING AS org_id" +
|
||||
", NULL::STRING AS id" +
|
||||
", NULL::TEXT AS org_id" +
|
||||
", NULL::TEXT AS id" +
|
||||
", members.project_id" +
|
||||
", NULL::STRING AS grant_id" +
|
||||
" FROM projections.project_members as members" +
|
||||
", NULL::TEXT AS grant_id" +
|
||||
" FROM projections.project_members2 AS members" +
|
||||
" UNION ALL " +
|
||||
"SELECT members.user_id" +
|
||||
", members.roles" +
|
||||
@@ -74,15 +74,15 @@ var (
|
||||
", members.sequence" +
|
||||
", members.resource_owner" +
|
||||
", members.instance_id" +
|
||||
", NULL::STRING AS org_id" +
|
||||
", NULL::STRING AS id" +
|
||||
", NULL::TEXT AS org_id" +
|
||||
", NULL::TEXT AS id" +
|
||||
", members.project_id" +
|
||||
", members.grant_id" +
|
||||
" FROM projections.project_grant_members as members" +
|
||||
" FROM projections.project_grant_members2 AS members" +
|
||||
") AS memberships" +
|
||||
" LEFT JOIN projections.projects ON memberships.project_id = projections.projects.id" +
|
||||
" 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_grants ON memberships.grant_id = projections.project_grants.grant_id")
|
||||
" LEFT JOIN projections.project_grants2 ON memberships.grant_id = projections.project_grants2.grant_id")
|
||||
membershipCols = []string{
|
||||
"user_id",
|
||||
"roles",
|
||||
@@ -134,7 +134,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
[][]driver.Value{
|
||||
{
|
||||
"user-id",
|
||||
pq.StringArray{"role1", "role2"},
|
||||
database.StringArray{"role1", "role2"},
|
||||
testNow,
|
||||
testNow,
|
||||
uint64(20211202),
|
||||
@@ -157,7 +157,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
Memberships: []*Membership{
|
||||
{
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role1", "role2"},
|
||||
Roles: database.StringArray{"role1", "role2"},
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211202,
|
||||
@@ -177,7 +177,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
[][]driver.Value{
|
||||
{
|
||||
"user-id",
|
||||
pq.StringArray{"role1", "role2"},
|
||||
database.StringArray{"role1", "role2"},
|
||||
testNow,
|
||||
testNow,
|
||||
uint64(20211202),
|
||||
@@ -200,7 +200,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
Memberships: []*Membership{
|
||||
{
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role1", "role2"},
|
||||
Roles: database.StringArray{"role1", "role2"},
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211202,
|
||||
@@ -220,7 +220,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
[][]driver.Value{
|
||||
{
|
||||
"user-id",
|
||||
pq.StringArray{"role1", "role2"},
|
||||
database.StringArray{"role1", "role2"},
|
||||
testNow,
|
||||
testNow,
|
||||
uint64(20211202),
|
||||
@@ -243,7 +243,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
Memberships: []*Membership{
|
||||
{
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role1", "role2"},
|
||||
Roles: database.StringArray{"role1", "role2"},
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211202,
|
||||
@@ -263,7 +263,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
[][]driver.Value{
|
||||
{
|
||||
"user-id",
|
||||
pq.StringArray{"role1", "role2"},
|
||||
database.StringArray{"role1", "role2"},
|
||||
testNow,
|
||||
testNow,
|
||||
uint64(20211202),
|
||||
@@ -286,7 +286,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
Memberships: []*Membership{
|
||||
{
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role1", "role2"},
|
||||
Roles: database.StringArray{"role1", "role2"},
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211202,
|
||||
@@ -311,7 +311,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
[][]driver.Value{
|
||||
{
|
||||
"user-id",
|
||||
pq.StringArray{"role1", "role2"},
|
||||
database.StringArray{"role1", "role2"},
|
||||
testNow,
|
||||
testNow,
|
||||
uint64(20211202),
|
||||
@@ -326,7 +326,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"user-id",
|
||||
pq.StringArray{"role1", "role2"},
|
||||
database.StringArray{"role1", "role2"},
|
||||
testNow,
|
||||
testNow,
|
||||
uint64(20211202),
|
||||
@@ -341,7 +341,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"user-id",
|
||||
pq.StringArray{"role1", "role2"},
|
||||
database.StringArray{"role1", "role2"},
|
||||
testNow,
|
||||
testNow,
|
||||
uint64(20211202),
|
||||
@@ -356,7 +356,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"user-id",
|
||||
pq.StringArray{"role1", "role2"},
|
||||
database.StringArray{"role1", "role2"},
|
||||
testNow,
|
||||
testNow,
|
||||
uint64(20211202),
|
||||
@@ -379,7 +379,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
Memberships: []*Membership{
|
||||
{
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role1", "role2"},
|
||||
Roles: database.StringArray{"role1", "role2"},
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211202,
|
||||
@@ -388,7 +388,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
},
|
||||
{
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role1", "role2"},
|
||||
Roles: database.StringArray{"role1", "role2"},
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211202,
|
||||
@@ -397,7 +397,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
},
|
||||
{
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role1", "role2"},
|
||||
Roles: database.StringArray{"role1", "role2"},
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211202,
|
||||
@@ -406,7 +406,7 @@ func Test_MembershipPrepares(t *testing.T) {
|
||||
},
|
||||
{
|
||||
UserID: "user-id",
|
||||
Roles: []string{"role1", "role2"},
|
||||
Roles: database.StringArray{"role1", "role2"},
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
Sequence: 20211202,
|
||||
|
||||
@@ -12,13 +12,13 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
userMetadataQuery = `SELECT projections.user_metadata2.creation_date,` +
|
||||
` projections.user_metadata2.change_date,` +
|
||||
` projections.user_metadata2.resource_owner,` +
|
||||
` projections.user_metadata2.sequence,` +
|
||||
` projections.user_metadata2.key,` +
|
||||
` projections.user_metadata2.value` +
|
||||
` FROM projections.user_metadata2`
|
||||
userMetadataQuery = `SELECT projections.user_metadata3.creation_date,` +
|
||||
` projections.user_metadata3.change_date,` +
|
||||
` projections.user_metadata3.resource_owner,` +
|
||||
` projections.user_metadata3.sequence,` +
|
||||
` projections.user_metadata3.key,` +
|
||||
` projections.user_metadata3.value` +
|
||||
` FROM projections.user_metadata3`
|
||||
userMetadataCols = []string{
|
||||
"creation_date",
|
||||
"change_date",
|
||||
@@ -27,14 +27,14 @@ var (
|
||||
"key",
|
||||
"value",
|
||||
}
|
||||
userMetadataListQuery = `SELECT projections.user_metadata2.creation_date,` +
|
||||
` projections.user_metadata2.change_date,` +
|
||||
` projections.user_metadata2.resource_owner,` +
|
||||
` projections.user_metadata2.sequence,` +
|
||||
` projections.user_metadata2.key,` +
|
||||
` projections.user_metadata2.value,` +
|
||||
userMetadataListQuery = `SELECT projections.user_metadata3.creation_date,` +
|
||||
` projections.user_metadata3.change_date,` +
|
||||
` projections.user_metadata3.resource_owner,` +
|
||||
` projections.user_metadata3.sequence,` +
|
||||
` projections.user_metadata3.key,` +
|
||||
` projections.user_metadata3.value,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.user_metadata2`
|
||||
` FROM projections.user_metadata3`
|
||||
userMetadataListCols = []string{
|
||||
"creation_date",
|
||||
"change_date",
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"time"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/query/projection"
|
||||
|
||||
@@ -72,7 +72,7 @@ type PersonalAccessToken struct {
|
||||
|
||||
UserID string
|
||||
Expiration time.Time
|
||||
Scopes []string
|
||||
Scopes database.StringArray
|
||||
}
|
||||
|
||||
type PersonalAccessTokenSearchQueries struct {
|
||||
@@ -161,7 +161,6 @@ func preparePersonalAccessTokenQuery() (sq.SelectBuilder, func(*sql.Row) (*Perso
|
||||
From(personalAccessTokensTable.identifier()).PlaceholderFormat(sq.Dollar),
|
||||
func(row *sql.Row) (*PersonalAccessToken, error) {
|
||||
p := new(PersonalAccessToken)
|
||||
scopes := pq.StringArray{}
|
||||
err := row.Scan(
|
||||
&p.ID,
|
||||
&p.CreationDate,
|
||||
@@ -170,9 +169,8 @@ func preparePersonalAccessTokenQuery() (sq.SelectBuilder, func(*sql.Row) (*Perso
|
||||
&p.Sequence,
|
||||
&p.UserID,
|
||||
&p.Expiration,
|
||||
&scopes,
|
||||
&p.Scopes,
|
||||
)
|
||||
p.Scopes = scopes
|
||||
if err != nil {
|
||||
if errs.Is(err, sql.ErrNoRows) {
|
||||
return nil, errors.ThrowNotFound(err, "QUERY-fk2fs", "Errors.PersonalAccessToken.NotFound")
|
||||
@@ -200,7 +198,6 @@ func preparePersonalAccessTokensQuery() (sq.SelectBuilder, func(*sql.Rows) (*Per
|
||||
var count uint64
|
||||
for rows.Next() {
|
||||
token := new(PersonalAccessToken)
|
||||
scopes := pq.StringArray{}
|
||||
err := rows.Scan(
|
||||
&token.ID,
|
||||
&token.CreationDate,
|
||||
@@ -209,13 +206,12 @@ func preparePersonalAccessTokensQuery() (sq.SelectBuilder, func(*sql.Rows) (*Per
|
||||
&token.Sequence,
|
||||
&token.UserID,
|
||||
&token.Expiration,
|
||||
&scopes,
|
||||
&token.Scopes,
|
||||
&count,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
token.Scopes = scopes
|
||||
personalAccessTokens = append(personalAccessTokens, token)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,22 +9,21 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/lib/pq"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
personalAccessTokenStmt = regexp.QuoteMeta(
|
||||
"SELECT projections.personal_access_tokens.id," +
|
||||
" projections.personal_access_tokens.creation_date," +
|
||||
" projections.personal_access_tokens.change_date," +
|
||||
" projections.personal_access_tokens.resource_owner," +
|
||||
" projections.personal_access_tokens.sequence," +
|
||||
" projections.personal_access_tokens.user_id," +
|
||||
" projections.personal_access_tokens.expiration," +
|
||||
" projections.personal_access_tokens.scopes" +
|
||||
" FROM projections.personal_access_tokens")
|
||||
"SELECT projections.personal_access_tokens2.id," +
|
||||
" projections.personal_access_tokens2.creation_date," +
|
||||
" projections.personal_access_tokens2.change_date," +
|
||||
" projections.personal_access_tokens2.resource_owner," +
|
||||
" projections.personal_access_tokens2.sequence," +
|
||||
" projections.personal_access_tokens2.user_id," +
|
||||
" projections.personal_access_tokens2.expiration," +
|
||||
" projections.personal_access_tokens2.scopes" +
|
||||
" FROM projections.personal_access_tokens2")
|
||||
personalAccessTokenCols = []string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -36,16 +35,16 @@ var (
|
||||
"scopes",
|
||||
}
|
||||
personalAccessTokensStmt = regexp.QuoteMeta(
|
||||
"SELECT projections.personal_access_tokens.id," +
|
||||
" projections.personal_access_tokens.creation_date," +
|
||||
" projections.personal_access_tokens.change_date," +
|
||||
" projections.personal_access_tokens.resource_owner," +
|
||||
" projections.personal_access_tokens.sequence," +
|
||||
" projections.personal_access_tokens.user_id," +
|
||||
" projections.personal_access_tokens.expiration," +
|
||||
" projections.personal_access_tokens.scopes," +
|
||||
"SELECT projections.personal_access_tokens2.id," +
|
||||
" projections.personal_access_tokens2.creation_date," +
|
||||
" projections.personal_access_tokens2.change_date," +
|
||||
" projections.personal_access_tokens2.resource_owner," +
|
||||
" projections.personal_access_tokens2.sequence," +
|
||||
" projections.personal_access_tokens2.user_id," +
|
||||
" projections.personal_access_tokens2.expiration," +
|
||||
" projections.personal_access_tokens2.scopes," +
|
||||
" COUNT(*) OVER ()" +
|
||||
" FROM projections.personal_access_tokens")
|
||||
" FROM projections.personal_access_tokens2")
|
||||
personalAccessTokensCols = []string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -103,7 +102,7 @@ func Test_PersonalAccessTokenPrepares(t *testing.T) {
|
||||
uint64(20211202),
|
||||
"user-id",
|
||||
time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC),
|
||||
pq.StringArray{"openid"},
|
||||
database.StringArray{"openid"},
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -115,7 +114,7 @@ func Test_PersonalAccessTokenPrepares(t *testing.T) {
|
||||
Sequence: 20211202,
|
||||
UserID: "user-id",
|
||||
Expiration: time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC),
|
||||
Scopes: []string{"openid"},
|
||||
Scopes: database.StringArray{"openid"},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -163,7 +162,7 @@ func Test_PersonalAccessTokenPrepares(t *testing.T) {
|
||||
uint64(20211202),
|
||||
"user-id",
|
||||
time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC),
|
||||
pq.StringArray{"openid"},
|
||||
database.StringArray{"openid"},
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -181,7 +180,7 @@ func Test_PersonalAccessTokenPrepares(t *testing.T) {
|
||||
Sequence: 20211202,
|
||||
UserID: "user-id",
|
||||
Expiration: time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC),
|
||||
Scopes: []string{"openid"},
|
||||
Scopes: database.StringArray{"openid"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -202,7 +201,7 @@ func Test_PersonalAccessTokenPrepares(t *testing.T) {
|
||||
uint64(20211202),
|
||||
"user-id",
|
||||
time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC),
|
||||
pq.StringArray{"openid"},
|
||||
database.StringArray{"openid"},
|
||||
},
|
||||
{
|
||||
"token-id2",
|
||||
@@ -212,7 +211,7 @@ func Test_PersonalAccessTokenPrepares(t *testing.T) {
|
||||
uint64(20211202),
|
||||
"user-id",
|
||||
time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC),
|
||||
pq.StringArray{"openid"},
|
||||
database.StringArray{"openid"},
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -230,7 +229,7 @@ func Test_PersonalAccessTokenPrepares(t *testing.T) {
|
||||
Sequence: 20211202,
|
||||
UserID: "user-id",
|
||||
Expiration: time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC),
|
||||
Scopes: []string{"openid"},
|
||||
Scopes: database.StringArray{"openid"},
|
||||
},
|
||||
{
|
||||
ID: "token-id2",
|
||||
@@ -240,7 +239,7 @@ func Test_PersonalAccessTokenPrepares(t *testing.T) {
|
||||
Sequence: 20211202,
|
||||
UserID: "user-id",
|
||||
Expiration: time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC),
|
||||
Scopes: []string{"openid"},
|
||||
Scopes: database.StringArray{"openid"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
+152
-152
@@ -9,51 +9,51 @@ import (
|
||||
"testing"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/lib/pq"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
userQuery = `SELECT projections.users2.id,` +
|
||||
` projections.users2.creation_date,` +
|
||||
` projections.users2.change_date,` +
|
||||
` projections.users2.resource_owner,` +
|
||||
` projections.users2.sequence,` +
|
||||
` projections.users2.state,` +
|
||||
` projections.users2.type,` +
|
||||
` projections.users2.username,` +
|
||||
userQuery = `SELECT projections.users3.id,` +
|
||||
` projections.users3.creation_date,` +
|
||||
` projections.users3.change_date,` +
|
||||
` projections.users3.resource_owner,` +
|
||||
` projections.users3.sequence,` +
|
||||
` projections.users3.state,` +
|
||||
` projections.users3.type,` +
|
||||
` projections.users3.username,` +
|
||||
` login_names.loginnames,` +
|
||||
` preferred_login_name.login_name,` +
|
||||
` projections.users2_humans.user_id,` +
|
||||
` projections.users2_humans.first_name,` +
|
||||
` projections.users2_humans.last_name,` +
|
||||
` projections.users2_humans.nick_name,` +
|
||||
` projections.users2_humans.display_name,` +
|
||||
` projections.users2_humans.preferred_language,` +
|
||||
` projections.users2_humans.gender,` +
|
||||
` projections.users2_humans.avatar_key,` +
|
||||
` projections.users2_humans.email,` +
|
||||
` projections.users2_humans.is_email_verified,` +
|
||||
` projections.users2_humans.phone,` +
|
||||
` projections.users2_humans.is_phone_verified,` +
|
||||
` projections.users2_machines.user_id,` +
|
||||
` projections.users2_machines.name,` +
|
||||
` projections.users2_machines.description` +
|
||||
` FROM projections.users2` +
|
||||
` LEFT JOIN projections.users2_humans ON projections.users2.id = projections.users2_humans.user_id` +
|
||||
` LEFT JOIN projections.users2_machines ON projections.users2.id = projections.users2_machines.user_id` +
|
||||
` projections.users3_humans.user_id,` +
|
||||
` projections.users3_humans.first_name,` +
|
||||
` projections.users3_humans.last_name,` +
|
||||
` projections.users3_humans.nick_name,` +
|
||||
` projections.users3_humans.display_name,` +
|
||||
` projections.users3_humans.preferred_language,` +
|
||||
` projections.users3_humans.gender,` +
|
||||
` projections.users3_humans.avatar_key,` +
|
||||
` projections.users3_humans.email,` +
|
||||
` projections.users3_humans.is_email_verified,` +
|
||||
` projections.users3_humans.phone,` +
|
||||
` projections.users3_humans.is_phone_verified,` +
|
||||
` projections.users3_machines.user_id,` +
|
||||
` projections.users3_machines.name,` +
|
||||
` projections.users3_machines.description` +
|
||||
` FROM projections.users3` +
|
||||
` LEFT JOIN projections.users3_humans ON projections.users3.id = projections.users3_humans.user_id` +
|
||||
` LEFT JOIN projections.users3_machines ON projections.users3.id = projections.users3_machines.user_id` +
|
||||
` LEFT JOIN` +
|
||||
` (SELECT login_names.user_id, ARRAY_AGG(login_names.login_name) as loginnames` +
|
||||
` FROM projections.login_names as login_names` +
|
||||
` (SELECT login_names.user_id, ARRAY_AGG(login_names.login_name)::TEXT[] AS loginnames` +
|
||||
` FROM projections.login_names AS login_names` +
|
||||
` WHERE login_names.instance_id = $1` +
|
||||
` GROUP BY login_names.user_id) as login_names` +
|
||||
` on login_names.user_id = projections.users2.id` +
|
||||
` GROUP BY login_names.user_id) AS login_names` +
|
||||
` ON login_names.user_id = projections.users3.id` +
|
||||
` LEFT JOIN` +
|
||||
` (SELECT preferred_login_name.user_id, preferred_login_name.login_name FROM projections.login_names as preferred_login_name WHERE preferred_login_name.instance_id = $2 AND preferred_login_name.is_primary = $3) as preferred_login_name` +
|
||||
` on preferred_login_name.user_id = projections.users2.id`
|
||||
` (SELECT preferred_login_name.user_id, preferred_login_name.login_name FROM projections.login_names AS preferred_login_name WHERE preferred_login_name.instance_id = $2 AND preferred_login_name.is_primary = $3) AS preferred_login_name` +
|
||||
` ON preferred_login_name.user_id = projections.users3.id`
|
||||
userCols = []string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -83,21 +83,21 @@ var (
|
||||
"name",
|
||||
"description",
|
||||
}
|
||||
profileQuery = `SELECT projections.users2.id,` +
|
||||
` projections.users2.creation_date,` +
|
||||
` projections.users2.change_date,` +
|
||||
` projections.users2.resource_owner,` +
|
||||
` projections.users2.sequence,` +
|
||||
` projections.users2_humans.user_id,` +
|
||||
` projections.users2_humans.first_name,` +
|
||||
` projections.users2_humans.last_name,` +
|
||||
` projections.users2_humans.nick_name,` +
|
||||
` projections.users2_humans.display_name,` +
|
||||
` projections.users2_humans.preferred_language,` +
|
||||
` projections.users2_humans.gender,` +
|
||||
` projections.users2_humans.avatar_key` +
|
||||
` FROM projections.users2` +
|
||||
` LEFT JOIN projections.users2_humans ON projections.users2.id = projections.users2_humans.user_id`
|
||||
profileQuery = `SELECT projections.users3.id,` +
|
||||
` projections.users3.creation_date,` +
|
||||
` projections.users3.change_date,` +
|
||||
` projections.users3.resource_owner,` +
|
||||
` projections.users3.sequence,` +
|
||||
` projections.users3_humans.user_id,` +
|
||||
` projections.users3_humans.first_name,` +
|
||||
` projections.users3_humans.last_name,` +
|
||||
` projections.users3_humans.nick_name,` +
|
||||
` projections.users3_humans.display_name,` +
|
||||
` projections.users3_humans.preferred_language,` +
|
||||
` projections.users3_humans.gender,` +
|
||||
` projections.users3_humans.avatar_key` +
|
||||
` FROM projections.users3` +
|
||||
` LEFT JOIN projections.users3_humans ON projections.users3.id = projections.users3_humans.user_id`
|
||||
profileCols = []string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -113,16 +113,16 @@ var (
|
||||
"gender",
|
||||
"avatar_key",
|
||||
}
|
||||
emailQuery = `SELECT projections.users2.id,` +
|
||||
` projections.users2.creation_date,` +
|
||||
` projections.users2.change_date,` +
|
||||
` projections.users2.resource_owner,` +
|
||||
` projections.users2.sequence,` +
|
||||
` projections.users2_humans.user_id,` +
|
||||
` projections.users2_humans.email,` +
|
||||
` projections.users2_humans.is_email_verified` +
|
||||
` FROM projections.users2` +
|
||||
` LEFT JOIN projections.users2_humans ON projections.users2.id = projections.users2_humans.user_id`
|
||||
emailQuery = `SELECT projections.users3.id,` +
|
||||
` projections.users3.creation_date,` +
|
||||
` projections.users3.change_date,` +
|
||||
` projections.users3.resource_owner,` +
|
||||
` projections.users3.sequence,` +
|
||||
` projections.users3_humans.user_id,` +
|
||||
` projections.users3_humans.email,` +
|
||||
` projections.users3_humans.is_email_verified` +
|
||||
` FROM projections.users3` +
|
||||
` LEFT JOIN projections.users3_humans ON projections.users3.id = projections.users3_humans.user_id`
|
||||
emailCols = []string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -133,16 +133,16 @@ var (
|
||||
"email",
|
||||
"is_email_verified",
|
||||
}
|
||||
phoneQuery = `SELECT projections.users2.id,` +
|
||||
` projections.users2.creation_date,` +
|
||||
` projections.users2.change_date,` +
|
||||
` projections.users2.resource_owner,` +
|
||||
` projections.users2.sequence,` +
|
||||
` projections.users2_humans.user_id,` +
|
||||
` projections.users2_humans.phone,` +
|
||||
` projections.users2_humans.is_phone_verified` +
|
||||
` FROM projections.users2` +
|
||||
` LEFT JOIN projections.users2_humans ON projections.users2.id = projections.users2_humans.user_id`
|
||||
phoneQuery = `SELECT projections.users3.id,` +
|
||||
` projections.users3.creation_date,` +
|
||||
` projections.users3.change_date,` +
|
||||
` projections.users3.resource_owner,` +
|
||||
` projections.users3.sequence,` +
|
||||
` projections.users3_humans.user_id,` +
|
||||
` projections.users3_humans.phone,` +
|
||||
` projections.users3_humans.is_phone_verified` +
|
||||
` FROM projections.users3` +
|
||||
` LEFT JOIN projections.users3_humans ON projections.users3.id = projections.users3_humans.user_id`
|
||||
phoneCols = []string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -153,14 +153,14 @@ var (
|
||||
"phone",
|
||||
"is_phone_verified",
|
||||
}
|
||||
userUniqueQuery = `SELECT projections.users2.id,` +
|
||||
` projections.users2.state,` +
|
||||
` projections.users2.username,` +
|
||||
` projections.users2_humans.user_id,` +
|
||||
` projections.users2_humans.email,` +
|
||||
` projections.users2_humans.is_email_verified` +
|
||||
` FROM projections.users2` +
|
||||
` LEFT JOIN projections.users2_humans ON projections.users2.id = projections.users2_humans.user_id`
|
||||
userUniqueQuery = `SELECT projections.users3.id,` +
|
||||
` projections.users3.state,` +
|
||||
` projections.users3.username,` +
|
||||
` projections.users3_humans.user_id,` +
|
||||
` projections.users3_humans.email,` +
|
||||
` projections.users3_humans.is_email_verified` +
|
||||
` FROM projections.users3` +
|
||||
` LEFT JOIN projections.users3_humans ON projections.users3.id = projections.users3_humans.user_id`
|
||||
userUniqueCols = []string{
|
||||
"id",
|
||||
"state",
|
||||
@@ -169,42 +169,42 @@ var (
|
||||
"email",
|
||||
"is_email_verified",
|
||||
}
|
||||
notifyUserQuery = `SELECT projections.users2.id,` +
|
||||
` projections.users2.creation_date,` +
|
||||
` projections.users2.change_date,` +
|
||||
` projections.users2.resource_owner,` +
|
||||
` projections.users2.sequence,` +
|
||||
` projections.users2.state,` +
|
||||
` projections.users2.type,` +
|
||||
` projections.users2.username,` +
|
||||
notifyUserQuery = `SELECT projections.users3.id,` +
|
||||
` projections.users3.creation_date,` +
|
||||
` projections.users3.change_date,` +
|
||||
` projections.users3.resource_owner,` +
|
||||
` projections.users3.sequence,` +
|
||||
` projections.users3.state,` +
|
||||
` projections.users3.type,` +
|
||||
` projections.users3.username,` +
|
||||
` login_names.loginnames,` +
|
||||
` preferred_login_name.login_name,` +
|
||||
` projections.users2_humans.user_id,` +
|
||||
` projections.users2_humans.first_name,` +
|
||||
` projections.users2_humans.last_name,` +
|
||||
` projections.users2_humans.nick_name,` +
|
||||
` projections.users2_humans.display_name,` +
|
||||
` projections.users2_humans.preferred_language,` +
|
||||
` projections.users2_humans.gender,` +
|
||||
` projections.users2_humans.avatar_key,` +
|
||||
` projections.users2_notifications.user_id,` +
|
||||
` projections.users2_notifications.last_email,` +
|
||||
` projections.users2_notifications.verified_email,` +
|
||||
` projections.users2_notifications.last_phone,` +
|
||||
` projections.users2_notifications.verified_phone,` +
|
||||
` projections.users2_notifications.password_set` +
|
||||
` FROM projections.users2` +
|
||||
` LEFT JOIN projections.users2_humans ON projections.users2.id = projections.users2_humans.user_id` +
|
||||
` LEFT JOIN projections.users2_notifications ON projections.users2.id = projections.users2_notifications.user_id` +
|
||||
` projections.users3_humans.user_id,` +
|
||||
` projections.users3_humans.first_name,` +
|
||||
` projections.users3_humans.last_name,` +
|
||||
` projections.users3_humans.nick_name,` +
|
||||
` projections.users3_humans.display_name,` +
|
||||
` projections.users3_humans.preferred_language,` +
|
||||
` projections.users3_humans.gender,` +
|
||||
` projections.users3_humans.avatar_key,` +
|
||||
` projections.users3_notifications.user_id,` +
|
||||
` projections.users3_notifications.last_email,` +
|
||||
` projections.users3_notifications.verified_email,` +
|
||||
` projections.users3_notifications.last_phone,` +
|
||||
` projections.users3_notifications.verified_phone,` +
|
||||
` projections.users3_notifications.password_set` +
|
||||
` FROM projections.users3` +
|
||||
` LEFT JOIN projections.users3_humans ON projections.users3.id = projections.users3_humans.user_id` +
|
||||
` LEFT JOIN projections.users3_notifications ON projections.users3.id = projections.users3_notifications.user_id` +
|
||||
` LEFT JOIN` +
|
||||
` (SELECT login_names.user_id, ARRAY_AGG(login_names.login_name) as loginnames` +
|
||||
` FROM projections.login_names as login_names` +
|
||||
` (SELECT login_names.user_id, ARRAY_AGG(login_names.login_name) AS loginnames` +
|
||||
` FROM projections.login_names AS login_names` +
|
||||
` WHERE login_names.instance_id = $1` +
|
||||
` GROUP BY login_names.user_id) as login_names` +
|
||||
` on login_names.user_id = projections.users2.id` +
|
||||
` GROUP BY login_names.user_id) AS login_names` +
|
||||
` ON login_names.user_id = projections.users3.id` +
|
||||
` LEFT JOIN` +
|
||||
` (SELECT preferred_login_name.user_id, preferred_login_name.login_name FROM projections.login_names as preferred_login_name WHERE preferred_login_name.instance_id = $2 AND preferred_login_name.is_primary = $3) as preferred_login_name` +
|
||||
` on preferred_login_name.user_id = projections.users2.id`
|
||||
` (SELECT preferred_login_name.user_id, preferred_login_name.login_name FROM projections.login_names AS preferred_login_name WHERE preferred_login_name.instance_id = $2 AND preferred_login_name.is_primary = $3) AS preferred_login_name` +
|
||||
` ON preferred_login_name.user_id = projections.users3.id`
|
||||
notifyUserCols = []string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -233,43 +233,43 @@ var (
|
||||
"verified_phone",
|
||||
"password_set",
|
||||
}
|
||||
usersQuery = `SELECT projections.users2.id,` +
|
||||
` projections.users2.creation_date,` +
|
||||
` projections.users2.change_date,` +
|
||||
` projections.users2.resource_owner,` +
|
||||
` projections.users2.sequence,` +
|
||||
` projections.users2.state,` +
|
||||
` projections.users2.type,` +
|
||||
` projections.users2.username,` +
|
||||
usersQuery = `SELECT projections.users3.id,` +
|
||||
` projections.users3.creation_date,` +
|
||||
` projections.users3.change_date,` +
|
||||
` projections.users3.resource_owner,` +
|
||||
` projections.users3.sequence,` +
|
||||
` projections.users3.state,` +
|
||||
` projections.users3.type,` +
|
||||
` projections.users3.username,` +
|
||||
` login_names.loginnames,` +
|
||||
` preferred_login_name.login_name,` +
|
||||
` projections.users2_humans.user_id,` +
|
||||
` projections.users2_humans.first_name,` +
|
||||
` projections.users2_humans.last_name,` +
|
||||
` projections.users2_humans.nick_name,` +
|
||||
` projections.users2_humans.display_name,` +
|
||||
` projections.users2_humans.preferred_language,` +
|
||||
` projections.users2_humans.gender,` +
|
||||
` projections.users2_humans.avatar_key,` +
|
||||
` projections.users2_humans.email,` +
|
||||
` projections.users2_humans.is_email_verified,` +
|
||||
` projections.users2_humans.phone,` +
|
||||
` projections.users2_humans.is_phone_verified,` +
|
||||
` projections.users2_machines.user_id,` +
|
||||
` projections.users2_machines.name,` +
|
||||
` projections.users2_machines.description,` +
|
||||
` projections.users3_humans.user_id,` +
|
||||
` projections.users3_humans.first_name,` +
|
||||
` projections.users3_humans.last_name,` +
|
||||
` projections.users3_humans.nick_name,` +
|
||||
` projections.users3_humans.display_name,` +
|
||||
` projections.users3_humans.preferred_language,` +
|
||||
` projections.users3_humans.gender,` +
|
||||
` projections.users3_humans.avatar_key,` +
|
||||
` projections.users3_humans.email,` +
|
||||
` projections.users3_humans.is_email_verified,` +
|
||||
` projections.users3_humans.phone,` +
|
||||
` projections.users3_humans.is_phone_verified,` +
|
||||
` projections.users3_machines.user_id,` +
|
||||
` projections.users3_machines.name,` +
|
||||
` projections.users3_machines.description,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.users2` +
|
||||
` LEFT JOIN projections.users2_humans ON projections.users2.id = projections.users2_humans.user_id` +
|
||||
` LEFT JOIN projections.users2_machines ON projections.users2.id = projections.users2_machines.user_id` +
|
||||
` FROM projections.users3` +
|
||||
` LEFT JOIN projections.users3_humans ON projections.users3.id = projections.users3_humans.user_id` +
|
||||
` LEFT JOIN projections.users3_machines ON projections.users3.id = projections.users3_machines.user_id` +
|
||||
` LEFT JOIN` +
|
||||
` (SELECT login_names.user_id, ARRAY_AGG(login_names.login_name) as loginnames` +
|
||||
` FROM projections.login_names as login_names` +
|
||||
` GROUP BY login_names.user_id) as login_names` +
|
||||
` on login_names.user_id = projections.users2.id` +
|
||||
` (SELECT login_names.user_id, ARRAY_AGG(login_names.login_name) AS loginnames` +
|
||||
` FROM projections.login_names AS login_names` +
|
||||
` GROUP BY login_names.user_id) AS login_names` +
|
||||
` ON login_names.user_id = projections.users3.id` +
|
||||
` LEFT JOIN` +
|
||||
` (SELECT preferred_login_name.user_id, preferred_login_name.login_name FROM projections.login_names as preferred_login_name WHERE preferred_login_name.is_primary = $1) as preferred_login_name` +
|
||||
` on preferred_login_name.user_id = projections.users2.id`
|
||||
` (SELECT preferred_login_name.user_id, preferred_login_name.login_name FROM projections.login_names AS preferred_login_name WHERE preferred_login_name.is_primary = $1) AS preferred_login_name` +
|
||||
` ON preferred_login_name.user_id = projections.users3.id`
|
||||
usersCols = []string{
|
||||
"id",
|
||||
"creation_date",
|
||||
@@ -351,7 +351,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
domain.UserStateActive,
|
||||
domain.UserTypeHuman,
|
||||
"username",
|
||||
pq.StringArray{"login_name1", "login_name2"},
|
||||
database.StringArray{"login_name1", "login_name2"},
|
||||
"login_name1",
|
||||
//human
|
||||
"id",
|
||||
@@ -382,7 +382,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
State: domain.UserStateActive,
|
||||
Type: domain.UserTypeHuman,
|
||||
Username: "username",
|
||||
LoginNames: []string{"login_name1", "login_name2"},
|
||||
LoginNames: database.StringArray{"login_name1", "login_name2"},
|
||||
PreferredLoginName: "login_name1",
|
||||
Human: &Human{
|
||||
FirstName: "first_name",
|
||||
@@ -417,7 +417,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
domain.UserStateActive,
|
||||
domain.UserTypeMachine,
|
||||
"username",
|
||||
pq.StringArray{"login_name1", "login_name2"},
|
||||
database.StringArray{"login_name1", "login_name2"},
|
||||
"login_name1",
|
||||
//human
|
||||
nil,
|
||||
@@ -448,7 +448,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
State: domain.UserStateActive,
|
||||
Type: domain.UserTypeMachine,
|
||||
Username: "username",
|
||||
LoginNames: []string{"login_name1", "login_name2"},
|
||||
LoginNames: database.StringArray{"login_name1", "login_name2"},
|
||||
PreferredLoginName: "login_name1",
|
||||
Machine: &Machine{
|
||||
Name: "name",
|
||||
@@ -861,7 +861,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
domain.UserStateActive,
|
||||
domain.UserTypeHuman,
|
||||
"username",
|
||||
pq.StringArray{"login_name1", "login_name2"},
|
||||
database.StringArray{"login_name1", "login_name2"},
|
||||
"login_name1",
|
||||
//human
|
||||
"id",
|
||||
@@ -891,7 +891,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
State: domain.UserStateActive,
|
||||
Type: domain.UserTypeHuman,
|
||||
Username: "username",
|
||||
LoginNames: []string{"login_name1", "login_name2"},
|
||||
LoginNames: database.StringArray{"login_name1", "login_name2"},
|
||||
PreferredLoginName: "login_name1",
|
||||
FirstName: "first_name",
|
||||
LastName: "last_name",
|
||||
@@ -925,7 +925,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
domain.UserStateActive,
|
||||
domain.UserTypeHuman,
|
||||
"username",
|
||||
pq.StringArray{"login_name1", "login_name2"},
|
||||
database.StringArray{"login_name1", "login_name2"},
|
||||
"login_name1",
|
||||
//human
|
||||
"id",
|
||||
@@ -1007,7 +1007,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
domain.UserStateActive,
|
||||
domain.UserTypeHuman,
|
||||
"username",
|
||||
pq.StringArray{"login_name1", "login_name2"},
|
||||
database.StringArray{"login_name1", "login_name2"},
|
||||
"login_name1",
|
||||
//human
|
||||
"id",
|
||||
@@ -1044,7 +1044,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
State: domain.UserStateActive,
|
||||
Type: domain.UserTypeHuman,
|
||||
Username: "username",
|
||||
LoginNames: []string{"login_name1", "login_name2"},
|
||||
LoginNames: database.StringArray{"login_name1", "login_name2"},
|
||||
PreferredLoginName: "login_name1",
|
||||
Human: &Human{
|
||||
FirstName: "first_name",
|
||||
@@ -1080,7 +1080,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
domain.UserStateActive,
|
||||
domain.UserTypeHuman,
|
||||
"username",
|
||||
pq.StringArray{"login_name1", "login_name2"},
|
||||
database.StringArray{"login_name1", "login_name2"},
|
||||
"login_name1",
|
||||
//human
|
||||
"id",
|
||||
@@ -1109,7 +1109,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
domain.UserStateActive,
|
||||
domain.UserTypeMachine,
|
||||
"username",
|
||||
pq.StringArray{"login_name1", "login_name2"},
|
||||
database.StringArray{"login_name1", "login_name2"},
|
||||
"login_name1",
|
||||
//human
|
||||
nil,
|
||||
@@ -1146,7 +1146,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
State: domain.UserStateActive,
|
||||
Type: domain.UserTypeHuman,
|
||||
Username: "username",
|
||||
LoginNames: []string{"login_name1", "login_name2"},
|
||||
LoginNames: database.StringArray{"login_name1", "login_name2"},
|
||||
PreferredLoginName: "login_name1",
|
||||
Human: &Human{
|
||||
FirstName: "first_name",
|
||||
@@ -1171,7 +1171,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
State: domain.UserStateActive,
|
||||
Type: domain.UserTypeMachine,
|
||||
Username: "username",
|
||||
LoginNames: []string{"login_name1", "login_name2"},
|
||||
LoginNames: database.StringArray{"login_name1", "login_name2"},
|
||||
PreferredLoginName: "login_name1",
|
||||
Machine: &Machine{
|
||||
Name: "name",
|
||||
|
||||
Reference in New Issue
Block a user