Documentation ¶
Overview ¶
Package pubsub is a generated GoMock package.
Package pubsub contains PubSub-related functionality, including: - authorization of accounts to subscribe; and - pushing of PubSub notifications when the AuthDB changes.
Index ¶
- Constants
- func AuthorizeSubscriber(ctx context.Context, email string) (retErr error)
- func DeauthorizeSubscriber(ctx context.Context, email string) (retErr error)
- func GetAuthDBChangeTopic(ctx context.Context) string
- func IsAuthorizedSubscriber(ctx context.Context, email string) (authorized bool, retErr error)
- func PublishAuthDBRevision(ctx context.Context, rev *protocol.AuthDBRevision, dryRun bool) error
- func RevokeStaleAuthorization(ctx context.Context, trustedGroup string, dryRun bool) (retErr error)
- func StubPolicy(emails ...string) *iam.Policy
- type MockPubsubClient
- func (m *MockPubsubClient) Close() error
- func (m *MockPubsubClient) EXPECT() *MockPubsubClientMockRecorder
- func (m *MockPubsubClient) GetIAMPolicy(ctx context.Context) (*iam.Policy, error)
- func (m *MockPubsubClient) Publish(ctx context.Context, msg *pubsub.Message) error
- func (m *MockPubsubClient) SetIAMPolicy(ctx context.Context, policy *iam.Policy) error
- type MockPubsubClientMockRecorder
- func (mr *MockPubsubClientMockRecorder) Close() *gomock.Call
- func (mr *MockPubsubClientMockRecorder) GetIAMPolicy(ctx interface{}) *gomock.Call
- func (mr *MockPubsubClientMockRecorder) Publish(ctx, msg interface{}) *gomock.Call
- func (mr *MockPubsubClientMockRecorder) SetIAMPolicy(ctx, policy interface{}) *gomock.Call
- type MockedPubsubClient
- type PubsubClient
Constants ¶
const (
// The topic name for AuthDB changes.
AuthDBChangeTopicName = "auth-db-changed"
)
Variables ¶
This section is empty.
Functions ¶
func AuthorizeSubscriber ¶
AuthorizeSubscriber authorizes the account to subscribe to Pubsub notifications of AuthDB changes.
Note this does not actually create the subscription, but rather, makes the account eligible to subscribe.
func DeauthorizeSubscriber ¶
DeauthorizeSubscriber revokes the subscribing authorization for the account to Pubsub notifications of AuthDB changes (i.e. making it ineligible to subscribe).
func GetAuthDBChangeTopic ¶
GetAuthDBChangeTopic returns the full topic path for changes to the AuthDB.
func IsAuthorizedSubscriber ¶
IsAuthorizedSubscriber returns whether the account is authorized to subscribe to Pubsub notifications of AuthDB changes.
func PublishAuthDBRevision ¶
PublishAuthDBRevision notifies subscribers there's another revision of the AuthDB available.
Publishing is skipped if: - the AuthDBRevision is invalid; or - the app server is a local development server; or - dryRun is true.
func RevokeStaleAuthorization ¶
RevokeStaleAuthorization revokes the subscribing authorization for all accounts that are no longer in the given trusted group.
func StubPolicy ¶
StubPolicy returns a stub IAM policy, where only the given emails have been granted the subscriber role. The stub policy can be used as the return value of mocks in tests.
Types ¶
type MockPubsubClient ¶
type MockPubsubClient struct {
// contains filtered or unexported fields
}
MockPubsubClient is a mock of PubsubClient interface.
func NewMockPubsubClient ¶
func NewMockPubsubClient(ctrl *gomock.Controller) *MockPubsubClient
NewMockPubsubClient creates a new mock instance.
func (*MockPubsubClient) EXPECT ¶
func (m *MockPubsubClient) EXPECT() *MockPubsubClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPubsubClient) GetIAMPolicy ¶
GetIAMPolicy mocks base method.
func (*MockPubsubClient) SetIAMPolicy ¶
SetIAMPolicy mocks base method.
type MockPubsubClientMockRecorder ¶
type MockPubsubClientMockRecorder struct {
// contains filtered or unexported fields
}
MockPubsubClientMockRecorder is the mock recorder for MockPubsubClient.
func (*MockPubsubClientMockRecorder) Close ¶
func (mr *MockPubsubClientMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockPubsubClientMockRecorder) GetIAMPolicy ¶
func (mr *MockPubsubClientMockRecorder) GetIAMPolicy(ctx interface{}) *gomock.Call
GetIAMPolicy indicates an expected call of GetIAMPolicy.
func (*MockPubsubClientMockRecorder) Publish ¶
func (mr *MockPubsubClientMockRecorder) Publish(ctx, msg interface{}) *gomock.Call
Publish indicates an expected call of Publish.
func (*MockPubsubClientMockRecorder) SetIAMPolicy ¶
func (mr *MockPubsubClientMockRecorder) SetIAMPolicy(ctx, policy interface{}) *gomock.Call
SetIAMPolicy indicates an expected call of SetIAMPolicy.
type MockedPubsubClient ¶
type MockedPubsubClient struct { Client *MockPubsubClient Ctx context.Context }
MockedPubsubClient is a mocked Pubsub client for testing. It wraps a MockPubsubClient and a context with the mocked client.
func NewMockedClient ¶
func NewMockedClient(ctx context.Context, ctl *gomock.Controller) *MockedPubsubClient
NewMockedClient returns a new MockedPubsubClient for testing.
type PubsubClient ¶
type PubsubClient interface { // Close closes the connection to the Pubsub server. Close() error // GetIAMPolicy returns the IAM policy for the AuthDBChange topic. GetIAMPolicy(ctx context.Context) (*iam.Policy, error) // SetIAMPolicy sets the IAM policy for the AuthDBChange topic. SetIAMPolicy(ctx context.Context, policy *iam.Policy) error // Publish publishes the message to the AuthDBChange topic. Publish(ctx context.Context, msg *pubsub.Message) error }
PubsubClient abstracts functionality to connect with Pubsub.
Non-production implementations are used for unit testing.