fake.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. */
  12. package fake
  13. import ksm "github.com/keeper-security/secrets-manager-go/core"
  14. type MockKeeperClient struct {
  15. GetSecretsFn func([]string) ([]*ksm.Record, error)
  16. GetSecretByTitleFn func(recordTitle string) (*ksm.Record, error)
  17. CreateSecretWithRecordDataFn func(recUID, folderUID string, recordData *ksm.RecordCreate) (string, error)
  18. DeleteSecretsFn func(recrecordUids []string) (map[string]string, error)
  19. SaveFn func(record *ksm.Record) error
  20. }
  21. type GetSecretsMockReturn struct {
  22. Secrets []*ksm.Record
  23. Err error
  24. }
  25. type GetSecretsByTitleMockReturn struct {
  26. Secret *ksm.Record
  27. Err error
  28. }
  29. type CreateSecretWithRecordDataMockReturn struct {
  30. ID string
  31. Err error
  32. }
  33. func (mc *MockKeeperClient) GetSecrets(filter []string) ([]*ksm.Record, error) {
  34. return mc.GetSecretsFn(filter)
  35. }
  36. func (mc *MockKeeperClient) GetSecretByTitle(recordTitle string) (*ksm.Record, error) {
  37. return mc.GetSecretByTitleFn(recordTitle)
  38. }
  39. func (mc *MockKeeperClient) CreateSecretWithRecordData(recUID, folderUID string, recordData *ksm.RecordCreate) (string, error) {
  40. return mc.CreateSecretWithRecordDataFn(recUID, folderUID, recordData)
  41. }
  42. func (mc *MockKeeperClient) DeleteSecrets(recrecordUids []string) (map[string]string, error) {
  43. return mc.DeleteSecretsFn(recrecordUids)
  44. }
  45. func (mc *MockKeeperClient) Save(record *ksm.Record) error {
  46. return mc.SaveFn(record)
  47. }