42 lines
968 B
Go
42 lines
968 B
Go
package bolt_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
platform "github.com/influxdata/influxdb"
|
|
platformtesting "github.com/influxdata/influxdb/testing"
|
|
)
|
|
|
|
func initBasicAuthService(f platformtesting.UserFields, t *testing.T) (platform.BasicAuthService, func()) {
|
|
c, closeFn, err := NewTestClient()
|
|
if err != nil {
|
|
t.Fatalf("failed to create new bolt client: %v", err)
|
|
}
|
|
c.IDGenerator = f.IDGenerator
|
|
ctx := context.Background()
|
|
for _, u := range f.Users {
|
|
if err := c.PutUser(ctx, u); err != nil {
|
|
t.Fatalf("failed to populate users")
|
|
}
|
|
}
|
|
return c, func() {
|
|
defer closeFn()
|
|
for _, u := range f.Users {
|
|
if err := c.DeleteUser(ctx, u.ID); err != nil {
|
|
t.Logf("failed to remove users: %v", err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestBasicAuth(t *testing.T) {
|
|
t.Parallel()
|
|
platformtesting.BasicAuth(initBasicAuthService, t)
|
|
}
|
|
|
|
func TestBasicAuth_CompareAndSet(t *testing.T) {
|
|
t.Parallel()
|
|
platformtesting.CompareAndSetPassword(initBasicAuthService, t)
|
|
}
|