github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/apiserver/stateauthenticator/export_test.go (about)

     1  // Copyright 2014-2018 Canonical Ltd. All rights reserved.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package stateauthenticator
     5  
     6  import (
     7  	"github.com/go-macaroon-bakery/macaroon-bakery/v3/bakery/identchecker"
     8  	"github.com/juju/names/v5"
     9  
    10  	"github.com/juju/juju/apiserver/authentication"
    11  )
    12  
    13  // TODO update the tests moved from apiserver to test via the public
    14  // interface, and then get rid of these.
    15  func EntityAuthenticator(authenticator *Authenticator, tag names.Tag) (authentication.EntityAuthenticator, error) {
    16  	return authenticator.authContext.authenticator("testing.invalid:1234").authenticatorForTag(tag)
    17  }
    18  
    19  func ServerBakery(a *Authenticator, identClient identchecker.IdentityClient) (*identchecker.Bakery, error) {
    20  	auth, err := a.authContext.externalMacaroonAuth(identClient)
    21  	if err != nil {
    22  		return nil, err
    23  	}
    24  	return auth.(*authentication.ExternalMacaroonAuthenticator).Bakery, nil
    25  }
    26  
    27  func ServerBakeryExpiresImmediately(a *Authenticator, identClient identchecker.IdentityClient) (*identchecker.Bakery, error) {
    28  	auth, err := newExternalMacaroonAuth(a.authContext.st, a.authContext.clock, 0, identClient)
    29  	if err != nil {
    30  		return nil, err
    31  	}
    32  	return auth.Bakery, nil
    33  }