pubsub

package
v0.0.0-...-d7353a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

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

View Source
const (
	// The topic name for AuthDB changes.
	AuthDBChangeTopicName = "auth-db-changed"
)

Variables

This section is empty.

Functions

func AuthorizeSubscriber

func AuthorizeSubscriber(ctx context.Context, email string) (retErr error)

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

func DeauthorizeSubscriber(ctx context.Context, email string) (retErr error)

DeauthorizeSubscriber revokes the subscribing authorization for the account to Pubsub notifications of AuthDB changes (i.e. making it ineligible to subscribe).

func GetAuthDBChangeTopic

func GetAuthDBChangeTopic(ctx context.Context) string

GetAuthDBChangeTopic returns the full topic path for changes to the AuthDB.

func IsAuthorizedSubscriber

func IsAuthorizedSubscriber(ctx context.Context, email string) (authorized bool, retErr error)

IsAuthorizedSubscriber returns whether the account is authorized to subscribe to Pubsub notifications of AuthDB changes.

func PublishAuthDBRevision

func PublishAuthDBRevision(ctx context.Context, rev *protocol.AuthDBRevision, dryRun bool) error

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

func RevokeStaleAuthorization(ctx context.Context, trustedGroup string, dryRun bool) (retErr error)

RevokeStaleAuthorization revokes the subscribing authorization for all accounts that are no longer in the given trusted group.

func StubPolicy

func StubPolicy(emails ...string) *iam.Policy

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) Close

func (m *MockPubsubClient) Close() error

Close mocks base method.

func (*MockPubsubClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPubsubClient) GetIAMPolicy

func (m *MockPubsubClient) GetIAMPolicy(ctx context.Context) (*iam.Policy, error)

GetIAMPolicy mocks base method.

func (*MockPubsubClient) Publish

func (m *MockPubsubClient) Publish(ctx context.Context, msg *pubsub.Message) error

Publish mocks base method.

func (*MockPubsubClient) SetIAMPolicy

func (m *MockPubsubClient) SetIAMPolicy(ctx context.Context, policy *iam.Policy) error

SetIAMPolicy mocks base method.

type MockPubsubClientMockRecorder

type MockPubsubClientMockRecorder struct {
	// contains filtered or unexported fields
}

MockPubsubClientMockRecorder is the mock recorder for MockPubsubClient.

func (*MockPubsubClientMockRecorder) Close

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL