refactor: rename package errors to zerrors (#7039)

* chore: rename package errors to zerrors

* rename package errors to gerrors

* fix error related linting issues

* fix zitadel error assertion

* fix gosimple linting issues

* fix deprecated linting issues

* resolve gci linting issues

* fix import structure

---------

Co-authored-by: Elio Bischof <elio@zitadel.com>
This commit is contained in:
Tim Möhlmann
2023-12-08 16:30:55 +02:00
committed by GitHub
parent ddbea119f1
commit f680dd934d
798 changed files with 5809 additions and 5813 deletions

View File

@@ -14,10 +14,10 @@ import (
"github.com/zitadel/zitadel/internal/crypto"
"github.com/zitadel/zitadel/internal/domain"
caos_errs "github.com/zitadel/zitadel/internal/errors"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/repository/org"
"github.com/zitadel/zitadel/internal/repository/user"
"github.com/zitadel/zitadel/internal/zerrors"
)
func TestCommandSide_SetOneTimePassword(t *testing.T) {
@@ -55,7 +55,7 @@ func TestCommandSide_SetOneTimePassword(t *testing.T) {
resourceOwner: "org1",
},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -72,7 +72,7 @@ func TestCommandSide_SetOneTimePassword(t *testing.T) {
resourceOwner: "org1",
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -114,7 +114,7 @@ func TestCommandSide_SetOneTimePassword(t *testing.T) {
},
res: res{
err: func(err error) bool {
return errors.Is(err, caos_errs.ThrowPermissionDenied(nil, "AUTHZ-HKJD33", "Errors.PermissionDenied"))
return errors.Is(err, zerrors.ThrowPermissionDenied(nil, "AUTHZ-HKJD33", "Errors.PermissionDenied"))
},
},
},
@@ -302,7 +302,7 @@ func TestCommandSide_SetPasswordWithVerifyCode(t *testing.T) {
resourceOwner: "org1",
},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -318,7 +318,7 @@ func TestCommandSide_SetPasswordWithVerifyCode(t *testing.T) {
resourceOwner: "org1",
},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -336,7 +336,7 @@ func TestCommandSide_SetPasswordWithVerifyCode(t *testing.T) {
password: "password",
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -370,7 +370,7 @@ func TestCommandSide_SetPasswordWithVerifyCode(t *testing.T) {
password: "string",
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -418,7 +418,7 @@ func TestCommandSide_SetPasswordWithVerifyCode(t *testing.T) {
password: "password",
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -553,7 +553,7 @@ func TestCommandSide_ChangePassword(t *testing.T) {
},
expect: []expect{},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -567,7 +567,7 @@ func TestCommandSide_ChangePassword(t *testing.T) {
},
expect: []expect{},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -581,7 +581,7 @@ func TestCommandSide_ChangePassword(t *testing.T) {
},
expect: []expect{},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -598,7 +598,7 @@ func TestCommandSide_ChangePassword(t *testing.T) {
expectFilter(),
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -632,7 +632,7 @@ func TestCommandSide_ChangePassword(t *testing.T) {
),
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -689,7 +689,7 @@ func TestCommandSide_ChangePassword(t *testing.T) {
),
},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -813,7 +813,7 @@ func TestCommandSide_RequestSetPassword(t *testing.T) {
resourceOwner: "org1",
},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -830,7 +830,7 @@ func TestCommandSide_RequestSetPassword(t *testing.T) {
resourceOwner: "org1",
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -879,7 +879,7 @@ func TestCommandSide_RequestSetPassword(t *testing.T) {
resourceOwner: "org1",
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -988,7 +988,7 @@ func TestCommandSide_PasswordCodeSent(t *testing.T) {
resourceOwner: "org1",
},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -1005,7 +1005,7 @@ func TestCommandSide_PasswordCodeSent(t *testing.T) {
resourceOwner: "org1",
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -1101,7 +1101,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
resourceOwner: "org1",
},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -1117,7 +1117,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
resourceOwner: "org1",
},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -1136,7 +1136,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
password: "password",
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -1177,7 +1177,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
password: "password",
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -1219,7 +1219,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
password: "password",
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -1281,7 +1281,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
password: "password",
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -1339,7 +1339,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
resourceOwner: "org1",
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -1423,7 +1423,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
lockoutPolicy: &domain.LockoutPolicy{},
},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -1513,7 +1513,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
},
},
res: res{
err: caos_errs.IsErrorInvalidArgument,
err: zerrors.IsErrorInvalidArgument,
},
},
{
@@ -1760,7 +1760,7 @@ func TestCommandSide_CheckPassword(t *testing.T) {
},
},
res: res{
err: caos_errs.IsPreconditionFailed,
err: zerrors.IsPreconditionFailed,
},
},
{
@@ -1893,17 +1893,17 @@ func Test_convertPasswapErr(t *testing.T) {
{
name: "mismatch",
args: args{passwap.ErrPasswordMismatch},
wantErr: caos_errs.ThrowInvalidArgument(passwap.ErrPasswordMismatch, "COMMAND-3M0fs", "Errors.User.Password.Invalid"),
wantErr: zerrors.ThrowInvalidArgument(passwap.ErrPasswordMismatch, "COMMAND-3M0fs", "Errors.User.Password.Invalid"),
},
{
name: "no change",
args: args{passwap.ErrPasswordNoChange},
wantErr: caos_errs.ThrowPreconditionFailed(passwap.ErrPasswordNoChange, "COMMAND-Aesh5", "Errors.User.Password.NotChanged"),
wantErr: zerrors.ThrowPreconditionFailed(passwap.ErrPasswordNoChange, "COMMAND-Aesh5", "Errors.User.Password.NotChanged"),
},
{
name: "other",
args: args{io.ErrClosedPipe},
wantErr: caos_errs.ThrowInternal(io.ErrClosedPipe, "COMMAND-CahN2", "Errors.Internal"),
wantErr: zerrors.ThrowInternal(io.ErrClosedPipe, "COMMAND-CahN2", "Errors.Internal"),
},
}
for _, tt := range tests {