github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/state/apiserver/export_test.go (about)

     1  // Copyright 2012, 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package apiserver
     5  
     6  import (
     7  	"reflect"
     8  
     9  	"github.com/juju/juju/state"
    10  	"github.com/juju/juju/state/api/params"
    11  )
    12  
    13  var (
    14  	RootType              = reflect.TypeOf(&srvRoot{})
    15  	NewPingTimeout        = newPingTimeout
    16  	MaxClientPingInterval = &maxClientPingInterval
    17  	MongoPingInterval     = &mongoPingInterval
    18  )
    19  
    20  const LoginRateLimit = loginRateLimit
    21  
    22  // DelayLogins changes how the Login code works so that logins won't proceed
    23  // until they get a message on the returned channel.
    24  // After calling this function, the caller is responsible for sending messages
    25  // on the nextChan in order for Logins to succeed. The original behavior can be
    26  // restored by calling the cleanup function.
    27  func DelayLogins() (nextChan chan struct{}, cleanup func()) {
    28  	nextChan = make(chan struct{}, 10)
    29  	cleanup = func() {
    30  		doCheckCreds = checkCreds
    31  	}
    32  	delayedCheckCreds := func(st *state.State, c params.Creds) (taggedAuthenticator, error) {
    33  		<-nextChan
    34  		return checkCreds(st, c)
    35  	}
    36  	doCheckCreds = delayedCheckCreds
    37  	return
    38  }
    39  
    40  func NewErrRoot(err error) *errRoot {
    41  	return &errRoot{err}
    42  }