mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-04 23:45:07 +00:00
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:
parent
2ea0b520fd
commit
56df515e5f
@ -3,7 +3,8 @@ package initialise
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
)
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/DATA-DOG/go-sqlmock"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
db_mock "github.com/zitadel/zitadel/internal/database/mock"
|
||||
)
|
||||
|
||||
type db struct {
|
||||
@ -16,7 +17,7 @@ type db struct {
|
||||
|
||||
func prepareDB(t *testing.T, expectations ...expectation) db {
|
||||
t.Helper()
|
||||
client, mock, err := sqlmock.New()
|
||||
client, mock, err := sqlmock.New(sqlmock.ValueConverterOption(new(db_mock.TypeConverter)))
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create sql mock: %v", err)
|
||||
}
|
||||
@ -44,7 +45,7 @@ func expectExec(stmt string, err error, args ...driver.Value) expectation {
|
||||
|
||||
func expectQuery(stmt string, err error, columns []string, rows [][]driver.Value, args ...driver.Value) expectation {
|
||||
return func(m sqlmock.Sqlmock) {
|
||||
res := sqlmock.NewRows(columns)
|
||||
res := m.NewRows(columns)
|
||||
for _, row := range rows {
|
||||
res.AddRow(row...)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
|
12
go.mod
12
go.mod
@ -37,14 +37,11 @@ require (
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1
|
||||
github.com/h2non/gock v1.2.0
|
||||
github.com/improbable-eng/grpc-web v0.15.0
|
||||
github.com/jackc/pgconn v1.14.3
|
||||
github.com/jackc/pgtype v1.14.2
|
||||
github.com/jackc/pgx/v4 v4.18.2
|
||||
github.com/jackc/pgx/v5 v5.5.5
|
||||
github.com/jarcoal/jpath v0.0.0-20140328210829-f76b8b2dbf52
|
||||
github.com/jinzhu/gorm v1.9.16
|
||||
github.com/k3a/html2text v1.2.1
|
||||
github.com/kevinburke/twilio-go v0.0.0-20231009225535-38b36b35294d
|
||||
github.com/lib/pq v1.10.9
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0
|
||||
github.com/minio/minio-go/v7 v7.0.68
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
@ -105,7 +102,9 @@ require (
|
||||
github.com/google/go-tpm v0.9.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 // indirect
|
||||
github.com/google/s2a-go v0.1.7 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||
github.com/lib/pq v1.10.9 // indirect
|
||||
github.com/mattermost/xml-roundtrip-validator v0.1.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
@ -165,10 +164,7 @@ require (
|
||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgproto3/v2 v2.3.3 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jonboulle/clockwork v0.4.0
|
||||
@ -211,5 +207,3 @@ require (
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
nhooyr.io/websocket v1.8.10 // indirect
|
||||
)
|
||||
|
||||
replace github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.4
|
||||
|
98
go.sum
98
go.sum
@ -34,8 +34,6 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/cloudmock v0
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.45.0 h1:o/Nf55GfyLwGDaHkVAkRGgBXeExce73L6N9w2PZTB3k=
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.45.0/go.mod h1:qkFPtMouQjW5ugdHIOthiTbweVHUTqbS0Qsu55KqXks=
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
|
||||
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
|
||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
@ -100,8 +98,6 @@ github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMn
|
||||
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
|
||||
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
||||
github.com/cockroachdb/cockroach-go/v2 v2.3.6 h1:Wlv9TzkrG9V7i6u8dEtmXPrBzvfFp+CgJNs696rAajM=
|
||||
github.com/cockroachdb/cockroach-go/v2 v2.3.6/go.mod h1:1wNJ45eSXW9AnOc3skntW9ZUZz6gxrQK3cOj3rK+BC8=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||
@ -110,8 +106,6 @@ github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be h1:J5BL
|
||||
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
@ -209,7 +203,7 @@ github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uq
|
||||
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
|
||||
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD50WnA=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
|
||||
@ -239,7 +233,7 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
|
||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
|
||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
@ -260,7 +254,6 @@ github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6Wezm
|
||||
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
|
||||
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
|
||||
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
|
||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
|
||||
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
|
||||
@ -406,53 +399,14 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
||||
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
|
||||
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
|
||||
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
||||
github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
|
||||
github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE=
|
||||
github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s=
|
||||
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
|
||||
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
|
||||
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
|
||||
github.com/jackc/pgconn v1.14.3 h1:bVoTr12EGANZz66nZPkMInAV/KHD2TxH9npjXXgiB3w=
|
||||
github.com/jackc/pgconn v1.14.3/go.mod h1:RZbme4uasqzybK2RK5c65VsHxoyaml09lx3tXOcO/VM=
|
||||
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
|
||||
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
|
||||
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
|
||||
github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c=
|
||||
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc=
|
||||
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
||||
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag=
|
||||
github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
||||
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA=
|
||||
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
|
||||
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
|
||||
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
|
||||
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
|
||||
github.com/jackc/pgtype v1.14.2 h1:QBdZQTKpPdBlw2AdKwHEyqUcm/lrl2cwWAHjCMyln/o=
|
||||
github.com/jackc/pgtype v1.14.2/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
|
||||
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
|
||||
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
|
||||
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
|
||||
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
|
||||
github.com/jackc/pgx/v4 v4.18.2 h1:xVpYkNR5pk5bMCZGfClbO962UIqVABcAGt7ha1s/FeU=
|
||||
github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw=
|
||||
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw=
|
||||
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
|
||||
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
|
||||
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/jarcoal/jpath v0.0.0-20140328210829-f76b8b2dbf52 h1:jny9eqYPwkG8IVy7foUoRjQmFLcArCSz+uPsL6KS0HQ=
|
||||
github.com/jarcoal/jpath v0.0.0-20140328210829-f76b8b2dbf52/go.mod h1:RDZ+4PR3mDOtTpVbI0qBE+rdhmtIrtbssiNn38/1OWA=
|
||||
github.com/jeremija/gosubmit v0.2.7 h1:At0OhGCFGPXyjPYAsCchoBUhE099pcBXmsb4iZqROIc=
|
||||
@ -502,7 +456,6 @@ github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
@ -511,7 +464,6 @@ github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NB
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
@ -520,11 +472,7 @@ github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtB
|
||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
|
||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
||||
@ -537,14 +485,10 @@ github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3v
|
||||
github.com/mattermost/xml-roundtrip-validator v0.1.0 h1:RXbVD2UAl7A7nOTR4u7E3ILa4IbtvKBHw64LDsmu9hU=
|
||||
github.com/mattermost/xml-roundtrip-validator v0.1.0/go.mod h1:qccnGMcpgwcNaBnxqpJpWWUiPNr5H3O8eDgGV9gT5To=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
@ -681,11 +625,8 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj
|
||||
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo=
|
||||
github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
|
||||
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
|
||||
github.com/russellhaering/goxmldsig v1.4.0 h1:8UcDh/xGyQiyrW+Fq5t8f+l2DLB1+zlhYzkPUJ7Qhys=
|
||||
github.com/russellhaering/goxmldsig v1.4.0/go.mod h1:gM4MDENBQf7M+V824SGfyIUVFWydB7n0KkEubVJl+Tw=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
@ -698,14 +639,9 @@ github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWR
|
||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
||||
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4=
|
||||
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
|
||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
@ -738,13 +674,11 @@ github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3
|
||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
@ -776,7 +710,6 @@ github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e/go.mod h1:N3UwUGtsr
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
||||
github.com/zenazn/goji v1.0.1 h1:4lbD8Mx2h7IvloP7r2C0D6ltZP6Ufip8Hn0wmSK5LR8=
|
||||
github.com/zenazn/goji v1.0.1/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
||||
github.com/zitadel/logging v0.6.0 h1:t5Nnt//r+m2ZhhoTmoPX+c96pbMarqJvW1Vq6xFTank=
|
||||
@ -823,7 +756,6 @@ go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7e
|
||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
@ -832,12 +764,10 @@ go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
|
||||
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
|
||||
@ -845,16 +775,11 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
|
||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
@ -943,21 +868,17 @@ golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@ -983,7 +904,6 @@ golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
@ -994,7 +914,6 @@ golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||
@ -1015,10 +934,8 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
@ -1030,8 +947,6 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@ -1102,7 +1017,6 @@ gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qS
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
||||
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
|
@ -2,6 +2,7 @@ package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
@ -394,11 +395,11 @@ func (s *Server) getLoginPolicy(ctx context.Context, orgID string, orgIDPs []str
|
||||
return nil, err
|
||||
}
|
||||
if !queriedLogin.IsDefault {
|
||||
pwCheck := durationpb.New(queriedLogin.PasswordCheckLifetime)
|
||||
externalLogin := durationpb.New(queriedLogin.ExternalLoginCheckLifetime)
|
||||
mfaInitSkip := durationpb.New(queriedLogin.MFAInitSkipLifetime)
|
||||
secondFactor := durationpb.New(queriedLogin.SecondFactorCheckLifetime)
|
||||
multiFactor := durationpb.New(queriedLogin.MultiFactorCheckLifetime)
|
||||
pwCheck := durationpb.New(time.Duration(queriedLogin.PasswordCheckLifetime))
|
||||
externalLogin := durationpb.New(time.Duration(queriedLogin.ExternalLoginCheckLifetime))
|
||||
mfaInitSkip := durationpb.New(time.Duration(queriedLogin.MFAInitSkipLifetime))
|
||||
secondFactor := durationpb.New(time.Duration(queriedLogin.SecondFactorCheckLifetime))
|
||||
multiFactor := durationpb.New(time.Duration(queriedLogin.MultiFactorCheckLifetime))
|
||||
|
||||
secondFactors := []policy_pb.SecondFactorType{}
|
||||
for _, factor := range queriedLogin.SecondFactors {
|
||||
|
@ -1153,11 +1153,11 @@ func (s *Server) dataOrgsV1ToDataOrgs(ctx context.Context, dataOrgs *v1_pb.Impor
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
org.LoginPolicy.ExternalLoginCheckLifetime = durationpb.New(defaultLoginPolicy.ExternalLoginCheckLifetime)
|
||||
org.LoginPolicy.MultiFactorCheckLifetime = durationpb.New(defaultLoginPolicy.MultiFactorCheckLifetime)
|
||||
org.LoginPolicy.SecondFactorCheckLifetime = durationpb.New(defaultLoginPolicy.SecondFactorCheckLifetime)
|
||||
org.LoginPolicy.PasswordCheckLifetime = durationpb.New(defaultLoginPolicy.PasswordCheckLifetime)
|
||||
org.LoginPolicy.MfaInitSkipLifetime = durationpb.New(defaultLoginPolicy.MFAInitSkipLifetime)
|
||||
org.LoginPolicy.ExternalLoginCheckLifetime = durationpb.New(time.Duration(defaultLoginPolicy.ExternalLoginCheckLifetime))
|
||||
org.LoginPolicy.MultiFactorCheckLifetime = durationpb.New(time.Duration(defaultLoginPolicy.MultiFactorCheckLifetime))
|
||||
org.LoginPolicy.SecondFactorCheckLifetime = durationpb.New(time.Duration(defaultLoginPolicy.SecondFactorCheckLifetime))
|
||||
org.LoginPolicy.PasswordCheckLifetime = durationpb.New(time.Duration(defaultLoginPolicy.PasswordCheckLifetime))
|
||||
org.LoginPolicy.MfaInitSkipLifetime = durationpb.New(time.Duration(defaultLoginPolicy.MFAInitSkipLifetime))
|
||||
|
||||
if orgV1.SecondFactors != nil {
|
||||
org.LoginPolicy.SecondFactors = make([]policy.SecondFactorType, len(orgV1.SecondFactors))
|
||||
|
@ -1,6 +1,8 @@
|
||||
package policy
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
@ -26,11 +28,11 @@ func ModelLoginPolicyToPb(policy *query.LoginPolicy) *policy_pb.LoginPolicy {
|
||||
DisableLoginWithEmail: policy.DisableLoginWithEmail,
|
||||
DisableLoginWithPhone: policy.DisableLoginWithPhone,
|
||||
DefaultRedirectUri: policy.DefaultRedirectURI,
|
||||
PasswordCheckLifetime: durationpb.New(policy.PasswordCheckLifetime),
|
||||
ExternalLoginCheckLifetime: durationpb.New(policy.ExternalLoginCheckLifetime),
|
||||
MfaInitSkipLifetime: durationpb.New(policy.MFAInitSkipLifetime),
|
||||
SecondFactorCheckLifetime: durationpb.New(policy.SecondFactorCheckLifetime),
|
||||
MultiFactorCheckLifetime: durationpb.New(policy.MultiFactorCheckLifetime),
|
||||
PasswordCheckLifetime: durationpb.New(time.Duration(policy.PasswordCheckLifetime)),
|
||||
ExternalLoginCheckLifetime: durationpb.New(time.Duration(policy.ExternalLoginCheckLifetime)),
|
||||
MfaInitSkipLifetime: durationpb.New(time.Duration(policy.MFAInitSkipLifetime)),
|
||||
SecondFactorCheckLifetime: durationpb.New(time.Duration(policy.SecondFactorCheckLifetime)),
|
||||
MultiFactorCheckLifetime: durationpb.New(time.Duration(policy.MultiFactorCheckLifetime)),
|
||||
SecondFactors: ModelSecondFactorTypesToPb(policy.SecondFactors),
|
||||
MultiFactors: ModelMultiFactorTypesToPb(policy.MultiFactors),
|
||||
Idps: idp_grpc.IDPLoginPolicyLinksToPb(policy.IDPLinks),
|
||||
|
@ -1,6 +1,8 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"google.golang.org/protobuf/types/known/durationpb"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/command"
|
||||
@ -32,11 +34,11 @@ func loginSettingsToPb(current *query.LoginPolicy) *settings.LoginSettings {
|
||||
DisableLoginWithEmail: current.DisableLoginWithEmail,
|
||||
DisableLoginWithPhone: current.DisableLoginWithPhone,
|
||||
DefaultRedirectUri: current.DefaultRedirectURI,
|
||||
PasswordCheckLifetime: durationpb.New(current.PasswordCheckLifetime),
|
||||
ExternalLoginCheckLifetime: durationpb.New(current.ExternalLoginCheckLifetime),
|
||||
MfaInitSkipLifetime: durationpb.New(current.MFAInitSkipLifetime),
|
||||
SecondFactorCheckLifetime: durationpb.New(current.SecondFactorCheckLifetime),
|
||||
MultiFactorCheckLifetime: durationpb.New(current.MultiFactorCheckLifetime),
|
||||
PasswordCheckLifetime: durationpb.New(time.Duration(current.PasswordCheckLifetime)),
|
||||
ExternalLoginCheckLifetime: durationpb.New(time.Duration(current.ExternalLoginCheckLifetime)),
|
||||
MfaInitSkipLifetime: durationpb.New(time.Duration(current.MFAInitSkipLifetime)),
|
||||
SecondFactorCheckLifetime: durationpb.New(time.Duration(current.SecondFactorCheckLifetime)),
|
||||
MultiFactorCheckLifetime: durationpb.New(time.Duration(current.MultiFactorCheckLifetime)),
|
||||
SecondFactors: second,
|
||||
MultiFactors: multi,
|
||||
ResourceOwnerType: isDefaultToResourceOwnerTypePb(current.IsDefault),
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/grpc"
|
||||
"github.com/zitadel/zitadel/internal/command"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
settings "github.com/zitadel/zitadel/pkg/grpc/settings/v2beta"
|
||||
@ -34,11 +35,11 @@ func Test_loginSettingsToPb(t *testing.T) {
|
||||
DisableLoginWithEmail: true,
|
||||
DisableLoginWithPhone: true,
|
||||
DefaultRedirectURI: "example.com",
|
||||
PasswordCheckLifetime: time.Hour,
|
||||
ExternalLoginCheckLifetime: time.Minute,
|
||||
MFAInitSkipLifetime: time.Millisecond,
|
||||
SecondFactorCheckLifetime: time.Microsecond,
|
||||
MultiFactorCheckLifetime: time.Nanosecond,
|
||||
PasswordCheckLifetime: database.Duration(time.Hour),
|
||||
ExternalLoginCheckLifetime: database.Duration(time.Minute),
|
||||
MFAInitSkipLifetime: database.Duration(time.Millisecond),
|
||||
SecondFactorCheckLifetime: database.Duration(time.Microsecond),
|
||||
MultiFactorCheckLifetime: database.Duration(time.Nanosecond),
|
||||
SecondFactors: []domain.SecondFactorType{
|
||||
domain.SecondFactorTypeTOTP,
|
||||
domain.SecondFactorTypeU2F,
|
||||
|
@ -912,11 +912,11 @@ func queryLoginPolicyToDomain(policy *query.LoginPolicy) *domain.LoginPolicy {
|
||||
IgnoreUnknownUsernames: policy.IgnoreUnknownUsernames,
|
||||
AllowDomainDiscovery: policy.AllowDomainDiscovery,
|
||||
DefaultRedirectURI: policy.DefaultRedirectURI,
|
||||
PasswordCheckLifetime: policy.PasswordCheckLifetime,
|
||||
ExternalLoginCheckLifetime: policy.ExternalLoginCheckLifetime,
|
||||
MFAInitSkipLifetime: policy.MFAInitSkipLifetime,
|
||||
SecondFactorCheckLifetime: policy.SecondFactorCheckLifetime,
|
||||
MultiFactorCheckLifetime: policy.MultiFactorCheckLifetime,
|
||||
PasswordCheckLifetime: time.Duration(policy.PasswordCheckLifetime),
|
||||
ExternalLoginCheckLifetime: time.Duration(policy.ExternalLoginCheckLifetime),
|
||||
MFAInitSkipLifetime: time.Duration(policy.MFAInitSkipLifetime),
|
||||
SecondFactorCheckLifetime: time.Duration(policy.SecondFactorCheckLifetime),
|
||||
MultiFactorCheckLifetime: time.Duration(policy.MultiFactorCheckLifetime),
|
||||
DisableLoginWithEmail: policy.DisableLoginWithEmail,
|
||||
DisableLoginWithPhone: policy.DisableLoginWithPhone,
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
cache "github.com/zitadel/zitadel/internal/auth_request/repository"
|
||||
"github.com/zitadel/zitadel/internal/auth_request/repository/mock"
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
@ -518,8 +519,8 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
loginPolicyProvider: &mockLoginPolicy{
|
||||
policy: &query.LoginPolicy{
|
||||
SecondFactors: []domain.SecondFactorType{domain.SecondFactorTypeTOTP},
|
||||
PasswordCheckLifetime: 10 * 24 * time.Hour,
|
||||
SecondFactorCheckLifetime: 18 * time.Hour,
|
||||
PasswordCheckLifetime: database.Duration(10 * 24 * time.Hour),
|
||||
SecondFactorCheckLifetime: database.Duration(18 * time.Hour),
|
||||
},
|
||||
},
|
||||
privacyPolicyProvider: &mockPrivacyPolicy{
|
||||
@ -820,7 +821,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
},
|
||||
loginPolicyProvider: &mockLoginPolicy{
|
||||
policy: &query.LoginPolicy{
|
||||
MultiFactorCheckLifetime: 10 * time.Hour,
|
||||
MultiFactorCheckLifetime: database.Duration(10 * time.Hour),
|
||||
},
|
||||
},
|
||||
idpUserLinksProvider: &mockIDPUserLinks{},
|
||||
@ -845,7 +846,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
},
|
||||
loginPolicyProvider: &mockLoginPolicy{
|
||||
policy: &query.LoginPolicy{
|
||||
MultiFactorCheckLifetime: 10 * time.Hour,
|
||||
MultiFactorCheckLifetime: database.Duration(10 * time.Hour),
|
||||
},
|
||||
},
|
||||
idpUserLinksProvider: &mockIDPUserLinks{},
|
||||
@ -871,7 +872,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
},
|
||||
loginPolicyProvider: &mockLoginPolicy{
|
||||
policy: &query.LoginPolicy{
|
||||
MultiFactorCheckLifetime: 10 * time.Hour,
|
||||
MultiFactorCheckLifetime: database.Duration(10 * time.Hour),
|
||||
},
|
||||
},
|
||||
idpUserLinksProvider: &mockIDPUserLinks{},
|
||||
@ -953,7 +954,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
orgViewProvider: &mockViewOrg{State: domain.OrgStateActive},
|
||||
loginPolicyProvider: &mockLoginPolicy{
|
||||
policy: &query.LoginPolicy{
|
||||
SecondFactorCheckLifetime: 18 * time.Hour,
|
||||
SecondFactorCheckLifetime: database.Duration(18 * time.Hour),
|
||||
},
|
||||
},
|
||||
idpUserLinksProvider: &mockIDPUserLinks{},
|
||||
@ -986,7 +987,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
orgViewProvider: &mockViewOrg{State: domain.OrgStateActive},
|
||||
loginPolicyProvider: &mockLoginPolicy{
|
||||
policy: &query.LoginPolicy{
|
||||
SecondFactorCheckLifetime: 18 * time.Hour,
|
||||
SecondFactorCheckLifetime: database.Duration(18 * time.Hour),
|
||||
},
|
||||
},
|
||||
idpUserLinksProvider: &mockIDPUserLinks{
|
||||
@ -1054,7 +1055,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
},
|
||||
loginPolicyProvider: &mockLoginPolicy{
|
||||
policy: &query.LoginPolicy{
|
||||
PasswordCheckLifetime: 10 * 24 * time.Hour,
|
||||
PasswordCheckLifetime: database.Duration(10 * 24 * time.Hour),
|
||||
},
|
||||
},
|
||||
idpUserLinksProvider: &mockIDPUserLinks{},
|
||||
@ -1591,7 +1592,7 @@ func TestAuthRequestRepo_nextSteps(t *testing.T) {
|
||||
},
|
||||
loginPolicyProvider: &mockLoginPolicy{
|
||||
policy: &query.LoginPolicy{
|
||||
SecondFactorCheckLifetime: 18 * time.Hour,
|
||||
SecondFactorCheckLifetime: database.Duration(18 * time.Hour),
|
||||
},
|
||||
},
|
||||
userEventProvider: &mockEventUser{},
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
z_db "github.com/zitadel/zitadel/internal/database"
|
||||
db_mock "github.com/zitadel/zitadel/internal/database/mock"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
@ -452,7 +453,7 @@ type db struct {
|
||||
|
||||
func dbMock(t *testing.T, expectations ...func(m sqlmock.Sqlmock)) db {
|
||||
t.Helper()
|
||||
client, mock, err := sqlmock.New()
|
||||
client, mock, err := sqlmock.New(sqlmock.ValueConverterOption(new(db_mock.TypeConverter)))
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create sql mock: %v", err)
|
||||
}
|
||||
@ -478,7 +479,7 @@ func expectQueryScanErr(stmt string, cols []string, rows [][]driver.Value, args
|
||||
m.ExpectBegin()
|
||||
q := m.ExpectQuery(regexp.QuoteMeta(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" {
|
||||
@ -496,7 +497,7 @@ func expectQuery(stmt string, cols []string, rows [][]driver.Value, args ...driv
|
||||
m.ExpectBegin()
|
||||
q := m.ExpectQuery(regexp.QuoteMeta(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" {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
_ "github.com/jackc/pgx/v4/stdlib"
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
|
@ -19,6 +19,7 @@ type expectation func(m sqlmock.Sqlmock)
|
||||
func NewSQLMock(t *testing.T, expectations ...expectation) *SQLMock {
|
||||
db, mock, err := sqlmock.New(
|
||||
sqlmock.QueryMatcherOption(sqlmock.QueryMatcherEqual),
|
||||
sqlmock.ValueConverterOption(new(TypeConverter)),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal("create mock failed", err)
|
||||
@ -97,23 +98,23 @@ func ExcpectExec(stmt string, opts ...ExecOpt) expectation {
|
||||
}
|
||||
}
|
||||
|
||||
type QueryOpt func(e *sqlmock.ExpectedQuery) *sqlmock.ExpectedQuery
|
||||
type QueryOpt func(m sqlmock.Sqlmock, e *sqlmock.ExpectedQuery) *sqlmock.ExpectedQuery
|
||||
|
||||
func WithQueryArgs(args ...driver.Value) QueryOpt {
|
||||
return func(e *sqlmock.ExpectedQuery) *sqlmock.ExpectedQuery {
|
||||
return func(_ sqlmock.Sqlmock, e *sqlmock.ExpectedQuery) *sqlmock.ExpectedQuery {
|
||||
return e.WithArgs(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func WithQueryErr(err error) QueryOpt {
|
||||
return func(e *sqlmock.ExpectedQuery) *sqlmock.ExpectedQuery {
|
||||
return func(_ sqlmock.Sqlmock, e *sqlmock.ExpectedQuery) *sqlmock.ExpectedQuery {
|
||||
return e.WillReturnError(err)
|
||||
}
|
||||
}
|
||||
|
||||
func WithQueryResult(columns []string, rows [][]driver.Value) QueryOpt {
|
||||
return func(e *sqlmock.ExpectedQuery) *sqlmock.ExpectedQuery {
|
||||
mockedRows := sqlmock.NewRows(columns)
|
||||
return func(m sqlmock.Sqlmock, e *sqlmock.ExpectedQuery) *sqlmock.ExpectedQuery {
|
||||
mockedRows := m.NewRows(columns)
|
||||
for _, row := range rows {
|
||||
mockedRows = mockedRows.AddRow(row...)
|
||||
}
|
||||
@ -125,7 +126,7 @@ func ExpectQuery(stmt string, opts ...QueryOpt) expectation {
|
||||
return func(m sqlmock.Sqlmock) {
|
||||
e := m.ExpectQuery(stmt)
|
||||
for _, opt := range opts {
|
||||
e = opt(e)
|
||||
e = opt(m, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
87
internal/database/mock/type_converter.go
Normal file
87
internal/database/mock/type_converter.go
Normal file
@ -0,0 +1,87 @@
|
||||
package mock
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var _ driver.ValueConverter = (*TypeConverter)(nil)
|
||||
|
||||
type TypeConverter struct{}
|
||||
|
||||
// ConvertValue converts a value to a driver Value.
|
||||
func (s TypeConverter) ConvertValue(v any) (driver.Value, error) {
|
||||
if driver.IsValue(v) {
|
||||
return v, nil
|
||||
}
|
||||
value := reflect.ValueOf(v)
|
||||
|
||||
if rawMessage, ok := v.(json.RawMessage); ok {
|
||||
return convertBytes(rawMessage), nil
|
||||
}
|
||||
|
||||
if value.Kind() == reflect.Slice {
|
||||
//nolint: exhaustive
|
||||
// only defined types
|
||||
switch value.Type().Elem().Kind() {
|
||||
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
|
||||
return convertSigned(value), nil
|
||||
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
|
||||
return convertUnsigned(value), nil
|
||||
case reflect.String:
|
||||
return convertText(value), nil
|
||||
}
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// converts a text array to valid pgx v5 representation
|
||||
func convertSigned(array reflect.Value) string {
|
||||
slice := make([]string, array.Len())
|
||||
for i := 0; i < array.Len(); i++ {
|
||||
slice[i] = strconv.FormatInt(array.Index(i).Int(), 10)
|
||||
}
|
||||
|
||||
return "{" + strings.Join(slice, ",") + "}"
|
||||
}
|
||||
|
||||
// converts a text array to valid pgx v5 representation
|
||||
func convertUnsigned(array reflect.Value) string {
|
||||
slice := make([]string, array.Len())
|
||||
for i := 0; i < array.Len(); i++ {
|
||||
slice[i] = strconv.FormatUint(array.Index(i).Uint(), 10)
|
||||
}
|
||||
|
||||
return "{" + strings.Join(slice, ",") + "}"
|
||||
}
|
||||
|
||||
// converts a text array to valid pgx v5 representation
|
||||
func convertText(array reflect.Value) string {
|
||||
slice := make([]string, array.Len())
|
||||
for i := 0; i < array.Len(); i++ {
|
||||
slice[i] = array.Index(i).String()
|
||||
}
|
||||
|
||||
return "{" + strings.Join(slice, ",") + "}"
|
||||
}
|
||||
|
||||
func convertBytes(array []byte) string {
|
||||
var builder strings.Builder
|
||||
builder.Grow(hex.EncodedLen(len(array)) + 4)
|
||||
builder.WriteString(`\x`)
|
||||
builder.Write(AppendEncode(nil, array))
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// TODO: remove function after we compile using go 1.22 and use function of hex package `hex.AppendEncode`
|
||||
func AppendEncode(dst, src []byte) []byte {
|
||||
n := hex.EncodedLen(len(src))
|
||||
dst = slices.Grow(dst, n)
|
||||
hex.Encode(dst[len(dst):][:n], src)
|
||||
return dst[:len(dst)+n]
|
||||
}
|
@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
_ "github.com/jackc/pgx/v4/stdlib"
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
|
@ -1,87 +1,166 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgtype"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
type TextArray[t ~string] []t
|
||||
type TextArray[T ~string] pgtype.FlatArray[T]
|
||||
|
||||
// Scan implements the [database/sql.Scanner] interface.
|
||||
func (s *TextArray[t]) Scan(src any) error {
|
||||
array := new(pgtype.TextArray)
|
||||
if err := array.Scan(src); err != nil {
|
||||
func (s *TextArray[T]) Scan(src any) error {
|
||||
var typedArray []string
|
||||
err := pgtype.NewMap().SQLScanner(&typedArray).Scan(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return array.AssignTo(s)
|
||||
}
|
||||
|
||||
// Value implements the [database/sql/driver.Valuer] interface.
|
||||
func (s TextArray[t]) Value() (driver.Value, error) {
|
||||
if len(s) == 0 {
|
||||
return nil, nil
|
||||
(*s) = make(TextArray[T], len(typedArray))
|
||||
for i, value := range typedArray {
|
||||
(*s)[i] = T(value)
|
||||
}
|
||||
|
||||
array := pgtype.TextArray{}
|
||||
if err := array.Set(s); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return array.Value()
|
||||
}
|
||||
|
||||
type arrayField interface {
|
||||
~int8 | ~uint8 | ~int16 | ~uint16 | ~int32 | ~uint32
|
||||
}
|
||||
|
||||
type Array[F arrayField] []F
|
||||
|
||||
// Scan implements the [database/sql.Scanner] interface.
|
||||
func (a *Array[F]) Scan(src any) error {
|
||||
array := new(pgtype.Int8Array)
|
||||
if err := array.Scan(src); err != nil {
|
||||
return err
|
||||
}
|
||||
elements := make([]int64, len(array.Elements))
|
||||
if err := array.AssignTo(&elements); err != nil {
|
||||
return err
|
||||
}
|
||||
*a = make([]F, len(elements))
|
||||
for i, element := range elements {
|
||||
(*a)[i] = F(element)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value implements the [database/sql/driver.Valuer] interface.
|
||||
func (a Array[F]) Value() (driver.Value, error) {
|
||||
if len(a) == 0 {
|
||||
func (s TextArray[T]) Value() (driver.Value, error) {
|
||||
if len(s) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
array := pgtype.Int8Array{}
|
||||
if err := array.Set(a); err != nil {
|
||||
return nil, err
|
||||
typed := make([]string, len(s))
|
||||
|
||||
for i, value := range s {
|
||||
typed[i] = string(value)
|
||||
}
|
||||
|
||||
return array.Value()
|
||||
return []byte("{" + strings.Join(typed, ",") + "}"), nil
|
||||
}
|
||||
|
||||
type ByteArray[T ~byte] pgtype.FlatArray[T]
|
||||
|
||||
// Scan implements the [database/sql.Scanner] interface.
|
||||
func (s *ByteArray[T]) Scan(src any) error {
|
||||
var typedArray []byte
|
||||
typedArray, ok := src.([]byte)
|
||||
if !ok {
|
||||
// tests use a different src type
|
||||
err := pgtype.NewMap().SQLScanner(&typedArray).Scan(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
(*s) = make(ByteArray[T], len(typedArray))
|
||||
for i, value := range typedArray {
|
||||
(*s)[i] = T(value)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value implements the [database/sql/driver.Valuer] interface.
|
||||
func (s ByteArray[T]) Value() (driver.Value, error) {
|
||||
if len(s) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
typed := make([]byte, len(s))
|
||||
|
||||
for i, value := range s {
|
||||
typed[i] = byte(value)
|
||||
}
|
||||
|
||||
return typed, nil
|
||||
}
|
||||
|
||||
type numberField interface {
|
||||
~int8 | ~uint8 | ~int16 | ~uint16 | ~int32 | ~uint32 | ~int64 | ~uint64 | ~int | ~uint
|
||||
}
|
||||
|
||||
type numberTypeField interface {
|
||||
int8 | uint8 | int16 | uint16 | int32 | uint32 | int64 | uint64 | int | uint
|
||||
}
|
||||
|
||||
var _ sql.Scanner = (*NumberArray[int8])(nil)
|
||||
|
||||
type NumberArray[F numberField] pgtype.FlatArray[F]
|
||||
|
||||
// Scan implements the [database/sql.Scanner] interface.
|
||||
func (a *NumberArray[F]) Scan(src any) (err error) {
|
||||
var (
|
||||
mapper func()
|
||||
scanner sql.Scanner
|
||||
)
|
||||
|
||||
//nolint: exhaustive
|
||||
// only defined types
|
||||
switch reflect.TypeOf(*a).Elem().Kind() {
|
||||
case reflect.Int8:
|
||||
mapper, scanner = castedScan[int8](a)
|
||||
case reflect.Uint8:
|
||||
// we provide int16 is a workaround because pgx thinks we want to scan a byte array if we provide uint8
|
||||
mapper, scanner = castedScan[int16](a)
|
||||
case reflect.Int16:
|
||||
mapper, scanner = castedScan[int16](a)
|
||||
case reflect.Uint16:
|
||||
mapper, scanner = castedScan[uint16](a)
|
||||
case reflect.Int32:
|
||||
mapper, scanner = castedScan[int32](a)
|
||||
case reflect.Uint32:
|
||||
mapper, scanner = castedScan[uint32](a)
|
||||
case reflect.Int64:
|
||||
mapper, scanner = castedScan[int64](a)
|
||||
case reflect.Uint64:
|
||||
mapper, scanner = castedScan[uint64](a)
|
||||
case reflect.Int:
|
||||
mapper, scanner = castedScan[int](a)
|
||||
case reflect.Uint:
|
||||
mapper, scanner = castedScan[uint](a)
|
||||
}
|
||||
|
||||
if err = scanner.Scan(src); err != nil {
|
||||
return err
|
||||
}
|
||||
mapper()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func castedScan[T numberTypeField, F numberField](a *NumberArray[F]) (mapper func(), scanner sql.Scanner) {
|
||||
var typedArray []T
|
||||
|
||||
mapper = func() {
|
||||
(*a) = make(NumberArray[F], len(typedArray))
|
||||
for i, value := range typedArray {
|
||||
(*a)[i] = F(value)
|
||||
}
|
||||
}
|
||||
scanner = pgtype.NewMap().SQLScanner(&typedArray)
|
||||
|
||||
return mapper, scanner
|
||||
}
|
||||
|
||||
type Map[V any] map[string]V
|
||||
|
||||
// Scan implements the [database/sql.Scanner] interface.
|
||||
func (m *Map[V]) Scan(src any) error {
|
||||
bytea := new(pgtype.Bytea)
|
||||
if err := bytea.Scan(src); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(bytea.Bytes) == 0 {
|
||||
if src == nil {
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(bytea.Bytes, &m)
|
||||
|
||||
bytes := src.([]byte)
|
||||
if len(bytes) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return json.Unmarshal(bytes, &m)
|
||||
}
|
||||
|
||||
// Value implements the [database/sql/driver.Valuer] interface.
|
||||
@ -96,14 +175,35 @@ type Duration time.Duration
|
||||
|
||||
// Scan implements the [database/sql.Scanner] interface.
|
||||
func (d *Duration) Scan(src any) error {
|
||||
switch duration := src.(type) {
|
||||
case *time.Duration:
|
||||
*d = Duration(*duration)
|
||||
return nil
|
||||
case time.Duration:
|
||||
*d = Duration(duration)
|
||||
return nil
|
||||
case *pgtype.Interval:
|
||||
*d = intervalToDuration(duration)
|
||||
return nil
|
||||
case pgtype.Interval:
|
||||
*d = intervalToDuration(&duration)
|
||||
return nil
|
||||
case int64:
|
||||
*d = Duration(duration)
|
||||
return nil
|
||||
}
|
||||
interval := new(pgtype.Interval)
|
||||
if err := interval.Scan(src); err != nil {
|
||||
return err
|
||||
}
|
||||
*d = Duration(time.Duration(interval.Microseconds*1000) + time.Duration(interval.Days)*24*time.Hour + time.Duration(interval.Months)*30*24*time.Hour)
|
||||
*d = intervalToDuration(interval)
|
||||
return nil
|
||||
}
|
||||
|
||||
func intervalToDuration(interval *pgtype.Interval) Duration {
|
||||
return Duration(time.Duration(interval.Microseconds*1000) + time.Duration(interval.Days)*24*time.Hour + time.Duration(interval.Months)*30*24*time.Hour)
|
||||
}
|
||||
|
||||
// NullDuration can be used for NULL intervals.
|
||||
// If Valid is false, the scanned value was NULL
|
||||
// This behavior is similar to [database/sql.NullString]
|
||||
|
@ -1,9 +1,9 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -11,7 +11,7 @@ import (
|
||||
|
||||
func TestMap_Scan(t *testing.T) {
|
||||
type args struct {
|
||||
src any
|
||||
src []byte
|
||||
}
|
||||
type res[V any] struct {
|
||||
want Map[V]
|
||||
@ -24,10 +24,19 @@ func TestMap_Scan(t *testing.T) {
|
||||
res[V]
|
||||
}
|
||||
tests := []testCase[string]{
|
||||
{
|
||||
"nil",
|
||||
Map[string]{},
|
||||
args{src: nil},
|
||||
res[string]{
|
||||
want: Map[string]{},
|
||||
err: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
"null",
|
||||
Map[string]{},
|
||||
args{src: "invalid"},
|
||||
args{src: []byte("invalid")},
|
||||
res[string]{
|
||||
want: Map[string]{},
|
||||
err: true,
|
||||
@ -119,83 +128,109 @@ func TestMap_Value(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNullDuration_Scan(t *testing.T) {
|
||||
type typedInt int
|
||||
|
||||
func TestNumberArray_Scan(t *testing.T) {
|
||||
type args struct {
|
||||
src any
|
||||
}
|
||||
type res struct {
|
||||
want NullDuration
|
||||
want any
|
||||
err bool
|
||||
}
|
||||
type testCase struct {
|
||||
name string
|
||||
m sql.Scanner
|
||||
args args
|
||||
res res
|
||||
}
|
||||
tests := []testCase{
|
||||
{
|
||||
"invalid",
|
||||
args{src: "invalid"},
|
||||
res{
|
||||
want: NullDuration{
|
||||
Valid: false,
|
||||
},
|
||||
err: true,
|
||||
name: "typedInt",
|
||||
m: new(NumberArray[typedInt]),
|
||||
args: args{src: "{1,2}"},
|
||||
res: res{
|
||||
want: &NumberArray[typedInt]{1, 2},
|
||||
},
|
||||
},
|
||||
{
|
||||
"null",
|
||||
args{src: nil},
|
||||
res{
|
||||
want: NullDuration{
|
||||
Valid: false,
|
||||
},
|
||||
err: false,
|
||||
name: "int8",
|
||||
m: new(NumberArray[int8]),
|
||||
args: args{src: "{1,2}"},
|
||||
res: res{
|
||||
want: &NumberArray[int8]{1, 2},
|
||||
},
|
||||
},
|
||||
{
|
||||
"valid",
|
||||
args{src: "1:0:0"},
|
||||
res{
|
||||
want: NullDuration{
|
||||
Valid: true,
|
||||
Duration: time.Hour,
|
||||
},
|
||||
name: "uint8",
|
||||
m: new(NumberArray[uint8]),
|
||||
args: args{src: "{1,2}"},
|
||||
res: res{
|
||||
want: &NumberArray[uint8]{1, 2},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
d := new(NullDuration)
|
||||
if err := d.Scan(tt.args.src); (err != nil) != tt.res.err {
|
||||
t.Errorf("Scan() error = %v, wantErr %v", err, tt.res.err)
|
||||
}
|
||||
assert.Equal(t, tt.res.want, *d)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestArray_ScanInt32(t *testing.T) {
|
||||
type args struct {
|
||||
src any
|
||||
}
|
||||
type res[V arrayField] struct {
|
||||
want Array[V]
|
||||
err bool
|
||||
}
|
||||
type testCase[V arrayField] struct {
|
||||
name string
|
||||
m Array[V]
|
||||
args args
|
||||
res[V]
|
||||
}
|
||||
tests := []testCase[int32]{
|
||||
{
|
||||
"number",
|
||||
Array[int32]{},
|
||||
args{src: "{1,2}"},
|
||||
res[int32]{
|
||||
want: []int32{1, 2},
|
||||
name: "int16",
|
||||
m: new(NumberArray[int16]),
|
||||
args: args{src: "{1,2}"},
|
||||
res: res{
|
||||
want: &NumberArray[int16]{1, 2},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "uint16",
|
||||
m: new(NumberArray[uint16]),
|
||||
args: args{src: "{1,2}"},
|
||||
res: res{
|
||||
want: &NumberArray[uint16]{1, 2},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "int32",
|
||||
m: new(NumberArray[int32]),
|
||||
args: args{src: "{1,2}"},
|
||||
res: res{
|
||||
want: &NumberArray[int32]{1, 2},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "uint32",
|
||||
m: new(NumberArray[uint32]),
|
||||
args: args{src: "{1,2}"},
|
||||
res: res{
|
||||
want: &NumberArray[uint32]{1, 2},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "int64",
|
||||
m: new(NumberArray[int64]),
|
||||
args: args{src: "{1,2}"},
|
||||
res: res{
|
||||
want: &NumberArray[int64]{1, 2},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "uint64",
|
||||
m: new(NumberArray[uint64]),
|
||||
args: args{src: "{1,2}"},
|
||||
res: res{
|
||||
want: &NumberArray[uint64]{1, 2},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "int",
|
||||
m: new(NumberArray[int]),
|
||||
args: args{src: "{1,2}"},
|
||||
res: res{
|
||||
want: &NumberArray[int]{1, 2},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "uint",
|
||||
m: new(NumberArray[uint]),
|
||||
args: args{src: "{1,2}"},
|
||||
res: res{
|
||||
want: &NumberArray[uint]{1, 2},
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -210,42 +245,80 @@ func TestArray_ScanInt32(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestArray_Value(t *testing.T) {
|
||||
type typedText string
|
||||
|
||||
func TestTextArray_Scan(t *testing.T) {
|
||||
type args struct {
|
||||
src any
|
||||
}
|
||||
type res struct {
|
||||
want sql.Scanner
|
||||
err bool
|
||||
}
|
||||
type testCase struct {
|
||||
name string
|
||||
m sql.Scanner
|
||||
args args
|
||||
res
|
||||
}
|
||||
tests := []testCase{
|
||||
{
|
||||
"string",
|
||||
new(TextArray[string]),
|
||||
args{src: "{asdf,fdas}"},
|
||||
res{
|
||||
want: &TextArray[string]{"asdf", "fdas"},
|
||||
},
|
||||
},
|
||||
{
|
||||
"typedText",
|
||||
new(TextArray[typedText]),
|
||||
args{src: "{asdf,fdas}"},
|
||||
res{
|
||||
want: &TextArray[typedText]{"asdf", "fdas"},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := tt.m.Scan(tt.args.src); (err != nil) != tt.res.err {
|
||||
t.Errorf("Scan() error = %v, wantErr %v", err, tt.res.err)
|
||||
}
|
||||
|
||||
assert.Equal(t, tt.res.want, tt.m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTextArray_Value(t *testing.T) {
|
||||
type res struct {
|
||||
want driver.Value
|
||||
err bool
|
||||
}
|
||||
type testCase[V arrayField] struct {
|
||||
type testCase struct {
|
||||
name string
|
||||
a Array[V]
|
||||
m driver.Valuer
|
||||
res res
|
||||
}
|
||||
tests := []testCase[int32]{
|
||||
{
|
||||
"nil",
|
||||
nil,
|
||||
res{
|
||||
want: nil,
|
||||
},
|
||||
},
|
||||
tests := []testCase{
|
||||
{
|
||||
"empty",
|
||||
Array[int32]{},
|
||||
TextArray[string]{},
|
||||
res{
|
||||
want: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
"set",
|
||||
Array[int32]([]int32{1, 2}),
|
||||
TextArray[string]{"a", "s", "d", "f"},
|
||||
res{
|
||||
want: driver.Value(string([]byte(`{1,2}`))),
|
||||
want: driver.Value([]byte("{a,s,d,f}")),
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := tt.a.Value()
|
||||
got, err := tt.m.Value()
|
||||
if tt.res.err {
|
||||
assert.Error(t, err)
|
||||
}
|
||||
@ -256,3 +329,126 @@ func TestArray_Value(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type typedByte byte
|
||||
|
||||
func TestByteArray_Scan(t *testing.T) {
|
||||
wantedBytes := []byte("asdf")
|
||||
wantedTypedBytes := []typedByte("asdf")
|
||||
type args struct {
|
||||
src any
|
||||
}
|
||||
type res struct {
|
||||
want sql.Scanner
|
||||
err bool
|
||||
}
|
||||
type testCase struct {
|
||||
name string
|
||||
m sql.Scanner
|
||||
args args
|
||||
res
|
||||
}
|
||||
tests := []testCase{
|
||||
{
|
||||
"bytes",
|
||||
new(ByteArray[byte]),
|
||||
args{src: []byte("asdf")},
|
||||
res{
|
||||
want: (*ByteArray[byte])(&wantedBytes),
|
||||
},
|
||||
},
|
||||
{
|
||||
"typed",
|
||||
new(ByteArray[typedByte]),
|
||||
args{src: []byte("asdf")},
|
||||
res{
|
||||
want: (*ByteArray[typedByte])(&wantedTypedBytes),
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := tt.m.Scan(tt.args.src); (err != nil) != tt.res.err {
|
||||
t.Errorf("Scan() error = %v, wantErr %v", err, tt.res.err)
|
||||
}
|
||||
|
||||
assert.Equal(t, tt.res.want, tt.m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestByteArray_Value(t *testing.T) {
|
||||
type res struct {
|
||||
want driver.Value
|
||||
err bool
|
||||
}
|
||||
type testCase struct {
|
||||
name string
|
||||
m driver.Valuer
|
||||
res res
|
||||
}
|
||||
tests := []testCase{
|
||||
{
|
||||
"empty",
|
||||
ByteArray[byte]{},
|
||||
res{
|
||||
want: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
"set",
|
||||
ByteArray[byte]([]byte("{\"type\": \"object\", \"$schema\": \"urn:zitadel:schema:v1\"}")),
|
||||
res{
|
||||
want: driver.Value([]byte("{\"type\": \"object\", \"$schema\": \"urn:zitadel:schema:v1\"}")),
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := tt.m.Value()
|
||||
if tt.res.err {
|
||||
assert.Error(t, err)
|
||||
}
|
||||
if !tt.res.err {
|
||||
require.NoError(t, err)
|
||||
assert.Equalf(t, tt.res.want, got, "Value()")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDuration_Scan(t *testing.T) {
|
||||
duration := Duration(10)
|
||||
type args struct {
|
||||
src any
|
||||
}
|
||||
type res struct {
|
||||
want sql.Scanner
|
||||
err bool
|
||||
}
|
||||
type testCase[V ~string] struct {
|
||||
name string
|
||||
m sql.Scanner
|
||||
args args
|
||||
res
|
||||
}
|
||||
tests := []testCase[string]{
|
||||
{
|
||||
name: "int64",
|
||||
m: new(Duration),
|
||||
args: args{src: int64(duration)},
|
||||
res: res{
|
||||
want: &duration,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := tt.m.Scan(tt.args.src); (err != nil) != tt.res.err {
|
||||
t.Errorf("Scan() error = %v, wantErr %v", err, tt.res.err)
|
||||
}
|
||||
|
||||
assert.Equal(t, tt.res.want, tt.m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/api/service"
|
||||
|
@ -11,6 +11,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/zerrors"
|
||||
)
|
||||
|
||||
@ -99,7 +100,7 @@ func TestStatementHandler_handleLock(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
client, mock, err := sqlmock.New()
|
||||
client, mock, err := sqlmock.New(sqlmock.ValueConverterOption(new(db_mock.TypeConverter)))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -209,7 +210,7 @@ func TestStatementHandler_renewLock(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
client, mock, err := sqlmock.New()
|
||||
client, mock, err := sqlmock.New(sqlmock.ValueConverterOption(new(db_mock.TypeConverter)))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -283,7 +284,7 @@ func TestStatementHandler_Unlock(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
client, mock, err := sqlmock.New()
|
||||
client, mock, err := sqlmock.New(sqlmock.ValueConverterOption(new(db_mock.TypeConverter)))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
@ -331,7 +331,7 @@ func (ai *existingInstances) AppendEvents(events ...eventstore.Event) {
|
||||
case instance.InstanceAddedEventType:
|
||||
*ai = append(*ai, event.Aggregate().InstanceID)
|
||||
case instance.InstanceRemovedEventType:
|
||||
slices.DeleteFunc(*ai, func(s string) bool {
|
||||
*ai = slices.DeleteFunc(*ai, func(s string) bool {
|
||||
return s == event.Aggregate().InstanceID
|
||||
})
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
|
@ -10,10 +10,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/database/mock"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
@ -213,11 +214,11 @@ func TestHandler_updateLastUpdated(t *testing.T) {
|
||||
"projection",
|
||||
"instance",
|
||||
"aggregate id",
|
||||
"aggregate type",
|
||||
eventstore.AggregateType("aggregate type"),
|
||||
uint64(42),
|
||||
mock.AnyType[time.Time]{},
|
||||
float64(42),
|
||||
uint16(0),
|
||||
uint32(0),
|
||||
),
|
||||
mock.WithExecRowsAffected(1),
|
||||
),
|
||||
|
@ -227,7 +227,7 @@ func instanceIDsFilter(builder *eventstore.SearchQueryBuilder, query *SearchQuer
|
||||
if builder.GetInstanceIDs() == nil {
|
||||
return nil
|
||||
}
|
||||
query.InstanceIDs = NewFilter(FieldInstanceID, builder.GetInstanceIDs(), OperationIn)
|
||||
query.InstanceIDs = NewFilter(FieldInstanceID, database.TextArray[string](builder.GetInstanceIDs()), OperationIn)
|
||||
return query.InstanceIDs
|
||||
}
|
||||
|
||||
@ -256,11 +256,7 @@ func eventTypeFilter(query *eventstore.SearchQuery) *Filter {
|
||||
if len(query.GetEventTypes()) == 1 {
|
||||
return NewFilter(FieldEventType, query.GetEventTypes()[0], OperationEquals)
|
||||
}
|
||||
eventTypes := make(database.TextArray[eventstore.EventType], len(query.GetEventTypes()))
|
||||
for i, eventType := range query.GetEventTypes() {
|
||||
eventTypes[i] = eventType
|
||||
}
|
||||
return NewFilter(FieldEventType, eventTypes, OperationIn)
|
||||
return NewFilter(FieldEventType, database.TextArray[eventstore.EventType](query.GetEventTypes()), OperationIn)
|
||||
}
|
||||
|
||||
func aggregateTypeFilter(query *eventstore.SearchQuery) *Filter {
|
||||
@ -270,11 +266,7 @@ func aggregateTypeFilter(query *eventstore.SearchQuery) *Filter {
|
||||
if len(query.GetAggregateTypes()) == 1 {
|
||||
return NewFilter(FieldAggregateType, query.GetAggregateTypes()[0], OperationEquals)
|
||||
}
|
||||
aggregateTypes := make(database.TextArray[eventstore.AggregateType], len(query.GetAggregateTypes()))
|
||||
for i, aggregateType := range query.GetAggregateTypes() {
|
||||
aggregateTypes[i] = aggregateType
|
||||
}
|
||||
return NewFilter(FieldAggregateType, aggregateTypes, OperationIn)
|
||||
return NewFilter(FieldAggregateType, database.TextArray[eventstore.AggregateType](query.GetAggregateTypes()), OperationIn)
|
||||
}
|
||||
|
||||
func eventDataFilter(query *eventstore.SearchQuery) *Filter {
|
||||
|
@ -10,8 +10,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/cockroachdb/cockroach-go/v2/crdb"
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/lib/pq"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
@ -438,11 +437,6 @@ func (db *CRDB) placeholder(query string) string {
|
||||
}
|
||||
|
||||
func (db *CRDB) isUniqueViolationError(err error) bool {
|
||||
if pqErr, ok := err.(*pq.Error); ok {
|
||||
if pqErr.Code == "23505" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if pgxErr, ok := err.(*pgconn.PgError); ok {
|
||||
if pgxErr.Code == "23505" {
|
||||
return true
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/database/cockroach"
|
||||
db_mock "github.com/zitadel/zitadel/internal/database/mock"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
@ -872,7 +873,7 @@ func (m *dbMock) expectQuery(t *testing.T, expectedQuery string, args []driver.V
|
||||
m.mock.ExpectBegin()
|
||||
query := m.mock.ExpectQuery(expectedQuery).WithArgs(args...)
|
||||
m.mock.ExpectCommit()
|
||||
rows := sqlmock.NewRows([]string{"sequence"})
|
||||
rows := m.mock.NewRows([]string{"sequence"})
|
||||
for _, event := range events {
|
||||
rows = rows.AddRow(event.Seq)
|
||||
}
|
||||
@ -884,7 +885,7 @@ func (m *dbMock) expectQueryScanErr(t *testing.T, expectedQuery string, args []d
|
||||
m.mock.ExpectBegin()
|
||||
query := m.mock.ExpectQuery(expectedQuery).WithArgs(args...)
|
||||
m.mock.ExpectRollback()
|
||||
rows := sqlmock.NewRows([]string{"sequence"})
|
||||
rows := m.mock.NewRows([]string{"sequence"})
|
||||
for _, event := range events {
|
||||
rows = rows.AddRow(event.Seq)
|
||||
}
|
||||
@ -900,7 +901,7 @@ func (m *dbMock) expectQueryErr(t *testing.T, expectedQuery string, args []drive
|
||||
|
||||
func newMockClient(t *testing.T) *dbMock {
|
||||
t.Helper()
|
||||
db, mock, err := sqlmock.New()
|
||||
db, mock, err := sqlmock.New(sqlmock.ValueConverterOption(new(db_mock.TypeConverter)))
|
||||
if err != nil {
|
||||
t.Errorf("unable to create mock client: %v", err)
|
||||
t.FailNow()
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/cockroachdb/cockroach-go/v2/crdb"
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/zitadel/logging"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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"},
|
||||
|
@ -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]
|
||||
)
|
||||
|
||||
|
@ -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"),
|
||||
},
|
||||
|
@ -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{
|
||||
|
@ -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 (
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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' "
|
||||
|
@ -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))
|
||||
|
@ -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"},
|
||||
|
@ -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}
|
||||
}(),
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
},
|
||||
|
@ -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},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -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",
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/DATA-DOG/go-sqlmock"
|
||||
|
||||
db_mock "github.com/zitadel/zitadel/internal/database/mock"
|
||||
"github.com/zitadel/zitadel/internal/static"
|
||||
)
|
||||
|
||||
@ -278,7 +279,7 @@ type db struct {
|
||||
|
||||
func prepareDB(t *testing.T, expectations ...expectation) db {
|
||||
t.Helper()
|
||||
client, mock, err := sqlmock.New()
|
||||
client, mock, err := sqlmock.New(sqlmock.ValueConverterOption(new(db_mock.TypeConverter)))
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create sql mock: %v", err)
|
||||
}
|
||||
@ -295,7 +296,7 @@ type expectation func(m sqlmock.Sqlmock)
|
||||
|
||||
func expectExists(query string, value bool, args ...driver.Value) expectation {
|
||||
return func(m sqlmock.Sqlmock) {
|
||||
m.ExpectQuery(regexp.QuoteMeta(query)).WithArgs(args...).WillReturnRows(sqlmock.NewRows([]string{"exists"}).AddRow(value))
|
||||
m.ExpectQuery(regexp.QuoteMeta(query)).WithArgs(args...).WillReturnRows(m.NewRows([]string{"exists"}).AddRow(value))
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,7 +308,7 @@ func expectQueryErr(query string, err error, args ...driver.Value) expectation {
|
||||
func expectQuery(stmt string, cols []string, rows [][]driver.Value, args ...driver.Value) func(m sqlmock.Sqlmock) {
|
||||
return func(m sqlmock.Sqlmock) {
|
||||
q := m.ExpectQuery(regexp.QuoteMeta(stmt)).WithArgs(args...)
|
||||
result := sqlmock.NewRows(cols)
|
||||
result := m.NewRows(cols)
|
||||
count := uint64(len(rows))
|
||||
for _, row := range rows {
|
||||
if cols[len(cols)-1] == "count" {
|
||||
|
@ -6,10 +6,10 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
|
||||
"github.com/DATA-DOG/go-sqlmock"
|
||||
"github.com/jinzhu/gorm"
|
||||
db_mock "github.com/zitadel/zitadel/internal/database/mock"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -130,15 +130,15 @@ func (db *dbMock) close() {
|
||||
|
||||
func mockDB(t *testing.T) *dbMock {
|
||||
mockDB := dbMock{}
|
||||
db, mock, err := sqlmock.New()
|
||||
db, mock, err := sqlmock.New(sqlmock.ValueConverterOption(new(db_mock.TypeConverter)))
|
||||
if err != nil {
|
||||
t.Fatalf("error occured while creating stub db %v", err)
|
||||
t.Fatalf("error occurred while creating stub db %v", err)
|
||||
}
|
||||
|
||||
mockDB.mock = mock
|
||||
mockDB.db, err = gorm.Open("postgres", db)
|
||||
if err != nil {
|
||||
t.Fatalf("error occured while connecting to stub db: %v", err)
|
||||
t.Fatalf("error occurred while connecting to stub db: %v", err)
|
||||
}
|
||||
|
||||
mockDB.mock.MatchExpectationsInOrder(true)
|
||||
@ -178,7 +178,7 @@ func (db *dbMock) expectGetByID(table, key, value string) *dbMock {
|
||||
db.mock.ExpectBegin()
|
||||
db.mock.ExpectQuery(query).
|
||||
WithArgs(value).
|
||||
WillReturnRows(sqlmock.NewRows([]string{key}).
|
||||
WillReturnRows(db.mock.NewRows([]string{key}).
|
||||
AddRow(key))
|
||||
db.mock.ExpectCommit()
|
||||
|
||||
@ -201,7 +201,7 @@ func (db *dbMock) expectGetByQuery(table, key, method, value string) *dbMock {
|
||||
db.mock.ExpectBegin()
|
||||
db.mock.ExpectQuery(query).
|
||||
WithArgs(value).
|
||||
WillReturnRows(sqlmock.NewRows([]string{key}).
|
||||
WillReturnRows(db.mock.NewRows([]string{key}).
|
||||
AddRow(key))
|
||||
db.mock.ExpectCommit()
|
||||
|
||||
@ -213,7 +213,7 @@ func (db *dbMock) expectGetByQueryCaseSensitive(table, key, method, value string
|
||||
db.mock.ExpectBegin()
|
||||
db.mock.ExpectQuery(query).
|
||||
WithArgs(value).
|
||||
WillReturnRows(sqlmock.NewRows([]string{key}).
|
||||
WillReturnRows(db.mock.NewRows([]string{key}).
|
||||
AddRow(key))
|
||||
db.mock.ExpectCommit()
|
||||
|
||||
@ -259,15 +259,15 @@ func (db *dbMock) expectRemove(table, key, value string) *dbMock {
|
||||
}
|
||||
|
||||
func (db *dbMock) expectRemoveKeys(table string, keys ...Key) *dbMock {
|
||||
keynames := make([]interface{}, len(keys))
|
||||
keyvalues := make([]driver.Value, len(keys))
|
||||
keyNames := make([]interface{}, len(keys))
|
||||
keyValues := make([]driver.Value, len(keys))
|
||||
for i, key := range keys {
|
||||
keynames[i] = key.Key.ToColumnName()
|
||||
keyvalues[i] = key.Value
|
||||
keyNames[i] = key.Key.ToColumnName()
|
||||
keyValues[i] = key.Value
|
||||
}
|
||||
query := fmt.Sprintf(expectedRemoveByKeys(len(keys), table), keynames...)
|
||||
query := fmt.Sprintf(expectedRemoveByKeys(len(keys), table), keyNames...)
|
||||
db.mock.ExpectExec(query).
|
||||
WithArgs(keyvalues...).
|
||||
WithArgs(keyValues...).
|
||||
WillReturnResult(sqlmock.NewResult(1, 1))
|
||||
|
||||
return db
|
||||
@ -318,7 +318,7 @@ func (db *dbMock) expectGetSearchRequestNoParams(table string, resultAmount, tot
|
||||
query := fmt.Sprintf(expectedSearch, table)
|
||||
queryCount := fmt.Sprintf(expectedSearchCount, table)
|
||||
|
||||
rows := sqlmock.NewRows([]string{"id"})
|
||||
rows := db.mock.NewRows([]string{"id"})
|
||||
for i := 0; i < resultAmount; i++ {
|
||||
rows.AddRow(fmt.Sprintf("hodor-%d", i))
|
||||
}
|
||||
@ -326,7 +326,7 @@ func (db *dbMock) expectGetSearchRequestNoParams(table string, resultAmount, tot
|
||||
db.mock.ExpectBegin()
|
||||
|
||||
db.mock.ExpectQuery(queryCount).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(total))
|
||||
WillReturnRows(db.mock.NewRows([]string{"count"}).AddRow(total))
|
||||
db.mock.ExpectQuery(query).
|
||||
WillReturnRows(rows)
|
||||
|
||||
@ -338,14 +338,14 @@ func (db *dbMock) expectGetSearchRequestWithLimit(table string, limit, resultAmo
|
||||
query := fmt.Sprintf(expectedSearchLimit, table, limit)
|
||||
queryCount := fmt.Sprintf(expectedSearchLimitCount, table)
|
||||
|
||||
rows := sqlmock.NewRows([]string{"id"})
|
||||
rows := db.mock.NewRows([]string{"id"})
|
||||
for i := 0; i < resultAmount; i++ {
|
||||
rows.AddRow(fmt.Sprintf("hodor-%d", i))
|
||||
}
|
||||
|
||||
db.mock.ExpectBegin()
|
||||
db.mock.ExpectQuery(queryCount).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(total))
|
||||
WillReturnRows(db.mock.NewRows([]string{"count"}).AddRow(total))
|
||||
db.mock.ExpectQuery(query).
|
||||
WillReturnRows(rows)
|
||||
db.mock.ExpectCommit()
|
||||
@ -356,14 +356,14 @@ func (db *dbMock) expectGetSearchRequestWithOffset(table string, offset, resultA
|
||||
query := fmt.Sprintf(expectedSearchOffset, table, offset)
|
||||
queryCount := fmt.Sprintf(expectedSearchOffsetCount, table)
|
||||
|
||||
rows := sqlmock.NewRows([]string{"id"})
|
||||
rows := db.mock.NewRows([]string{"id"})
|
||||
for i := 0; i < resultAmount; i++ {
|
||||
rows.AddRow(fmt.Sprintf("hodor-%d", i))
|
||||
}
|
||||
|
||||
db.mock.ExpectBegin()
|
||||
db.mock.ExpectQuery(queryCount).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(total))
|
||||
WillReturnRows(db.mock.NewRows([]string{"count"}).AddRow(total))
|
||||
db.mock.ExpectQuery(query).
|
||||
WillReturnRows(rows)
|
||||
db.mock.ExpectCommit()
|
||||
@ -374,14 +374,14 @@ func (db *dbMock) expectGetSearchRequestWithSorting(table, sorting string, sorti
|
||||
query := fmt.Sprintf(expectedSearchSorting, table, sortingColumn.ToColumnName(), sorting)
|
||||
queryCount := fmt.Sprintf(expectedSearchSortingCount, table)
|
||||
|
||||
rows := sqlmock.NewRows([]string{"id"})
|
||||
rows := db.mock.NewRows([]string{"id"})
|
||||
for i := 0; i < resultAmount; i++ {
|
||||
rows.AddRow(fmt.Sprintf("hodor-%d", i))
|
||||
}
|
||||
|
||||
db.mock.ExpectBegin()
|
||||
db.mock.ExpectQuery(queryCount).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(total))
|
||||
WillReturnRows(db.mock.NewRows([]string{"count"}).AddRow(total))
|
||||
db.mock.ExpectQuery(query).
|
||||
WillReturnRows(rows)
|
||||
db.mock.ExpectCommit()
|
||||
@ -392,7 +392,7 @@ func (db *dbMock) expectGetSearchRequestWithSearchQuery(table, key, method, valu
|
||||
query := fmt.Sprintf(expectedSearchQuery, table, key, method)
|
||||
queryCount := fmt.Sprintf(expectedSearchQueryCount, table, key, method)
|
||||
|
||||
rows := sqlmock.NewRows([]string{"id"})
|
||||
rows := db.mock.NewRows([]string{"id"})
|
||||
for i := 0; i < resultAmount; i++ {
|
||||
rows.AddRow(fmt.Sprintf("hodor-%d", i))
|
||||
}
|
||||
@ -400,7 +400,7 @@ func (db *dbMock) expectGetSearchRequestWithSearchQuery(table, key, method, valu
|
||||
db.mock.ExpectBegin()
|
||||
db.mock.ExpectQuery(queryCount).
|
||||
WithArgs(value).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(total))
|
||||
WillReturnRows(db.mock.NewRows([]string{"count"}).AddRow(total))
|
||||
db.mock.ExpectQuery(query).
|
||||
WithArgs(value).
|
||||
WillReturnRows(rows)
|
||||
@ -412,7 +412,7 @@ func (db *dbMock) expectGetSearchRequestWithAllParams(table, key, method, value,
|
||||
query := fmt.Sprintf(expectedSearchQueryAllParams, table, key, method, sortingColumn.ToColumnName(), sorting, limit, offset)
|
||||
queryCount := fmt.Sprintf(expectedSearchQueryAllParamCount, table, key, method)
|
||||
|
||||
rows := sqlmock.NewRows([]string{"id"})
|
||||
rows := db.mock.NewRows([]string{"id"})
|
||||
for i := 0; i < resultAmount; i++ {
|
||||
rows.AddRow(fmt.Sprintf("hodor-%d", i))
|
||||
}
|
||||
@ -420,7 +420,7 @@ func (db *dbMock) expectGetSearchRequestWithAllParams(table, key, method, value,
|
||||
db.mock.ExpectBegin()
|
||||
db.mock.ExpectQuery(queryCount).
|
||||
WithArgs(value).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(total))
|
||||
WillReturnRows(db.mock.NewRows([]string{"count"}).AddRow(total))
|
||||
db.mock.ExpectQuery(query).
|
||||
WithArgs(value).
|
||||
WillReturnRows(rows)
|
||||
@ -432,14 +432,14 @@ func (db *dbMock) expectGetSearchRequestErr(table string, resultAmount, total in
|
||||
query := fmt.Sprintf(expectedSearch, table)
|
||||
queryCount := fmt.Sprintf(expectedSearchCount, table)
|
||||
|
||||
rows := sqlmock.NewRows([]string{"id"})
|
||||
rows := db.mock.NewRows([]string{"id"})
|
||||
for i := 0; i < resultAmount; i++ {
|
||||
rows.AddRow(fmt.Sprintf("hodor-%d", i))
|
||||
}
|
||||
|
||||
db.mock.ExpectBegin()
|
||||
db.mock.ExpectQuery(queryCount).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(total))
|
||||
WillReturnRows(db.mock.NewRows([]string{"count"}).AddRow(total))
|
||||
db.mock.ExpectQuery(query).
|
||||
WillReturnError(err)
|
||||
db.mock.ExpectCommit()
|
||||
|
Loading…
Reference in New Issue
Block a user