simplify token issuer/verifier interface
This commit is contained in:
@@ -19,14 +19,14 @@ type FakeKeyProvider struct {
|
||||
getSecretReturnsOnCall map[int]struct {
|
||||
result1 string
|
||||
}
|
||||
KeyCountStub func() int
|
||||
keyCountMutex sync.RWMutex
|
||||
keyCountArgsForCall []struct {
|
||||
NumKeysStub func() int
|
||||
numKeysMutex sync.RWMutex
|
||||
numKeysArgsForCall []struct {
|
||||
}
|
||||
keyCountReturns struct {
|
||||
numKeysReturns struct {
|
||||
result1 int
|
||||
}
|
||||
keyCountReturnsOnCall map[int]struct {
|
||||
numKeysReturnsOnCall map[int]struct {
|
||||
result1 int
|
||||
}
|
||||
invocations map[string][][]interface{}
|
||||
@@ -95,14 +95,14 @@ func (fake *FakeKeyProvider) GetSecretReturnsOnCall(i int, result1 string) {
|
||||
}
|
||||
|
||||
func (fake *FakeKeyProvider) NumKeys() int {
|
||||
fake.keyCountMutex.Lock()
|
||||
ret, specificReturn := fake.keyCountReturnsOnCall[len(fake.keyCountArgsForCall)]
|
||||
fake.keyCountArgsForCall = append(fake.keyCountArgsForCall, struct {
|
||||
fake.numKeysMutex.Lock()
|
||||
ret, specificReturn := fake.numKeysReturnsOnCall[len(fake.numKeysArgsForCall)]
|
||||
fake.numKeysArgsForCall = append(fake.numKeysArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.KeyCountStub
|
||||
fakeReturns := fake.keyCountReturns
|
||||
stub := fake.NumKeysStub
|
||||
fakeReturns := fake.numKeysReturns
|
||||
fake.recordInvocation("NumKeys", []interface{}{})
|
||||
fake.keyCountMutex.Unlock()
|
||||
fake.numKeysMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
@@ -112,37 +112,37 @@ func (fake *FakeKeyProvider) NumKeys() int {
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *FakeKeyProvider) KeyCountCallCount() int {
|
||||
fake.keyCountMutex.RLock()
|
||||
defer fake.keyCountMutex.RUnlock()
|
||||
return len(fake.keyCountArgsForCall)
|
||||
func (fake *FakeKeyProvider) NumKeysCallCount() int {
|
||||
fake.numKeysMutex.RLock()
|
||||
defer fake.numKeysMutex.RUnlock()
|
||||
return len(fake.numKeysArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeKeyProvider) KeyCountCalls(stub func() int) {
|
||||
fake.keyCountMutex.Lock()
|
||||
defer fake.keyCountMutex.Unlock()
|
||||
fake.KeyCountStub = stub
|
||||
func (fake *FakeKeyProvider) NumKeysCalls(stub func() int) {
|
||||
fake.numKeysMutex.Lock()
|
||||
defer fake.numKeysMutex.Unlock()
|
||||
fake.NumKeysStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeKeyProvider) KeyCountReturns(result1 int) {
|
||||
fake.keyCountMutex.Lock()
|
||||
defer fake.keyCountMutex.Unlock()
|
||||
fake.KeyCountStub = nil
|
||||
fake.keyCountReturns = struct {
|
||||
func (fake *FakeKeyProvider) NumKeysReturns(result1 int) {
|
||||
fake.numKeysMutex.Lock()
|
||||
defer fake.numKeysMutex.Unlock()
|
||||
fake.NumKeysStub = nil
|
||||
fake.numKeysReturns = struct {
|
||||
result1 int
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeKeyProvider) KeyCountReturnsOnCall(i int, result1 int) {
|
||||
fake.keyCountMutex.Lock()
|
||||
defer fake.keyCountMutex.Unlock()
|
||||
fake.KeyCountStub = nil
|
||||
if fake.keyCountReturnsOnCall == nil {
|
||||
fake.keyCountReturnsOnCall = make(map[int]struct {
|
||||
func (fake *FakeKeyProvider) NumKeysReturnsOnCall(i int, result1 int) {
|
||||
fake.numKeysMutex.Lock()
|
||||
defer fake.numKeysMutex.Unlock()
|
||||
fake.NumKeysStub = nil
|
||||
if fake.numKeysReturnsOnCall == nil {
|
||||
fake.numKeysReturnsOnCall = make(map[int]struct {
|
||||
result1 int
|
||||
})
|
||||
}
|
||||
fake.keyCountReturnsOnCall[i] = struct {
|
||||
fake.numKeysReturnsOnCall[i] = struct {
|
||||
result1 int
|
||||
}{result1}
|
||||
}
|
||||
@@ -152,8 +152,8 @@ func (fake *FakeKeyProvider) Invocations() map[string][][]interface{} {
|
||||
defer fake.invocationsMutex.RUnlock()
|
||||
fake.getSecretMutex.RLock()
|
||||
defer fake.getSecretMutex.RUnlock()
|
||||
fake.keyCountMutex.RLock()
|
||||
defer fake.keyCountMutex.RUnlock()
|
||||
fake.numKeysMutex.RLock()
|
||||
defer fake.numKeysMutex.RUnlock()
|
||||
copiedInvocations := map[string][][]interface{}{}
|
||||
for key, value := range fake.invocations {
|
||||
copiedInvocations[key] = value
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
// Code generated by counterfeiter. DO NOT EDIT.
|
||||
package authfakes
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/auth"
|
||||
)
|
||||
|
||||
type FakeTokenIssuer struct {
|
||||
CreateTokenStub func(*auth.GrantClaims, time.Duration) (string, error)
|
||||
createTokenMutex sync.RWMutex
|
||||
createTokenArgsForCall []struct {
|
||||
arg1 *auth.GrantClaims
|
||||
arg2 time.Duration
|
||||
}
|
||||
createTokenReturns struct {
|
||||
result1 string
|
||||
result2 error
|
||||
}
|
||||
createTokenReturnsOnCall map[int]struct {
|
||||
result1 string
|
||||
result2 error
|
||||
}
|
||||
invocations map[string][][]interface{}
|
||||
invocationsMutex sync.RWMutex
|
||||
}
|
||||
|
||||
func (fake *FakeTokenIssuer) CreateToken(arg1 *auth.GrantClaims, arg2 time.Duration) (string, error) {
|
||||
fake.createTokenMutex.Lock()
|
||||
ret, specificReturn := fake.createTokenReturnsOnCall[len(fake.createTokenArgsForCall)]
|
||||
fake.createTokenArgsForCall = append(fake.createTokenArgsForCall, struct {
|
||||
arg1 *auth.GrantClaims
|
||||
arg2 time.Duration
|
||||
}{arg1, arg2})
|
||||
stub := fake.CreateTokenStub
|
||||
fakeReturns := fake.createTokenReturns
|
||||
fake.recordInvocation("CreateToken", []interface{}{arg1, arg2})
|
||||
fake.createTokenMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub(arg1, arg2)
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1, ret.result2
|
||||
}
|
||||
return fakeReturns.result1, fakeReturns.result2
|
||||
}
|
||||
|
||||
func (fake *FakeTokenIssuer) CreateTokenCallCount() int {
|
||||
fake.createTokenMutex.RLock()
|
||||
defer fake.createTokenMutex.RUnlock()
|
||||
return len(fake.createTokenArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeTokenIssuer) CreateTokenCalls(stub func(*auth.GrantClaims, time.Duration) (string, error)) {
|
||||
fake.createTokenMutex.Lock()
|
||||
defer fake.createTokenMutex.Unlock()
|
||||
fake.CreateTokenStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeTokenIssuer) CreateTokenArgsForCall(i int) (*auth.GrantClaims, time.Duration) {
|
||||
fake.createTokenMutex.RLock()
|
||||
defer fake.createTokenMutex.RUnlock()
|
||||
argsForCall := fake.createTokenArgsForCall[i]
|
||||
return argsForCall.arg1, argsForCall.arg2
|
||||
}
|
||||
|
||||
func (fake *FakeTokenIssuer) CreateTokenReturns(result1 string, result2 error) {
|
||||
fake.createTokenMutex.Lock()
|
||||
defer fake.createTokenMutex.Unlock()
|
||||
fake.CreateTokenStub = nil
|
||||
fake.createTokenReturns = struct {
|
||||
result1 string
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *FakeTokenIssuer) CreateTokenReturnsOnCall(i int, result1 string, result2 error) {
|
||||
fake.createTokenMutex.Lock()
|
||||
defer fake.createTokenMutex.Unlock()
|
||||
fake.CreateTokenStub = nil
|
||||
if fake.createTokenReturnsOnCall == nil {
|
||||
fake.createTokenReturnsOnCall = make(map[int]struct {
|
||||
result1 string
|
||||
result2 error
|
||||
})
|
||||
}
|
||||
fake.createTokenReturnsOnCall[i] = struct {
|
||||
result1 string
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *FakeTokenIssuer) Invocations() map[string][][]interface{} {
|
||||
fake.invocationsMutex.RLock()
|
||||
defer fake.invocationsMutex.RUnlock()
|
||||
fake.createTokenMutex.RLock()
|
||||
defer fake.createTokenMutex.RUnlock()
|
||||
copiedInvocations := map[string][][]interface{}{}
|
||||
for key, value := range fake.invocations {
|
||||
copiedInvocations[key] = value
|
||||
}
|
||||
return copiedInvocations
|
||||
}
|
||||
|
||||
func (fake *FakeTokenIssuer) recordInvocation(key string, args []interface{}) {
|
||||
fake.invocationsMutex.Lock()
|
||||
defer fake.invocationsMutex.Unlock()
|
||||
if fake.invocations == nil {
|
||||
fake.invocations = map[string][][]interface{}{}
|
||||
}
|
||||
if fake.invocations[key] == nil {
|
||||
fake.invocations[key] = [][]interface{}{}
|
||||
}
|
||||
fake.invocations[key] = append(fake.invocations[key], args)
|
||||
}
|
||||
|
||||
var _ auth.TokenIssuer = new(FakeTokenIssuer)
|
||||
@@ -8,33 +8,98 @@ import (
|
||||
)
|
||||
|
||||
type FakeTokenVerifier struct {
|
||||
VerifyStub func() (*auth.GrantClaims, error)
|
||||
IdentityStub func() string
|
||||
identityMutex sync.RWMutex
|
||||
identityArgsForCall []struct {
|
||||
}
|
||||
identityReturns struct {
|
||||
result1 string
|
||||
}
|
||||
identityReturnsOnCall map[int]struct {
|
||||
result1 string
|
||||
}
|
||||
VerifyStub func(interface{}) (*auth.VideoGrant, error)
|
||||
verifyMutex sync.RWMutex
|
||||
verifyArgsForCall []struct {
|
||||
arg1 interface{}
|
||||
}
|
||||
verifyReturns struct {
|
||||
result1 *auth.GrantClaims
|
||||
result1 *auth.VideoGrant
|
||||
result2 error
|
||||
}
|
||||
verifyReturnsOnCall map[int]struct {
|
||||
result1 *auth.GrantClaims
|
||||
result1 *auth.VideoGrant
|
||||
result2 error
|
||||
}
|
||||
invocations map[string][][]interface{}
|
||||
invocationsMutex sync.RWMutex
|
||||
}
|
||||
|
||||
func (fake *FakeTokenVerifier) Verify() (*auth.GrantClaims, error) {
|
||||
func (fake *FakeTokenVerifier) Identity() string {
|
||||
fake.identityMutex.Lock()
|
||||
ret, specificReturn := fake.identityReturnsOnCall[len(fake.identityArgsForCall)]
|
||||
fake.identityArgsForCall = append(fake.identityArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.IdentityStub
|
||||
fakeReturns := fake.identityReturns
|
||||
fake.recordInvocation("Identity", []interface{}{})
|
||||
fake.identityMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *FakeTokenVerifier) IdentityCallCount() int {
|
||||
fake.identityMutex.RLock()
|
||||
defer fake.identityMutex.RUnlock()
|
||||
return len(fake.identityArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeTokenVerifier) IdentityCalls(stub func() string) {
|
||||
fake.identityMutex.Lock()
|
||||
defer fake.identityMutex.Unlock()
|
||||
fake.IdentityStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeTokenVerifier) IdentityReturns(result1 string) {
|
||||
fake.identityMutex.Lock()
|
||||
defer fake.identityMutex.Unlock()
|
||||
fake.IdentityStub = nil
|
||||
fake.identityReturns = struct {
|
||||
result1 string
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeTokenVerifier) IdentityReturnsOnCall(i int, result1 string) {
|
||||
fake.identityMutex.Lock()
|
||||
defer fake.identityMutex.Unlock()
|
||||
fake.IdentityStub = nil
|
||||
if fake.identityReturnsOnCall == nil {
|
||||
fake.identityReturnsOnCall = make(map[int]struct {
|
||||
result1 string
|
||||
})
|
||||
}
|
||||
fake.identityReturnsOnCall[i] = struct {
|
||||
result1 string
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeTokenVerifier) Verify(arg1 interface{}) (*auth.VideoGrant, error) {
|
||||
fake.verifyMutex.Lock()
|
||||
ret, specificReturn := fake.verifyReturnsOnCall[len(fake.verifyArgsForCall)]
|
||||
fake.verifyArgsForCall = append(fake.verifyArgsForCall, struct {
|
||||
}{})
|
||||
arg1 interface{}
|
||||
}{arg1})
|
||||
stub := fake.VerifyStub
|
||||
fakeReturns := fake.verifyReturns
|
||||
fake.recordInvocation("Verify", []interface{}{})
|
||||
fake.recordInvocation("Verify", []interface{}{arg1})
|
||||
fake.verifyMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
return stub(arg1)
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1, ret.result2
|
||||
@@ -48,34 +113,41 @@ func (fake *FakeTokenVerifier) VerifyCallCount() int {
|
||||
return len(fake.verifyArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeTokenVerifier) VerifyCalls(stub func() (*auth.GrantClaims, error)) {
|
||||
func (fake *FakeTokenVerifier) VerifyCalls(stub func(interface{}) (*auth.VideoGrant, error)) {
|
||||
fake.verifyMutex.Lock()
|
||||
defer fake.verifyMutex.Unlock()
|
||||
fake.VerifyStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeTokenVerifier) VerifyReturns(result1 *auth.GrantClaims, result2 error) {
|
||||
func (fake *FakeTokenVerifier) VerifyArgsForCall(i int) interface{} {
|
||||
fake.verifyMutex.RLock()
|
||||
defer fake.verifyMutex.RUnlock()
|
||||
argsForCall := fake.verifyArgsForCall[i]
|
||||
return argsForCall.arg1
|
||||
}
|
||||
|
||||
func (fake *FakeTokenVerifier) VerifyReturns(result1 *auth.VideoGrant, result2 error) {
|
||||
fake.verifyMutex.Lock()
|
||||
defer fake.verifyMutex.Unlock()
|
||||
fake.VerifyStub = nil
|
||||
fake.verifyReturns = struct {
|
||||
result1 *auth.GrantClaims
|
||||
result1 *auth.VideoGrant
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *FakeTokenVerifier) VerifyReturnsOnCall(i int, result1 *auth.GrantClaims, result2 error) {
|
||||
func (fake *FakeTokenVerifier) VerifyReturnsOnCall(i int, result1 *auth.VideoGrant, result2 error) {
|
||||
fake.verifyMutex.Lock()
|
||||
defer fake.verifyMutex.Unlock()
|
||||
fake.VerifyStub = nil
|
||||
if fake.verifyReturnsOnCall == nil {
|
||||
fake.verifyReturnsOnCall = make(map[int]struct {
|
||||
result1 *auth.GrantClaims
|
||||
result1 *auth.VideoGrant
|
||||
result2 error
|
||||
})
|
||||
}
|
||||
fake.verifyReturnsOnCall[i] = struct {
|
||||
result1 *auth.GrantClaims
|
||||
result1 *auth.VideoGrant
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
@@ -83,6 +155,8 @@ func (fake *FakeTokenVerifier) VerifyReturnsOnCall(i int, result1 *auth.GrantCla
|
||||
func (fake *FakeTokenVerifier) Invocations() map[string][][]interface{} {
|
||||
fake.invocationsMutex.RLock()
|
||||
defer fake.invocationsMutex.RUnlock()
|
||||
fake.identityMutex.RLock()
|
||||
defer fake.identityMutex.RUnlock()
|
||||
fake.verifyMutex.RLock()
|
||||
defer fake.verifyMutex.RUnlock()
|
||||
copiedInvocations := map[string][][]interface{}{}
|
||||
|
||||
Reference in New Issue
Block a user