fake.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. GetSecretsByTitleFn func(recordTitle string) (records []*ksm.Record, err error)
  18. CreateSecretWithRecordDataFn func(recUID, folderUID string, recordData *ksm.RecordCreate) (string, error)
  19. DeleteSecretsFn func(recrecordUids []string) (map[string]string, error)
  20. SaveFn func(record *ksm.Record) error
  21. }
  22. type GetSecretsMockReturn struct {
  23. Secrets []*ksm.Record
  24. Err error
  25. }
  26. type GetSecretsByTitleMockReturn struct {
  27. Secret *ksm.Record
  28. Err error
  29. }
  30. type CreateSecretWithRecordDataMockReturn struct {
  31. ID string
  32. Err error
  33. }
  34. func (mc *MockKeeperClient) GetSecrets(filter []string) ([]*ksm.Record, error) {
  35. return mc.GetSecretsFn(filter)
  36. }
  37. func (mc *MockKeeperClient) GetSecretByTitle(recordTitle string) (*ksm.Record, error) {
  38. return mc.GetSecretByTitleFn(recordTitle)
  39. }
  40. func (mc *MockKeeperClient) GetSecretsByTitle(recordTitle string) (records []*ksm.Record, err error) {
  41. return mc.GetSecretsByTitleFn(recordTitle)
  42. }
  43. func (mc *MockKeeperClient) CreateSecretWithRecordData(recUID, folderUID string, recordData *ksm.RecordCreate) (string, error) {
  44. return mc.CreateSecretWithRecordDataFn(recUID, folderUID, recordData)
  45. }
  46. func (mc *MockKeeperClient) DeleteSecrets(recrecordUids []string) (map[string]string, error) {
  47. return mc.DeleteSecretsFn(recrecordUids)
  48. }
  49. func (mc *MockKeeperClient) Save(record *ksm.Record) error {
  50. return mc.SaveFn(record)
  51. }