testclient

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfig

func NewConfig(client ldap.Client) ldapclient.Config

NewConfig creates a new Config impl that regurgitates the given data

func NewDNMappingClient

func NewDNMappingClient(parent ldap.Client, DNMapping map[string][]*ldap.Entry) ldap.Client

NewDNMappingClient returns a new DNMappingClient sitting on top of the parent client. This client returns the ldap entries mapped to with this DN in its' internal DN map, or defers to the parent if the DN is not mapped.

func NewMatchingSearchErrorClient

func NewMatchingSearchErrorClient(parent ldap.Client, baseDN string, returnErr error) ldap.Client

NewMatchingSearchErrorClient returns a new MatchingSeachError client sitting on top of the parent client. This client returns the given error when a search base DN matches the given base DN, and defers to the parent otherwise.

func NewPagingOnlyClient added in v1.1.3

func NewPagingOnlyClient(parent ldap.Client, response *ldap.SearchResult) ldap.Client

NewPagingOnlyClient returns a new PagingOnlyClient sitting on top of the parent client. This client returns the provided search response for any calls to SearchWithPaging, or defers to the parent if the call is not to the paged search function.

Types

type DNMappingClient

type DNMappingClient struct {
	ldap.Client
	DNMapping map[string][]*ldap.Entry
}

DNMappingClient returns the LDAP entry mapped to by the base dn given, or if no mapping happens, defers to the parent

func (*DNMappingClient) Search

func (c *DNMappingClient) Search(searchRequest *ldap.SearchRequest) (*ldap.SearchResult, error)

type Fake

type Fake struct {
	SimpleBindResponse     *ldap.SimpleBindResult
	PasswordModifyResponse *ldap.PasswordModifyResult
	SearchResponse         *ldap.SearchResult
}

Fake is a mock client for an LDAP server The following methods define safe defaults for the return values. In order to adapt this test client for a specific test, anonymously include it and override the method being tested. In the over-riden method, if you are not covering all method calls with your override, defer to the parent for handling.

func New

func New() *Fake

NewTestClient returns a new test client with safe default return values

func (*Fake) Add

func (c *Fake) Add(addRequest *ldap.AddRequest) error

Add forwards an addition request to the LDAP server

func (*Fake) Bind

func (c *Fake) Bind(username, password string) error

Bind binds to the LDAP server with a bind DN and password

func (*Fake) Close

func (c *Fake) Close()

Close closes an LDAP connection

func (*Fake) Compare

func (c *Fake) Compare(dn, attribute, value string) (bool, error)

Compare ... ?

func (*Fake) Del

func (c *Fake) Del(delRequest *ldap.DelRequest) error

Del forwards a deletion request to the LDAP server

func (*Fake) Modify

func (c *Fake) Modify(modifyRequest *ldap.ModifyRequest) error

Modify forwards a modification request to the LDAP server

func (*Fake) PasswordModify

func (c *Fake) PasswordModify(passwordModifyRequest *ldap.PasswordModifyRequest) (*ldap.PasswordModifyResult, error)

PasswordModify forwards a password modify request to the LDAP server

func (*Fake) Search

func (c *Fake) Search(searchRequest *ldap.SearchRequest) (*ldap.SearchResult, error)

Search forwards a search request to the LDAP server

func (*Fake) SearchWithPaging

func (c *Fake) SearchWithPaging(searchRequest *ldap.SearchRequest, pagingSize uint32) (*ldap.SearchResult, error)

SearchWithPaging forwards a search request to the LDAP server and pages the response

func (*Fake) SimpleBind

func (c *Fake) SimpleBind(simpleBindRequest *ldap.SimpleBindRequest) (*ldap.SimpleBindResult, error)

SimpleBind binds to the LDAP server using the Simple Bind mechanism

func (*Fake) Start

func (c *Fake) Start()

Start starts the LDAP connection

func (*Fake) StartTLS

func (c *Fake) StartTLS(config *tls.Config) error

StartTLS begins a TLS-wrapped LDAP connection

type MatchingSearchErrClient

type MatchingSearchErrClient struct {
	ldap.Client
	BaseDN    string
	ReturnErr error
}

MatchingSearchErrClient returns the ReturnErr on every Search() where the search base DN matches the given DN or defers the search to the parent client

func (*MatchingSearchErrClient) Search

func (c *MatchingSearchErrClient) Search(searchRequest *ldap.SearchRequest) (*ldap.SearchResult, error)

type PagingOnlyClient added in v1.1.3

type PagingOnlyClient struct {
	ldap.Client
	Response *ldap.SearchResult
}

PagingOnlyClient responds with a canned search result for any calls to SearchWithPaging

func (*PagingOnlyClient) SearchWithPaging added in v1.1.3

func (c *PagingOnlyClient) SearchWithPaging(searchRequest *ldap.SearchRequest, pagingSize uint32) (*ldap.SearchResult, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL