mock

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeExtensionImpl

type FakeExtensionImpl struct {
	MockCreateFirebaseCustomTokenFn           func(ctx context.Context, uid string) (string, error)
	MockAuthenticateCustomFirebaseTokenFn     func(customAuthToken string) (*firebasetools.FirebaseUserTokens, error)
	MockGetLoggedInUserUIDFn                  func(ctx context.Context) (string, error)
	MockMakeRequestFn                         func(ctx context.Context, method string, path string, body interface{}) (*http.Response, error)
	MockLoginFn                               func(ctx context.Context) http.HandlerFunc
	MockNamespacePubsubIdentifierFn           func(serviceName string, topicID string, environment string, version string) string
	MockPublishToPubsubFn                     func(ctx context.Context, pubsubClient *pubsub.Client, topicID string, environment string, serviceName string, version string, payload []byte) error
	MockEnsureTopicsExistFn                   func(ctx context.Context, pubsubClient *pubsub.Client, topicIDs []string) error
	MockEnsureSubscriptionsExistFn            func(ctx context.Context, pubsubClient *pubsub.Client, topicSubscriptionMap map[string]string, callbackURL string) error
	MockVerifyPubSubJWTAndDecodePayloadFn     func(w http.ResponseWriter, r *http.Request) (*pubsubtools.PubSubPayload, error)
	MockLoadDepsFromYAMLFn                    func() (*interserviceclient.DepsConfig, error)
	MockSetupISCclientFn                      func(config interserviceclient.DepsConfig, serviceName string) (*interserviceclient.InterServiceClient, error)
	MockCreateFirebaseCustomTokenWithClaimsFn func(ctx context.Context, uid string, claims map[string]interface{}) (string, error)
}

FakeExtensionImpl mocks the external calls logic

func NewFakeExtension

func NewFakeExtension() *FakeExtensionImpl

NewFakeExtension initializes a new instance of the external calls mock

func (*FakeExtensionImpl) AuthenticateCustomFirebaseToken

func (f *FakeExtensionImpl) AuthenticateCustomFirebaseToken(customAuthToken string) (*firebasetools.FirebaseUserTokens, error)

AuthenticateCustomFirebaseToken mocks the authenticate custom firebase token method

func (*FakeExtensionImpl) CreateFirebaseCustomToken

func (f *FakeExtensionImpl) CreateFirebaseCustomToken(ctx context.Context, uid string) (string, error)

CreateFirebaseCustomToken mocks the create firebase custom token method

func (*FakeExtensionImpl) CreateFirebaseCustomTokenWithClaims

func (f *FakeExtensionImpl) CreateFirebaseCustomTokenWithClaims(ctx context.Context, uid string, claims map[string]interface{}) (string, error)

CreateFirebaseCustomTokenWithClaims creates a custom auth token for the user with the indicated UID and additional claims

func (*FakeExtensionImpl) EnsureSubscriptionsExist

func (f *FakeExtensionImpl) EnsureSubscriptionsExist(ctx context.Context, pubsubClient *pubsub.Client, topicSubscriptionMap map[string]string, callbackURL string) error

EnsureSubscriptionsExist ensures that the subscriptions named in the supplied topic:subscription map exist. If any does not exist, it is created.

func (*FakeExtensionImpl) EnsureTopicsExist

func (f *FakeExtensionImpl) EnsureTopicsExist(ctx context.Context, pubsubClient *pubsub.Client, topicIDs []string) error

EnsureTopicsExist creates the topic(s) in the suppplied list if they do not already exist.

func (*FakeExtensionImpl) GetLoggedInUserUID

func (f *FakeExtensionImpl) GetLoggedInUserUID(ctx context.Context) (string, error)

GetLoggedInUserUID mocks the implementation of getting a logged in user

func (*FakeExtensionImpl) LoadDepsFromYAML

func (f *FakeExtensionImpl) LoadDepsFromYAML() (*interserviceclient.DepsConfig, error)

LoadDepsFromYAML loads the dependency config

func (*FakeExtensionImpl) Login

Login mocks the login implementation to retrieve a token

func (*FakeExtensionImpl) MakeRequest

func (f *FakeExtensionImpl) MakeRequest(ctx context.Context, method string, path string, body interface{}) (*http.Response, error)

MakeRequest mocks the implementation of making a http request

func (*FakeExtensionImpl) PublishToPubsub

func (f *FakeExtensionImpl) PublishToPubsub(ctx context.Context, pubsubClient *pubsub.Client, topicID string, environment string, serviceName string, version string, payload []byte) error

PublishToPubsub sends the supplied payload to the indicated topic

func (*FakeExtensionImpl) SetupISCclient

SetupISCclient creates an isc client

func (*FakeExtensionImpl) VerifyPubSubJWTAndDecodePayload

func (f *FakeExtensionImpl) VerifyPubSubJWTAndDecodePayload(w http.ResponseWriter, r *http.Request) (*pubsubtools.PubSubPayload, error)

VerifyPubSubJWTAndDecodePayload confirms that there is a valid Google signed JWT and decodes the pubsub message payload into a struct.

It's use will simplify & shorten the handler funcs that process Cloud Pubsub push notifications.

Jump to

Keyboard shortcuts

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