m365

package
v0.0.0-...-880cb89 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const IncrementalsDestContainerPrefix = "incrementals_ci_"

Does not use the tester.DefaultTestRestoreDestination syntax as some of these items are created directly, not as a result of restoration, and we want to ensure they get clearly selected without accidental overlap.

Variables

This section is empty.

Functions

func BuildCollections

func BuildCollections(
	t *testing.T,
	service path.ServiceType,
	tenant, user string,
	restoreCfg control.RestoreConfig,
	colls []IncrementalCollection,
) []data.RestoreCollection

func CheckBackupIsInManifests

func CheckBackupIsInManifests(
	t *testing.T,
	ctx context.Context,
	kw *kopia.Wrapper,
	sw store.BackupStorer,
	bo *operations.BackupOperation,
	sel selectors.Selector,
	resourceOwner string,
	categories ...path.CategoryType,
)

func CheckMetadataFilesExist

func CheckMetadataFilesExist(
	t *testing.T,
	ctx context.Context,
	backupID model.StableID,
	kw *kopia.Wrapper,
	ms *kopia.ModelStore,
	tenant, resourceOwner string,
	service path.ServiceType,
	filesByCat map[path.CategoryType][][]string,
)

func CheckRestoreCounts

func CheckRestoreCounts(
	t *testing.T,
	ctr *count.Bus,
	expectSkips, expectReplaces, expectNew int,
)

func ControllerWithSelector

func ControllerWithSelector(
	t *testing.T,
	ctx context.Context,
	acct account.Account,
	sel selectors.Selector,
	ins idname.Cacher,
	onFail func(*testing.T, context.Context),
	counter *count.Bus,
) (*m365.Controller, selectors.Selector)

A QoL builder for live instances that updates the selector's owner id and name in the process to help avoid gotchas.

func FilterCollisionKeyResults

func FilterCollisionKeyResults[T any](
	t *testing.T,
	ctx context.Context,
	protectedResourceID, containerID string,
	giicbck GetItemsInContainerByCollisionKeyer[T],
	filterOut map[string]T,
) map[string]T

func GenerateContainerOfItems

func GenerateContainerOfItems(
	t *testing.T,
	ctx context.Context,
	ctrl *m365.Controller,
	service path.ServiceType,
	cat path.CategoryType,
	sel selectors.Selector,
	tenantID, resourceOwner, siteID, driveID, destFldr string,
	howManyItems int,
	backupVersion int,
	dbf DataBuilderFunc,
) *details.Details

func GenerateItemData

func GenerateItemData(
	t *testing.T,
	category path.CategoryType,
	resourceOwner string,
	dbf DataBuilderFunc,
) (string, []byte)

func GetDriveCollKeysAndItemIDs

func GetDriveCollKeysAndItemIDs(
	t *testing.T,
	ctx context.Context,
	gikafbn GetItemsKeysAndFolderByNameer,
	driveID, parentContainerID string,
	containerNames ...string,
) (map[string]api.DriveItemIDType, map[string]api.DriveItemIDType)

func GetTestExtensionFactories

func GetTestExtensionFactories() []extensions.CreateItemExtensioner

func GockClient

func GockClient(creds account.M365Config, counter *count.Bus) (api.Client, error)

GockClient produces a new exchange api client that can be mocked using gock.

func NewTestBackupOp

func NewTestBackupOp(
	t *testing.T,
	ctx context.Context,
	bod *BackupOpDependencies,
	bus events.Eventer,
	opts control.Options,
	counter *count.Bus,
) operations.BackupOperation

NewTestBackupOp accepts the clients required to compose a backup operation, plus any other metadata, and uses them to generate a new backup operation. This allows backup chains to utilize the same temp directory and configuration details.

func NewTestRestoreOp

func NewTestRestoreOp(
	t *testing.T,
	ctx context.Context,
	rod *RestoreOpDependencies,
	backupID model.StableID,
	bus events.Eventer,
	counter *count.Bus,
	opts control.Options,
	restoreCfg control.RestoreConfig,
) operations.RestoreOperation

NewTestRestoreOp accepts the clients required to compose a restore operation, plus any other metadata, and uses them to generate a new restore operation. This allows restore chains to utilize the same temp directory and configuration details.

func RunAndCheckBackup

func RunAndCheckBackup(
	t *testing.T,
	ctx context.Context,
	bo *operations.BackupOperation,
	mb *evmock.Bus,
	acceptNoData bool,
)

func RunAndCheckRestore

func RunAndCheckRestore(
	t *testing.T,
	ctx context.Context,
	ro *operations.RestoreOperation,
	mb *evmock.Bus,
	acceptNoData bool,
) *details.Details

func RunBasicDriveishBackupTests

func RunBasicDriveishBackupTests(
	suite tester.Suite,
	service path.ServiceType,
	opts control.Options,
	sel selectors.Selector,
)

func RunDriveAssistBaseGroupsUpdate

func RunDriveAssistBaseGroupsUpdate(
	suite tester.Suite,
	sel selectors.Selector,
	expectCached bool,
)

func RunDriveRestoreToAlternateProtectedResource

