rename path ResourceOwner() to ProtectedResource()

This commit is contained in:
ryanfkeepers 2023-08-09 14:59:09 -06:00
parent be60a6d1e4
commit d0ea40984a
20 changed files with 92 additions and 92 deletions

View File

@ -804,13 +804,13 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections() {
reasons := []identity.Reasoner{ reasons := []identity.Reasoner{
NewReason( NewReason(
testTenant, testTenant,
suite.storePath1.ResourceOwner(), suite.storePath1.ProtectedResource(),
suite.storePath1.Service(), suite.storePath1.Service(),
suite.storePath1.Category(), suite.storePath1.Category(),
), ),
NewReason( NewReason(
testTenant, testTenant,
suite.storePath2.ResourceOwner(), suite.storePath2.ProtectedResource(),
suite.storePath2.Service(), suite.storePath2.Service(),
suite.storePath2.Category(), suite.storePath2.Category(),
), ),
@ -1076,7 +1076,7 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections_NoDetailsForMeta() {
reasons := []identity.Reasoner{ reasons := []identity.Reasoner{
NewReason( NewReason(
testTenant, testTenant,
storePath.ResourceOwner(), storePath.ProtectedResource(),
storePath.Service(), storePath.Service(),
storePath.Category()), storePath.Category()),
} }

View File

@ -57,7 +57,7 @@ func ConsumeRestoreCollections(
ictx = clues.Add(ctx, ictx = clues.Add(ctx,
"category", category, "category", category,
"restore_location", clues.Hide(rcc.RestoreConfig.Location), "restore_location", clues.Hide(rcc.RestoreConfig.Location),
"protected_resource", clues.Hide(dc.FullPath().ResourceOwner()), "protected_resource", clues.Hide(dc.FullPath().ProtectedResource()),
"full_path", dc.FullPath()) "full_path", dc.FullPath())
) )

View File

@ -942,7 +942,7 @@ func checkHasCollections(
p, err := loc.ToDataLayerPath( p, err := loc.ToDataLayerPath(
fp.Tenant(), fp.Tenant(),
fp.ResourceOwner(), fp.ProtectedResource(),
fp.Service(), fp.Service(),
fp.Category(), fp.Category(),
false) false)

View File

@ -50,7 +50,7 @@ func mustGetDefaultDriveID(
ctx context.Context, //revive:disable-line:context-as-argument ctx context.Context, //revive:disable-line:context-as-argument
ac api.Client, ac api.Client,
service path.ServiceType, service path.ServiceType,
resourceOwner string, protectedResource string,
) string { ) string {
var ( var (
err error err error
@ -59,9 +59,9 @@ func mustGetDefaultDriveID(
switch service { switch service {
case path.OneDriveService: case path.OneDriveService:
d, err = ac.Users().GetDefaultDrive(ctx, resourceOwner) d, err = ac.Users().GetDefaultDrive(ctx, protectedResource)
case path.SharePointService: case path.SharePointService:
d, err = ac.Sites().GetDefaultDrive(ctx, resourceOwner) d, err = ac.Sites().GetDefaultDrive(ctx, protectedResource)
default: default:
assert.FailNowf(t, "unknown service type %s", service.String()) assert.FailNowf(t, "unknown service type %s", service.String())
} }
@ -86,10 +86,10 @@ type suiteInfo interface {
PrimaryUser() (string, string) PrimaryUser() (string, string)
SecondaryUser() (string, string) SecondaryUser() (string, string)
TertiaryUser() (string, string) TertiaryUser() (string, string)
// ResourceOwner returns the resource owner to run the backup/restore // ProtectedResource returns the resource owner to run the backup/restore
// with. This can be different from the values used for permissions and it can // with. This can be different from the values used for permissions and it can
// also be a site. // also be a site.
ResourceOwner() string ProtectedResource() string
Service() path.ServiceType Service() path.ServiceType
Resource() resource.Category Resource() resource.Category
} }
@ -102,7 +102,7 @@ type oneDriveSuite interface {
type suiteInfoImpl struct { type suiteInfoImpl struct {
ac api.Client ac api.Client
controller *Controller controller *Controller
resourceOwner string protectedResource string
resourceCategory resource.Category resourceCategory resource.Category
secondaryUser string secondaryUser string
secondaryUserID string secondaryUserID string
@ -116,7 +116,7 @@ type suiteInfoImpl struct {
func NewSuiteInfoImpl( func NewSuiteInfoImpl(
t *testing.T, t *testing.T,
ctx context.Context, //revive:disable-line:context-as-argument ctx context.Context, //revive:disable-line:context-as-argument
resourceOwner string, protectedResource string,
service path.ServiceType, service path.ServiceType,
) suiteInfoImpl { ) suiteInfoImpl {
rsc := resource.Users rsc := resource.Users
@ -129,7 +129,7 @@ func NewSuiteInfoImpl(
return suiteInfoImpl{ return suiteInfoImpl{
ac: ctrl.AC, ac: ctrl.AC,
controller: ctrl, controller: ctrl,
resourceOwner: resourceOwner, protectedResource: protectedResource,
resourceCategory: rsc, resourceCategory: rsc,
secondaryUser: tconfig.SecondaryM365UserID(t), secondaryUser: tconfig.SecondaryM365UserID(t),
service: service, service: service,
@ -158,8 +158,8 @@ func (si suiteInfoImpl) TertiaryUser() (string, string) {
return si.tertiaryUser, si.tertiaryUserID return si.tertiaryUser, si.tertiaryUserID
} }
func (si suiteInfoImpl) ResourceOwner() string { func (si suiteInfoImpl) ProtectedResource() string {
return si.resourceOwner return si.protectedResource
} }
func (si suiteInfoImpl) Service() path.ServiceType { func (si suiteInfoImpl) Service() path.ServiceType {
@ -388,7 +388,7 @@ func testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(
ctx, ctx,
suite.APIClient(), suite.APIClient(),
suite.Service(), suite.Service(),
suite.ResourceOwner()) suite.ProtectedResource())
rootPath := []string{ rootPath := []string{
odConsts.DrivesPathDir, odConsts.DrivesPathDir,
@ -526,7 +526,7 @@ func testRestoreAndBackupMultipleFilesAndFoldersNoPermissions(
t, t,
testData, testData,
suite.Tenant(), suite.Tenant(),
[]string{suite.ResourceOwner()}, []string{suite.ProtectedResource()},
control.DefaultOptions(), control.DefaultOptions(),
restoreCfg) restoreCfg)
}) })
@ -547,7 +547,7 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
ctx, ctx,
suite.APIClient(), suite.APIClient(),
suite.Service(), suite.Service(),
suite.ResourceOwner()) suite.ProtectedResource())
fileName2 := "test-file2.txt" fileName2 := "test-file2.txt"
folderCName := "folder-c" folderCName := "folder-c"
@ -775,7 +775,7 @@ func testPermissionsRestoreAndBackup(suite oneDriveSuite, startVersion int) {
t, t,
testData, testData,
suite.Tenant(), suite.Tenant(),
[]string{suite.ResourceOwner()}, []string{suite.ProtectedResource()},
control.DefaultOptions(), control.DefaultOptions(),
restoreCfg) restoreCfg)
}) })
@ -796,7 +796,7 @@ func testRestoreNoPermissionsAndBackup(suite oneDriveSuite, startVersion int) {
ctx, ctx,
suite.APIClient(), suite.APIClient(),
suite.Service(), suite.Service(),
suite.ResourceOwner()) suite.ProtectedResource())
inputCols := []stub.ColInfo{ inputCols := []stub.ColInfo{
{ {
@ -867,7 +867,7 @@ func testRestoreNoPermissionsAndBackup(suite oneDriveSuite, startVersion int) {
t, t,
testData, testData,
suite.Tenant(), suite.Tenant(),
[]string{suite.ResourceOwner()}, []string{suite.ProtectedResource()},
control.DefaultOptions(), control.DefaultOptions(),
restoreCfg) restoreCfg)
}) })
@ -891,7 +891,7 @@ func testPermissionsInheritanceRestoreAndBackup(suite oneDriveSuite, startVersio
ctx, ctx,
suite.APIClient(), suite.APIClient(),
suite.Service(), suite.Service(),
suite.ResourceOwner()) suite.ProtectedResource())
folderAName := "custom" folderAName := "custom"
folderBName := "inherited" folderBName := "inherited"
@ -1072,7 +1072,7 @@ func testPermissionsInheritanceRestoreAndBackup(suite oneDriveSuite, startVersio
t, t,
testData, testData,
suite.Tenant(), suite.Tenant(),
[]string{suite.ResourceOwner()}, []string{suite.ProtectedResource()},
control.DefaultOptions(), control.DefaultOptions(),
restoreCfg) restoreCfg)
}) })
@ -1094,7 +1094,7 @@ func testLinkSharesInheritanceRestoreAndBackup(suite oneDriveSuite, startVersion
ctx, ctx,
suite.APIClient(), suite.APIClient(),
suite.Service(), suite.Service(),
suite.ResourceOwner()) suite.ProtectedResource())
folderAName := "custom" folderAName := "custom"
folderBName := "inherited" folderBName := "inherited"
@ -1267,7 +1267,7 @@ func testLinkSharesInheritanceRestoreAndBackup(suite oneDriveSuite, startVersion
t, t,
testData, testData,
suite.Tenant(), suite.Tenant(),
[]string{suite.ResourceOwner()}, []string{suite.ProtectedResource()},
control.DefaultOptions(), control.DefaultOptions(),
restoreCfg) restoreCfg)
}) })
@ -1289,7 +1289,7 @@ func testRestoreFolderNamedFolderRegression(
ctx, ctx,
suite.APIClient(), suite.APIClient(),
suite.Service(), suite.Service(),
suite.ResourceOwner()) suite.ProtectedResource())
rootPath := []string{ rootPath := []string{
odConsts.DrivesPathDir, odConsts.DrivesPathDir,
@ -1383,7 +1383,7 @@ func testRestoreFolderNamedFolderRegression(
t, t,
testData, testData,
suite.Tenant(), suite.Tenant(),
[]string{suite.ResourceOwner()}, []string{suite.ProtectedResource()},
control.DefaultOptions(), control.DefaultOptions(),
restoreCfg) restoreCfg)
}) })

