fix: provider type column in idp_login_policy_links projection (#4325)

This commit is contained in:
Livio Spring 2022-09-06 08:39:03 +02:00 committed by GitHub
parent 8a5c3b0fa1
commit 4723e911f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 26 deletions

View File

@ -12,12 +12,12 @@ import (
) )
var ( var (
loginPolicyIDPLinksQuery = regexp.QuoteMeta(`SELECT projections.idp_login_policy_links2.idp_id,` + loginPolicyIDPLinksQuery = regexp.QuoteMeta(`SELECT projections.idp_login_policy_links3.idp_id,` +
` projections.idps2.name,` + ` projections.idps2.name,` +
` projections.idps2.type,` + ` projections.idps2.type,` +
` COUNT(*) OVER ()` + ` COUNT(*) OVER ()` +
` FROM projections.idp_login_policy_links2` + ` FROM projections.idp_login_policy_links3` +
` LEFT JOIN projections.idps2 ON projections.idp_login_policy_links2.idp_id = projections.idps2.id`) ` LEFT JOIN projections.idps2 ON projections.idp_login_policy_links3.idp_id = projections.idps2.id`)
loginPolicyIDPLinksCols = []string{ loginPolicyIDPLinksCols = []string{
"idp_id", "idp_id",
"name", "name",

View File

@ -50,14 +50,14 @@ func Test_LoginPolicyPrepares(t *testing.T) {
` projections.login_policies.mfa_init_skip_lifetime,`+ ` projections.login_policies.mfa_init_skip_lifetime,`+
` projections.login_policies.second_factor_check_lifetime,`+ ` projections.login_policies.second_factor_check_lifetime,`+
` projections.login_policies.multi_factor_check_lifetime,`+ ` projections.login_policies.multi_factor_check_lifetime,`+
` projections.idp_login_policy_links2.idp_id,`+ ` projections.idp_login_policy_links3.idp_id,`+
` projections.idps2.name,`+ ` projections.idps2.name,`+
` projections.idps2.type`+ ` projections.idps2.type`+
` FROM projections.login_policies`+ ` FROM projections.login_policies`+
` LEFT JOIN projections.idp_login_policy_links2 ON `+ ` LEFT JOIN projections.idp_login_policy_links3 ON `+
` projections.login_policies.aggregate_id = projections.idp_login_policy_links2.aggregate_id`+ ` projections.login_policies.aggregate_id = projections.idp_login_policy_links3.aggregate_id`+
` LEFT JOIN projections.idps2 ON`+ ` LEFT JOIN projections.idps2 ON`+
` projections.idp_login_policy_links2.idp_id = projections.idps2.id`), ` projections.idp_login_policy_links3.idp_id = projections.idps2.id`),
nil, nil,
nil, nil,
), ),
@ -95,14 +95,14 @@ func Test_LoginPolicyPrepares(t *testing.T) {
` projections.login_policies.mfa_init_skip_lifetime,`+ ` projections.login_policies.mfa_init_skip_lifetime,`+
` projections.login_policies.second_factor_check_lifetime,`+ ` projections.login_policies.second_factor_check_lifetime,`+
` projections.login_policies.multi_factor_check_lifetime,`+ ` projections.login_policies.multi_factor_check_lifetime,`+
` projections.idp_login_policy_links2.idp_id,`+ ` projections.idp_login_policy_links3.idp_id,`+
` projections.idps2.name,`+ ` projections.idps2.name,`+
` projections.idps2.type`+ ` projections.idps2.type`+
` FROM projections.login_policies`+ ` FROM projections.login_policies`+
` LEFT JOIN projections.idp_login_policy_links2 ON `+ ` LEFT JOIN projections.idp_login_policy_links3 ON `+
` projections.login_policies.aggregate_id = projections.idp_login_policy_links2.aggregate_id`+ ` projections.login_policies.aggregate_id = projections.idp_login_policy_links3.aggregate_id`+
` LEFT JOIN projections.idps2 ON`+ ` LEFT JOIN projections.idps2 ON`+
` projections.idp_login_policy_links2.idp_id = projections.idps2.id`), ` projections.idp_login_policy_links3.idp_id = projections.idps2.id`),
[]string{ []string{
"aggregate_id", "aggregate_id",
"creation_date", "creation_date",
@ -210,14 +210,14 @@ func Test_LoginPolicyPrepares(t *testing.T) {
` projections.login_policies.mfa_init_skip_lifetime,`+ ` projections.login_policies.mfa_init_skip_lifetime,`+
` projections.login_policies.second_factor_check_lifetime,`+ ` projections.login_policies.second_factor_check_lifetime,`+
` projections.login_policies.multi_factor_check_lifetime,`+ ` projections.login_policies.multi_factor_check_lifetime,`+
` projections.idp_login_policy_links2.idp_id,`+ ` projections.idp_login_policy_links3.idp_id,`+
` projections.idps2.name,`+ ` projections.idps2.name,`+
` projections.idps2.type`+ ` projections.idps2.type`+
` FROM projections.login_policies`+ ` FROM projections.login_policies`+
` LEFT JOIN projections.idp_login_policy_links2 ON `+ ` LEFT JOIN projections.idp_login_policy_links3 ON `+
` projections.login_policies.aggregate_id = projections.idp_login_policy_links2.aggregate_id`+ ` projections.login_policies.aggregate_id = projections.idp_login_policy_links3.aggregate_id`+
` LEFT JOIN projections.idps2 ON`+ ` LEFT JOIN projections.idps2 ON`+
` projections.idp_login_policy_links2.idp_id = projections.idps2.id`), ` projections.idp_login_policy_links3.idp_id = projections.idps2.id`),
sql.ErrConnDone, sql.ErrConnDone,
), ),
err: func(err error) (error, bool) { err: func(err error) (error, bool) {

View File

@ -14,7 +14,7 @@ import (
) )
const ( const (
IDPLoginPolicyLinkTable = "projections.idp_login_policy_links2" IDPLoginPolicyLinkTable = "projections.idp_login_policy_links3"
IDPLoginPolicyLinkIDPIDCol = "idp_id" IDPLoginPolicyLinkIDPIDCol = "idp_id"
IDPLoginPolicyLinkAggregateIDCol = "aggregate_id" IDPLoginPolicyLinkAggregateIDCol = "aggregate_id"
@ -43,7 +43,7 @@ func newIDPLoginPolicyLinkProjection(ctx context.Context, config crdb.StatementH
crdb.NewColumn(IDPLoginPolicyLinkSequenceCol, crdb.ColumnTypeInt64), crdb.NewColumn(IDPLoginPolicyLinkSequenceCol, crdb.ColumnTypeInt64),
crdb.NewColumn(IDPLoginPolicyLinkResourceOwnerCol, crdb.ColumnTypeText), crdb.NewColumn(IDPLoginPolicyLinkResourceOwnerCol, crdb.ColumnTypeText),
crdb.NewColumn(IDPLoginPolicyLinkInstanceIDCol, crdb.ColumnTypeText), crdb.NewColumn(IDPLoginPolicyLinkInstanceIDCol, crdb.ColumnTypeText),
crdb.NewColumn(IDPLoginPolicyLinkProviderTypeCol, crdb.ColumnTypeText), crdb.NewColumn(IDPLoginPolicyLinkProviderTypeCol, crdb.ColumnTypeEnum),
}, },
crdb.NewPrimaryKey(IDPLoginPolicyLinkInstanceIDCol, IDPLoginPolicyLinkAggregateIDCol, IDPLoginPolicyLinkIDPIDCol), crdb.NewPrimaryKey(IDPLoginPolicyLinkInstanceIDCol, IDPLoginPolicyLinkAggregateIDCol, IDPLoginPolicyLinkIDPIDCol),
crdb.WithIndex(crdb.NewIndex("link_ro_idx", []string{IDPLoginPolicyLinkResourceOwnerCol})), crdb.WithIndex(crdb.NewIndex("link_ro_idx", []string{IDPLoginPolicyLinkResourceOwnerCol})),

View File

@ -43,7 +43,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
executer: &testExecuter{ executer: &testExecuter{
executions: []execution{ executions: []execution{
{ {
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)", expectedStmt: "INSERT INTO projections.idp_login_policy_links3 (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{}{ expectedArgs: []interface{}{
"idp-config-id", "idp-config-id",
"agg-id", "agg-id",
@ -80,7 +80,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
executer: &testExecuter{ executer: &testExecuter{
executions: []execution{ executions: []execution{
{ {
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (aggregate_id = $2)", expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2)",
expectedArgs: []interface{}{ expectedArgs: []interface{}{
"idp-config-id", "idp-config-id",
"agg-id", "agg-id",
@ -111,7 +111,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
executer: &testExecuter{ executer: &testExecuter{
executions: []execution{ executions: []execution{
{ {
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (aggregate_id = $2)", expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2)",
expectedArgs: []interface{}{ expectedArgs: []interface{}{
"idp-config-id", "idp-config-id",
"agg-id", "agg-id",
@ -142,7 +142,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
executer: &testExecuter{ executer: &testExecuter{
executions: []execution{ executions: []execution{
{ {
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)", expectedStmt: "INSERT INTO projections.idp_login_policy_links3 (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{}{ expectedArgs: []interface{}{
"idp-config-id", "idp-config-id",
"agg-id", "agg-id",
@ -179,7 +179,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
executer: &testExecuter{ executer: &testExecuter{
executions: []execution{ executions: []execution{
{ {
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (aggregate_id = $2)", expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2)",
expectedArgs: []interface{}{ expectedArgs: []interface{}{
"idp-config-id", "idp-config-id",
"agg-id", "agg-id",
@ -210,7 +210,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
executer: &testExecuter{ executer: &testExecuter{
executions: []execution{ executions: []execution{
{ {
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (aggregate_id = $2)", expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2)",
expectedArgs: []interface{}{ expectedArgs: []interface{}{
"idp-config-id", "idp-config-id",
"agg-id", "agg-id",
@ -238,7 +238,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
executer: &testExecuter{ executer: &testExecuter{
executions: []execution{ executions: []execution{
{ {
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (resource_owner = $1)", expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (resource_owner = $1)",
expectedArgs: []interface{}{ expectedArgs: []interface{}{
"agg-id", "agg-id",
}, },
@ -267,7 +267,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
executer: &testExecuter{ executer: &testExecuter{
executions: []execution{ executions: []execution{
{ {
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (resource_owner = $2)", expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{ expectedArgs: []interface{}{
"idp-config-id", "idp-config-id",
"ro-id", "ro-id",
@ -297,7 +297,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
executer: &testExecuter{ executer: &testExecuter{
executions: []execution{ executions: []execution{
{ {
expectedStmt: "DELETE FROM projections.idp_login_policy_links2 WHERE (idp_id = $1) AND (resource_owner = $2)", expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (resource_owner = $2)",
expectedArgs: []interface{}{ expectedArgs: []interface{}{
"idp-config-id", "idp-config-id",
"ro-id", "ro-id",