first pass on ServiceResource tuple compliance
First pass for updating code outside of the path package to comply with ServiceResource tuple slices. Compliance is still incomplete, so the build and tests will still fail. Changes in this PR are focused on the easier-to-make changes, mostly generating ServiceResources where there were previously manual declarations of service and resource.
This commit is contained in:
parent
dfd486cd41
commit
6ed54fad9c
@ -177,7 +177,7 @@ type collection struct {
|
|||||||
|
|
||||||
func buildCollections(
|
func buildCollections(
|
||||||
service path.ServiceType,
|
service path.ServiceType,
|
||||||
tenant, user string,
|
tenant, protectedResource string,
|
||||||
restoreCfg control.RestoreConfig,
|
restoreCfg control.RestoreConfig,
|
||||||
colls []collection,
|
colls []collection,
|
||||||
) ([]data.RestoreCollection, error) {
|
) ([]data.RestoreCollection, error) {
|
||||||
@ -186,8 +186,10 @@ func buildCollections(
|
|||||||
for _, c := range colls {
|
for _, c := range colls {
|
||||||
pth, err := path.Build(
|
pth, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
user,
|
[]path.ServiceResource{{
|
||||||
service,
|
Service: service,
|
||||||
|
ProtectedResource: protectedResource,
|
||||||
|
}},
|
||||||
c.category,
|
c.category,
|
||||||
false,
|
false,
|
||||||
c.PathElements...)
|
c.PathElements...)
|
||||||
|
|||||||
@ -21,11 +21,35 @@ func TestDataCollectionSuite(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DataCollectionSuite) TestStateOf() {
|
func (suite *DataCollectionSuite) TestStateOf() {
|
||||||
fooP, err := path.Build("t", "u", path.ExchangeService, path.EmailCategory, false, "foo")
|
fooP, err := path.Build(
|
||||||
|
"t",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "u",
|
||||||
|
}},
|
||||||
|
path.EmailCategory,
|
||||||
|
false,
|
||||||
|
"foo")
|
||||||
require.NoError(suite.T(), err, clues.ToCore(err))
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
||||||
barP, err := path.Build("t", "u", path.ExchangeService, path.EmailCategory, false, "bar")
|
barP, err := path.Build(
|
||||||
|
"t",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "u",
|
||||||
|
}},
|
||||||
|
path.EmailCategory,
|
||||||
|
false,
|
||||||
|
"bar")
|
||||||
require.NoError(suite.T(), err, clues.ToCore(err))
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
||||||
preP, err := path.Build("_t", "_u", path.ExchangeService, path.EmailCategory, false, "foo")
|
preP, err := path.Build(
|
||||||
|
"_t",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "u",
|
||||||
|
}},
|
||||||
|
path.EmailCategory,
|
||||||
|
false,
|
||||||
|
"foo")
|
||||||
require.NoError(suite.T(), err, clues.ToCore(err))
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
||||||
|
|
||||||
table := []struct {
|
table := []struct {
|
||||||
|
|||||||
@ -78,8 +78,10 @@ func (suite *KopiaDataCollectionUnitSuite) TestReturnsPath() {
|
|||||||
|
|
||||||
pth, err := path.Build(
|
pth, err := path.Build(
|
||||||
"a-tenant",
|
"a-tenant",
|
||||||
"a-user",
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "a-user",
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
"some", "path", "for", "data")
|
"some", "path", "for", "data")
|
||||||
@ -330,8 +332,10 @@ func (suite *KopiaDataCollectionUnitSuite) TestFetchItemByName() {
|
|||||||
|
|
||||||
pth, err := path.Build(
|
pth, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
user,
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: user,
|
||||||
|
}},
|
||||||
category,
|
category,
|
||||||
false,
|
false,
|
||||||
folder1, folder2)
|
folder1, folder2)
|
||||||
|
|||||||
@ -32,8 +32,10 @@ func (suite *MergeCollectionUnitSuite) TestReturnsPath() {
|
|||||||
|
|
||||||
pth, err := path.Build(
|
pth, err := path.Build(
|
||||||
"a-tenant",
|
"a-tenant",
|
||||||
"a-user",
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "a-user",
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
"some", "path", "for", "data")
|
"some", "path", "for", "data")
|
||||||
@ -61,8 +63,10 @@ func (suite *MergeCollectionUnitSuite) TestItems() {
|
|||||||
|
|
||||||
pth, err := path.Build(
|
pth, err := path.Build(
|
||||||
"a-tenant",
|
"a-tenant",
|
||||||
"a-user",
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "a-user",
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
"some", "path", "for", "data")
|
"some", "path", "for", "data")
|
||||||
@ -101,8 +105,10 @@ func (suite *MergeCollectionUnitSuite) TestAddCollection_DifferentPathFails() {
|
|||||||
|
|
||||||
pth1, err := path.Build(
|
pth1, err := path.Build(
|
||||||
"a-tenant",
|
"a-tenant",
|
||||||
"a-user",
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "a-user",
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
"some", "path", "for", "data")
|
"some", "path", "for", "data")
|
||||||
@ -110,8 +116,10 @@ func (suite *MergeCollectionUnitSuite) TestAddCollection_DifferentPathFails() {
|
|||||||
|
|
||||||
pth2, err := path.Build(
|
pth2, err := path.Build(
|
||||||
"a-tenant",
|
"a-tenant",
|
||||||
"a-user",
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "a-user",
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
"some", "path", "for", "data2")
|
"some", "path", "for", "data2")
|
||||||
@ -142,8 +150,10 @@ func (suite *MergeCollectionUnitSuite) TestFetchItemByName() {
|
|||||||
|
|
||||||
pth, err := path.Build(
|
pth, err := path.Build(
|
||||||
"a-tenant",
|
"a-tenant",
|
||||||
"a-user",
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "a-user",
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
"some", "path", "for", "data")
|
"some", "path", "for", "data")
|
||||||
|
|||||||
@ -364,8 +364,10 @@ func TestCorsoProgressUnitSuite(t *testing.T) {
|
|||||||
func (suite *CorsoProgressUnitSuite) SetupSuite() {
|
func (suite *CorsoProgressUnitSuite) SetupSuite() {
|
||||||
p, err := path.Build(
|
p, err := path.Build(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: testUser,
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
true,
|
true,
|
||||||
testInboxDir, "testFile")
|
testInboxDir, "testFile")
|
||||||
@ -2867,16 +2869,40 @@ func (suite *HierarchyBuilderUnitSuite) TestBuildDirectoryTreeSelectsMigrateSubt
|
|||||||
migratedUser = "user_migrate"
|
migratedUser = "user_migrate"
|
||||||
)
|
)
|
||||||
|
|
||||||
oldPrefixPathEmail, err := path.BuildPrefix(testTenant, testUser, path.ExchangeService, path.EmailCategory)
|
oldPrefixPathEmail, err := path.BuildPrefix(
|
||||||
|
testTenant,
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: testUser,
|
||||||
|
}},
|
||||||
|
path.EmailCategory)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
newPrefixPathEmail, err := path.BuildPrefix(testTenant, migratedUser, path.ExchangeService, path.EmailCategory)
|
newPrefixPathEmail, err := path.BuildPrefix(
|
||||||
|
testTenant,
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: migratedUser,
|
||||||
|
}},
|
||||||
|
path.EmailCategory)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
oldPrefixPathCont, err := path.BuildPrefix(testTenant, testUser, path.ExchangeService, path.ContactsCategory)
|
oldPrefixPathCont, err := path.BuildPrefix(
|
||||||
|
testTenant,
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: testUser,
|
||||||
|
}},
|
||||||
|
path.ContactsCategory)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
newPrefixPathCont, err := path.BuildPrefix(testTenant, migratedUser, path.ExchangeService, path.ContactsCategory)
|
newPrefixPathCont, err := path.BuildPrefix(
|
||||||
|
testTenant,
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: migratedUser,
|
||||||
|
}},
|
||||||
|
path.ContactsCategory)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@ -1248,8 +1248,10 @@ func (suite *OneDriveCollectionsUnitSuite) TestGet() {
|
|||||||
|
|
||||||
metadataPath, err := path.Builder{}.ToServiceCategoryMetadataPath(
|
metadataPath, err := path.Builder{}.ToServiceCategoryMetadataPath(
|
||||||
tenant,
|
tenant,
|
||||||
user,
|
[]path.ServiceResource{{
|
||||||
path.OneDriveService,
|
Service: path.OneDriveService,
|
||||||
|
ProtectedResource: user,
|
||||||
|
}},
|
||||||
path.FilesCategory,
|
path.FilesCategory,
|
||||||
false)
|
false)
|
||||||
require.NoError(suite.T(), err, "making metadata path", clues.ToCore(err))
|
require.NoError(suite.T(), err, "making metadata path", clues.ToCore(err))
|
||||||
|
|||||||
@ -46,8 +46,10 @@ func (h itemBackupHandler) PathPrefix(
|
|||||||
) (path.Path, error) {
|
) (path.Path, error) {
|
||||||
return path.Build(
|
return path.Build(
|
||||||
tenantID,
|
tenantID,
|
||||||
resourceOwner,
|
[]path.ServiceResource{{
|
||||||
path.OneDriveService,
|
Service: path.OneDriveService,
|
||||||
|
ProtectedResource: resourceOwner,
|
||||||
|
}},
|
||||||
path.FilesCategory,
|
path.FilesCategory,
|
||||||
false,
|
false,
|
||||||
odConsts.DrivesPathDir,
|
odConsts.DrivesPathDir,
|
||||||
|
|||||||
@ -41,8 +41,10 @@ func (h libraryBackupHandler) PathPrefix(
|
|||||||
) (path.Path, error) {
|
) (path.Path, error) {
|
||||||
return path.Build(
|
return path.Build(
|
||||||
tenantID,
|
tenantID,
|
||||||
resourceOwner,
|
[]path.ServiceResource{{
|
||||||
path.SharePointService,
|
Service: path.SharePointService,
|
||||||
|
ProtectedResource: resourceOwner,
|
||||||
|
}},
|
||||||
path.LibrariesCategory,
|
path.LibrariesCategory,
|
||||||
false,
|
false,
|
||||||
odConsts.DrivesPathDir,
|
odConsts.DrivesPathDir,
|
||||||
|
|||||||
@ -42,8 +42,10 @@ func runComputeParentPermissionsTest(
|
|||||||
|
|
||||||
entry, err := path.Build(
|
entry, err := path.Build(
|
||||||
"tenant",
|
"tenant",
|
||||||
resourceOwner,
|
[]path.ServiceResource{{
|
||||||
service,
|
Service: service,
|
||||||
|
ProtectedResource: resourceOwner,
|
||||||
|
}},
|
||||||
category,
|
category,
|
||||||
false,
|
false,
|
||||||
strings.Split(entryPath, "/")...)
|
strings.Split(entryPath, "/")...)
|
||||||
@ -51,8 +53,10 @@ func runComputeParentPermissionsTest(
|
|||||||
|
|
||||||
rootEntry, err := path.Build(
|
rootEntry, err := path.Build(
|
||||||
"tenant",
|
"tenant",
|
||||||
resourceOwner,
|
[]path.ServiceResource{{
|
||||||
service,
|
Service: service,
|
||||||
|
ProtectedResource: resourceOwner,
|
||||||
|
}},
|
||||||
category,
|
category,
|
||||||
false,
|
false,
|
||||||
strings.Split(rootEntryPath, "/")...)
|
strings.Split(rootEntryPath, "/")...)
|
||||||
|
|||||||
@ -93,8 +93,10 @@ func CollectPages(
|
|||||||
|
|
||||||
dir, err := path.Build(
|
dir, err := path.Build(
|
||||||
creds.AzureTenantID,
|
creds.AzureTenantID,
|
||||||
bpc.ProtectedResource.ID(),
|
[]path.ServiceResource{{
|
||||||
path.SharePointService,
|
Service: path.SharePointService,
|
||||||
|
ProtectedResource: bpc.ProtectedResource.ID(),
|
||||||
|
}},
|
||||||
path.PagesCategory,
|
path.PagesCategory,
|
||||||
false,
|
false,
|
||||||
tuple.Name)
|
tuple.Name)
|
||||||
@ -144,8 +146,10 @@ func CollectLists(
|
|||||||
|
|
||||||
dir, err := path.Build(
|
dir, err := path.Build(
|
||||||
tenantID,
|
tenantID,
|
||||||
bpc.ProtectedResource.ID(),
|
[]path.ServiceResource{{
|
||||||
path.SharePointService,
|
Service: path.SharePointService,
|
||||||
|
ProtectedResource: bpc.ProtectedResource.ID(),
|
||||||
|
}},
|
||||||
path.ListsCategory,
|
path.ListsCategory,
|
||||||
false,
|
false,
|
||||||
tuple.Name)
|
tuple.Name)
|
||||||
|
|||||||
@ -95,8 +95,10 @@ func (suite *SharePointCollectionSuite) TestCollection_Items() {
|
|||||||
getDir: func(t *testing.T) path.Path {
|
getDir: func(t *testing.T) path.Path {
|
||||||
dir, err := path.Build(
|
dir, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
user,
|
[]path.ServiceResource{{
|
||||||
path.SharePointService,
|
Service: path.SharePointService,
|
||||||
|
ProtectedResource: user,
|
||||||
|
}},
|
||||||
path.ListsCategory,
|
path.ListsCategory,
|
||||||
false,
|
false,
|
||||||
dirRoot)
|
dirRoot)
|
||||||
@ -131,8 +133,10 @@ func (suite *SharePointCollectionSuite) TestCollection_Items() {
|
|||||||
getDir: func(t *testing.T) path.Path {
|
getDir: func(t *testing.T) path.Path {
|
||||||
dir, err := path.Build(
|
dir, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
user,
|
[]path.ServiceResource{{
|
||||||
path.SharePointService,
|
Service: path.SharePointService,
|
||||||
|
ProtectedResource: user,
|
||||||
|
}},
|
||||||
path.PagesCategory,
|
path.PagesCategory,
|
||||||
false,
|
false,
|
||||||
dirRoot)
|
dirRoot)
|
||||||
|
|||||||
@ -1111,9 +1111,11 @@ func (suite *ControllerIntegrationSuite) TestMultiFolderBackupDifferentNames() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
totalItems, _, collections, expectedData, err := stub.CollectionsForInfo(
|
totalItems, _, collections, expectedData, err := stub.CollectionsForInfo(
|
||||||
test.service,
|
|
||||||
suite.ctrl.tenant,
|
suite.ctrl.tenant,
|
||||||
suite.user,
|
[]path.ServiceResource{{
|
||||||
|
Service: test.service,
|
||||||
|
ProtectedResource: suite.user,
|
||||||
|
}},
|
||||||
restoreCfg,
|
restoreCfg,
|
||||||
[]stub.ColInfo{collection},
|
[]stub.ColInfo{collection},
|
||||||
version.Backup,
|
version.Backup,
|
||||||
|
|||||||
@ -79,7 +79,13 @@ func BaseCollections(
|
|||||||
for cat := range categories {
|
for cat := range categories {
|
||||||
ictx := clues.Add(ctx, "base_service", service, "base_category", cat)
|
ictx := clues.Add(ctx, "base_service", service, "base_category", cat)
|
||||||
|
|
||||||
full, err := path.BuildPrefix(tenant, rOwner, service, cat)
|
full, err := path.BuildPrefix(
|
||||||
|
tenant,
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: service,
|
||||||
|
ProtectedResource: rOwner,
|
||||||
|
}},
|
||||||
|
cat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Shouldn't happen.
|
// Shouldn't happen.
|
||||||
err = clues.Wrap(err, "making path").WithClues(ictx)
|
err = clues.Wrap(err, "making path").WithClues(ictx)
|
||||||
|
|||||||
@ -24,16 +24,44 @@ func (suite *CollectionsUnitSuite) TestNewPrefixCollection() {
|
|||||||
serv := path.OneDriveService
|
serv := path.OneDriveService
|
||||||
cat := path.FilesCategory
|
cat := path.FilesCategory
|
||||||
|
|
||||||
p1, err := path.BuildPrefix("t", "ro1", serv, cat)
|
p1, err := path.BuildPrefix(
|
||||||
|
"t",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: serv,
|
||||||
|
ProtectedResource: "ro1",
|
||||||
|
}},
|
||||||
|
cat)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
p2, err := path.BuildPrefix("t", "ro2", serv, cat)
|
p2, err := path.BuildPrefix(
|
||||||
|
"t",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: serv,
|
||||||
|
ProtectedResource: "ro2",
|
||||||
|
}},
|
||||||
|
cat)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
items, err := path.Build("t", "ro", serv, cat, true, "fld", "itm")
|
items, err := path.Build(
|
||||||
|
"t",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: serv,
|
||||||
|
ProtectedResource: "ro",
|
||||||
|
}},
|
||||||
|
cat,
|
||||||
|
true,
|
||||||
|
"fld", "itm")
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
folders, err := path.Build("t", "ro", serv, cat, false, "fld")
|
folders, err := path.Build(
|
||||||
|
"t",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: serv,
|
||||||
|
ProtectedResource: "ro",
|
||||||
|
}},
|
||||||
|
cat,
|
||||||
|
false,
|
||||||
|
"fld")
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
table := []struct {
|
table := []struct {
|
||||||
|
|||||||
@ -92,8 +92,10 @@ func (suite *MetadataUnitSuite) TestIsMetadataFile_Files_MetaSuffixes() {
|
|||||||
|
|
||||||
p, err := path.Build(
|
p, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
user,
|
[]path.ServiceResource{{
|
||||||
test.service,
|
Service: test.service,
|
||||||
|
ProtectedResource: user,
|
||||||
|
}},
|
||||||
test.category,
|
test.category,
|
||||||
true,
|
true,
|
||||||
"file"+ext)
|
"file"+ext)
|
||||||
@ -113,8 +115,10 @@ func (suite *MetadataUnitSuite) TestIsMetadataFile_Files_NotMetaSuffixes() {
|
|||||||
|
|
||||||
p, err := path.Build(
|
p, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
user,
|
[]path.ServiceResource{{
|
||||||
test.service,
|
Service: test.service,
|
||||||
|
ProtectedResource: user,
|
||||||
|
}},
|
||||||
test.category,
|
test.category,
|
||||||
true,
|
true,
|
||||||
"file"+ext)
|
"file"+ext)
|
||||||
@ -136,8 +140,10 @@ func (suite *MetadataUnitSuite) TestIsMetadataFile_Directories() {
|
|||||||
|
|
||||||
p, err := path.Build(
|
p, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
user,
|
[]path.ServiceResource{{
|
||||||
test.service,
|
Service: test.service,
|
||||||
|
ProtectedResource: user,
|
||||||
|
}},
|
||||||
test.category,
|
test.category,
|
||||||
false,
|
false,
|
||||||
"file"+ext)
|
"file"+ext)
|
||||||
|
|||||||
@ -75,8 +75,10 @@ func MakeMetadataCollection(
|
|||||||
|
|
||||||
p, err := path.Builder{}.ToServiceCategoryMetadataPath(
|
p, err := path.Builder{}.ToServiceCategoryMetadataPath(
|
||||||
tenant,
|
tenant,
|
||||||
resourceOwner,
|
[]path.ServiceResource{{
|
||||||
service,
|
Service: service,
|
||||||
|
ProtectedResource: resourceOwner,
|
||||||
|
}},
|
||||||
cat,
|
cat,
|
||||||
false)
|
false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -30,8 +30,10 @@ func (suite *MetadataCollectionUnitSuite) TestFullPath() {
|
|||||||
|
|
||||||
p, err := path.Build(
|
p, err := path.Build(
|
||||||
"a-tenant",
|
"a-tenant",
|
||||||
"a-user",
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "a-user",
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
"foo")
|
"foo")
|
||||||
@ -72,8 +74,10 @@ func (suite *MetadataCollectionUnitSuite) TestItems() {
|
|||||||
|
|
||||||
p, err := path.Build(
|
p, err := path.Build(
|
||||||
"a-tenant",
|
"a-tenant",
|
||||||
"a-user",
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "a-user",
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
"foo")
|
"foo")
|
||||||
|
|||||||
@ -942,8 +942,7 @@ func checkHasCollections(
|
|||||||
|
|
||||||
p, err := loc.ToDataLayerPath(
|
p, err := loc.ToDataLayerPath(
|
||||||
fp.Tenant(),
|
fp.Tenant(),
|
||||||
fp.ResourceOwner(),
|
fp.ServiceResources(),
|
||||||
fp.Service(),
|
|
||||||
fp.Category(),
|
fp.Category(),
|
||||||
false)
|
false)
|
||||||
if !assert.NoError(t, err, clues.ToCore(err)) {
|
if !assert.NoError(t, err, clues.ToCore(err)) {
|
||||||
|
|||||||
@ -343,8 +343,10 @@ func (f failingColl) Items(ctx context.Context, errs *fault.Bus) <-chan data.Str
|
|||||||
func (f failingColl) FullPath() path.Path {
|
func (f failingColl) FullPath() path.Path {
|
||||||
tmp, err := path.Build(
|
tmp, err := path.Build(
|
||||||
"tenant",
|
"tenant",
|
||||||
"user",
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "user",
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
"inbox")
|
"inbox")
|
||||||
@ -1267,8 +1269,10 @@ func (suite *CollectionPopulationSuite) TestFilterContainersAndFillCollections_D
|
|||||||
oldPath1 := func(t *testing.T, cat path.CategoryType) path.Path {
|
oldPath1 := func(t *testing.T, cat path.CategoryType) path.Path {
|
||||||
res, err := location.Append("1").ToDataLayerPath(
|
res, err := location.Append("1").ToDataLayerPath(
|
||||||
suite.creds.AzureTenantID,
|
suite.creds.AzureTenantID,
|
||||||
qp.ProtectedResource.ID(),
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: qp.ProtectedResource.ID(),
|
||||||
|
}},
|
||||||
cat,
|
cat,
|
||||||
false)
|
false)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
@ -1279,8 +1283,10 @@ func (suite *CollectionPopulationSuite) TestFilterContainersAndFillCollections_D
|
|||||||
oldPath2 := func(t *testing.T, cat path.CategoryType) path.Path {
|
oldPath2 := func(t *testing.T, cat path.CategoryType) path.Path {
|
||||||
res, err := location.Append("2").ToDataLayerPath(
|
res, err := location.Append("2").ToDataLayerPath(
|
||||||
suite.creds.AzureTenantID,
|
suite.creds.AzureTenantID,
|
||||||
qp.ProtectedResource.ID(),
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: qp.ProtectedResource.ID(),
|
||||||
|
}},
|
||||||
cat,
|
cat,
|
||||||
false)
|
false)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
@ -1291,8 +1297,10 @@ func (suite *CollectionPopulationSuite) TestFilterContainersAndFillCollections_D
|
|||||||
idPath1 := func(t *testing.T, cat path.CategoryType) path.Path {
|
idPath1 := func(t *testing.T, cat path.CategoryType) path.Path {
|
||||||
res, err := path.Builder{}.Append("1").ToDataLayerPath(
|
res, err := path.Builder{}.Append("1").ToDataLayerPath(
|
||||||
suite.creds.AzureTenantID,
|
suite.creds.AzureTenantID,
|
||||||
qp.ProtectedResource.ID(),
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: qp.ProtectedResource.ID(),
|
||||||
|
}},
|
||||||
cat,
|
cat,
|
||||||
false)
|
false)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
@ -1303,8 +1311,10 @@ func (suite *CollectionPopulationSuite) TestFilterContainersAndFillCollections_D
|
|||||||
idPath2 := func(t *testing.T, cat path.CategoryType) path.Path {
|
idPath2 := func(t *testing.T, cat path.CategoryType) path.Path {
|
||||||
res, err := path.Builder{}.Append("2").ToDataLayerPath(
|
res, err := path.Builder{}.Append("2").ToDataLayerPath(
|
||||||
suite.creds.AzureTenantID,
|
suite.creds.AzureTenantID,
|
||||||
qp.ProtectedResource.ID(),
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: qp.ProtectedResource.ID(),
|
||||||
|
}},
|
||||||
cat,
|
cat,
|
||||||
false)
|
false)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
@ -1706,7 +1716,15 @@ func (suite *CollectionPopulationSuite) TestFilterContainersAndFillCollections_i
|
|||||||
)
|
)
|
||||||
|
|
||||||
prevPath := func(t *testing.T, at ...string) path.Path {
|
prevPath := func(t *testing.T, at ...string) path.Path {
|
||||||
p, err := path.Build(tenantID, userID, path.ExchangeService, cat, false, at...)
|
p, err := path.Build(
|
||||||
|
tenantID,
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: userID,
|
||||||
|
}},
|
||||||
|
cat,
|
||||||
|
false,
|
||||||
|
at...)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
return p
|
return p
|
||||||
|
|||||||
@ -89,8 +89,10 @@ func (suite *CollectionSuite) TestColleciton_FullPath() {
|
|||||||
|
|
||||||
fullPath, err := path.Build(
|
fullPath, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
user,
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: user,
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
folder)
|
folder)
|
||||||
@ -113,8 +115,10 @@ func (suite *CollectionSuite) TestCollection_NewCollection() {
|
|||||||
|
|
||||||
fullPath, err := path.Build(
|
fullPath, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
user,
|
[]path.ServiceResource{{
|
||||||
path.ExchangeService,
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: user,
|
||||||
|
}},
|
||||||
path.EmailCategory,
|
path.EmailCategory,
|
||||||
false,
|
false,
|
||||||
folder)
|
folder)
|
||||||
@ -129,9 +133,25 @@ func (suite *CollectionSuite) TestCollection_NewCollection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *CollectionSuite) TestNewCollection_state() {
|
func (suite *CollectionSuite) TestNewCollection_state() {
|
||||||
fooP, err := path.Build("t", "u", path.ExchangeService, path.EmailCategory, false, "foo")
|
fooP, err := path.Build(
|
||||||
|
"t",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "u",
|
||||||
|
}},
|
||||||
|
path.EmailCategory,
|
||||||
|
false,
|
||||||
|
"foo")
|
||||||
require.NoError(suite.T(), err, clues.ToCore(err))
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
||||||
barP, err := path.Build("t", "u", path.ExchangeService, path.EmailCategory, false, "bar")
|
barP, err := path.Build(
|
||||||
|
"t",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "u",
|
||||||
|
}},
|
||||||
|
path.EmailCategory,
|
||||||
|
false,
|
||||||
|
"bar")
|
||||||
require.NoError(suite.T(), err, clues.ToCore(err))
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
||||||
|
|
||||||
locPB := path.Builder{}.Append("human-readable")
|
locPB := path.Builder{}.Append("human-readable")
|
||||||
|
|||||||
@ -812,8 +812,10 @@ func runCreateDestinationTest(
|
|||||||
|
|
||||||
path1, err := path.Build(
|
path1, err := path.Build(
|
||||||
tenantID,
|
tenantID,
|
||||||
userID,
|
[]path.ServiceResource{{
|
||||||
svc,
|
Service: svc,
|
||||||
|
ProtectedResource: userID,
|
||||||
|
}},
|
||||||
category,
|
category,
|
||||||
false,
|
false,
|
||||||
containerNames1...)
|
containerNames1...)
|
||||||
@ -833,8 +835,10 @@ func runCreateDestinationTest(
|
|||||||
|
|
||||||
path2, err := path.Build(
|
path2, err := path.Build(
|
||||||
tenantID,
|
tenantID,
|
||||||
userID,
|
[]path.ServiceResource{{
|
||||||
svc,
|
Service: svc,
|
||||||
|
ProtectedResource: userID,
|
||||||
|
}},
|
||||||
category,
|
category,
|
||||||
false,
|
false,
|
||||||
containerNames2...)
|
containerNames2...)
|
||||||
|
|||||||
@ -111,8 +111,10 @@ func migrationCollections(
|
|||||||
// backup, onedrive needs to force the owner PN -> ID migration
|
// backup, onedrive needs to force the owner PN -> ID migration
|
||||||
mc, err := path.BuildPrefix(
|
mc, err := path.BuildPrefix(
|
||||||
tenant,
|
tenant,
|
||||||
bpc.ProtectedResource.ID(),
|
[]path.ServiceResource{{
|
||||||
path.OneDriveService,
|
Service: path.OneDriveService,
|
||||||
|
ProtectedResource: bpc.ProtectedResource.ID(),
|
||||||
|
}},
|
||||||
path.FilesCategory)
|
path.FilesCategory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, clues.Wrap(err, "creating user id migration path")
|
return nil, clues.Wrap(err, "creating user id migration path")
|
||||||
@ -120,8 +122,10 @@ func migrationCollections(
|
|||||||
|
|
||||||
mpc, err := path.BuildPrefix(
|
mpc, err := path.BuildPrefix(
|
||||||
tenant,
|
tenant,
|
||||||
bpc.ProtectedResource.Name(),
|
[]path.ServiceResource{{
|
||||||
path.OneDriveService,
|
Service: path.OneDriveService,
|
||||||
|
ProtectedResource: bpc.ProtectedResource.Name(),
|
||||||
|
}},
|
||||||
path.FilesCategory)
|
path.FilesCategory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, clues.Wrap(err, "creating user name migration path")
|
return nil, clues.Wrap(err, "creating user name migration path")
|
||||||
|
|||||||
@ -161,8 +161,10 @@ type pathPrefixer func(tID, ro, driveID string) (path.Path, error)
|
|||||||
var defaultOneDrivePathPrefixer = func(tID, ro, driveID string) (path.Path, error) {
|
var defaultOneDrivePathPrefixer = func(tID, ro, driveID string) (path.Path, error) {
|
||||||
return path.Build(
|
return path.Build(
|
||||||
tID,
|
tID,
|
||||||
ro,
|
[]path.ServiceResource{{
|
||||||
path.OneDriveService,
|
Service: path.OneDriveService,
|
||||||
|
ProtectedResource: ro,
|
||||||
|
}},
|
||||||
path.FilesCategory,
|
path.FilesCategory,
|
||||||
false,
|
false,
|
||||||
odConsts.DrivesPathDir,
|
odConsts.DrivesPathDir,
|
||||||
@ -173,8 +175,10 @@ var defaultOneDrivePathPrefixer = func(tID, ro, driveID string) (path.Path, erro
|
|||||||
var defaultSharePointPathPrefixer = func(tID, ro, driveID string) (path.Path, error) {
|
var defaultSharePointPathPrefixer = func(tID, ro, driveID string) (path.Path, error) {
|
||||||
return path.Build(
|
return path.Build(
|
||||||
tID,
|
tID,
|
||||||
ro,
|
[]path.ServiceResource{{
|
||||||
path.SharePointService,
|
Service: path.SharePointService,
|
||||||
|
ProtectedResource: ro,
|
||||||
|
}},
|
||||||
path.LibrariesCategory,
|
path.LibrariesCategory,
|
||||||
false,
|
false,
|
||||||
odConsts.DrivesPathDir,
|
odConsts.DrivesPathDir,
|
||||||
|
|||||||
@ -84,8 +84,8 @@ func GetCollectionsAndExpected(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CollectionsForInfo(
|
func CollectionsForInfo(
|
||||||
service path.ServiceType,
|
tenant string,
|
||||||
tenant, user string,
|
srs []path.ServiceResource,
|
||||||
restoreCfg control.RestoreConfig,
|
restoreCfg control.RestoreConfig,
|
||||||
allInfo []ColInfo,
|
allInfo []ColInfo,
|
||||||
backupVersion int,
|
backupVersion int,
|
||||||
@ -100,8 +100,7 @@ func CollectionsForInfo(
|
|||||||
for _, info := range allInfo {
|
for _, info := range allInfo {
|
||||||
pth, err := path.Build(
|
pth, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
user,
|
srs,
|
||||||
service,
|
|
||||||
info.Category,
|
info.Category,
|
||||||
false,
|
false,
|
||||||
info.PathElements...)
|
info.PathElements...)
|
||||||
|
|||||||
@ -218,8 +218,10 @@ func makeMetadataBasePath(
|
|||||||
|
|
||||||
p, err := path.Builder{}.ToServiceCategoryMetadataPath(
|
p, err := path.Builder{}.ToServiceCategoryMetadataPath(
|
||||||
tenant,
|
tenant,
|
||||||
resourceOwner,
|
[]path.ServiceResource{{
|
||||||
service,
|
Service: service,
|
||||||
|
ProtectedResource: resourceOwner,
|
||||||
|
}},
|
||||||
category,
|
category,
|
||||||
false)
|
false)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
@ -1635,7 +1637,15 @@ func (suite *AssistBackupIntegrationSuite) TestBackupTypesForFailureModes() {
|
|||||||
|
|
||||||
pathElements := []string{odConsts.DrivesPathDir, "drive-id", odConsts.RootPathDir, folderID}
|
pathElements := []string{odConsts.DrivesPathDir, "drive-id", odConsts.RootPathDir, folderID}
|
||||||
|
|
||||||
tmp, err := path.Build(tenantID, userID, path.OneDriveService, path.FilesCategory, false, pathElements...)
|
tmp, err := path.Build(
|
||||||
|
tenantID,
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.OneDriveService,
|
||||||
|
ProtectedResource: userID,
|
||||||
|
}},
|
||||||
|
path.FilesCategory,
|
||||||
|
false,
|
||||||
|
pathElements...)
|
||||||
require.NoError(suite.T(), err, clues.ToCore(err))
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
||||||
|
|
||||||
locPath := path.Builder{}.Append(tmp.Folders()...)
|
locPath := path.Builder{}.Append(tmp.Folders()...)
|
||||||
@ -1916,7 +1926,15 @@ func (suite *AssistBackupIntegrationSuite) TestExtensionsIncrementals() {
|
|||||||
|
|
||||||
pathElements := []string{odConsts.DrivesPathDir, "drive-id", odConsts.RootPathDir, folderID}
|
pathElements := []string{odConsts.DrivesPathDir, "drive-id", odConsts.RootPathDir, folderID}
|
||||||
|
|
||||||
tmp, err := path.Build(tenantID, userID, path.OneDriveService, path.FilesCategory, false, pathElements...)
|
tmp, err := path.Build(
|
||||||
|
tenantID,
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.OneDriveService,
|
||||||
|
ProtectedResource: userID,
|
||||||
|
}},
|
||||||
|
path.FilesCategory,
|
||||||
|
false,
|
||||||
|
pathElements...)
|
||||||
require.NoError(suite.T(), err, clues.ToCore(err))
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
||||||
|
|
||||||
locPath := path.Builder{}.Append(tmp.Folders()...)
|
locPath := path.Builder{}.Append(tmp.Folders()...)
|
||||||
|
|||||||
@ -344,7 +344,7 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata() {
|
|||||||
assert.Equal(
|
assert.Equal(
|
||||||
t,
|
t,
|
||||||
path.ExchangeMetadataService,
|
path.ExchangeMetadataService,
|
||||||
p.Service(),
|
p.ServiceResources()[0].Service,
|
||||||
"read data service")
|
"read data service")
|
||||||
|
|
||||||
assert.Contains(
|
assert.Contains(
|
||||||
@ -354,8 +354,7 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata() {
|
|||||||
path.ContactsCategory,
|
path.ContactsCategory,
|
||||||
},
|
},
|
||||||
p.Category(),
|
p.Category(),
|
||||||
"read data category doesn't match a given reason",
|
"read data category doesn't match a given reason")
|
||||||
)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
expectMans: kopia.NewMockBackupBases().WithMergeBases(
|
expectMans: kopia.NewMockBackupBases().WithMergeBases(
|
||||||
|
|||||||
@ -44,8 +44,7 @@ func basicLocationPath(repoRef path.Path, locRef *path.Builder) (path.Path, erro
|
|||||||
if len(locRef.Elements()) == 0 {
|
if len(locRef.Elements()) == 0 {
|
||||||
res, err := path.BuildPrefix(
|
res, err := path.BuildPrefix(
|
||||||
repoRef.Tenant(),
|
repoRef.Tenant(),
|
||||||
repoRef.ResourceOwner(),
|
repoRef.ServiceResources(),
|
||||||
repoRef.Service(),
|
|
||||||
repoRef.Category())
|
repoRef.Category())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, clues.Wrap(err, "getting prefix for empty location")
|
return nil, clues.Wrap(err, "getting prefix for empty location")
|
||||||
@ -56,8 +55,7 @@ func basicLocationPath(repoRef path.Path, locRef *path.Builder) (path.Path, erro
|
|||||||
|
|
||||||
return locRef.ToDataLayerPath(
|
return locRef.ToDataLayerPath(
|
||||||
repoRef.Tenant(),
|
repoRef.Tenant(),
|
||||||
repoRef.ResourceOwner(),
|
repoRef.ServiceResources(),
|
||||||
repoRef.Service(),
|
|
||||||
repoRef.Category(),
|
repoRef.Category(),
|
||||||
false)
|
false)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -347,7 +347,13 @@ func testExchangeContinuousBackups(suite *ExchangeBackupIntgSuite, toggles contr
|
|||||||
// },
|
// },
|
||||||
}
|
}
|
||||||
|
|
||||||
rrPfx, err := path.BuildPrefix(acct.ID(), uidn.ID(), service, path.EmailCategory)
|
rrPfx, err := path.BuildPrefix(
|
||||||
|
acct.ID(),
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: service,
|
||||||
|
ProtectedResource: uidn.ID(),
|
||||||
|
}},
|
||||||
|
path.EmailCategory)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
// strip the category from the prefix; we primarily want the tenant and resource owner.
|
// strip the category from the prefix; we primarily want the tenant and resource owner.
|
||||||
|
|||||||
@ -291,11 +291,15 @@ func checkMetadataFilesExist(
|
|||||||
|
|
||||||
paths := []path.RestorePaths{}
|
paths := []path.RestorePaths{}
|
||||||
pathsByRef := map[string][]string{}
|
pathsByRef := map[string][]string{}
|
||||||
|
srs := []path.ServiceResource{{
|
||||||
|
Service: service,
|
||||||
|
ProtectedResource: resourceOwner,
|
||||||
|
}}
|
||||||
|
|
||||||
for _, fName := range files {
|
for _, fName := range files {
|
||||||
p, err := path.Builder{}.
|
p, err := path.Builder{}.
|
||||||
Append(fName).
|
Append(fName).
|
||||||
ToServiceCategoryMetadataPath(tenant, resourceOwner, service, category, true)
|
ToServiceCategoryMetadataPath(tenant, srs, category, true)
|
||||||
if !assert.NoError(t, err, "bad metadata path", clues.ToCore(err)) {
|
if !assert.NoError(t, err, "bad metadata path", clues.ToCore(err)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@ -213,7 +213,13 @@ func runDriveIncrementalTest(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
rrPfx, err := path.BuildPrefix(atid, roidn.ID(), service, category)
|
rrPfx, err := path.BuildPrefix(
|
||||||
|
atid,
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: service,
|
||||||
|
ProtectedResource: roidn.ID(),
|
||||||
|
}},
|
||||||
|
category)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
// strip the category from the prefix; we primarily want the tenant and resource owner.
|
// strip the category from the prefix; we primarily want the tenant and resource owner.
|
||||||
|
|||||||
@ -1122,8 +1122,10 @@ func makeItemPath(
|
|||||||
|
|
||||||
p, err := path.Build(
|
p, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
resourceOwner,
|
[]path.ServiceResource{{
|
||||||
service,
|
Service: service,
|
||||||
|
ProtectedResource: resourceOwner,
|
||||||
|
}},
|
||||||
category,
|
category,
|
||||||
true,
|
true,
|
||||||
elems...)
|
elems...)
|
||||||
|
|||||||
@ -104,7 +104,17 @@ func (suite *RestoreUnitSuite) TestEnsureRestoreConfigDefaults() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *RestoreUnitSuite) TestRestoreConfig_piiHandling() {
|
func (suite *RestoreUnitSuite) TestRestoreConfig_piiHandling() {
|
||||||
p, err := path.Build("tid", "ro", path.ExchangeService, path.EmailCategory, true, "foo", "bar", "baz")
|
p, err := path.Build(
|
||||||
|
"tid",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "ro",
|
||||||
|
}},
|
||||||
|
path.EmailCategory,
|
||||||
|
true,
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"baz")
|
||||||
require.NoError(suite.T(), err, clues.ToCore(err))
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
||||||
|
|
||||||
cdrc := control.DefaultRestoreConfig(dttm.HumanReadable)
|
cdrc := control.DefaultRestoreConfig(dttm.HumanReadable)
|
||||||
|
|||||||
@ -19,7 +19,15 @@ const itemID = "item_id"
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
itemPath, _ = path.Build("tid", "own", path.ExchangeService, path.ContactsCategory, false, "foo")
|
itemPath, _ = path.Build(
|
||||||
|
"tid",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: "own",
|
||||||
|
}},
|
||||||
|
path.ContactsCategory,
|
||||||
|
false,
|
||||||
|
"foo")
|
||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
@ -387,12 +387,9 @@ func (suite *PathUnitSuite) TestFromDataLayerPath() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for service, cats := range serviceCategories {
|
for service, cats := range serviceCategories {
|
||||||
|
|
||||||
for cat := range cats {
|
for cat := range cats {
|
||||||
|
|
||||||
for _, item := range isItem {
|
for _, item := range isItem {
|
||||||
suite.Run(fmt.Sprintf("%s-%s-%s", service, cat, item.name), func() {
|
suite.Run(fmt.Sprintf("%s-%s-%s", service, cat, item.name), func() {
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.Run(test.name, func() {
|
suite.Run(test.name, func() {
|
||||||
var (
|
var (
|
||||||
@ -461,7 +458,8 @@ func (suite *PathUnitSuite) TestBuildPrefix() {
|
|||||||
"t",
|
"t",
|
||||||
GroupsService.String(), "roo",
|
GroupsService.String(), "roo",
|
||||||
SharePointService.String(), "oor",
|
SharePointService.String(), "oor",
|
||||||
LibrariesCategory.String()}),
|
LibrariesCategory.String(),
|
||||||
|
}),
|
||||||
expectErr: require.NoError,
|
expectErr: require.NoError,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -157,13 +157,13 @@ func toMetadataServices(srs []ServiceResource) []ServiceResource {
|
|||||||
metadataService := UnknownService
|
metadataService := UnknownService
|
||||||
|
|
||||||
switch sr.Service {
|
switch sr.Service {
|
||||||
|
// TODO: add groups
|
||||||
case ExchangeService:
|
case ExchangeService:
|
||||||
metadataService = ExchangeMetadataService
|
metadataService = ExchangeMetadataService
|
||||||
case OneDriveService:
|
case OneDriveService:
|
||||||
metadataService = OneDriveMetadataService
|
metadataService = OneDriveMetadataService
|
||||||
case SharePointService:
|
case SharePointService:
|
||||||
metadataService = SharePointMetadataService
|
metadataService = SharePointMetadataService
|
||||||
// TODO: add groups
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msr.Service = metadataService
|
msr.Service = metadataService
|
||||||
|
|||||||
@ -3,10 +3,10 @@ package path
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -3,10 +3,10 @@ package path
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -348,7 +348,7 @@ func ensureAllUsersInDetails(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ro := p.ResourceOwner()
|
ro := p.ServiceResources()[0].ProtectedResource
|
||||||
if !assert.NotEmpty(t, ro, "resource owner in path: "+rr) {
|
if !assert.NotEmpty(t, ro, "resource owner in path: "+rr) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@ -816,7 +816,9 @@ func (suite *ExchangeSelectorSuite) TestExchangeRestore_Reduce() {
|
|||||||
|
|
||||||
joinedFldrs := strings.Join(newElems, "/")
|
joinedFldrs := strings.Join(newElems, "/")
|
||||||
|
|
||||||
return stubRepoRef(p.Service(), p.Category(), p.ResourceOwner(), joinedFldrs, p.Item())
|
sr0 := p.ServiceResources()[0]
|
||||||
|
|
||||||
|
return stubRepoRef(sr0.Service, p.Category(), sr0.ProtectedResource, joinedFldrs, p.Item())
|
||||||
}
|
}
|
||||||
|
|
||||||
makeDeets := func(refs ...path.Path) *details.Details {
|
makeDeets := func(refs ...path.Path) *details.Details {
|
||||||
|
|||||||
@ -213,7 +213,15 @@ func scopeMustHave[T scopeT](t *testing.T, sc T, m map[categorizer][]string) {
|
|||||||
// stubPath ensures test path production matches that of fullPath design,
|
// stubPath ensures test path production matches that of fullPath design,
|
||||||
// stubbing out static values where necessary.
|
// stubbing out static values where necessary.
|
||||||
func stubPath(t *testing.T, user string, s []string, cat path.CategoryType) path.Path {
|
func stubPath(t *testing.T, user string, s []string, cat path.CategoryType) path.Path {
|
||||||
pth, err := path.Build("tid", user, path.ExchangeService, cat, true, s...)
|
pth, err := path.Build(
|
||||||
|
"tid",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.ExchangeService,
|
||||||
|
ProtectedResource: user,
|
||||||
|
}},
|
||||||
|
cat,
|
||||||
|
true,
|
||||||
|
s...)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
return pth
|
return pth
|
||||||
|
|||||||
@ -314,7 +314,15 @@ func (suite *OneDriveSelectorSuite) TestOneDriveCategory_PathValues() {
|
|||||||
shortRef := "short"
|
shortRef := "short"
|
||||||
elems := []string{odConsts.DrivesPathDir, "driveID", odConsts.RootPathDir, "dir1.d", "dir2.d", fileID}
|
elems := []string{odConsts.DrivesPathDir, "driveID", odConsts.RootPathDir, "dir1.d", "dir2.d", fileID}
|
||||||
|
|
||||||
filePath, err := path.Build("tenant", "user", path.OneDriveService, path.FilesCategory, true, elems...)
|
filePath, err := path.Build(
|
||||||
|
"tenant",
|
||||||
|
[]path.ServiceResource{{
|
||||||
|
Service: path.OneDriveService,
|
||||||
|
ProtectedResource: "user",
|
||||||
|
}},
|
||||||
|
path.FilesCategory,
|
||||||
|
true,
|
||||||
|
elems...)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
fileLoc := path.Builder{}.Append("dir1", "dir2")
|
fileLoc := path.Builder{}.Append("dir1", "dir2")
|
||||||
@ -351,8 +359,10 @@ func (suite *OneDriveSelectorSuite) TestOneDriveCategory_PathValues() {
|
|||||||
|
|
||||||
itemPath, err := path.Build(
|
itemPath, err := path.Build(
|
||||||
"tenant",
|
"tenant",
|
||||||
"site",
|
[]path.ServiceResource{{
|
||||||
path.OneDriveService,
|
Service: path.OneDriveService,
|
||||||
|
ProtectedResource: "site",
|
||||||
|
}},
|
||||||
path.FilesCategory,
|
path.FilesCategory,
|
||||||
true,
|
true,
|
||||||
test.pathElems...)
|
test.pathElems...)
|
||||||
|
|||||||
@ -417,10 +417,12 @@ func (suite *SharePointSelectorSuite) TestSharePointCategory_PathValues() {
|
|||||||
suite.Run(test.name, func() {
|
suite.Run(test.name, func() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
|
srs, err := path.NewServiceResources(path.SharePointService, "site")
|
||||||
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
itemPath, err := path.Build(
|
itemPath, err := path.Build(
|
||||||
"tenant",
|
"tenant",
|
||||||
"site",
|
srs,
|
||||||
path.SharePointService,
|
|
||||||
test.sc.PathType(),
|
test.sc.PathType(),
|
||||||
true,
|
true,
|
||||||
test.pathElems...)
|
test.pathElems...)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user