View File

@ -219,7 +219,7 @@ func (sc *Collection) retrieveLists(
lists, err := loadSiteLists( lists, err := loadSiteLists(
ctx, ctx,
sc.client.Stable, sc.client.Stable,
sc.fullPath.ResourceOwner(), sc.fullPath.ProtectedResource(),
sc.jobs, sc.jobs,
errs) errs)
if err != nil { if err != nil {
@ -282,14 +282,14 @@ func (sc *Collection) retrievePages(
return metrics, clues.New("beta service required").WithClues(ctx) return metrics, clues.New("beta service required").WithClues(ctx)
} }
parent, err := as.GetByID(ctx, sc.fullPath.ResourceOwner()) parent, err := as.GetByID(ctx, sc.fullPath.ProtectedResource())
if err != nil { if err != nil {
return metrics, err return metrics, err
} }
root := ptr.Val(parent.GetWebUrl()) root := ptr.Val(parent.GetWebUrl())
pages, err := betaAPI.GetSitePages(ctx, betaService, sc.fullPath.ResourceOwner(), sc.jobs, errs) pages, err := betaAPI.GetSitePages(ctx, betaService, sc.fullPath.ProtectedResource(), sc.jobs, errs)
if err != nil { if err != nil {
return metrics, err return metrics, err
} }

View File

@ -69,7 +69,7 @@ func ConsumeRestoreCollections(
ictx = clues.Add(ctx, ictx = clues.Add(ctx,
"category", category, "category", category,
"restore_location", clues.Hide(rcc.RestoreConfig.Location), "restore_location", clues.Hide(rcc.RestoreConfig.Location),
"resource_owner", clues.Hide(dc.FullPath().ResourceOwner()), "resource_owner", clues.Hide(dc.FullPath().ProtectedResource()),
"full_path", dc.FullPath()) "full_path", dc.FullPath())
) )
@ -219,7 +219,7 @@ func RestoreListCollection(
var ( var (
metrics = support.CollectionMetrics{} metrics = support.CollectionMetrics{}
directory = dc.FullPath() directory = dc.FullPath()
siteID = directory.ResourceOwner() siteID = directory.ProtectedResource()
items = dc.Items(ctx, errs) items = dc.Items(ctx, errs)
el = errs.Local() el = errs.Local()
) )
@ -292,7 +292,7 @@ func RestorePageCollection(
var ( var (
metrics = support.CollectionMetrics{} metrics = support.CollectionMetrics{}
directory = dc.FullPath() directory = dc.FullPath()
siteID = directory.ResourceOwner() siteID = directory.ProtectedResource()
) )
trace.Log(ctx, "m365:sharepoint:restorePageCollection", directory.String()) trace.Log(ctx, "m365:sharepoint:restorePageCollection", directory.String())

View File

@ -183,7 +183,7 @@ func backupOutputPathFromRestore(
return path.Build( return path.Build(
inputPath.Tenant(), inputPath.Tenant(),
inputPath.ResourceOwner(), inputPath.ProtectedResource(),
inputPath.Service(), inputPath.Service(),
inputPath.Category(), inputPath.Category(),
false, false,

View File

@ -482,7 +482,7 @@ func consumeBackupCollections(
func matchesReason(reasons []identity.Reasoner, p path.Path) bool { func matchesReason(reasons []identity.Reasoner, p path.Path) bool {
for _, reason := range reasons { for _, reason := range reasons {
if p.ResourceOwner() == reason.ProtectedResource() && if p.ProtectedResource() == reason.ProtectedResource() &&
p.Service() == reason.Service() && p.Service() == reason.Service() &&
p.Category() == reason.Category() { p.Category() == reason.Category() {
return true return true

View File

@ -538,12 +538,12 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
pathReason1 = kopia.NewReason( pathReason1 = kopia.NewReason(
"", "",
itemPath1.ResourceOwner(), itemPath1.ProtectedResource(),
itemPath1.Service(), itemPath1.Service(),
itemPath1.Category()) itemPath1.Category())
pathReason3 = kopia.NewReason( pathReason3 = kopia.NewReason(
"", "",
itemPath3.ResourceOwner(), itemPath3.ProtectedResource(),
itemPath3.Service(), itemPath3.Service(),
itemPath3.Category()) itemPath3.Category())
) )
@ -685,7 +685,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
[]string{ []string{
itemPath1.Tenant(), itemPath1.Tenant(),
itemPath1.Service().String(), itemPath1.Service().String(),
itemPath1.ResourceOwner(), itemPath1.ProtectedResource(),
path.UnknownCategory.String(), path.UnknownCategory.String(),
}, },
itemPath1.Folders()..., itemPath1.Folders()...,
@ -714,7 +714,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
[]string{ []string{
itemPath1.Tenant(), itemPath1.Tenant(),
path.OneDriveService.String(), path.OneDriveService.String(),
itemPath1.ResourceOwner(), itemPath1.ProtectedResource(),
path.FilesCategory.String(), path.FilesCategory.String(),
"personal", "personal",
"item1", "item1",
@ -973,7 +973,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsFolde
pathReason1 = kopia.NewReason( pathReason1 = kopia.NewReason(
"", "",
itemPath1.ResourceOwner(), itemPath1.ProtectedResource(),
itemPath1.Service(), itemPath1.Service(),
itemPath1.Category()) itemPath1.Category())

View File

@ -44,7 +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.ProtectedResource(),
repoRef.Service(), repoRef.Service(),
repoRef.Category()) repoRef.Category())
if err != nil { if err != nil {
@ -56,7 +56,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.ProtectedResource(),
repoRef.Service(), repoRef.Service(),
repoRef.Category(), repoRef.Category(),
false) false)

View File

@ -40,7 +40,7 @@ func (suite *RestorePathTransformerUnitSuite) TestGetPaths() {
Append( Append(
repoRef.Tenant(), repoRef.Tenant(),
repoRef.Service().String(), repoRef.Service().String(),
repoRef.ResourceOwner(), repoRef.ProtectedResource(),
repoRef.Category().String()). repoRef.Category().String()).
Append(unescapedFolders...). Append(unescapedFolders...).
String() String()

View File

@ -104,7 +104,7 @@ func (p repoRefAndLocRef) locationAsRepoRef() path.Path {
res, err := tmp.ToDataLayerPath( res, err := tmp.ToDataLayerPath(
p.RR.Tenant(), p.RR.Tenant(),
p.RR.ResourceOwner(), p.RR.ProtectedResource(),
p.RR.Service(), p.RR.Service(),
p.RR.Category(), p.RR.Category(),
len(p.ItemLocation()) > 0) len(p.ItemLocation()) > 0)
@ -133,7 +133,7 @@ func mustPathRep(ref string, isItem bool) repoRefAndLocRef {
rr, err := rrPB.ToDataLayerPath( rr, err := rrPB.ToDataLayerPath(
tmp.Tenant(), tmp.Tenant(),
tmp.ResourceOwner(), tmp.ProtectedResource(),
tmp.Service(), tmp.Service(),
tmp.Category(), tmp.Category(),
isItem) isItem)

View File

@ -201,10 +201,10 @@ func (pb Builder) withPrefix(elements ...string) *Builder {
return res return res
} }
// verifyPrefix ensures that the tenant and resourceOwner are valid // verifyPrefix ensures that the tenant and protectedResource are valid
// values, and that the builder has some directory structure. // values, and that the builder has some directory structure.
func (pb Builder) verifyPrefix(tenant, resourceOwner string) error { func (pb Builder) verifyPrefix(tenant, protectedResource string) error {
if err := verifyInputValues(tenant, resourceOwner); err != nil { if err := verifyInputValues(tenant, protectedResource); err != nil {
return err return err
} }

View File

@ -82,7 +82,7 @@ type Path interface {
Service() ServiceType Service() ServiceType
Category() CategoryType Category() CategoryType
Tenant() string Tenant() string
ResourceOwner() string ProtectedResource() string
Folder(escaped bool) string Folder(escaped bool) string
Folders() Elements Folders() Elements
Item() string Item() string
@ -132,7 +132,7 @@ type RestorePaths struct {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
func Build( func Build(
tenant, resourceOwner string, tenant, protectedResource string,
service ServiceType, service ServiceType,
category CategoryType, category CategoryType,
hasItem bool, hasItem bool,
@ -141,13 +141,13 @@ func Build(
b := Builder{}.Append(elements...) b := Builder{}.Append(elements...)
return b.ToDataLayerPath( return b.ToDataLayerPath(
tenant, resourceOwner, tenant, protectedResource,
service, category, service, category,
hasItem) hasItem)
} }
func BuildPrefix( func BuildPrefix(
tenant, resourceOwner string, tenant, protectedResource string,
s ServiceType, s ServiceType,
c CategoryType, c CategoryType,
) (Path, error) { ) (Path, error) {
@ -157,12 +157,12 @@ func BuildPrefix(
return nil, err return nil, err
} }
if err := verifyInputValues(tenant, resourceOwner); err != nil { if err := verifyInputValues(tenant, protectedResource); err != nil {
return nil, err return nil, err
} }
return &dataLayerResourcePath{ return &dataLayerResourcePath{
Builder: *pb.withPrefix(tenant, s.String(), resourceOwner, c.String()), Builder: *pb.withPrefix(tenant, s.String(), protectedResource, c.String()),
service: s, service: s,
category: c, category: c,
hasItem: false, hasItem: false,
@ -290,13 +290,13 @@ func Split(segment string) []string {
// Unexported Helpers // Unexported Helpers
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
func verifyInputValues(tenant, resourceOwner string) error { func verifyInputValues(tenant, protectedResource string) error {
if len(tenant) == 0 { if len(tenant) == 0 {
return clues.Stack(errMissingSegment, clues.New("tenant")) return clues.Stack(errMissingSegment, clues.New("tenant"))
} }
if len(resourceOwner) == 0 { if len(protectedResource) == 0 {
return clues.Stack(errMissingSegment, clues.New("resourceOwner")) return clues.Stack(errMissingSegment, clues.New("protected resource"))
} }
return nil return nil

View File

@ -407,7 +407,7 @@ func (suite *PathUnitSuite) TestFromDataLayerPath() {
assert.Equal(t, service, p.Service(), "service") assert.Equal(t, service, p.Service(), "service")
assert.Equal(t, cat, p.Category(), "category") assert.Equal(t, cat, p.Category(), "category")
assert.Equal(t, testTenant, p.Tenant(), "tenant") assert.Equal(t, testTenant, p.Tenant(), "tenant")
assert.Equal(t, testUser, p.ResourceOwner(), "resource owner") assert.Equal(t, testUser, p.ProtectedResource(), "protected resource")
fld := p.Folder(false) fld := p.Folder(false)
escfld := p.Folder(true) escfld := p.Folder(true)
@ -438,7 +438,7 @@ func (suite *PathUnitSuite) TestBuildPrefix() {
service ServiceType service ServiceType
category CategoryType category CategoryType
tenant string tenant string
owner string resource string
expect string expect string
expectErr require.ErrorAssertionFunc expectErr require.ErrorAssertionFunc
}{ }{
@ -447,7 +447,7 @@ func (suite *PathUnitSuite) TestBuildPrefix() {
service: ExchangeService, service: ExchangeService,
category: ContactsCategory, category: ContactsCategory,
tenant: "t", tenant: "t",
owner: "ro", resource: "ro",
expect: join([]string{"t", ExchangeService.String(), "ro", ContactsCategory.String()}), expect: join([]string{"t", ExchangeService.String(), "ro", ContactsCategory.String()}),
expectErr: require.NoError, expectErr: require.NoError,
}, },
@ -456,7 +456,7 @@ func (suite *PathUnitSuite) TestBuildPrefix() {
service: ExchangeService, service: ExchangeService,
category: FilesCategory, category: FilesCategory,
tenant: "t", tenant: "t",
owner: "ro", resource: "ro",
expectErr: require.Error, expectErr: require.Error,
}, },
{ {
@ -464,15 +464,15 @@ func (suite *PathUnitSuite) TestBuildPrefix() {
service: ExchangeService, service: ExchangeService,
category: ContactsCategory, category: ContactsCategory,
tenant: "", tenant: "",
owner: "ro", resource: "ro",
expectErr: require.Error, expectErr: require.Error,
}, },
{ {
name: "bad owner", name: "bad resource",
service: ExchangeService, service: ExchangeService,
category: ContactsCategory, category: ContactsCategory,
tenant: "t", tenant: "t",
owner: "", resource: "",
expectErr: require.Error, expectErr: require.Error,
}, },
} }
@ -480,7 +480,7 @@ func (suite *PathUnitSuite) TestBuildPrefix() {
suite.Run(test.name, func() { suite.Run(test.name, func() {
t := suite.T() t := suite.T()
r, err := BuildPrefix(test.tenant, test.owner, test.service, test.category) r, err := BuildPrefix(test.tenant, test.resource, test.service, test.category)
test.expectErr(t, err, clues.ToCore(err)) test.expectErr(t, err, clues.ToCore(err))
if r == nil { if r == nil {

View File

@ -10,7 +10,7 @@ import (
// dataLayerResourcePath with invalid service/category combinations. // dataLayerResourcePath with invalid service/category combinations.
// //
// All dataLayerResourcePaths start with the same prefix: // All dataLayerResourcePaths start with the same prefix:
// <tenant ID>/<service>/<resource owner ID>/<category> // <tenant ID>/<service>/<protected resource ID>[/<subService>/<protected resource ID>]/<category>
// which allows extracting high-level information from the path. The path // which allows extracting high-level information from the path. The path
// elements after this prefix represent zero or more folders and, if the path // elements after this prefix represent zero or more folders and, if the path
// refers to a file or item, an item ID. A valid dataLayerResourcePath must have // refers to a file or item, an item ID. A valid dataLayerResourcePath must have
@ -38,9 +38,9 @@ func (rp dataLayerResourcePath) Category() CategoryType {
return rp.category return rp.category
} }
// ResourceOwner returns the user ID or group ID embedded in the // ProtectedResource returns the resource ID embedded in the
// dataLayerResourcePath. // dataLayerResourcePath.
func (rp dataLayerResourcePath) ResourceOwner() string { func (rp dataLayerResourcePath) ProtectedResource() string {
return rp.Builder.elements[2] return rp.Builder.elements[2]
} }

View File

@ -37,7 +37,7 @@ var (
rest: rest, rest: rest,
}, },
{ {
name: "NoResourceOwner", name: "NoProtectedResource",
tenant: testTenant, tenant: testTenant,
user: "", user: "",
rest: rest, rest: rest,
@ -404,7 +404,7 @@ func (suite *DataLayerResourcePath) TestToExchangePathForCategory() {
assert.Equal(t, testTenant, p.Tenant()) assert.Equal(t, testTenant, p.Tenant())
assert.Equal(t, path.ExchangeService, p.Service()) assert.Equal(t, path.ExchangeService, p.Service())
assert.Equal(t, test.category, p.Category()) assert.Equal(t, test.category, p.Category())
assert.Equal(t, testUser, p.ResourceOwner()) assert.Equal(t, testUser, p.ProtectedResource())
assert.Equal(t, strings.Join(m.expectedFolders, "/"), p.Folder(false)) assert.Equal(t, strings.Join(m.expectedFolders, "/"), p.Folder(false))
assert.Equal(t, path.Elements(m.expectedFolders), p.Folders()) assert.Equal(t, path.Elements(m.expectedFolders), p.Folders())
assert.Equal(t, m.expectedItem, p.Item()) assert.Equal(t, m.expectedItem, p.Item())
@ -471,12 +471,12 @@ func (suite *PopulatedDataLayerResourcePath) TestCategory() {
} }
} }
func (suite *PopulatedDataLayerResourcePath) TestResourceOwner() { func (suite *PopulatedDataLayerResourcePath) TestProtectedResource() {
for _, m := range modes { for _, m := range modes {
suite.Run(m.name, func() { suite.Run(m.name, func() {
t := suite.T() t := suite.T()
assert.Equal(t, testUser, suite.paths[m.isItem].ResourceOwner()) assert.Equal(t, testUser, suite.paths[m.isItem].ProtectedResource())
}) })
} }
} }

View File

@ -348,7 +348,7 @@ func ensureAllUsersInDetails(
continue continue
} }
ro := p.ResourceOwner() ro := p.ProtectedResource()
if !assert.NotEmpty(t, ro, "resource owner in path: "+rr) { if !assert.NotEmpty(t, ro, "resource owner in path: "+rr) {
continue continue
} }

View File

@ -816,7 +816,7 @@ func (suite *ExchangeSelectorSuite) TestExchangeRestore_Reduce() {
joinedFldrs := strings.Join(newElems, "/") joinedFldrs := strings.Join(newElems, "/")
return stubRepoRef(p.Service(), p.Category(), p.ResourceOwner(), joinedFldrs, p.Item()) return stubRepoRef(p.Service(), p.Category(), p.ProtectedResource(), joinedFldrs, p.Item())
} }
makeDeets := func(refs ...path.Path) *details.Details { makeDeets := func(refs ...path.Path) *details.Details {

View File

@ -545,7 +545,7 @@ func reduce[T scopeT, C categoryT](
} }
// first check, every entry needs to match the selector's resource owners. // first check, every entry needs to match the selector's resource owners.
if !matchesResourceOwner.Compare(repoPath.ResourceOwner()) { if !matchesResourceOwner.Compare(repoPath.ProtectedResource()) {
continue continue
} }