# Functions
AddKeystoneAPIFixture adds a keystone-api simulator to an already created http server.
NewKeystoneAPIFixtureWithServer set up a keystone-api simulator with an embedded http server.
NewTestHelper returns a TestHelper.
# Structs
KeystoneAPIFixture is simulator for the OpenStack Keystone API for EnvTest You can simulate the happy path with the following code snippet:
f := NewKeystoneAPIFixtureWithServer(logger) f.Setup() DeferCleanup(f.Cleanup)
name := th.CreateKeystoneAPIWithFixture(namespace, f) DeferCleanup(th.DeleteKeystoneAPI, name)
But you can also inject failures by passing custom handlers to Setup:
f := NewKeystoneAPIFixtureWithServer(logger) f.Setup( Handler{Patter: "/", Func: f.HandleVersion}, Handler{Patter: "/v3/auth/tokens", Func: f.HandleToken}, Handler{Patter: "/v3/users", Func: func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": f.GetUsers(w, r) case "POST": w.WriteHeader(409) } }}, ) DeferCleanup(f.Cleanup).
TestHelper is a collection of helpers for testing operators.