github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/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 "gopkg.in/juju/names.v2" 8 "gopkg.in/macaroon.v2-unstable" 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 ServerMacaroon(a *Authenticator) (*macaroon.Macaroon, error) { 20 auth, err := a.authContext.externalMacaroonAuth() 21 if err != nil { 22 return nil, err 23 } 24 return auth.(*authentication.ExternalMacaroonAuthenticator).Macaroon, nil 25 } 26 27 func ServerBakeryService(a *Authenticator) (authentication.BakeryService, error) { 28 auth, err := a.authContext.externalMacaroonAuth() 29 if err != nil { 30 return nil, err 31 } 32 return auth.(*authentication.ExternalMacaroonAuthenticator).Service, nil 33 }