chore: use pgx v5 (#7577)

* chore: use pgx v5

* chore: update go version

* remove direct pq dependency

* remove unnecessary type

* scan test

* map scanner

* converter

* uint8 number array

* duration

* most unit tests work

* unit tests work

* chore: coverage

* go 1.21

* linting

* int64 gopfertammi

* retry go 1.22

* retry go 1.22

* revert to go v1.21.5

* update go toolchain to 1.21.8

* go 1.21.8

* remove test flag

* go 1.21.5

* linting

* update toolchain

* use correct array

* use correct array

* add byte array

* correct value

* correct error message

* go 1.21 compatible
This commit is contained in:
Silvan
2024-03-27 14:48:22 +01:00
committed by GitHub
parent 2ea0b520fd
commit 56df515e5f
49 changed files with 801 additions and 493 deletions

View File

@@ -42,8 +42,8 @@ type App struct {
type OIDCApp struct {
RedirectURIs database.TextArray[string]
ResponseTypes database.Array[domain.OIDCResponseType]
GrantTypes database.Array[domain.OIDCGrantType]
ResponseTypes database.NumberArray[domain.OIDCResponseType]
GrantTypes database.NumberArray[domain.OIDCGrantType]
AppType domain.OIDCApplicationType
ClientID string
AuthMethodType domain.OIDCAuthMethodType
@@ -835,8 +835,8 @@ type sqlOIDCConfig struct {
iDTokenUserinfoAssertion sql.NullBool
clockSkew sql.NullInt64
additionalOrigins database.TextArray[string]
responseTypes database.Array[domain.OIDCResponseType]
grantTypes database.Array[domain.OIDCGrantType]
responseTypes database.NumberArray[domain.OIDCResponseType]
grantTypes database.NumberArray[domain.OIDCGrantType]
skipNativeAppSuccessPage sql.NullBool
}

View File

@@ -421,8 +421,8 @@ func Test_AppsPrepare(t *testing.T) {
domain.OIDCVersionV1,
"oidc-client-id",
database.TextArray[string]{"https://redirect.to/me"},
database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
domain.OIDCApplicationTypeUserAgent,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"post.logout.ch"},
@@ -461,8 +461,8 @@ func Test_AppsPrepare(t *testing.T) {
Version: domain.OIDCVersionV1,
ClientID: "oidc-client-id",
RedirectURIs: database.TextArray[string]{"https://redirect.to/me"},
ResponseTypes: database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
ResponseTypes: database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
AppType: domain.OIDCApplicationTypeUserAgent,
AuthMethodType: domain.OIDCAuthMethodTypeNone,
PostLogoutRedirectURIs: database.TextArray[string]{"post.logout.ch"},
@@ -507,8 +507,8 @@ func Test_AppsPrepare(t *testing.T) {
domain.OIDCVersionV1,
"oidc-client-id",
database.TextArray[string]{"https://redirect.to/me"},
database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
domain.OIDCApplicationTypeUserAgent,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"post.logout.ch"},
@@ -547,8 +547,8 @@ func Test_AppsPrepare(t *testing.T) {
Version: domain.OIDCVersionV1,
ClientID: "oidc-client-id",
RedirectURIs: database.TextArray[string]{"https://redirect.to/me"},
ResponseTypes: database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
ResponseTypes: database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
AppType: domain.OIDCApplicationTypeUserAgent,
AuthMethodType: domain.OIDCAuthMethodTypeNone,
PostLogoutRedirectURIs: database.TextArray[string]{"post.logout.ch"},
@@ -593,8 +593,8 @@ func Test_AppsPrepare(t *testing.T) {
domain.OIDCVersionV1,
"oidc-client-id",
database.TextArray[string]{"https://redirect.to/me"},
database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
domain.OIDCApplicationTypeUserAgent,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"post.logout.ch"},
@@ -633,8 +633,8 @@ func Test_AppsPrepare(t *testing.T) {
Version: domain.OIDCVersionV1,
ClientID: "oidc-client-id",
RedirectURIs: database.TextArray[string]{"https://redirect.to/me"},
ResponseTypes: database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
ResponseTypes: database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
AppType: domain.OIDCApplicationTypeUserAgent,
AuthMethodType: domain.OIDCAuthMethodTypeNone,
PostLogoutRedirectURIs: database.TextArray[string]{"post.logout.ch"},
@@ -679,8 +679,8 @@ func Test_AppsPrepare(t *testing.T) {
domain.OIDCVersionV1,
"oidc-client-id",
database.TextArray[string]{"https://redirect.to/me"},
database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
domain.OIDCApplicationTypeUserAgent,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"post.logout.ch"},
@@ -719,8 +719,8 @@ func Test_AppsPrepare(t *testing.T) {
Version: domain.OIDCVersionV1,
ClientID: "oidc-client-id",
RedirectURIs: database.TextArray[string]{"https://redirect.to/me"},
ResponseTypes: database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
ResponseTypes: database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
AppType: domain.OIDCApplicationTypeUserAgent,
AuthMethodType: domain.OIDCAuthMethodTypeNone,
PostLogoutRedirectURIs: database.TextArray[string]{"post.logout.ch"},
@@ -765,8 +765,8 @@ func Test_AppsPrepare(t *testing.T) {
domain.OIDCVersionV1,
"oidc-client-id",
database.TextArray[string]{"https://redirect.to/me"},
database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
domain.OIDCApplicationTypeUserAgent,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"post.logout.ch"},
@@ -805,8 +805,8 @@ func Test_AppsPrepare(t *testing.T) {
Version: domain.OIDCVersionV1,
ClientID: "oidc-client-id",
RedirectURIs: database.TextArray[string]{"https://redirect.to/me"},
ResponseTypes: database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
ResponseTypes: database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
AppType: domain.OIDCApplicationTypeUserAgent,
AuthMethodType: domain.OIDCAuthMethodTypeNone,
PostLogoutRedirectURIs: database.TextArray[string]{"post.logout.ch"},
@@ -851,8 +851,8 @@ func Test_AppsPrepare(t *testing.T) {
domain.OIDCVersionV1,
"oidc-client-id",
database.TextArray[string]{"https://redirect.to/me"},
database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
domain.OIDCApplicationTypeNative,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"post.logout.ch"},
@@ -891,8 +891,8 @@ func Test_AppsPrepare(t *testing.T) {
Version: domain.OIDCVersionV1,
ClientID: "oidc-client-id",
RedirectURIs: database.TextArray[string]{"https://redirect.to/me"},
ResponseTypes: database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
ResponseTypes: database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
AppType: domain.OIDCApplicationTypeNative,
AuthMethodType: domain.OIDCAuthMethodTypeNone,
PostLogoutRedirectURIs: database.TextArray[string]{"post.logout.ch"},
@@ -937,8 +937,8 @@ func Test_AppsPrepare(t *testing.T) {
domain.OIDCVersionV1,
"oidc-client-id",
database.TextArray[string]{"https://redirect.to/me"},
database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
domain.OIDCApplicationTypeUserAgent,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"post.logout.ch"},
@@ -1051,8 +1051,8 @@ func Test_AppsPrepare(t *testing.T) {
Version: domain.OIDCVersionV1,
ClientID: "oidc-client-id",
RedirectURIs: database.TextArray[string]{"https://redirect.to/me"},
ResponseTypes: database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
ResponseTypes: database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
AppType: domain.OIDCApplicationTypeUserAgent,
AuthMethodType: domain.OIDCAuthMethodTypeNone,
PostLogoutRedirectURIs: database.TextArray[string]{"post.logout.ch"},
@@ -1120,6 +1120,9 @@ func Test_AppsPrepare(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.name == "prepareAppsQuery oidc app" {
_ = tt.name
}
assertPrepare(t, tt.prepare, tt.object, tt.want.sqlExpectations, tt.want.err, defaultPrepareArgs...)
})
}
@@ -1300,8 +1303,8 @@ func Test_AppPrepare(t *testing.T) {
domain.OIDCVersionV1,
"oidc-client-id",
database.TextArray[string]{"https://redirect.to/me"},
database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
domain.OIDCApplicationTypeUserAgent,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"post.logout.ch"},
@@ -1335,8 +1338,8 @@ func Test_AppPrepare(t *testing.T) {
Version: domain.OIDCVersionV1,
ClientID: "oidc-client-id",
RedirectURIs: database.TextArray[string]{"https://redirect.to/me"},
ResponseTypes: database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
ResponseTypes: database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
AppType: domain.OIDCApplicationTypeUserAgent,
AuthMethodType: domain.OIDCAuthMethodTypeNone,
PostLogoutRedirectURIs: database.TextArray[string]{"post.logout.ch"},
@@ -1442,8 +1445,8 @@ func Test_AppPrepare(t *testing.T) {
domain.OIDCVersionV1,
"oidc-client-id",
database.TextArray[string]{"https://redirect.to/me"},
database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
domain.OIDCApplicationTypeUserAgent,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"post.logout.ch"},
@@ -1477,8 +1480,8 @@ func Test_AppPrepare(t *testing.T) {
Version: domain.OIDCVersionV1,
ClientID: "oidc-client-id",
RedirectURIs: database.TextArray[string]{"https://redirect.to/me"},
ResponseTypes: database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
ResponseTypes: database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
AppType: domain.OIDCApplicationTypeUserAgent,
AuthMethodType: domain.OIDCAuthMethodTypeNone,
PostLogoutRedirectURIs: database.TextArray[string]{"post.logout.ch"},
@@ -1521,8 +1524,8 @@ func Test_AppPrepare(t *testing.T) {
domain.OIDCVersionV1,
"oidc-client-id",
database.TextArray[string]{"https://redirect.to/me"},
database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
domain.OIDCApplicationTypeUserAgent,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"post.logout.ch"},
@@ -1556,8 +1559,8 @@ func Test_AppPrepare(t *testing.T) {
Version: domain.OIDCVersionV1,
ClientID: "oidc-client-id",
RedirectURIs: database.TextArray[string]{"https://redirect.to/me"},
ResponseTypes: database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
ResponseTypes: database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
AppType: domain.OIDCApplicationTypeUserAgent,
AuthMethodType: domain.OIDCAuthMethodTypeNone,
PostLogoutRedirectURIs: database.TextArray[string]{"post.logout.ch"},
@@ -1600,8 +1603,8 @@ func Test_AppPrepare(t *testing.T) {
domain.OIDCVersionV1,
"oidc-client-id",
database.TextArray[string]{"https://redirect.to/me"},
database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
domain.OIDCApplicationTypeUserAgent,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"post.logout.ch"},
@@ -1635,8 +1638,8 @@ func Test_AppPrepare(t *testing.T) {
Version: domain.OIDCVersionV1,
ClientID: "oidc-client-id",
RedirectURIs: database.TextArray[string]{"https://redirect.to/me"},
ResponseTypes: database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
ResponseTypes: database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
AppType: domain.OIDCApplicationTypeUserAgent,
AuthMethodType: domain.OIDCAuthMethodTypeNone,
PostLogoutRedirectURIs: database.TextArray[string]{"post.logout.ch"},
@@ -1679,8 +1682,8 @@ func Test_AppPrepare(t *testing.T) {
domain.OIDCVersionV1,
"oidc-client-id",
database.TextArray[string]{"https://redirect.to/me"},
database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
domain.OIDCApplicationTypeUserAgent,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"post.logout.ch"},
@@ -1714,8 +1717,8 @@ func Test_AppPrepare(t *testing.T) {
Version: domain.OIDCVersionV1,
ClientID: "oidc-client-id",
RedirectURIs: database.TextArray[string]{"https://redirect.to/me"},
ResponseTypes: database.Array[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.Array[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
ResponseTypes: database.NumberArray[domain.OIDCResponseType]{domain.OIDCResponseTypeIDTokenToken},
GrantTypes: database.NumberArray[domain.OIDCGrantType]{domain.OIDCGrantTypeImplicit},
AppType: domain.OIDCApplicationTypeUserAgent,
AuthMethodType: domain.OIDCAuthMethodTypeNone,
PostLogoutRedirectURIs: database.TextArray[string]{"post.logout.ch"},

View File

@@ -61,7 +61,7 @@ func (q *Queries) AuthRequestByID(ctx context.Context, shouldTriggerBulk bool, i
var (
scope database.TextArray[string]
prompt database.Array[domain.Prompt]
prompt database.NumberArray[domain.Prompt]
locales database.TextArray[string]
)

View File

@@ -65,7 +65,7 @@ func TestQueries_AuthRequestByID(t *testing.T) {
"clientID",
database.TextArray[string]{"a", "b", "c"},
"example.com",
database.Array[domain.Prompt]{domain.PromptLogin, domain.PromptConsent},
database.NumberArray[domain.Prompt]{domain.PromptLogin, domain.PromptConsent},
database.TextArray[string]{"en", "fi"},
"me@example.com",
int64(time.Minute),
@@ -99,11 +99,11 @@ func TestQueries_AuthRequestByID(t *testing.T) {
"clientID",
database.TextArray[string]{"a", "b", "c"},
"example.com",
database.Array[domain.Prompt]{domain.PromptLogin, domain.PromptConsent},
database.NumberArray[domain.Prompt]{domain.PromptLogin, domain.PromptConsent},
database.TextArray[string]{"en", "fi"},
sql.NullString{},
sql.NullInt64{},
sql.NullString{},
nil,
nil,
nil,
}, "123", "instanceID"),
want: &AuthRequest{
ID: "id",
@@ -151,11 +151,11 @@ func TestQueries_AuthRequestByID(t *testing.T) {
"clientID",
database.TextArray[string]{"a", "b", "c"},
"example.com",
database.Array[domain.Prompt]{domain.PromptLogin, domain.PromptConsent},
database.NumberArray[domain.Prompt]{domain.PromptLogin, domain.PromptConsent},
database.TextArray[string]{"en", "fi"},
sql.NullString{},
sql.NullInt64{},
sql.NullString{},
nil,
nil,
nil,
}, "123", "instanceID"),
wantErr: zerrors.ThrowPermissionDeniedf(nil, "OIDCv2-aL0ag", "Errors.AuthRequest.WrongLoginClient"),
},

View File

@@ -17,6 +17,7 @@ import (
"github.com/zitadel/zitadel/internal/api/authz"
"github.com/zitadel/zitadel/internal/database"
db_mock "github.com/zitadel/zitadel/internal/database/mock"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/repository/deviceauth"
@@ -188,7 +189,7 @@ var (
)
func TestQueries_DeviceAuthRequestByUserCode(t *testing.T) {
client, mock, err := sqlmock.New()
client, mock, err := sqlmock.New(sqlmock.ValueConverterOption(new(db_mock.TypeConverter)))
if err != nil {
t.Fatalf("failed to build mock client: %v", err)
}
@@ -196,7 +197,7 @@ func TestQueries_DeviceAuthRequestByUserCode(t *testing.T) {
mock.ExpectBegin()
mock.ExpectQuery(expectedDeviceAuthWhereUserCodeQuery).WillReturnRows(
sqlmock.NewRows(deviceAuthSelectColumns).AddRow(expectedDeviceAuthValues...),
mock.NewRows(deviceAuthSelectColumns).AddRow(expectedDeviceAuthValues...),
)
mock.ExpectCommit()
q := Queries{

View File

@@ -30,8 +30,8 @@ type LoginPolicy struct {
AllowExternalIDPs bool
ForceMFA bool
ForceMFALocalOnly bool
SecondFactors database.Array[domain.SecondFactorType]
MultiFactors database.Array[domain.MultiFactorType]
SecondFactors database.NumberArray[domain.SecondFactorType]
MultiFactors database.NumberArray[domain.MultiFactorType]
PasswordlessType domain.PasswordlessType
IsDefault bool
HidePasswordReset bool
@@ -40,22 +40,22 @@ type LoginPolicy struct {
DisableLoginWithEmail bool
DisableLoginWithPhone bool
DefaultRedirectURI string
PasswordCheckLifetime time.Duration
ExternalLoginCheckLifetime time.Duration
MFAInitSkipLifetime time.Duration
SecondFactorCheckLifetime time.Duration
MultiFactorCheckLifetime time.Duration
PasswordCheckLifetime database.Duration
ExternalLoginCheckLifetime database.Duration
MFAInitSkipLifetime database.Duration
SecondFactorCheckLifetime database.Duration
MultiFactorCheckLifetime database.Duration
IDPLinks []*IDPLoginPolicyLink
}
type SecondFactors struct {
SearchResponse
Factors database.Array[domain.SecondFactorType]
Factors database.NumberArray[domain.SecondFactorType]
}
type MultiFactors struct {
SearchResponse
Factors database.Array[domain.MultiFactorType]
Factors database.NumberArray[domain.MultiFactorType]
}
var (

View File

@@ -84,6 +84,7 @@ var (
)
func Test_LoginPolicyPrepares(t *testing.T) {
duration := 2 * time.Hour
type want struct {
sqlExpectations sqlExpectation
err checkErr
@@ -129,8 +130,8 @@ func Test_LoginPolicyPrepares(t *testing.T) {
true,
true,
true,
database.Array[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
database.Array[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
database.NumberArray[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
database.NumberArray[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
domain.PasswordlessTypeAllowed,
true,
true,
@@ -139,11 +140,11 @@ func Test_LoginPolicyPrepares(t *testing.T) {
true,
true,
"https://example.com/redirect",
time.Hour * 2,
time.Hour * 2,
time.Hour * 2,
time.Hour * 2,
time.Hour * 2,
&duration,
&duration,
&duration,
&duration,
&duration,
},
),
},
@@ -157,8 +158,8 @@ func Test_LoginPolicyPrepares(t *testing.T) {
AllowExternalIDPs: true,
ForceMFA: true,
ForceMFALocalOnly: true,
SecondFactors: database.Array[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
MultiFactors: database.Array[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
SecondFactors: database.NumberArray[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
MultiFactors: database.NumberArray[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
PasswordlessType: domain.PasswordlessTypeAllowed,
IsDefault: true,
HidePasswordReset: true,
@@ -167,11 +168,11 @@ func Test_LoginPolicyPrepares(t *testing.T) {
DisableLoginWithEmail: true,
DisableLoginWithPhone: true,
DefaultRedirectURI: "https://example.com/redirect",
PasswordCheckLifetime: time.Hour * 2,
ExternalLoginCheckLifetime: time.Hour * 2,
MFAInitSkipLifetime: time.Hour * 2,
SecondFactorCheckLifetime: time.Hour * 2,
MultiFactorCheckLifetime: time.Hour * 2,
PasswordCheckLifetime: database.Duration(duration),
ExternalLoginCheckLifetime: database.Duration(duration),
MFAInitSkipLifetime: database.Duration(duration),
SecondFactorCheckLifetime: database.Duration(duration),
MultiFactorCheckLifetime: database.Duration(duration),
},
},
{
@@ -217,7 +218,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
regexp.QuoteMeta(prepareLoginPolicy2FAsStmt),
prepareLoginPolicy2FAsCols,
[]driver.Value{
database.Array[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
database.NumberArray[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
},
),
},
@@ -225,7 +226,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
SearchResponse: SearchResponse{
Count: 1,
},
Factors: database.Array[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
Factors: database.NumberArray[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
},
},
{
@@ -236,11 +237,11 @@ func Test_LoginPolicyPrepares(t *testing.T) {
regexp.QuoteMeta(prepareLoginPolicy2FAsStmt),
prepareLoginPolicy2FAsCols,
[]driver.Value{
database.Array[domain.SecondFactorType]{},
database.NumberArray[domain.SecondFactorType]{},
},
),
},
object: &SecondFactors{Factors: database.Array[domain.SecondFactorType]{}},
object: &SecondFactors{Factors: database.NumberArray[domain.SecondFactorType]{}},
},
{
name: "prepareLoginPolicy2FAsQuery sql err",
@@ -285,7 +286,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
regexp.QuoteMeta(prepareLoginPolicyMFAsStmt),
prepareLoginPolicyMFAsCols,
[]driver.Value{
database.Array[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
database.NumberArray[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
},
),
},
@@ -293,7 +294,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
SearchResponse: SearchResponse{
Count: 1,
},
Factors: database.Array[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
Factors: database.NumberArray[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
},
},
{
@@ -304,11 +305,11 @@ func Test_LoginPolicyPrepares(t *testing.T) {
regexp.QuoteMeta(prepareLoginPolicyMFAsStmt),
prepareLoginPolicyMFAsCols,
[]driver.Value{
database.Array[domain.MultiFactorType]{},
database.NumberArray[domain.MultiFactorType]{},
},
),
},
object: &MultiFactors{Factors: database.Array[domain.MultiFactorType]{}},
object: &MultiFactors{Factors: database.NumberArray[domain.MultiFactorType]{}},
},
{
name: "prepareLoginPolicyMFAsQuery sql err",

View File

@@ -12,6 +12,7 @@ import (
"github.com/DATA-DOG/go-sqlmock"
"github.com/zitadel/zitadel/internal/database"
db_mock "github.com/zitadel/zitadel/internal/database/mock"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/zerrors"
)
@@ -405,7 +406,10 @@ func TestQueries_IsOrgUnique(t *testing.T) {
},
}
for _, tt := range tests {
client, mock, err := sqlmock.New(sqlmock.QueryMatcherOption(sqlmock.QueryMatcherEqual))
client, mock, err := sqlmock.New(
sqlmock.QueryMatcherOption(sqlmock.QueryMatcherEqual),
sqlmock.ValueConverterOption(new(db_mock.TypeConverter)),
)
if err != nil {
t.Fatalf("unable to mock db: %v", err)
}

View File

@@ -13,11 +13,11 @@ import (
"github.com/DATA-DOG/go-sqlmock"
sq "github.com/Masterminds/squirrel"
"github.com/jackc/pgtype"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/zitadel/zitadel/internal/database"
db_mock "github.com/zitadel/zitadel/internal/database/mock"
)
var (
@@ -35,7 +35,7 @@ var (
func assertPrepare(t *testing.T, prepareFunc, expectedObject interface{}, sqlExpectation sqlExpectation, isErr checkErr, prepareArgs ...reflect.Value) bool {
t.Helper()
client, mock, err := sqlmock.New()
client, mock, err := sqlmock.New(sqlmock.ValueConverterOption(new(db_mock.TypeConverter)))
if err != nil {
t.Fatalf("failed to build mock client: %v", err)
}
@@ -85,7 +85,7 @@ func mockQuery(stmt string, cols []string, row []driver.Value, args ...driver.Va
m.ExpectBegin()
q := m.ExpectQuery(stmt).WithArgs(args...)
m.ExpectCommit()
result := sqlmock.NewRows(cols)
result := m.NewRows(cols)
if len(row) > 0 {
result.AddRow(row...)
}
@@ -99,7 +99,7 @@ func mockQueryScanErr(stmt string, cols []string, row []driver.Value, args ...dr
m.ExpectBegin()
q := m.ExpectQuery(stmt).WithArgs(args...)
m.ExpectRollback()
result := sqlmock.NewRows(cols)
result := m.NewRows(cols)
if len(row) > 0 {
result.AddRow(row...)
}
@@ -113,7 +113,7 @@ func mockQueries(stmt string, cols []string, rows [][]driver.Value, args ...driv
m.ExpectBegin()
q := m.ExpectQuery(stmt).WithArgs(args...)
m.ExpectCommit()
result := sqlmock.NewRows(cols)
result := m.NewRows(cols)
count := uint64(len(rows))
for _, row := range rows {
if cols[len(cols)-1] == "count" {
@@ -132,7 +132,7 @@ func mockQueriesScanErr(stmt string, cols []string, rows [][]driver.Value, args
m.ExpectBegin()
q := m.ExpectQuery(stmt).WithArgs(args...)
m.ExpectRollback()
result := sqlmock.NewRows(cols)
result := m.NewRows(cols)
count := uint64(len(rows))
for _, row := range rows {
if cols[len(cols)-1] == "count" {
@@ -157,7 +157,7 @@ func mockQueryErr(stmt string, err error, args ...driver.Value) func(m sqlmock.S
}
func execMock(t testing.TB, exp sqlExpectation, run func(db *sql.DB)) {
db, mock, err := sqlmock.New()
db, mock, err := sqlmock.New(sqlmock.ValueConverterOption(new(db_mock.TypeConverter)))
require.NoError(t, err)
defer db.Close()
mock = exp(mock)
@@ -172,6 +172,8 @@ var (
)
func execScan(t testing.TB, client *database.DB, builder sq.SelectBuilder, scan interface{}, errCheck checkErr) (object interface{}, ok bool, didScan bool) {
t.Helper()
scanType := reflect.TypeOf(scan)
err := validateScan(scanType)
if err != nil {
@@ -388,15 +390,6 @@ func TestValidatePrepare(t *testing.T) {
}
}
func intervalDriverValue(t *testing.T, src time.Duration) pgtype.Interval {
interval := pgtype.Interval{}
err := interval.Set(src)
if err != nil {
t.Fatal(err)
}
return interval
}
type prepareDB struct{}
const asOfSystemTime = " AS OF SYSTEM TIME '-1 ms' "

View File

@@ -451,8 +451,8 @@ func (p *appProjection) reduceOIDCConfigAdded(event eventstore.Event) (*handler.
handler.NewCol(AppOIDCConfigColumnClientID, e.ClientID),
handler.NewCol(AppOIDCConfigColumnClientSecret, e.ClientSecret),
handler.NewCol(AppOIDCConfigColumnRedirectUris, database.TextArray[string](e.RedirectUris)),
handler.NewCol(AppOIDCConfigColumnResponseTypes, database.Array[domain.OIDCResponseType](e.ResponseTypes)),
handler.NewCol(AppOIDCConfigColumnGrantTypes, database.Array[domain.OIDCGrantType](e.GrantTypes)),
handler.NewCol(AppOIDCConfigColumnResponseTypes, database.NumberArray[domain.OIDCResponseType](e.ResponseTypes)),
handler.NewCol(AppOIDCConfigColumnGrantTypes, database.NumberArray[domain.OIDCGrantType](e.GrantTypes)),
handler.NewCol(AppOIDCConfigColumnApplicationType, e.ApplicationType),
handler.NewCol(AppOIDCConfigColumnAuthMethodType, e.AuthMethodType),
handler.NewCol(AppOIDCConfigColumnPostLogoutRedirectUris, database.TextArray[string](e.PostLogoutRedirectUris)),
@@ -494,10 +494,10 @@ func (p *appProjection) reduceOIDCConfigChanged(event eventstore.Event) (*handle
cols = append(cols, handler.NewCol(AppOIDCConfigColumnRedirectUris, database.TextArray[string](*e.RedirectUris)))
}
if e.ResponseTypes != nil {
cols = append(cols, handler.NewCol(AppOIDCConfigColumnResponseTypes, database.Array[domain.OIDCResponseType](*e.ResponseTypes)))
cols = append(cols, handler.NewCol(AppOIDCConfigColumnResponseTypes, database.NumberArray[domain.OIDCResponseType](*e.ResponseTypes)))
}
if e.GrantTypes != nil {
cols = append(cols, handler.NewCol(AppOIDCConfigColumnGrantTypes, database.Array[domain.OIDCGrantType](*e.GrantTypes)))
cols = append(cols, handler.NewCol(AppOIDCConfigColumnGrantTypes, database.NumberArray[domain.OIDCGrantType](*e.GrantTypes)))
}
if e.ApplicationType != nil {
cols = append(cols, handler.NewCol(AppOIDCConfigColumnApplicationType, *e.ApplicationType))

View File

@@ -455,8 +455,8 @@ func TestAppProjection_reduces(t *testing.T) {
"client-id",
anyArg{},
database.TextArray[string]{"redirect.one.ch", "redirect.two.ch"},
database.Array[domain.OIDCResponseType]{1, 2},
database.Array[domain.OIDCGrantType]{1, 2},
database.NumberArray[domain.OIDCResponseType]{1, 2},
database.NumberArray[domain.OIDCGrantType]{1, 2},
domain.OIDCApplicationTypeNative,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"logout.one.ch", "logout.two.ch"},
@@ -522,8 +522,8 @@ func TestAppProjection_reduces(t *testing.T) {
expectedArgs: []interface{}{
domain.OIDCVersionV1,
database.TextArray[string]{"redirect.one.ch", "redirect.two.ch"},
database.Array[domain.OIDCResponseType]{1, 2},
database.Array[domain.OIDCGrantType]{1, 2},
database.NumberArray[domain.OIDCResponseType]{1, 2},
database.NumberArray[domain.OIDCGrantType]{1, 2},
domain.OIDCApplicationTypeNative,
domain.OIDCAuthMethodTypeNone,
database.TextArray[string]{"logout.one.ch", "logout.two.ch"},

View File

@@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/zitadel/zitadel/internal/database"
db_mock "github.com/zitadel/zitadel/internal/database/mock"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/handler/v2"
"github.com/zitadel/zitadel/internal/repository/instance"
@@ -384,15 +385,15 @@ func Test_quotaProjection_IncrementUsage(t *testing.T) {
name: "",
fields: fields{
client: func() *database.DB {
db, mock, _ := sqlmock.New()
db, mock, _ := sqlmock.New(sqlmock.ValueConverterOption(new(db_mock.TypeConverter)))
mock.ExpectQuery(regexp.QuoteMeta(incrementQuotaStatement)).
WithArgs(
"instance_id",
1,
quota.Unit(1),
testNow,
2,
uint64(2),
).
WillReturnRows(sqlmock.NewRows([]string{"key"}).
WillReturnRows(mock.NewRows([]string{"key"}).
AddRow(3))
return &database.DB{DB: db}
}(),

View File

@@ -92,7 +92,7 @@ func prepareQuotaQuery(ctx context.Context, db prepareDatabase) (sq.SelectBuilde
From(quotasTable.identifier()).
PlaceholderFormat(sq.Dollar), func(row *sql.Row) (*Quota, error) {
q := new(Quota)
var interval database.Duration
var interval database.NullDuration
var now time.Time
err := row.Scan(&q.ID, &q.From, &interval, &q.Amount, &q.Limit, &now)
if err != nil {
@@ -101,7 +101,7 @@ func prepareQuotaQuery(ctx context.Context, db prepareDatabase) (sq.SelectBuilde
}
return nil, zerrors.ThrowInternal(err, "QUERY-LqySK", "Errors.Internal")
}
q.ResetInterval = time.Duration(interval)
q.ResetInterval = interval.Duration
q.CurrentPeriodStart = pushPeriodStart(q.From, q.ResetInterval, now)
return q, nil
}

View File

@@ -9,6 +9,8 @@ import (
"testing"
"time"
"github.com/jackc/pgx/v5/pgtype"
"github.com/zitadel/zitadel/internal/zerrors"
)
@@ -70,7 +72,9 @@ func Test_QuotaPrepare(t *testing.T) {
[]driver.Value{
"quota-id",
dayNow,
intervalDriverValue(t, time.Hour*24),
&pgtype.Interval{
Days: 1,
},
uint64(1000),
true,
testNow,

View File

@@ -32,7 +32,7 @@ type UserSchema struct {
Type string
Revision uint32
Schema json.RawMessage
PossibleAuthenticators database.Array[domain.AuthenticatorType]
PossibleAuthenticators database.NumberArray[domain.AuthenticatorType]
}
type UserSchemaSearchQueries struct {
@@ -144,6 +144,7 @@ func prepareUserSchemaQuery() (sq.SelectBuilder, func(*sql.Row) (*UserSchema, er
PlaceholderFormat(sq.Dollar),
func(row *sql.Row) (*UserSchema, error) {
u := new(UserSchema)
var schema database.ByteArray[byte]
err := row.Scan(
&u.ID,
&u.EventDate,
@@ -152,16 +153,19 @@ func prepareUserSchemaQuery() (sq.SelectBuilder, func(*sql.Row) (*UserSchema, er
&u.State,
&u.Type,
&u.Revision,
&u.Schema,
&schema,
&u.PossibleAuthenticators,
)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, zerrors.ThrowNotFound(err, "QUERY-SAF3t", "Errors.Metadata.NotFound")
return nil, zerrors.ThrowNotFound(err, "QUERY-SAF3t", "Errors.UserSchema.NotExists")
}
return nil, zerrors.ThrowInternal(err, "QUERY-WRB2Q", "Errors.Internal")
}
u.Schema = json.RawMessage(schema)
return u, nil
}
}
@@ -181,8 +185,12 @@ func prepareUserSchemasQuery() (sq.SelectBuilder, func(*sql.Rows) (*UserSchemas,
From(userSchemaTable.identifier()).
PlaceholderFormat(sq.Dollar),
func(rows *sql.Rows) (*UserSchemas, error) {
schema := make([]*UserSchema, 0)
var count uint64
schemas := make([]*UserSchema, 0)
var (
schema database.ByteArray[byte]
count uint64
)
for rows.Next() {
u := new(UserSchema)
err := rows.Scan(
@@ -193,7 +201,7 @@ func prepareUserSchemasQuery() (sq.SelectBuilder, func(*sql.Rows) (*UserSchemas,
&u.State,
&u.Type,
&u.Revision,
&u.Schema,
&schema,
&u.PossibleAuthenticators,
&count,
)
@@ -201,7 +209,8 @@ func prepareUserSchemasQuery() (sq.SelectBuilder, func(*sql.Rows) (*UserSchemas,
return nil, err
}
schema = append(schema, u)
u.Schema = json.RawMessage(schema)
schemas = append(schemas, u)
}
if err := rows.Close(); err != nil {
@@ -209,7 +218,7 @@ func prepareUserSchemasQuery() (sq.SelectBuilder, func(*sql.Rows) (*UserSchemas,
}
return &UserSchemas{
UserSchemas: schema,
UserSchemas: schemas,
SearchResponse: SearchResponse{
Count: count,
},

View File

@@ -102,7 +102,7 @@ func Test_UserSchemaPrepares(t *testing.T) {
"type",
1,
json.RawMessage(`{"$schema":"urn:zitadel:schema:v1","properties":{"name":{"type":"string","urn:zitadel:schema:permission":{"self":"rw"}}},"type":"object"}`),
database.Array[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
database.NumberArray[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
},
},
),
@@ -123,7 +123,7 @@ func Test_UserSchemaPrepares(t *testing.T) {
Type: "type",
Revision: 1,
Schema: json.RawMessage(`{"$schema":"urn:zitadel:schema:v1","properties":{"name":{"type":"string","urn:zitadel:schema:permission":{"self":"rw"}}},"type":"object"}`),
PossibleAuthenticators: database.Array[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
PossibleAuthenticators: database.NumberArray[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
},
},
},
@@ -145,7 +145,7 @@ func Test_UserSchemaPrepares(t *testing.T) {
"type1",
1,
json.RawMessage(`{"$schema":"urn:zitadel:schema:v1","properties":{"name":{"type":"string","urn:zitadel:schema:permission":{"self":"rw"}}},"type":"object"}`),
database.Array[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
database.NumberArray[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
},
{
"id-2",
@@ -156,7 +156,7 @@ func Test_UserSchemaPrepares(t *testing.T) {
"type2",
2,
json.RawMessage(`{"$schema":"urn:zitadel:schema:v1","properties":{"name":{"type":"string","urn:zitadel:schema:permission":{"self":"rw"}}},"type":"object"}`),
database.Array[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
database.NumberArray[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
},
},
),
@@ -177,7 +177,7 @@ func Test_UserSchemaPrepares(t *testing.T) {
Type: "type1",
Revision: 1,
Schema: json.RawMessage(`{"$schema":"urn:zitadel:schema:v1","properties":{"name":{"type":"string","urn:zitadel:schema:permission":{"self":"rw"}}},"type":"object"}`),
PossibleAuthenticators: database.Array[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
PossibleAuthenticators: database.NumberArray[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
},
{
ID: "id-2",
@@ -190,7 +190,7 @@ func Test_UserSchemaPrepares(t *testing.T) {
Type: "type2",
Revision: 2,
Schema: json.RawMessage(`{"$schema":"urn:zitadel:schema:v1","properties":{"name":{"type":"string","urn:zitadel:schema:permission":{"self":"rw"}}},"type":"object"}`),
PossibleAuthenticators: database.Array[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
PossibleAuthenticators: database.NumberArray[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
},
},
},
@@ -246,7 +246,7 @@ func Test_UserSchemaPrepares(t *testing.T) {
"type",
1,
json.RawMessage(`{"$schema":"urn:zitadel:schema:v1","properties":{"name":{"type":"string","urn:zitadel:schema:permission":{"self":"rw"}}},"type":"object"}`),
database.Array[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
database.NumberArray[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
},
),
},
@@ -261,7 +261,7 @@ func Test_UserSchemaPrepares(t *testing.T) {
Type: "type",
Revision: 1,
Schema: json.RawMessage(`{"$schema":"urn:zitadel:schema:v1","properties":{"name":{"type":"string","urn:zitadel:schema:permission":{"self":"rw"}}},"type":"object"}`),
PossibleAuthenticators: database.Array[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
PossibleAuthenticators: database.NumberArray[domain.AuthenticatorType]{domain.AuthenticatorTypeUsername, domain.AuthenticatorTypePassword},
},
},
{

View File

@@ -65,7 +65,7 @@ func TestQueries_GetOIDCUserInfo(t *testing.T) {
args: args{
userID: "231965491734773762",
},
mock: mockQueryErr(expQuery, sql.ErrConnDone, "231965491734773762", "instanceID", nil),
mock: mockQueryErr(expQuery, sql.ErrConnDone, "231965491734773762", "instanceID", database.TextArray[string](nil)),
wantErr: sql.ErrConnDone,
},
{
@@ -73,7 +73,7 @@ func TestQueries_GetOIDCUserInfo(t *testing.T) {
args: args{
userID: "231965491734773762",
},
mock: mockQuery(expQuery, []string{"json_build_object"}, []driver.Value{testdataUserInfoNotFound}, "231965491734773762", "instanceID", nil),
mock: mockQuery(expQuery, []string{"json_build_object"}, []driver.Value{testdataUserInfoNotFound}, "231965491734773762", "instanceID", database.TextArray[string](nil)),
wantErr: zerrors.ThrowNotFound(nil, "QUERY-ahs4S", "Errors.User.NotFound"),
},
{
@@ -81,7 +81,7 @@ func TestQueries_GetOIDCUserInfo(t *testing.T) {
args: args{
userID: "231965491734773762",
},
mock: mockQuery(expQuery, []string{"json_build_object"}, []driver.Value{testdataUserInfoHumanNoMD}, "231965491734773762", "instanceID", nil),
mock: mockQuery(expQuery, []string{"json_build_object"}, []driver.Value{testdataUserInfoHumanNoMD}, "231965491734773762", "instanceID", database.TextArray[string](nil)),
want: &OIDCUserInfo{
User: &User{
ID: "231965491734773762",
@@ -120,7 +120,7 @@ func TestQueries_GetOIDCUserInfo(t *testing.T) {
args: args{
userID: "231965491734773762",
},
mock: mockQuery(expQuery, []string{"json_build_object"}, []driver.Value{testdataUserInfoHuman}, "231965491734773762", "instanceID", nil),
mock: mockQuery(expQuery, []string{"json_build_object"}, []driver.Value{testdataUserInfoHuman}, "231965491734773762", "instanceID", database.TextArray[string](nil)),
want: &OIDCUserInfo{
User: &User{
ID: "231965491734773762",
@@ -277,7 +277,7 @@ func TestQueries_GetOIDCUserInfo(t *testing.T) {
args: args{
userID: "240707570677841922",
},
mock: mockQuery(expQuery, []string{"json_build_object"}, []driver.Value{testdataUserInfoMachine}, "240707570677841922", "instanceID", nil),
mock: mockQuery(expQuery, []string{"json_build_object"}, []driver.Value{testdataUserInfoMachine}, "240707570677841922", "instanceID", database.TextArray[string](nil)),
want: &OIDCUserInfo{
User: &User{
ID: "240707570677841922",