34 lines
840 B
Go
34 lines
840 B
Go
|
|
package httpauth_test
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"firebase.google.com/go/v4/auth"
|
||
|
|
|
||
|
|
httpauth "code.nochebuena.dev/go/httpauth-firebase"
|
||
|
|
"code.nochebuena.dev/go/rbac"
|
||
|
|
)
|
||
|
|
|
||
|
|
type mockVerifier struct{}
|
||
|
|
|
||
|
|
func (m *mockVerifier) VerifyIDTokenAndCheckRevoked(_ context.Context, _ string) (*auth.Token, error) {
|
||
|
|
return nil, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
type mockEnricher struct{}
|
||
|
|
|
||
|
|
func (m *mockEnricher) Enrich(_ context.Context, _ string, _ map[string]any) (rbac.Identity, error) {
|
||
|
|
return rbac.Identity{}, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
type mockProvider struct{}
|
||
|
|
|
||
|
|
func (m *mockProvider) ResolveMask(_ context.Context, _, _ string) (rbac.PermissionMask, error) {
|
||
|
|
return 0, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// Compile-time interface satisfaction checks.
|
||
|
|
var _ httpauth.TokenVerifier = (*mockVerifier)(nil)
|
||
|
|
var _ httpauth.IdentityEnricher = (*mockEnricher)(nil)
|
||
|
|
var _ httpauth.PermissionProvider = (*mockProvider)(nil)
|