Documentation
¶
Overview ¶
Package test runs tests against LDAP directories, OpenLDAP, 389 DS and SMB LDS, with a manager connected to each. Each directory is in a container which starts when a test first needs it, and is shared by the package's tests, until they've all run. They need docker, and are skipped with -short. LDAP_TEST_SERVER chooses some of them, separated by commas, such as "openldap,389ds".
Index ¶
- Constants
- func Attribute(t *testing.T, server Server, dn, name string) []string
- func ForEach(t *testing.T, ...)
- func Main(m *testing.M)
- func Manager(t *testing.T, ctx context.Context, server Server, opts ...manager.Opt) *manager.Manager
- func OU(t *testing.T, ctx context.Context, m *manager.Manager) string
- func Subschema(t *testing.T, server Server) (classes, attrs []string)
- type Fake
- type Server
Constants ¶
const ServerEnv = "LDAP_TEST_SERVER"
ServerEnv chooses the servers, by name, separated by commas
Variables ¶
This section is empty.
Functions ¶
func Attribute ¶
Attribute returns the entry's values of the attribute, as the started server has them, read with go-ldap, not the manager, which hides some
func ForEach ¶
func ForEach(t *testing.T, fn func(t *testing.T, ctx context.Context, server Server, manager *manager.Manager), opts ...manager.Opt)
ForEach runs the test against each chosen directory, as a subtest, with a new manager, bound as the server's user, with the options, which is disconnected after it. It's skipped with -short.
func Main ¶
Main runs the tests, then stops the containers they started. It's called from a package's TestMain.
func Manager ¶
func Manager(t *testing.T, ctx context.Context, server Server, opts ...manager.Opt) *manager.Manager
Manager returns a manager of the started server, bound as its user, with the options, which is disconnected when the test ends
Types ¶
type Fake ¶
type Fake struct {
sync.Mutex
// When they're set, BeforeAdd and BeforeModify are called before an add
// or modify of the DN is answered, and Stall stops a request of the
// operation, such as ldap.ApplicationBindRequest, being answered
BeforeAdd func(dn string)
BeforeModify func(dn string)
Stall func(op uint8, dn string) bool
// contains filtered or unexported fields
}
Fake is an LDAP directory in memory, which answers binds, searches of one entry, by its DN, or of the entries directly under it, adds, modifies, deletes and password modifies, so tests can make a request stall, or another manager change something first, every time. It has no schema, filters, paging, renames or extended operations, so the directories in containers are for everything else.
func NewFake ¶
NewFake returns a directory listening on localhost, with TLS, whose certificate isn't trusted, when secure is true, which is closed when the test ends
func (*Fake) Connections ¶
Connections returns how many connections the directory has accepted
func (*Fake) Drop ¶
func (d *Fake) Drop()
Drop closes the connections the directory has accepted, as a directory which goes away does
func (*Fake) Requests ¶
Requests returns the requests of the operation, as their DNs: "bind", "search", "add", "modify", "delete", "password" or "whoami"
type Server ¶
type Server struct {
Name string
Image string
TLSPort string
BaseDN string
BindDN string
BindPassword string
UserDN string
GroupDN string
Env map[string]string
// URL is the ldaps URL of the server's container, when it's started.
// Its certificate isn't trusted.
URL string
// ActiveDirectory is true when the directory is Active Directory, or
// like it, whose users have the "user" class, and unicodePwd passwords
ActiveDirectory bool
// KeepsOldPassword is true when a user's old password still binds for
// a while after it's changed, as Samba's "old password allowed period"
// does, for an hour
KeepsOldPassword bool
// ConnectTimeout is how long the directory can take to accept a bind,
// once its container has started
ConnectTimeout time.Duration
// contains filtered or unexported fields
}
Server is a directory which the tests run against