mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
improve some functions
This commit is contained in:
parent
fa750a5068
commit
59dc4dbe85
@ -74,9 +74,7 @@ func Test_GetUserMethodPermissions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
errFunc: func(err error) bool {
|
errFunc: caos_errs.IsUnauthenticated,
|
||||||
return caos_errs.IsUnauthenticated(err)
|
|
||||||
},
|
|
||||||
result: []string{"project.read"},
|
result: []string{"project.read"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -393,7 +391,6 @@ func Test_AddRoleContextIDToPerm(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_ExistisPerm(t *testing.T) {
|
func Test_ExistisPerm(t *testing.T) {
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
existing []string
|
existing []string
|
||||||
perm string
|
perm string
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/caos/zitadel/internal/errors"
|
"github.com/caos/zitadel/internal/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ EncryptionAlg = (*AESCrypto)(nil)
|
var _ EncryptionAlgorithm = (*AESCrypto)(nil)
|
||||||
|
|
||||||
type AESCrypto struct {
|
type AESCrypto struct {
|
||||||
keys map[string]string
|
keys map[string]string
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ HashAlg = (*BCrypt)(nil)
|
var _ HashAlgorithm = (*BCrypt)(nil)
|
||||||
|
|
||||||
type BCrypt struct {
|
type BCrypt struct {
|
||||||
cost int
|
cost int
|
||||||
|
@ -24,7 +24,7 @@ type Generator interface {
|
|||||||
type EncryptionGenerator struct {
|
type EncryptionGenerator struct {
|
||||||
length uint
|
length uint
|
||||||
expiry time.Duration
|
expiry time.Duration
|
||||||
alg EncryptionAlg
|
alg EncryptionAlgorithm
|
||||||
runes []rune
|
runes []rune
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ func (g *EncryptionGenerator) Runes() []rune {
|
|||||||
return g.runes
|
return g.runes
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEncryptionGenerator(length uint, expiry time.Duration, alg EncryptionAlg, runes []rune) *EncryptionGenerator {
|
func NewEncryptionGenerator(length uint, expiry time.Duration, alg EncryptionAlgorithm, runes []rune) *EncryptionGenerator {
|
||||||
return &EncryptionGenerator{
|
return &EncryptionGenerator{
|
||||||
length: length,
|
length: length,
|
||||||
expiry: expiry,
|
expiry: expiry,
|
||||||
@ -56,7 +56,7 @@ func NewEncryptionGenerator(length uint, expiry time.Duration, alg EncryptionAlg
|
|||||||
type HashGenerator struct {
|
type HashGenerator struct {
|
||||||
length uint
|
length uint
|
||||||
expiry time.Duration
|
expiry time.Duration
|
||||||
alg HashAlg
|
alg HashAlgorithm
|
||||||
runes []rune
|
runes []rune
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ func (g *HashGenerator) Runes() []rune {
|
|||||||
return g.runes
|
return g.runes
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHashGenerator(length uint, expiry time.Duration, alg HashAlg, runes []rune) *HashGenerator {
|
func NewHashGenerator(length uint, expiry time.Duration, alg HashAlgorithm, runes []rune) *HashGenerator {
|
||||||
return &HashGenerator{
|
return &HashGenerator{
|
||||||
length: length,
|
length: length,
|
||||||
expiry: expiry,
|
expiry: expiry,
|
||||||
@ -106,9 +106,9 @@ func VerifyCode(creationDate time.Time, expiry time.Duration, cryptoCode *Crypto
|
|||||||
return errors.ThrowPreconditionFailed(nil, "CODE-QvUQ4P", "verification code is expired")
|
return errors.ThrowPreconditionFailed(nil, "CODE-QvUQ4P", "verification code is expired")
|
||||||
}
|
}
|
||||||
switch alg := g.Alg().(type) {
|
switch alg := g.Alg().(type) {
|
||||||
case EncryptionAlg:
|
case EncryptionAlgorithm:
|
||||||
return verifyEncryptedCode(cryptoCode, verificationCode, alg)
|
return verifyEncryptedCode(cryptoCode, verificationCode, alg)
|
||||||
case HashAlg:
|
case HashAlgorithm:
|
||||||
return verifyHashedCode(cryptoCode, verificationCode, alg)
|
return verifyHashedCode(cryptoCode, verificationCode, alg)
|
||||||
}
|
}
|
||||||
return errors.ThrowInvalidArgument(nil, "CODE-fW2gNa", "generator alg is not supported")
|
return errors.ThrowInvalidArgument(nil, "CODE-fW2gNa", "generator alg is not supported")
|
||||||
@ -136,7 +136,7 @@ func generateRandomString(length uint, chars []rune) (string, error) {
|
|||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyEncryptedCode(cryptoCode *CryptoValue, verificationCode string, alg EncryptionAlg) error {
|
func verifyEncryptedCode(cryptoCode *CryptoValue, verificationCode string, alg EncryptionAlgorithm) error {
|
||||||
code, err := DecryptString(cryptoCode, alg)
|
code, err := DecryptString(cryptoCode, alg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -148,6 +148,6 @@ func verifyEncryptedCode(cryptoCode *CryptoValue, verificationCode string, alg E
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyHashedCode(cryptoCode *CryptoValue, verificationCode string, alg HashAlg) error {
|
func verifyHashedCode(cryptoCode *CryptoValue, verificationCode string, alg HashAlgorithm) error {
|
||||||
return CompareHash(cryptoCode, []byte(verificationCode), alg)
|
return CompareHash(cryptoCode, []byte(verificationCode), alg)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Test_Encrypted_OK(t *testing.T) {
|
func Test_Encrypted_OK(t *testing.T) {
|
||||||
mCrypto := NewMockEncryptionAlg(gomock.NewController(t))
|
mCrypto := NewMockEncryptionAlgorithm(gomock.NewController(t))
|
||||||
mCrypto.EXPECT().Algorithm().AnyTimes().Return("enc")
|
mCrypto.EXPECT().Algorithm().AnyTimes().Return("enc")
|
||||||
mCrypto.EXPECT().EncryptionKeyID().AnyTimes().Return("id")
|
mCrypto.EXPECT().EncryptionKeyID().AnyTimes().Return("id")
|
||||||
mCrypto.EXPECT().DecryptionKeyIDs().AnyTimes().Return([]string{"id"})
|
mCrypto.EXPECT().DecryptionKeyIDs().AnyTimes().Return([]string{"id"})
|
||||||
@ -35,7 +35,7 @@ func Test_Encrypted_OK(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_Verify_Encrypted_OK(t *testing.T) {
|
func Test_Verify_Encrypted_OK(t *testing.T) {
|
||||||
mCrypto := NewMockEncryptionAlg(gomock.NewController(t))
|
mCrypto := NewMockEncryptionAlgorithm(gomock.NewController(t))
|
||||||
mCrypto.EXPECT().Algorithm().AnyTimes().Return("enc")
|
mCrypto.EXPECT().Algorithm().AnyTimes().Return("enc")
|
||||||
mCrypto.EXPECT().EncryptionKeyID().AnyTimes().Return("id")
|
mCrypto.EXPECT().EncryptionKeyID().AnyTimes().Return("id")
|
||||||
mCrypto.EXPECT().DecryptionKeyIDs().AnyTimes().Return([]string{"id"})
|
mCrypto.EXPECT().DecryptionKeyIDs().AnyTimes().Return([]string{"id"})
|
||||||
@ -57,7 +57,7 @@ func Test_Verify_Encrypted_OK(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
func Test_Verify_Encrypted_Invalid_Err(t *testing.T) {
|
func Test_Verify_Encrypted_Invalid_Err(t *testing.T) {
|
||||||
mCrypto := NewMockEncryptionAlg(gomock.NewController(t))
|
mCrypto := NewMockEncryptionAlgorithm(gomock.NewController(t))
|
||||||
mCrypto.EXPECT().Algorithm().AnyTimes().Return("enc")
|
mCrypto.EXPECT().Algorithm().AnyTimes().Return("enc")
|
||||||
mCrypto.EXPECT().EncryptionKeyID().AnyTimes().Return("id")
|
mCrypto.EXPECT().EncryptionKeyID().AnyTimes().Return("id")
|
||||||
mCrypto.EXPECT().DecryptionKeyIDs().AnyTimes().Return([]string{"id"})
|
mCrypto.EXPECT().DecryptionKeyIDs().AnyTimes().Return([]string{"id"})
|
||||||
|
@ -13,7 +13,7 @@ type Crypto interface {
|
|||||||
Algorithm() string
|
Algorithm() string
|
||||||
}
|
}
|
||||||
|
|
||||||
type EncryptionAlg interface {
|
type EncryptionAlgorithm interface {
|
||||||
Crypto
|
Crypto
|
||||||
EncryptionKeyID() string
|
EncryptionKeyID() string
|
||||||
DecryptionKeyIDs() []string
|
DecryptionKeyIDs() []string
|
||||||
@ -22,7 +22,7 @@ type EncryptionAlg interface {
|
|||||||
DecryptString(hashed []byte, keyID string) (string, error)
|
DecryptString(hashed []byte, keyID string) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type HashAlg interface {
|
type HashAlgorithm interface {
|
||||||
Crypto
|
Crypto
|
||||||
Hash(value []byte) ([]byte, error)
|
Hash(value []byte) ([]byte, error)
|
||||||
CompareHash(hashed, comparer []byte) error
|
CompareHash(hashed, comparer []byte) error
|
||||||
@ -39,15 +39,15 @@ type CryptoType int
|
|||||||
|
|
||||||
func Crypt(value []byte, c Crypto) (*CryptoValue, error) {
|
func Crypt(value []byte, c Crypto) (*CryptoValue, error) {
|
||||||
switch alg := c.(type) {
|
switch alg := c.(type) {
|
||||||
case EncryptionAlg:
|
case EncryptionAlgorithm:
|
||||||
return Encrypt(value, alg)
|
return Encrypt(value, alg)
|
||||||
case HashAlg:
|
case HashAlgorithm:
|
||||||
return Hash(value, alg)
|
return Hash(value, alg)
|
||||||
}
|
}
|
||||||
return nil, errors.ThrowInternal(nil, "CRYPT-r4IaHZ", "algorithm not supported")
|
return nil, errors.ThrowInternal(nil, "CRYPT-r4IaHZ", "algorithm not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Encrypt(value []byte, alg EncryptionAlg) (*CryptoValue, error) {
|
func Encrypt(value []byte, alg EncryptionAlgorithm) (*CryptoValue, error) {
|
||||||
encrypted, err := alg.Encrypt(value)
|
encrypted, err := alg.Encrypt(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.ThrowInternal(err, "CRYPT-qCD0JB", "error encrypting value")
|
return nil, errors.ThrowInternal(err, "CRYPT-qCD0JB", "error encrypting value")
|
||||||
@ -60,21 +60,21 @@ func Encrypt(value []byte, alg EncryptionAlg) (*CryptoValue, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Decrypt(value *CryptoValue, alg EncryptionAlg) ([]byte, error) {
|
func Decrypt(value *CryptoValue, alg EncryptionAlgorithm) ([]byte, error) {
|
||||||
if err := checkEncAlg(value, alg); err != nil {
|
if err := checkEncryptionAlgorithm(value, alg); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return alg.Decrypt(value.Crypted, value.KeyID)
|
return alg.Decrypt(value.Crypted, value.KeyID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DecryptString(value *CryptoValue, alg EncryptionAlg) (string, error) {
|
func DecryptString(value *CryptoValue, alg EncryptionAlgorithm) (string, error) {
|
||||||
if err := checkEncAlg(value, alg); err != nil {
|
if err := checkEncryptionAlgorithm(value, alg); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return alg.DecryptString(value.Crypted, value.KeyID)
|
return alg.DecryptString(value.Crypted, value.KeyID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkEncAlg(value *CryptoValue, alg EncryptionAlg) error {
|
func checkEncryptionAlgorithm(value *CryptoValue, alg EncryptionAlgorithm) error {
|
||||||
if value.Algorithm != alg.Algorithm() {
|
if value.Algorithm != alg.Algorithm() {
|
||||||
return errors.ThrowInvalidArgument(nil, "CRYPT-Nx7XlT", "value was encrypted with a different key")
|
return errors.ThrowInvalidArgument(nil, "CRYPT-Nx7XlT", "value was encrypted with a different key")
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ func checkEncAlg(value *CryptoValue, alg EncryptionAlg) error {
|
|||||||
return errors.ThrowInvalidArgument(nil, "CRYPT-Kq12vn", "value was encrypted with a different key")
|
return errors.ThrowInvalidArgument(nil, "CRYPT-Kq12vn", "value was encrypted with a different key")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Hash(value []byte, alg HashAlg) (*CryptoValue, error) {
|
func Hash(value []byte, alg HashAlgorithm) (*CryptoValue, error) {
|
||||||
hashed, err := alg.Hash(value)
|
hashed, err := alg.Hash(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.ThrowInternal(err, "CRYPT-rBVaJU", "error hashing value")
|
return nil, errors.ThrowInternal(err, "CRYPT-rBVaJU", "error hashing value")
|
||||||
@ -98,6 +98,6 @@ func Hash(value []byte, alg HashAlg) (*CryptoValue, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CompareHash(value *CryptoValue, comparer []byte, alg HashAlg) error {
|
func CompareHash(value *CryptoValue, comparer []byte, alg HashAlgorithm) error {
|
||||||
return alg.CompareHash(value.Crypted, comparer)
|
return alg.CompareHash(value.Crypted, comparer)
|
||||||
}
|
}
|
||||||
|
@ -46,31 +46,31 @@ func (mr *MockCryptoMockRecorder) Algorithm() *gomock.Call {
|
|||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Algorithm", reflect.TypeOf((*MockCrypto)(nil).Algorithm))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Algorithm", reflect.TypeOf((*MockCrypto)(nil).Algorithm))
|
||||||
}
|
}
|
||||||
|
|
||||||
// MockEncryptionAlg is a mock of EncryptionAlg interface
|
// MockEncryptionAlgorithm is a mock of EncryptionAlgorithm interface
|
||||||
type MockEncryptionAlg struct {
|
type MockEncryptionAlgorithm struct {
|
||||||
ctrl *gomock.Controller
|
ctrl *gomock.Controller
|
||||||
recorder *MockEncryptionAlgMockRecorder
|
recorder *MockEncryptionAlgorithmMockRecorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// MockEncryptionAlgMockRecorder is the mock recorder for MockEncryptionAlg
|
// MockEncryptionAlgorithmMockRecorder is the mock recorder for MockEncryptionAlgorithm
|
||||||
type MockEncryptionAlgMockRecorder struct {
|
type MockEncryptionAlgorithmMockRecorder struct {
|
||||||
mock *MockEncryptionAlg
|
mock *MockEncryptionAlgorithm
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMockEncryptionAlg creates a new mock instance
|
// NewMockEncryptionAlgorithm creates a new mock instance
|
||||||
func NewMockEncryptionAlg(ctrl *gomock.Controller) *MockEncryptionAlg {
|
func NewMockEncryptionAlgorithm(ctrl *gomock.Controller) *MockEncryptionAlgorithm {
|
||||||
mock := &MockEncryptionAlg{ctrl: ctrl}
|
mock := &MockEncryptionAlgorithm{ctrl: ctrl}
|
||||||
mock.recorder = &MockEncryptionAlgMockRecorder{mock}
|
mock.recorder = &MockEncryptionAlgorithmMockRecorder{mock}
|
||||||
return mock
|
return mock
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPECT returns an object that allows the caller to indicate expected use
|
// EXPECT returns an object that allows the caller to indicate expected use
|
||||||
func (m *MockEncryptionAlg) EXPECT() *MockEncryptionAlgMockRecorder {
|
func (m *MockEncryptionAlgorithm) EXPECT() *MockEncryptionAlgorithmMockRecorder {
|
||||||
return m.recorder
|
return m.recorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Algorithm mocks base method
|
// Algorithm mocks base method
|
||||||
func (m *MockEncryptionAlg) Algorithm() string {
|
func (m *MockEncryptionAlgorithm) Algorithm() string {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Algorithm")
|
ret := m.ctrl.Call(m, "Algorithm")
|
||||||
ret0, _ := ret[0].(string)
|
ret0, _ := ret[0].(string)
|
||||||
@ -78,13 +78,13 @@ func (m *MockEncryptionAlg) Algorithm() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Algorithm indicates an expected call of Algorithm
|
// Algorithm indicates an expected call of Algorithm
|
||||||
func (mr *MockEncryptionAlgMockRecorder) Algorithm() *gomock.Call {
|
func (mr *MockEncryptionAlgorithmMockRecorder) Algorithm() *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Algorithm", reflect.TypeOf((*MockEncryptionAlg)(nil).Algorithm))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Algorithm", reflect.TypeOf((*MockEncryptionAlgorithm)(nil).Algorithm))
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncryptionKeyID mocks base method
|
// EncryptionKeyID mocks base method
|
||||||
func (m *MockEncryptionAlg) EncryptionKeyID() string {
|
func (m *MockEncryptionAlgorithm) EncryptionKeyID() string {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "EncryptionKeyID")
|
ret := m.ctrl.Call(m, "EncryptionKeyID")
|
||||||
ret0, _ := ret[0].(string)
|
ret0, _ := ret[0].(string)
|
||||||
@ -92,13 +92,13 @@ func (m *MockEncryptionAlg) EncryptionKeyID() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EncryptionKeyID indicates an expected call of EncryptionKeyID
|
// EncryptionKeyID indicates an expected call of EncryptionKeyID
|
||||||
func (mr *MockEncryptionAlgMockRecorder) EncryptionKeyID() *gomock.Call {
|
func (mr *MockEncryptionAlgorithmMockRecorder) EncryptionKeyID() *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EncryptionKeyID", reflect.TypeOf((*MockEncryptionAlg)(nil).EncryptionKeyID))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EncryptionKeyID", reflect.TypeOf((*MockEncryptionAlgorithm)(nil).EncryptionKeyID))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecryptionKeyIDs mocks base method
|
// DecryptionKeyIDs mocks base method
|
||||||
func (m *MockEncryptionAlg) DecryptionKeyIDs() []string {
|
func (m *MockEncryptionAlgorithm) DecryptionKeyIDs() []string {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "DecryptionKeyIDs")
|
ret := m.ctrl.Call(m, "DecryptionKeyIDs")
|
||||||
ret0, _ := ret[0].([]string)
|
ret0, _ := ret[0].([]string)
|
||||||
@ -106,13 +106,13 @@ func (m *MockEncryptionAlg) DecryptionKeyIDs() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DecryptionKeyIDs indicates an expected call of DecryptionKeyIDs
|
// DecryptionKeyIDs indicates an expected call of DecryptionKeyIDs
|
||||||
func (mr *MockEncryptionAlgMockRecorder) DecryptionKeyIDs() *gomock.Call {
|
func (mr *MockEncryptionAlgorithmMockRecorder) DecryptionKeyIDs() *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecryptionKeyIDs", reflect.TypeOf((*MockEncryptionAlg)(nil).DecryptionKeyIDs))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecryptionKeyIDs", reflect.TypeOf((*MockEncryptionAlgorithm)(nil).DecryptionKeyIDs))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encrypt mocks base method
|
// Encrypt mocks base method
|
||||||
func (m *MockEncryptionAlg) Encrypt(value []byte) ([]byte, error) {
|
func (m *MockEncryptionAlgorithm) Encrypt(value []byte) ([]byte, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Encrypt", value)
|
ret := m.ctrl.Call(m, "Encrypt", value)
|
||||||
ret0, _ := ret[0].([]byte)
|
ret0, _ := ret[0].([]byte)
|
||||||
@ -121,13 +121,13 @@ func (m *MockEncryptionAlg) Encrypt(value []byte) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Encrypt indicates an expected call of Encrypt
|
// Encrypt indicates an expected call of Encrypt
|
||||||
func (mr *MockEncryptionAlgMockRecorder) Encrypt(value interface{}) *gomock.Call {
|
func (mr *MockEncryptionAlgorithmMockRecorder) Encrypt(value interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Encrypt", reflect.TypeOf((*MockEncryptionAlg)(nil).Encrypt), value)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Encrypt", reflect.TypeOf((*MockEncryptionAlgorithm)(nil).Encrypt), value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decrypt mocks base method
|
// Decrypt mocks base method
|
||||||
func (m *MockEncryptionAlg) Decrypt(hashed []byte, keyID string) ([]byte, error) {
|
func (m *MockEncryptionAlgorithm) Decrypt(hashed []byte, keyID string) ([]byte, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Decrypt", hashed, keyID)
|
ret := m.ctrl.Call(m, "Decrypt", hashed, keyID)
|
||||||
ret0, _ := ret[0].([]byte)
|
ret0, _ := ret[0].([]byte)
|
||||||
@ -136,13 +136,13 @@ func (m *MockEncryptionAlg) Decrypt(hashed []byte, keyID string) ([]byte, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Decrypt indicates an expected call of Decrypt
|
// Decrypt indicates an expected call of Decrypt
|
||||||
func (mr *MockEncryptionAlgMockRecorder) Decrypt(hashed, keyID interface{}) *gomock.Call {
|
func (mr *MockEncryptionAlgorithmMockRecorder) Decrypt(hashed, keyID interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Decrypt", reflect.TypeOf((*MockEncryptionAlg)(nil).Decrypt), hashed, keyID)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Decrypt", reflect.TypeOf((*MockEncryptionAlgorithm)(nil).Decrypt), hashed, keyID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecryptString mocks base method
|
// DecryptString mocks base method
|
||||||
func (m *MockEncryptionAlg) DecryptString(hashed []byte, keyID string) (string, error) {
|
func (m *MockEncryptionAlgorithm) DecryptString(hashed []byte, keyID string) (string, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "DecryptString", hashed, keyID)
|
ret := m.ctrl.Call(m, "DecryptString", hashed, keyID)
|
||||||
ret0, _ := ret[0].(string)
|
ret0, _ := ret[0].(string)
|
||||||
@ -151,36 +151,36 @@ func (m *MockEncryptionAlg) DecryptString(hashed []byte, keyID string) (string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DecryptString indicates an expected call of DecryptString
|
// DecryptString indicates an expected call of DecryptString
|
||||||
func (mr *MockEncryptionAlgMockRecorder) DecryptString(hashed, keyID interface{}) *gomock.Call {
|
func (mr *MockEncryptionAlgorithmMockRecorder) DecryptString(hashed, keyID interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecryptString", reflect.TypeOf((*MockEncryptionAlg)(nil).DecryptString), hashed, keyID)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DecryptString", reflect.TypeOf((*MockEncryptionAlgorithm)(nil).DecryptString), hashed, keyID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MockHashAlg is a mock of HashAlg interface
|
// MockHashAlgorithm is a mock of HashAlgorithm interface
|
||||||
type MockHashAlg struct {
|
type MockHashAlgorithm struct {
|
||||||
ctrl *gomock.Controller
|
ctrl *gomock.Controller
|
||||||
recorder *MockHashAlgMockRecorder
|
recorder *MockHashAlgorithmMockRecorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// MockHashAlgMockRecorder is the mock recorder for MockHashAlg
|
// MockHashAlgorithmMockRecorder is the mock recorder for MockHashAlgorithm
|
||||||
type MockHashAlgMockRecorder struct {
|
type MockHashAlgorithmMockRecorder struct {
|
||||||
mock *MockHashAlg
|
mock *MockHashAlgorithm
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMockHashAlg creates a new mock instance
|
// NewMockHashAlgorithm creates a new mock instance
|
||||||
func NewMockHashAlg(ctrl *gomock.Controller) *MockHashAlg {
|
func NewMockHashAlgorithm(ctrl *gomock.Controller) *MockHashAlgorithm {
|
||||||
mock := &MockHashAlg{ctrl: ctrl}
|
mock := &MockHashAlgorithm{ctrl: ctrl}
|
||||||
mock.recorder = &MockHashAlgMockRecorder{mock}
|
mock.recorder = &MockHashAlgorithmMockRecorder{mock}
|
||||||
return mock
|
return mock
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPECT returns an object that allows the caller to indicate expected use
|
// EXPECT returns an object that allows the caller to indicate expected use
|
||||||
func (m *MockHashAlg) EXPECT() *MockHashAlgMockRecorder {
|
func (m *MockHashAlgorithm) EXPECT() *MockHashAlgorithmMockRecorder {
|
||||||
return m.recorder
|
return m.recorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Algorithm mocks base method
|
// Algorithm mocks base method
|
||||||
func (m *MockHashAlg) Algorithm() string {
|
func (m *MockHashAlgorithm) Algorithm() string {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Algorithm")
|
ret := m.ctrl.Call(m, "Algorithm")
|
||||||
ret0, _ := ret[0].(string)
|
ret0, _ := ret[0].(string)
|
||||||
@ -188,13 +188,13 @@ func (m *MockHashAlg) Algorithm() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Algorithm indicates an expected call of Algorithm
|
// Algorithm indicates an expected call of Algorithm
|
||||||
func (mr *MockHashAlgMockRecorder) Algorithm() *gomock.Call {
|
func (mr *MockHashAlgorithmMockRecorder) Algorithm() *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Algorithm", reflect.TypeOf((*MockHashAlg)(nil).Algorithm))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Algorithm", reflect.TypeOf((*MockHashAlgorithm)(nil).Algorithm))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash mocks base method
|
// Hash mocks base method
|
||||||
func (m *MockHashAlg) Hash(value []byte) ([]byte, error) {
|
func (m *MockHashAlgorithm) Hash(value []byte) ([]byte, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Hash", value)
|
ret := m.ctrl.Call(m, "Hash", value)
|
||||||
ret0, _ := ret[0].([]byte)
|
ret0, _ := ret[0].([]byte)
|
||||||
@ -203,13 +203,13 @@ func (m *MockHashAlg) Hash(value []byte) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Hash indicates an expected call of Hash
|
// Hash indicates an expected call of Hash
|
||||||
func (mr *MockHashAlgMockRecorder) Hash(value interface{}) *gomock.Call {
|
func (mr *MockHashAlgorithmMockRecorder) Hash(value interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Hash", reflect.TypeOf((*MockHashAlg)(nil).Hash), value)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Hash", reflect.TypeOf((*MockHashAlgorithm)(nil).Hash), value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompareHash mocks base method
|
// CompareHash mocks base method
|
||||||
func (m *MockHashAlg) CompareHash(hashed, comparer []byte) error {
|
func (m *MockHashAlgorithm) CompareHash(hashed, comparer []byte) error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "CompareHash", hashed, comparer)
|
ret := m.ctrl.Call(m, "CompareHash", hashed, comparer)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
@ -217,7 +217,7 @@ func (m *MockHashAlg) CompareHash(hashed, comparer []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CompareHash indicates an expected call of CompareHash
|
// CompareHash indicates an expected call of CompareHash
|
||||||
func (mr *MockHashAlgMockRecorder) CompareHash(hashed, comparer interface{}) *gomock.Call {
|
func (mr *MockHashAlgorithmMockRecorder) CompareHash(hashed, comparer interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompareHash", reflect.TypeOf((*MockHashAlg)(nil).CompareHash), hashed, comparer)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompareHash", reflect.TypeOf((*MockHashAlgorithm)(nil).CompareHash), hashed, comparer)
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func TestCrypt(t *testing.T) {
|
|||||||
func TestEncrypt(t *testing.T) {
|
func TestEncrypt(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
value []byte
|
value []byte
|
||||||
c EncryptionAlg
|
c EncryptionAlgorithm
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -136,7 +136,7 @@ func TestEncrypt(t *testing.T) {
|
|||||||
func TestDecrypt(t *testing.T) {
|
func TestDecrypt(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
value *CryptoValue
|
value *CryptoValue
|
||||||
c EncryptionAlg
|
c EncryptionAlgorithm
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -174,7 +174,7 @@ func TestDecrypt(t *testing.T) {
|
|||||||
func TestDecryptString(t *testing.T) {
|
func TestDecryptString(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
value *CryptoValue
|
value *CryptoValue
|
||||||
c EncryptionAlg
|
c EncryptionAlgorithm
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -212,7 +212,7 @@ func TestDecryptString(t *testing.T) {
|
|||||||
func TestHash(t *testing.T) {
|
func TestHash(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
value []byte
|
value []byte
|
||||||
c HashAlg
|
c HashAlgorithm
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -245,7 +245,7 @@ func TestCompareHash(t *testing.T) {
|
|||||||
type args struct {
|
type args struct {
|
||||||
value *CryptoValue
|
value *CryptoValue
|
||||||
comparer []byte
|
comparer []byte
|
||||||
c HashAlg
|
c HashAlgorithm
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
Loading…
Reference in New Issue
Block a user