summaryrefslogtreecommitdiff
path: root/backend_test.go
diff options
context:
space:
mode:
authorAria <me@aria.rip>2023-09-25 00:12:03 +0100
committerAria <me@aria.rip>2023-09-25 00:12:03 +0100
commit0bd62b1d8b13ad1d38f61a6388c1f2e292b191a5 (patch)
tree68cf96bbcd113061daab8adabdfc8cb4fccde27f /backend_test.go
fockin BOOOILLEEERPLAAATEEE
Diffstat (limited to 'backend_test.go')
-rw-r--r--backend_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/backend_test.go b/backend_test.go
new file mode 100644
index 0000000..3452533
--- /dev/null
+++ b/backend_test.go
@@ -0,0 +1,41 @@
+package secretsengine
+
+import (
+ "context"
+ "fmt"
+
+ log "github.com/hashicorp/go-hclog"
+ "github.com/hashicorp/vault/sdk/helper/logging"
+ "github.com/hashicorp/vault/sdk/logical"
+)
+
+func getBackend() (*krbBackend, logical.Storage) {
+ config := &logical.BackendConfig{
+ Logger: logging.NewVaultLogger(log.Debug),
+ StorageView: &logical.InmemStorage{},
+ }
+
+ b := newBackend()
+ b.Setup(context.Background(), config)
+
+ return b, config.StorageView
+}
+
+var _ KerberosClient = fakeLdapClient{}
+
+type fakeLdapClient struct {
+ passwords map[string]string
+}
+
+func (c fakeLdapClient) SetPassword(username string, password string) error {
+ c.passwords[username] = password
+ return nil
+}
+
+func (c fakeLdapClient) SetPasswordWithOld(username string, oldPassword, newPassword string) error {
+ if realOldPassword, ok := c.passwords[username]; ok && oldPassword != realOldPassword {
+ return fmt.Errorf("invalid old password")
+ }
+ c.passwords[username] = newPassword
+ return nil
+}