chore: use pgx v5 (#7577)

* chore: use pgx v5

* chore: update go version

* remove direct pq dependency

* remove unnecessary type

* scan test

* map scanner

* converter

* uint8 number array

* duration

* most unit tests work

* unit tests work

* chore: coverage

* go 1.21

* linting

* int64 gopfertammi

* retry go 1.22

* retry go 1.22

* revert to go v1.21.5

* update go toolchain to 1.21.8

* go 1.21.8

* remove test flag

* go 1.21.5

* linting

* update toolchain

* use correct array

* use correct array

* add byte array

* correct value

* correct error message

* go 1.21 compatible
This commit is contained in:
Silvan
2024-03-27 15:48:22 +02:00
committed by GitHub
parent 2ea0b520fd
commit 56df515e5f
49 changed files with 801 additions and 493 deletions
+23 -22
View File
@@ -84,6 +84,7 @@ var (
)
func Test_LoginPolicyPrepares(t *testing.T) {
duration := 2 * time.Hour
type want struct {
sqlExpectations sqlExpectation
err checkErr
@@ -129,8 +130,8 @@ func Test_LoginPolicyPrepares(t *testing.T) {
true,
true,
true,
database.Array[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
database.Array[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
database.NumberArray[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
database.NumberArray[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
domain.PasswordlessTypeAllowed,
true,
true,
@@ -139,11 +140,11 @@ func Test_LoginPolicyPrepares(t *testing.T) {
true,
true,
"https://example.com/redirect",
time.Hour * 2,
time.Hour * 2,
time.Hour * 2,
time.Hour * 2,
time.Hour * 2,
&duration,
&duration,
&duration,
&duration,
&duration,
},
),
},
@@ -157,8 +158,8 @@ func Test_LoginPolicyPrepares(t *testing.T) {
AllowExternalIDPs: true,
ForceMFA: true,
ForceMFALocalOnly: true,
SecondFactors: database.Array[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
MultiFactors: database.Array[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
SecondFactors: database.NumberArray[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
MultiFactors: database.NumberArray[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
PasswordlessType: domain.PasswordlessTypeAllowed,
IsDefault: true,
HidePasswordReset: true,
@@ -167,11 +168,11 @@ func Test_LoginPolicyPrepares(t *testing.T) {
DisableLoginWithEmail: true,
DisableLoginWithPhone: true,
DefaultRedirectURI: "https://example.com/redirect",
PasswordCheckLifetime: time.Hour * 2,
ExternalLoginCheckLifetime: time.Hour * 2,
MFAInitSkipLifetime: time.Hour * 2,
SecondFactorCheckLifetime: time.Hour * 2,
MultiFactorCheckLifetime: time.Hour * 2,
PasswordCheckLifetime: database.Duration(duration),
ExternalLoginCheckLifetime: database.Duration(duration),
MFAInitSkipLifetime: database.Duration(duration),
SecondFactorCheckLifetime: database.Duration(duration),
MultiFactorCheckLifetime: database.Duration(duration),
},
},
{
@@ -217,7 +218,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
regexp.QuoteMeta(prepareLoginPolicy2FAsStmt),
prepareLoginPolicy2FAsCols,
[]driver.Value{
database.Array[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
database.NumberArray[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
},
),
},
@@ -225,7 +226,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
SearchResponse: SearchResponse{
Count: 1,
},
Factors: database.Array[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
Factors: database.NumberArray[domain.SecondFactorType]{domain.SecondFactorTypeTOTP},
},
},
{
@@ -236,11 +237,11 @@ func Test_LoginPolicyPrepares(t *testing.T) {
regexp.QuoteMeta(prepareLoginPolicy2FAsStmt),
prepareLoginPolicy2FAsCols,
[]driver.Value{
database.Array[domain.SecondFactorType]{},
database.NumberArray[domain.SecondFactorType]{},
},
),
},
object: &SecondFactors{Factors: database.Array[domain.SecondFactorType]{}},
object: &SecondFactors{Factors: database.NumberArray[domain.SecondFactorType]{}},
},
{
name: "prepareLoginPolicy2FAsQuery sql err",
@@ -285,7 +286,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
regexp.QuoteMeta(prepareLoginPolicyMFAsStmt),
prepareLoginPolicyMFAsCols,
[]driver.Value{
database.Array[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
database.NumberArray[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
},
),
},
@@ -293,7 +294,7 @@ func Test_LoginPolicyPrepares(t *testing.T) {
SearchResponse: SearchResponse{
Count: 1,
},
Factors: database.Array[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
Factors: database.NumberArray[domain.MultiFactorType]{domain.MultiFactorTypeU2FWithPIN},
},
},
{
@@ -304,11 +305,11 @@ func Test_LoginPolicyPrepares(t *testing.T) {
regexp.QuoteMeta(prepareLoginPolicyMFAsStmt),
prepareLoginPolicyMFAsCols,
[]driver.Value{
database.Array[domain.MultiFactorType]{},
database.NumberArray[domain.MultiFactorType]{},
},
),
},
object: &MultiFactors{Factors: database.Array[domain.MultiFactorType]{}},
object: &MultiFactors{Factors: database.NumberArray[domain.MultiFactorType]{}},
},
{
name: "prepareLoginPolicyMFAsQuery sql err",