mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:07:31 +00:00
fix(query): realtime data on defined requests (#3726)
* feat: directly specify factors on addCustomLoginPolicy and return on LoginPolicy responses * fix proto * update login policy * feat: directly specify idp on addCustomLoginPolicy and return on LoginPolicy responses * fix: tests * fix(projection): trigger bulk * refactor: clean projection pkg * instance should bulk * fix(query): should trigger bulk on id calls * tests * build prerelease * fix: add shouldTriggerBulk * fix: test Co-authored-by: Livio Amstutz <livio.a@gmail.com> Co-authored-by: Max Peintner <max@caos.ch>
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
func Test_UserAuthMethodPrepares(t *testing.T) {
|
||||
@@ -218,110 +217,6 @@ func Test_UserAuthMethodPrepares(t *testing.T) {
|
||||
},
|
||||
object: nil,
|
||||
},
|
||||
{
|
||||
name: "prepareUserAuthMethodQuery no result",
|
||||
prepare: prepareUserAuthMethodQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
`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`+
|
||||
` FROM projections.user_auth_methods`,
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
if !errs.IsNotFound(err) {
|
||||
return fmt.Errorf("err should be zitadel.NotFoundError got: %w", err), false
|
||||
}
|
||||
return nil, true
|
||||
},
|
||||
},
|
||||
object: (*AuthMethod)(nil),
|
||||
},
|
||||
{
|
||||
name: "prepareUserAuthMethodQuery found",
|
||||
prepare: prepareUserAuthMethodQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
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`+
|
||||
` FROM projections.user_auth_methods`),
|
||||
[]string{
|
||||
"token_id",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"user_id",
|
||||
"sequence",
|
||||
"name",
|
||||
"state",
|
||||
"method_type",
|
||||
},
|
||||
[]driver.Value{
|
||||
"token_id",
|
||||
testNow,
|
||||
testNow,
|
||||
"ro",
|
||||
"user_id",
|
||||
uint64(20211108),
|
||||
"name",
|
||||
domain.MFAStateReady,
|
||||
domain.UserAuthMethodTypeU2F,
|
||||
},
|
||||
),
|
||||
},
|
||||
object: &AuthMethod{
|
||||
TokenID: "token_id",
|
||||
CreationDate: testNow,
|
||||
ChangeDate: testNow,
|
||||
ResourceOwner: "ro",
|
||||
UserID: "user_id",
|
||||
Sequence: 20211108,
|
||||
Name: "name",
|
||||
State: domain.MFAStateReady,
|
||||
Type: domain.UserAuthMethodTypeU2F,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "prepareUserAuthMethodQuery sql err",
|
||||
prepare: prepareUserAuthMethodQuery,
|
||||
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`+
|
||||
` FROM projections.user_auth_methods`),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
if !errors.Is(err, sql.ErrConnDone) {
|
||||
return fmt.Errorf("err should be sql.ErrConnDone got: %w", err), false
|
||||
}
|
||||
return nil, true
|
||||
},
|
||||
},
|
||||
object: nil,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user