func RunDriveRestoreToAlternateProtectedResource(
	t *testing.T,
	suite tester.Suite,
	ac api.Client,
	sel selectors.Selector,
	driveFrom, driveTo its.IDs,
	toResource string,
)

func RunDriveRestoreWithAdvancedOptions

func RunDriveRestoreWithAdvancedOptions(
	t *testing.T,
	suite tester.Suite,
	ac api.Client,
	sel selectors.Selector,
	driveID, rootFolderID string,
)

func RunDriveishBackupWithExtensionsTests

func RunDriveishBackupWithExtensionsTests(
	suite tester.Suite,
	service path.ServiceType,
	opts control.Options,
	sel selectors.Selector,
)

func RunIncrementalDriveishBackupTest

func RunIncrementalDriveishBackupTest(
	suite tester.Suite,
	opts control.Options,
	owner, permissionsUser string,
	service path.ServiceType,
	category path.CategoryType,
	includeContainers func([]string) selectors.Selector,
	getTestDriveID func(*testing.T, context.Context) string,
	getTestSiteID func(*testing.T, context.Context) string,
	getRestoreHandler func(api.Client) drive.RestoreHandler,
	skipPermissionsTests bool,
)

func RunMergeBaseGroupsUpdate

func RunMergeBaseGroupsUpdate(
	suite tester.Suite,
	sel selectors.Selector,
	expectCached bool,
)

func ToDataLayerPath

func ToDataLayerPath(
	t *testing.T,
	service path.ServiceType,
	tenant, resourceOwner string,
	category path.CategoryType,
	elements []string,
	isItem bool,
) path.Path

func VerifyExtensionData

func VerifyExtensionData(
	t *testing.T,
	itemInfo details.ItemInfo,
	p path.ServiceType,
)

Types

type BackupOpDependencies

type BackupOpDependencies struct {
	Acct account.Account
	Ctrl *m365.Controller
	KMS  *kopia.ModelStore
	KW   *kopia.Wrapper
	Sel  selectors.Selector
	SSS  streamstore.Streamer
	St   storage.Storage
	SW   store.BackupStorer
	// contains filtered or unexported fields
}

func PrepNewTestBackupOp

func PrepNewTestBackupOp(
	t *testing.T,
	ctx context.Context,
	bus events.Eventer,
	sel selectors.Selector,
	opts control.Options,
	backupVersion int,
	counter *count.Bus,
) (
	operations.BackupOperation,
	*BackupOpDependencies,
)

PrepNewTestBackupOp generates all clients required to run a backup operation, returning both a backup operation created with those clients, as well as the clients themselves.

func (*BackupOpDependencies) Close

func (bod *BackupOpDependencies) Close(
	t *testing.T,
	ctx context.Context,
)

type CreateFailFirstRead

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

func NewCreateSingleFileFailExtension

func NewCreateSingleFileFailExtension() *CreateFailFirstRead

func (*CreateFailFirstRead) CreateItemExtension

type DataBuilderFunc

type DataBuilderFunc func(id, timeStamp, subject, body string) []byte

the params here are what generateContainerOfItems passes into the func. the callback provider can use them, or not, as wanted.

type FailFirstRead

type FailFirstRead struct {
	io.ReadCloser
	// contains filtered or unexported fields
}

FailFirstRead fails the first read on a file being uploaded during a snapshot. Only one file is failed during the snapshot even if it the snapshot contains multiple files.

func (*FailFirstRead) Read

func (e *FailFirstRead) Read(p []byte) (int, error)

type GetItemsInContainerByCollisionKeyer

type GetItemsInContainerByCollisionKeyer[T any] interface {
	GetItemsInContainerByCollisionKey(
		ctx context.Context,
		userID, containerID string,
	) (map[string]T, error)
}

type GetItemsKeysAndFolderByNameer

type GetItemsKeysAndFolderByNameer interface {
	GetItemIDsInContainer(
		ctx context.Context,
		driveID, containerID string,
	) (map[string]api.DriveItemIDType, error)
	GetFolderByName(
		ctx context.Context,
		driveID, parentFolderID, folderName string,
	) (models.DriveItemable, error)
	GetItemsInContainerByCollisionKey(
		ctx context.Context,
		driveID, containerID string,
	) (map[string]api.DriveItemIDType, error)
}

type IncrementalCollection

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

type IncrementalItem

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

type RestoreOpDependencies

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

func PrepNewTestRestoreOp

func PrepNewTestRestoreOp(
	t *testing.T,
	ctx context.Context,
	backupStore storage.Storage,
	backupID model.StableID,
	bus events.Eventer,
	counter *count.Bus,
	sel selectors.Selector,
	opts control.Options,
	restoreCfg control.RestoreConfig,
) (
	operations.RestoreOperation,
	*RestoreOpDependencies,
)

PrepNewTestRestoreOp generates all clients required to run a restore operation, returning both a restore operation created with those clients, as well as the clients themselves.

func (*RestoreOpDependencies) Close

func (rod *RestoreOpDependencies) Close(
	t *testing.T,
	ctx context.Context,
)

Jump to

Keyboard shortcuts

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