GC: Component: Version 40.0 (#917)
## Description Upgrades Graph API to the newest version. Breaking change from the previous version, all functionality needs to be inspected to ensure operation. <!-- Insert PR description--> ## Type of change <!--- Please check the type of change your PR introduces: ---> - [x] 🌻 Feature ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> *closes #828<issue> ## Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
a838be583d
commit
3f3c8217a3
@ -186,7 +186,7 @@ type purgable interface {
|
||||
|
||||
func purgeMailFolders(ctx context.Context, gc *connector.GraphConnector, boundary time.Time) error {
|
||||
getter := func(gs graph.Service, uid, prefix string) ([]purgable, error) {
|
||||
mfs, err := exchange.GetAllMailFolders(gs, uid, prefix)
|
||||
mfs, err := exchange.GetAllMailFolders(ctx, gs, uid, prefix)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -201,7 +201,7 @@ func purgeMailFolders(ctx context.Context, gc *connector.GraphConnector, boundar
|
||||
}
|
||||
|
||||
deleter := func(gs graph.Service, uid, fid string) error {
|
||||
return exchange.DeleteMailFolder(gs, uid, fid)
|
||||
return exchange.DeleteMailFolder(ctx, gs, uid, fid)
|
||||
}
|
||||
|
||||
return purgeFolders(ctx, gc, boundary, "mail", getter, deleter)
|
||||
@ -211,7 +211,7 @@ func purgeMailFolders(ctx context.Context, gc *connector.GraphConnector, boundar
|
||||
|
||||
func purgeCalendarFolders(ctx context.Context, gc *connector.GraphConnector, boundary time.Time) error {
|
||||
getter := func(gs graph.Service, uid, prefix string) ([]purgable, error) {
|
||||
cfs, err := exchange.GetAllCalendars(gs, uid, prefix)
|
||||
cfs, err := exchange.GetAllCalendars(ctx, gs, uid, prefix)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -226,7 +226,7 @@ func purgeCalendarFolders(ctx context.Context, gc *connector.GraphConnector, bou
|
||||
}
|
||||
|
||||
deleter := func(gs graph.Service, uid, fid string) error {
|
||||
return exchange.DeleteCalendar(gs, uid, fid)
|
||||
return exchange.DeleteCalendar(ctx, gs, uid, fid)
|
||||
}
|
||||
|
||||
return purgeFolders(ctx, gc, boundary, "calendar", getter, deleter)
|
||||
@ -236,7 +236,7 @@ func purgeCalendarFolders(ctx context.Context, gc *connector.GraphConnector, bou
|
||||
|
||||
func purgeContactFolders(ctx context.Context, gc *connector.GraphConnector, boundary time.Time) error {
|
||||
getter := func(gs graph.Service, uid, prefix string) ([]purgable, error) {
|
||||
cfs, err := exchange.GetAllContactFolders(gs, uid, prefix)
|
||||
cfs, err := exchange.GetAllContactFolders(ctx, gs, uid, prefix)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -251,7 +251,7 @@ func purgeContactFolders(ctx context.Context, gc *connector.GraphConnector, boun
|
||||
}
|
||||
|
||||
deleter := func(gs graph.Service, uid, fid string) error {
|
||||
return exchange.DeleteContactFolder(gs, uid, fid)
|
||||
return exchange.DeleteContactFolder(ctx, gs, uid, fid)
|
||||
}
|
||||
|
||||
return purgeFolders(ctx, gc, boundary, "contact", getter, deleter)
|
||||
@ -323,7 +323,7 @@ func getGC(ctx context.Context) (*connector.GraphConnector, error) {
|
||||
}
|
||||
|
||||
// build a graph connector
|
||||
gc, err := connector.NewGraphConnector(acct)
|
||||
gc, err := connector.NewGraphConnector(ctx, acct)
|
||||
if err != nil {
|
||||
return nil, Only(ctx, errors.Wrap(err, "connecting to graph api"))
|
||||
}
|
||||
|
||||
35
src/go.mod
35
src/go.mod
@ -5,17 +5,17 @@ go 1.18
|
||||
replace github.com/kopia/kopia => github.com/kopia/kopia v0.11.4-0.20220822194227-5c88bcf1a6e7
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0
|
||||
github.com/aws/aws-sdk-go v1.44.81
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/hashicorp/go-multierror v1.1.1
|
||||
github.com/kopia/kopia v0.11.1
|
||||
github.com/microsoft/kiota-abstractions-go v0.8.2
|
||||
github.com/microsoft/kiota-authentication-azure-go v0.3.0
|
||||
github.com/microsoft/kiota-http-go v0.6.0
|
||||
github.com/microsoft/kiota-serialization-json-go v0.5.5
|
||||
github.com/microsoftgraph/msgraph-sdk-go v0.34.0
|
||||
github.com/microsoftgraph/msgraph-sdk-go-core v0.27.0
|
||||
github.com/microsoft/kiota-abstractions-go v0.10.1
|
||||
github.com/microsoft/kiota-authentication-azure-go v0.4.1
|
||||
github.com/microsoft/kiota-http-go v0.7.2
|
||||
github.com/microsoft/kiota-serialization-json-go v0.6.0
|
||||
github.com/microsoftgraph/msgraph-sdk-go v0.40.0
|
||||
github.com/microsoftgraph/msgraph-sdk-go-core v0.28.1
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rudderlabs/analytics-go v3.3.3+incompatible
|
||||
github.com/spf13/cobra v1.4.0
|
||||
@ -44,20 +44,21 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.1 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.3 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.1 // indirect
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/chmduquesne/rollinghash v4.0.0+incompatible // indirect
|
||||
github.com/cjlapao/common-go v0.0.25 // indirect
|
||||
github.com/cjlapao/common-go v0.0.27 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||
github.com/edsrzf/mmap-go v1.1.0 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/golang-jwt/jwt v3.2.1+incompatible // indirect
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/hashicorp/errwrap v1.0.0 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
@ -74,7 +75,7 @@ require (
|
||||
github.com/mattn/go-runewidth v0.0.13 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
||||
github.com/microsoft/kiota-serialization-text-go v0.4.1 // indirect
|
||||
github.com/microsoft/kiota-serialization-text-go v0.5.0 // indirect
|
||||
github.com/minio/md5-simd v1.1.2 // indirect
|
||||
github.com/minio/minio-go/v7 v7.0.34 // indirect
|
||||
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||
@ -82,7 +83,7 @@ require (
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/natefinch/atomic v1.0.1 // indirect
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
|
||||
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_golang v1.13.0 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
@ -101,11 +102,11 @@ require (
|
||||
go.opentelemetry.io/otel/trace v1.9.0 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
|
||||
golang.org/x/crypto v0.0.0-20220919173607-35f4265a4bc0 // indirect
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
|
||||
golang.org/x/net v0.0.0-20220920191752-2e0b12c274b7 // indirect
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
|
||||
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20220720214146-176da50484ac // indirect
|
||||
google.golang.org/grpc v1.48.0 // indirect
|
||||
|
||||
36
src/go.sum
36
src/go.sum
@ -38,12 +38,20 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.1 h1:tz19qLF65vuu2ibfTqGVJxG/zZAI27NEIIbvAOQwYbw=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.1/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.3 h1:8LoU8N2lIUzkmstvwXvVfniMZlFbesfT2AmA1aqvRr8=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.3/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.1 h1:XUNQ4mw+zJmaA2KXzP9JlQiecy1SI+Eog7xVkPiqIbg=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.1/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 h1:VgSJlZH5u0k2qxSpqyghcFQKmvYckj46uymKK5XzkBM=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0/go.mod h1:BDJ5qMFKx9DugEg3+uQSDCdbYPr5s9vBTrL9P8TpqOU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
@ -73,6 +81,8 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/cjlapao/common-go v0.0.25 h1:/a5SdWGtOFzXceM1RnB3v4hgUK8woMo9Ma/XRgCQ87g=
|
||||
github.com/cjlapao/common-go v0.0.25/go.mod h1:OyTAY388jfEj8uaRzx0uYneFghKDLL5KP+ewSydlQ5g=
|
||||
github.com/cjlapao/common-go v0.0.27 h1:7k8R1Mz2LAudnPb1kaqQ/l+Ba7uL92FG7Rqp9W67mGM=
|
||||
github.com/cjlapao/common-go v0.0.27/go.mod h1:OyTAY388jfEj8uaRzx0uYneFghKDLL5KP+ewSydlQ5g=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
@ -121,7 +131,10 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c=
|
||||
github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||
github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs=
|
||||
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
@ -257,18 +270,32 @@ github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQ
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||
github.com/microsoft/kiota-abstractions-go v0.8.2 h1:KxHr72YwlntvVgF0C+8CtNmNQajtIq7fedq2N0+74Uk=
|
||||
github.com/microsoft/kiota-abstractions-go v0.8.2/go.mod h1:i1wK2rdsLGSjgpnpLHjC60nEa/UdCVS6ulCh1Q+1COw=
|
||||
github.com/microsoft/kiota-abstractions-go v0.10.1 h1:R4vk1l/wn0Dij01yxVX5lD/1UKMEO9Hz5TXkBl6E8do=
|
||||
github.com/microsoft/kiota-abstractions-go v0.10.1/go.mod h1:wOO+hpReDIJa3BxbLNz4qvtZk2llS555mejkMc203bQ=
|
||||
github.com/microsoft/kiota-authentication-azure-go v0.3.0 h1:iLyy5qldAjBiYMGMk1r/rJkcmARA8cKboiN7/XbRxv4=
|
||||
github.com/microsoft/kiota-authentication-azure-go v0.3.0/go.mod h1:qyZWSCug2eG1zrRnCSacyFHGsgQa4aSCWn3EOkY9Z1M=
|
||||
github.com/microsoft/kiota-authentication-azure-go v0.4.1 h1:C+n4Vp3oCj8W8LPiKZDyASTNaKyUomQtUiXQ+B2W0TU=
|
||||
github.com/microsoft/kiota-authentication-azure-go v0.4.1/go.mod h1:jIJAhpPh34bDQWNME65kd/yjqY6+CJZi5jus8H9EH4s=
|
||||
github.com/microsoft/kiota-http-go v0.6.0 h1:pNdkRDLGBMuFryS5XvHUGzCsteAg2a4XMdsG8b7YQJs=
|
||||
github.com/microsoft/kiota-http-go v0.6.0/go.mod h1:4N7GGz5qCZ5JCsEpMyRmGecRckp2evUYRLetIvPBuYs=
|
||||
github.com/microsoft/kiota-http-go v0.7.2 h1:R40vG0EkIFqGvVz5dZtLe4g1sXGVfBO5HxjdBjpwv8k=
|
||||
github.com/microsoft/kiota-http-go v0.7.2/go.mod h1:QTbXPh25mJsbxE23bFqw64BckCioCGfaE77hF/F3rIQ=
|
||||
github.com/microsoft/kiota-serialization-json-go v0.5.5 h1:B0iKBKOdi+9NKFlormLRqduQ1+77MPGRsZ7xnd74EqQ=
|
||||
github.com/microsoft/kiota-serialization-json-go v0.5.5/go.mod h1:GI9vrssO1EvqzDtvMKuhjALn40phZOWkeeaMgtCk6xE=
|
||||
github.com/microsoft/kiota-serialization-json-go v0.6.0 h1:irdhbaY2Vl9t2SLwIC5WyPKJRp3mE52GEBEbAyu7thk=
|
||||
github.com/microsoft/kiota-serialization-json-go v0.6.0/go.mod h1:ceR++Qc8n6McdAR+Ili2UhV4iR8CEx3+RPtANi1UdXc=
|
||||
github.com/microsoft/kiota-serialization-text-go v0.4.1 h1:6QPH7+geUPCpaSZkKCQw0Scngx2IF0vKodrvvWWiu2A=
|
||||
github.com/microsoft/kiota-serialization-text-go v0.4.1/go.mod h1:DsriFnVBDCc4D84qxG3j8q/1Sxu16JILfhxMZm3kdfw=
|
||||
github.com/microsoft/kiota-serialization-text-go v0.5.0 h1:TWb9Y6IsIwzsMVcbBBDLFpVg47mRu2FhQJ6i1dqpLOs=
|
||||
github.com/microsoft/kiota-serialization-text-go v0.5.0/go.mod h1:x9h+VE4X4t8njowIZXyTaAzE6bGK8Zr90MLYV6J6S9U=
|
||||
github.com/microsoftgraph/msgraph-sdk-go v0.34.0 h1:AXPTyCUKaxy4i0qSLBuUbaZTw4thoZTMS2i8KWCItlo=
|
||||
github.com/microsoftgraph/msgraph-sdk-go v0.34.0/go.mod h1:5KCKGk0dKyEK17M40vCHTnyaayUe/SqIOh9aww0ECpU=
|
||||
github.com/microsoftgraph/msgraph-sdk-go v0.40.0 h1:9AxA3FS+S3c7Him5C+7Lt0I8zaNXoSqXsLDink1Fg40=
|
||||
github.com/microsoftgraph/msgraph-sdk-go v0.40.0/go.mod h1:B8HORKdf1K05Z93FbkpiqJ25dnytjPEyAby6gHhOLiM=
|
||||
github.com/microsoftgraph/msgraph-sdk-go-core v0.27.0 h1:FqKddh8nTTbNyUtRCCmPKtgxSNGz944Kw8Q+WU/H+lo=
|
||||
github.com/microsoftgraph/msgraph-sdk-go-core v0.27.0/go.mod h1:kcTY0sEZ/LOJiSj/1OMxcs0T51uodJ/bOeVfWo4lo/s=
|
||||
github.com/microsoftgraph/msgraph-sdk-go-core v0.28.1 h1:gN3pVVvx50KzhQdYwQKVnRSOSOIRaFpXj7pgPfqnNXw=
|
||||
github.com/microsoftgraph/msgraph-sdk-go-core v0.28.1/go.mod h1:BnumnwWU8xUgX7ncgo68novbS1wMlO66Iny9iVhvHuM=
|
||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||
github.com/minio/minio-go/v7 v7.0.34 h1:JMfS5fudx1mN6V2MMNyCJ7UMrjEzZzIvMgfkWc1Vnjk=
|
||||
@ -297,6 +324,8 @@ github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9F
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI=
|
||||
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
@ -425,6 +454,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm
|
||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
|
||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220919173607-35f4265a4bc0 h1:a5Yg6ylndHHYJqIPrdq0AhvR6KTvDTAvgBtaidhEevY=
|
||||
golang.org/x/crypto v0.0.0-20220919173607-35f4265a4bc0/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@ -501,6 +532,8 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.0.0-20220920191752-2e0b12c274b7 h1:DTGA3sVb/sQX+3poldfq5cO4KiOPwLSRBjn2rtck5RM=
|
||||
golang.org/x/net v0.0.0-20220920191752-2e0b12c274b7/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@ -571,6 +604,7 @@ golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@ -578,6 +612,8 @@ golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 h1:h+EGohizhe9XlX18rfpa8k8RAc5XyaeamM+0VHRd4lc=
|
||||
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
||||
@ -133,7 +133,7 @@ func (col *Collection) populateByOptionIdentifier(
|
||||
}
|
||||
|
||||
for _, identifier := range col.jobs {
|
||||
response, err := query(col.service, user, identifier)
|
||||
response, err := query(ctx, col.service, user, identifier)
|
||||
if err != nil {
|
||||
errs = support.WrapAndAppendf(user, err, errs)
|
||||
|
||||
@ -207,7 +207,7 @@ func eventToDataCollection(
|
||||
UsersById(user).
|
||||
EventsById(*event.GetId()).
|
||||
Attachments().
|
||||
Get()
|
||||
Get(ctx, nil)
|
||||
retriesErr = err
|
||||
|
||||
if err == nil && attached != nil {
|
||||
@ -311,7 +311,7 @@ func messageToDataCollection(
|
||||
UsersById(user).
|
||||
MessagesById(*aMessage.GetId()).
|
||||
Attachments().
|
||||
Get()
|
||||
Get(ctx, nil)
|
||||
retriesErr = err
|
||||
|
||||
if err == nil {
|
||||
|
||||
@ -260,6 +260,7 @@ func (suite *ExchangeServiceSuite) TestSetupExchangeCollection() {
|
||||
// TestGraphQueryFunctions verifies if Query functions APIs
|
||||
// through Microsoft Graph are functional
|
||||
func (suite *ExchangeServiceSuite) TestGraphQueryFunctions() {
|
||||
ctx := context.Background()
|
||||
userID := tester.M365UserID(suite.T())
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -297,7 +298,7 @@ func (suite *ExchangeServiceSuite) TestGraphQueryFunctions() {
|
||||
|
||||
for _, test := range tests {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
response, err := test.function(suite.es, userID)
|
||||
response, err := test.function(ctx, suite.es, userID)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, response)
|
||||
})
|
||||
@ -373,11 +374,12 @@ func (suite *ExchangeServiceSuite) TestGetContainerID() {
|
||||
// The result should be all successful items restored within the same folder.
|
||||
func (suite *ExchangeServiceSuite) TestRestoreMessages() {
|
||||
t := suite.T()
|
||||
ctx := context.Background()
|
||||
userID := tester.M365UserID(t)
|
||||
now := time.Now()
|
||||
|
||||
folderName := "TestRestoreMessage: " + common.FormatSimpleDateTime(now)
|
||||
folder, err := CreateMailFolder(suite.es, userID, folderName)
|
||||
folder, err := CreateMailFolder(ctx, suite.es, userID, folderName)
|
||||
require.NoError(t, err)
|
||||
|
||||
folderID := *folder.GetId()
|
||||
@ -390,7 +392,7 @@ func (suite *ExchangeServiceSuite) TestRestoreMessages() {
|
||||
userID,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
err = DeleteMailFolder(suite.es, userID, folderID)
|
||||
err = DeleteMailFolder(ctx, suite.es, userID, folderID)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
@ -398,13 +400,14 @@ func (suite *ExchangeServiceSuite) TestRestoreMessages() {
|
||||
// the Corso Folder. The function handles test clean-up.
|
||||
func (suite *ExchangeServiceSuite) TestRestoreContact() {
|
||||
t := suite.T()
|
||||
ctx := context.Background()
|
||||
// TODO: #884 - reinstate when able to specify root folder by name
|
||||
t.Skip("#884 - reinstate when able to specify root folder by name")
|
||||
userID := tester.M365UserID(t)
|
||||
now := time.Now()
|
||||
|
||||
folderName := "TestRestoreContact: " + common.FormatSimpleDateTime(now)
|
||||
aFolder, err := CreateContactFolder(suite.es, userID, folderName)
|
||||
aFolder, err := CreateContactFolder(ctx, suite.es, userID, folderName)
|
||||
require.NoError(t, err)
|
||||
|
||||
folderID := *aFolder.GetId()
|
||||
@ -416,7 +419,7 @@ func (suite *ExchangeServiceSuite) TestRestoreContact() {
|
||||
userID)
|
||||
assert.NoError(t, err)
|
||||
// Removes folder containing contact prior to exiting test
|
||||
err = DeleteContactFolder(suite.es, userID, folderID)
|
||||
err = DeleteContactFolder(ctx, suite.es, userID, folderID)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
@ -424,11 +427,12 @@ func (suite *ExchangeServiceSuite) TestRestoreContact() {
|
||||
// and sent into the test account of the Corso user in the newly created Corso Calendar
|
||||
func (suite *ExchangeServiceSuite) TestRestoreEvent() {
|
||||
t := suite.T()
|
||||
ctx := context.Background()
|
||||
// TODO: #884 - reinstate when able to specify root folder by name
|
||||
t.Skip("#884 - reinstate when able to specify root folder by name")
|
||||
userID := tester.M365UserID(t)
|
||||
name := "TestRestoreEvent: " + common.FormatSimpleDateTime(time.Now())
|
||||
calendar, err := CreateCalendar(suite.es, userID, name)
|
||||
calendar, err := CreateCalendar(ctx, suite.es, userID, name)
|
||||
require.NoError(t, err)
|
||||
|
||||
calendarID := *calendar.GetId()
|
||||
@ -440,7 +444,7 @@ func (suite *ExchangeServiceSuite) TestRestoreEvent() {
|
||||
userID)
|
||||
assert.NoError(t, err)
|
||||
// Removes calendar containing events created during the test
|
||||
err = DeleteCalendar(suite.es, userID, *calendar.GetId())
|
||||
err = DeleteCalendar(ctx, suite.es, userID, *calendar.GetId())
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
@ -452,7 +456,7 @@ func (suite *ExchangeServiceSuite) TestGetRestoreContainer() {
|
||||
name string
|
||||
option path.CategoryType
|
||||
checkError assert.ErrorAssertionFunc
|
||||
cleanupFunc func(graph.Service, string, string) error
|
||||
cleanupFunc func(context.Context, graph.Service, string, string) error
|
||||
}{
|
||||
{
|
||||
name: "Establish User Restore Folder",
|
||||
@ -497,7 +501,7 @@ func (suite *ExchangeServiceSuite) TestGetRestoreContainer() {
|
||||
require.True(t, test.checkError(t, err, support.ConnectorStackErrorTrace(err)))
|
||||
|
||||
if test.cleanupFunc != nil {
|
||||
err = test.cleanupFunc(suite.es, userID, containerID)
|
||||
err = test.cleanupFunc(ctx, suite.es, userID, containerID)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
})
|
||||
@ -515,7 +519,7 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
|
||||
name string
|
||||
bytes []byte
|
||||
category path.CategoryType
|
||||
cleanupFunc func(graph.Service, string, string) error
|
||||
cleanupFunc func(context.Context, graph.Service, string, string) error
|
||||
destination func() string
|
||||
}{
|
||||
{
|
||||
@ -525,7 +529,7 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
|
||||
cleanupFunc: DeleteMailFolder,
|
||||
destination: func() string {
|
||||
folderName := "TestRestoreMailObject: " + common.FormatSimpleDateTime(now)
|
||||
folder, err := CreateMailFolder(suite.es, userID, folderName)
|
||||
folder, err := CreateMailFolder(ctx, suite.es, userID, folderName)
|
||||
require.NoError(t, err)
|
||||
|
||||
return *folder.GetId()
|
||||
@ -573,7 +577,7 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
|
||||
userID,
|
||||
)
|
||||
assert.NoError(t, err)
|
||||
cleanupError := test.cleanupFunc(service, userID, destination)
|
||||
cleanupError := test.cleanupFunc(ctx, service, userID, destination)
|
||||
assert.NoError(t, cleanupError)
|
||||
})
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ func (suite *ExchangeIteratorSuite) TestIterativeFunctions() {
|
||||
}
|
||||
for _, test := range tests {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
response, err := test.queryFunction(service, userID)
|
||||
response, err := test.queryFunction(ctx, service, userID)
|
||||
require.NoError(t, err)
|
||||
// Create Iterator
|
||||
pageIterator, err := msgraphgocore.NewPageIterator(response,
|
||||
@ -192,7 +192,7 @@ func (suite *ExchangeIteratorSuite) TestIterativeFunctions() {
|
||||
collections,
|
||||
nil)
|
||||
|
||||
iterateError := pageIterator.Iterate(callbackFunc)
|
||||
iterateError := pageIterator.Iterate(ctx, callbackFunc)
|
||||
assert.NoError(t, iterateError)
|
||||
assert.NoError(t, errs)
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ type mailFolderCache struct {
|
||||
|
||||
// populateRoot fetches and populates the root folder in the cache so the cache
|
||||
// knows when to stop resolving the path.
|
||||
func (mc *mailFolderCache) populateRoot(context.Context) error {
|
||||
func (mc *mailFolderCache) populateRoot(ctx context.Context) error {
|
||||
wantedOpts := []string{"displayName", "parentFolderId"}
|
||||
|
||||
opts, err := optionsForMailFoldersItem(wantedOpts)
|
||||
@ -68,7 +68,7 @@ func (mc *mailFolderCache) populateRoot(context.Context) error {
|
||||
Client().
|
||||
UsersById(mc.userID).
|
||||
MailFoldersById(rootFolderAlias).
|
||||
GetWithRequestConfigurationAndResponseHandler(opts, nil)
|
||||
Get(ctx, opts)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "fetching root folder")
|
||||
}
|
||||
@ -125,7 +125,7 @@ func (mc *mailFolderCache) Populate(ctx context.Context) error {
|
||||
var errs *multierror.Error
|
||||
|
||||
for {
|
||||
resp, err := builder.Get()
|
||||
resp, err := builder.Get(ctx, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -67,63 +67,71 @@ func createService(credentials account.M365Config, shouldFailFast bool) (*exchan
|
||||
|
||||
// CreateMailFolder makes a mail folder iff a folder of the same name does not exist
|
||||
// Reference: https://docs.microsoft.com/en-us/graph/api/user-post-mailfolders?view=graph-rest-1.0&tabs=http
|
||||
func CreateMailFolder(gs graph.Service, user, folder string) (models.MailFolderable, error) {
|
||||
func CreateMailFolder(ctx context.Context, gs graph.Service, user, folder string) (models.MailFolderable, error) {
|
||||
requestBody := models.NewMailFolder()
|
||||
requestBody.SetDisplayName(&folder)
|
||||
|
||||
isHidden := false
|
||||
requestBody.SetIsHidden(&isHidden)
|
||||
|
||||
return gs.Client().UsersById(user).MailFolders().Post(requestBody)
|
||||
return gs.Client().UsersById(user).MailFolders().Post(ctx, requestBody, nil)
|
||||
}
|
||||
|
||||
// DeleteMailFolder removes a mail folder with the corresponding M365 ID from the user's M365 Exchange account
|
||||
// Reference: https://docs.microsoft.com/en-us/graph/api/mailfolder-delete?view=graph-rest-1.0&tabs=http
|
||||
func DeleteMailFolder(gs graph.Service, user, folderID string) error {
|
||||
return gs.Client().UsersById(user).MailFoldersById(folderID).Delete()
|
||||
func DeleteMailFolder(ctx context.Context, gs graph.Service, user, folderID string) error {
|
||||
return gs.Client().UsersById(user).MailFoldersById(folderID).Delete(ctx, nil)
|
||||
}
|
||||
|
||||
// CreateCalendar makes an event Calendar with the name in the user's M365 exchange account
|
||||
// Reference: https://docs.microsoft.com/en-us/graph/api/user-post-calendars?view=graph-rest-1.0&tabs=go
|
||||
func CreateCalendar(gs graph.Service, user, calendarName string) (models.Calendarable, error) {
|
||||
func CreateCalendar(ctx context.Context, gs graph.Service, user, calendarName string) (models.Calendarable, error) {
|
||||
requestbody := models.NewCalendar()
|
||||
requestbody.SetName(&calendarName)
|
||||
|
||||
return gs.Client().UsersById(user).Calendars().Post(requestbody)
|
||||
return gs.Client().UsersById(user).Calendars().Post(ctx, requestbody, nil)
|
||||
}
|
||||
|
||||
// DeleteCalendar removes calendar from user's M365 account
|
||||
// Reference: https://docs.microsoft.com/en-us/graph/api/calendar-delete?view=graph-rest-1.0&tabs=go
|
||||
func DeleteCalendar(gs graph.Service, user, calendarID string) error {
|
||||
return gs.Client().UsersById(user).CalendarsById(calendarID).Delete()
|
||||
func DeleteCalendar(ctx context.Context, gs graph.Service, user, calendarID string) error {
|
||||
return gs.Client().UsersById(user).CalendarsById(calendarID).Delete(ctx, nil)
|
||||
}
|
||||
|
||||
// CreateContactFolder makes a contact folder with the displayName of folderName.
|
||||
// If successful, returns the created folder object.
|
||||
func CreateContactFolder(gs graph.Service, user, folderName string) (models.ContactFolderable, error) {
|
||||
func CreateContactFolder(
|
||||
ctx context.Context,
|
||||
gs graph.Service,
|
||||
user, folderName string,
|
||||
) (models.ContactFolderable, error) {
|
||||
requestBody := models.NewContactFolder()
|
||||
temp := folderName
|
||||
requestBody.SetDisplayName(&temp)
|
||||
|
||||
return gs.Client().UsersById(user).ContactFolders().Post(requestBody)
|
||||
return gs.Client().UsersById(user).ContactFolders().Post(ctx, requestBody, nil)
|
||||
}
|
||||
|
||||
// DeleteContactFolder deletes the ContactFolder associated with the M365 ID if permissions are valid.
|
||||
// Errors returned if the function call was not successful.
|
||||
func DeleteContactFolder(gs graph.Service, user, folderID string) error {
|
||||
return gs.Client().UsersById(user).ContactFoldersById(folderID).Delete()
|
||||
func DeleteContactFolder(ctx context.Context, gs graph.Service, user, folderID string) error {
|
||||
return gs.Client().UsersById(user).ContactFoldersById(folderID).Delete(ctx, nil)
|
||||
}
|
||||
|
||||
// GetAllMailFolders retrieves all mail folders for the specified user.
|
||||
// If nameContains is populated, only returns mail matching that property.
|
||||
// Returns a slice of {ID, DisplayName} tuples.
|
||||
func GetAllMailFolders(gs graph.Service, user, nameContains string) ([]models.MailFolderable, error) {
|
||||
func GetAllMailFolders(
|
||||
ctx context.Context,
|
||||
gs graph.Service,
|
||||
user, nameContains string,
|
||||
) ([]models.MailFolderable, error) {
|
||||
var (
|
||||
mfs = []models.MailFolderable{}
|
||||
err error
|
||||
)
|
||||
|
||||
resp, err := GetAllFolderNamesForUser(gs, user)
|
||||
resp, err := GetAllFolderNamesForUser(ctx, gs, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -150,7 +158,7 @@ func GetAllMailFolders(gs graph.Service, user, nameContains string) ([]models.Ma
|
||||
return true
|
||||
}
|
||||
|
||||
if err := iter.Iterate(cb); err != nil {
|
||||
if err := iter.Iterate(ctx, cb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -160,13 +168,13 @@ func GetAllMailFolders(gs graph.Service, user, nameContains string) ([]models.Ma
|
||||
// GetAllCalendars retrieves all event calendars for the specified user.
|
||||
// If nameContains is populated, only returns calendars matching that property.
|
||||
// Returns a slice of {ID, DisplayName} tuples.
|
||||
func GetAllCalendars(gs graph.Service, user, nameContains string) ([]CalendarDisplayable, error) {
|
||||
func GetAllCalendars(ctx context.Context, gs graph.Service, user, nameContains string) ([]CalendarDisplayable, error) {
|
||||
var (
|
||||
cs = []CalendarDisplayable{}
|
||||
err error
|
||||
)
|
||||
|
||||
resp, err := GetAllCalendarNamesForUser(gs, user)
|
||||
resp, err := GetAllCalendarNamesForUser(ctx, gs, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -193,7 +201,7 @@ func GetAllCalendars(gs graph.Service, user, nameContains string) ([]CalendarDis
|
||||
return true
|
||||
}
|
||||
|
||||
if err := iter.Iterate(cb); err != nil {
|
||||
if err := iter.Iterate(ctx, cb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -203,13 +211,17 @@ func GetAllCalendars(gs graph.Service, user, nameContains string) ([]CalendarDis
|
||||
// GetAllContactFolders retrieves all contacts folders for the specified user.
|
||||
// If nameContains is populated, only returns folders matching that property.
|
||||
// Returns a slice of {ID, DisplayName} tuples.
|
||||
func GetAllContactFolders(gs graph.Service, user, nameContains string) ([]models.ContactFolderable, error) {
|
||||
func GetAllContactFolders(
|
||||
ctx context.Context,
|
||||
gs graph.Service,
|
||||
user, nameContains string,
|
||||
) ([]models.ContactFolderable, error) {
|
||||
var (
|
||||
cs = []models.ContactFolderable{}
|
||||
err error
|
||||
)
|
||||
|
||||
resp, err := GetAllContactFolderNamesForUser(gs, user)
|
||||
resp, err := GetAllContactFolderNamesForUser(ctx, gs, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -236,7 +248,7 @@ func GetAllContactFolders(gs graph.Service, user, nameContains string) ([]models
|
||||
return true
|
||||
}
|
||||
|
||||
if err := iter.Iterate(cb); err != nil {
|
||||
if err := iter.Iterate(ctx, cb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -280,7 +292,7 @@ func GetContainerID(
|
||||
return nil, fmt.Errorf("unsupported category %s for GetContainerID()", category)
|
||||
}
|
||||
|
||||
response, err := query(service, user)
|
||||
response, err := query(ctx, service, user)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(
|
||||
err,
|
||||
@ -306,7 +318,7 @@ func GetContainerID(
|
||||
errUpdater,
|
||||
)
|
||||
|
||||
if err := pageIterator.Iterate(callbackFunc); err != nil {
|
||||
if err := pageIterator.Iterate(ctx, callbackFunc); err != nil {
|
||||
return nil, support.WrapAndAppend(service.Adapter().GetBaseUrl(), err, errs)
|
||||
}
|
||||
|
||||
|
||||
@ -1,20 +1,17 @@
|
||||
package exchange_test
|
||||
package exchange
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/connector"
|
||||
"github.com/alcionai/corso/src/internal/connector/exchange"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
)
|
||||
|
||||
type ServiceFunctionsIntegrationSuite struct {
|
||||
suite.Suite
|
||||
gc *connector.GraphConnector
|
||||
m365UserID string
|
||||
}
|
||||
|
||||
@ -30,21 +27,12 @@ func TestServiceFunctionsIntegrationSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *ServiceFunctionsIntegrationSuite) SetupSuite() {
|
||||
t := suite.T()
|
||||
|
||||
_, err := tester.GetRequiredEnvSls(tester.AWSStorageCredEnvs)
|
||||
require.NoError(t, err)
|
||||
|
||||
acct := tester.NewM365Account(t)
|
||||
gc, err := connector.NewGraphConnector(acct)
|
||||
require.NoError(t, err)
|
||||
|
||||
suite.gc = gc
|
||||
suite.m365UserID = tester.M365UserID(t)
|
||||
suite.m365UserID = tester.M365UserID(suite.T())
|
||||
}
|
||||
|
||||
func (suite *ServiceFunctionsIntegrationSuite) TestGetAllCalendars() {
|
||||
gs := suite.gc.Service()
|
||||
gs := loadService(suite.T())
|
||||
ctx := context.Background()
|
||||
|
||||
table := []struct {
|
||||
name, contains, user string
|
||||
@ -80,7 +68,7 @@ func (suite *ServiceFunctionsIntegrationSuite) TestGetAllCalendars() {
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
cals, err := exchange.GetAllCalendars(gs, test.user, test.contains)
|
||||
cals, err := GetAllCalendars(ctx, gs, test.user, test.contains)
|
||||
test.expectErr(t, err)
|
||||
test.expectCount(t, len(cals), 0)
|
||||
})
|
||||
@ -88,7 +76,8 @@ func (suite *ServiceFunctionsIntegrationSuite) TestGetAllCalendars() {
|
||||
}
|
||||
|
||||
func (suite *ServiceFunctionsIntegrationSuite) TestGetAllContactFolders() {
|
||||
gs := suite.gc.Service()
|
||||
gs := loadService(suite.T())
|
||||
ctx := context.Background()
|
||||
|
||||
table := []struct {
|
||||
name, contains, user string
|
||||
@ -124,7 +113,7 @@ func (suite *ServiceFunctionsIntegrationSuite) TestGetAllContactFolders() {
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
cals, err := exchange.GetAllContactFolders(gs, test.user, test.contains)
|
||||
cals, err := GetAllContactFolders(ctx, gs, test.user, test.contains)
|
||||
test.expectErr(t, err)
|
||||
test.expectCount(t, len(cals), 0)
|
||||
})
|
||||
@ -132,7 +121,8 @@ func (suite *ServiceFunctionsIntegrationSuite) TestGetAllContactFolders() {
|
||||
}
|
||||
|
||||
func (suite *ServiceFunctionsIntegrationSuite) TestGetAllMailFolders() {
|
||||
gs := suite.gc.Service()
|
||||
gs := loadService(suite.T())
|
||||
ctx := context.Background()
|
||||
|
||||
table := []struct {
|
||||
name, contains, user string
|
||||
@ -168,7 +158,7 @@ func (suite *ServiceFunctionsIntegrationSuite) TestGetAllMailFolders() {
|
||||
}
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
cals, err := exchange.GetAllMailFolders(gs, test.user, test.contains)
|
||||
cals, err := GetAllMailFolders(ctx, gs, test.user, test.contains)
|
||||
test.expectErr(t, err)
|
||||
test.expectCount(t, len(cals), 0)
|
||||
})
|
||||
|
||||
@ -147,7 +147,7 @@ func IterateSelectAllEventsFromCalendars(
|
||||
eventResponseable, err := service.Client().
|
||||
UsersById(qp.User).
|
||||
CalendarsById(*shell.GetId()).
|
||||
Events().Get()
|
||||
Events().Get(ctx, nil)
|
||||
if err != nil {
|
||||
errUpdater(qp.User, err)
|
||||
}
|
||||
@ -419,7 +419,7 @@ func IterateSelectAllContactsForCollections(
|
||||
statusUpdater,
|
||||
)
|
||||
|
||||
listOfIDs, err := ReturnContactIDsFromDirectory(service, qp.User, *folder.GetParentFolderId())
|
||||
listOfIDs, err := ReturnContactIDsFromDirectory(ctx, service, qp.User, *folder.GetParentFolderId())
|
||||
if err != nil {
|
||||
errUpdater(
|
||||
qp.User,
|
||||
@ -445,7 +445,7 @@ func IterateSelectAllContactsForCollections(
|
||||
return true // Not included
|
||||
}
|
||||
|
||||
listOfIDs, err := ReturnContactIDsFromDirectory(service, qp.User, *folder.GetId())
|
||||
listOfIDs, err := ReturnContactIDsFromDirectory(ctx, service, qp.User, *folder.GetId())
|
||||
if err != nil {
|
||||
errUpdater(
|
||||
qp.User,
|
||||
@ -516,11 +516,11 @@ func iterateFindContainerID(
|
||||
|
||||
// IDistFunc collection of helper functions which return a list of strings
|
||||
// from a response.
|
||||
type IDListFunc func(gs graph.Service, user, m365ID string) ([]string, error)
|
||||
type IDListFunc func(ctx context.Context, gs graph.Service, user, m365ID string) ([]string, error)
|
||||
|
||||
// ReturnContactIDsFromDirectory function that returns a list of all the m365IDs of the contacts
|
||||
// of the targeted directory
|
||||
func ReturnContactIDsFromDirectory(gs graph.Service, user, directoryID string) ([]string, error) {
|
||||
func ReturnContactIDsFromDirectory(ctx context.Context, gs graph.Service, user, directoryID string) ([]string, error) {
|
||||
options, err := optionsForContactFoldersItem([]string{"parentFolderId"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -532,7 +532,7 @@ func ReturnContactIDsFromDirectory(gs graph.Service, user, directoryID string) (
|
||||
UsersById(user).
|
||||
ContactFoldersById(directoryID).
|
||||
Contacts().
|
||||
GetWithRequestConfigurationAndResponseHandler(options, nil)
|
||||
Get(ctx, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -555,7 +555,7 @@ func ReturnContactIDsFromDirectory(gs graph.Service, user, directoryID string) (
|
||||
return true
|
||||
}
|
||||
|
||||
if iterateErr := pageIterator.Iterate(callbackFunc); iterateErr != nil {
|
||||
if iterateErr := pageIterator.Iterate(ctx, callbackFunc); iterateErr != nil {
|
||||
return nil, iterateErr
|
||||
}
|
||||
|
||||
|
||||
@ -17,10 +17,10 @@ import (
|
||||
// into M365 backstore. Responses -> returned items will only contain the information
|
||||
// that is included in the options
|
||||
// TODO: use selector or path for granularity into specific folders or specific date ranges
|
||||
type GraphQuery func(gs graph.Service, userID string) (absser.Parsable, error)
|
||||
type GraphQuery func(ctx context.Context, gs graph.Service, userID string) (absser.Parsable, error)
|
||||
|
||||
// GetAllMessagesForUser is a GraphQuery function for receiving all messages for a single user
|
||||
func GetAllMessagesForUser(gs graph.Service, user string) (absser.Parsable, error) {
|
||||
func GetAllMessagesForUser(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) {
|
||||
selecting := []string{"id", "parentFolderId"}
|
||||
|
||||
options, err := optionsForMessages(selecting)
|
||||
@ -28,11 +28,11 @@ func GetAllMessagesForUser(gs graph.Service, user string) (absser.Parsable, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return gs.Client().UsersById(user).Messages().GetWithRequestConfigurationAndResponseHandler(options, nil)
|
||||
return gs.Client().UsersById(user).Messages().Get(ctx, options)
|
||||
}
|
||||
|
||||
// GetAllContactsForUser is a GraphQuery function for querying all the contacts in a user's account
|
||||
func GetAllContactsForUser(gs graph.Service, user string) (absser.Parsable, error) {
|
||||
func GetAllContactsForUser(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) {
|
||||
selecting := []string{"parentFolderId"}
|
||||
|
||||
options, err := optionsForContacts(selecting)
|
||||
@ -40,44 +40,44 @@ func GetAllContactsForUser(gs graph.Service, user string) (absser.Parsable, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return gs.Client().UsersById(user).Contacts().GetWithRequestConfigurationAndResponseHandler(options, nil)
|
||||
return gs.Client().UsersById(user).Contacts().Get(ctx, options)
|
||||
}
|
||||
|
||||
// GetAllFolderDisplayNamesForUser is a GraphQuery function for getting FolderId and display
|
||||
// names for Mail Folder. All other information for the MailFolder object is omitted.
|
||||
func GetAllFolderNamesForUser(gs graph.Service, user string) (absser.Parsable, error) {
|
||||
func GetAllFolderNamesForUser(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) {
|
||||
options, err := optionsForMailFolders([]string{"displayName"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return gs.Client().UsersById(user).MailFolders().GetWithRequestConfigurationAndResponseHandler(options, nil)
|
||||
return gs.Client().UsersById(user).MailFolders().Get(ctx, options)
|
||||
}
|
||||
|
||||
func GetAllCalendarNamesForUser(gs graph.Service, user string) (absser.Parsable, error) {
|
||||
func GetAllCalendarNamesForUser(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) {
|
||||
options, err := optionsForCalendars([]string{"name", "owner"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return gs.Client().UsersById(user).Calendars().GetWithRequestConfigurationAndResponseHandler(options, nil)
|
||||
return gs.Client().UsersById(user).Calendars().Get(ctx, options)
|
||||
}
|
||||
|
||||
// GetAllContactFolderNamesForUser is a GraphQuery function for getting ContactFolderId
|
||||
// and display names for contacts. All other information is omitted.
|
||||
// Does not return the primary Contact Folder
|
||||
func GetAllContactFolderNamesForUser(gs graph.Service, user string) (absser.Parsable, error) {
|
||||
func GetAllContactFolderNamesForUser(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) {
|
||||
options, err := optionsForContactFolders([]string{"displayName", "parentFolderId"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return gs.Client().UsersById(user).ContactFolders().GetWithRequestConfigurationAndResponseHandler(options, nil)
|
||||
return gs.Client().UsersById(user).ContactFolders().Get(ctx, options)
|
||||
}
|
||||
|
||||
// GetAllUsersForTenant is a GraphQuery for retrieving all the UserCollectionResponse with
|
||||
// that contains the UserID and email for each user. All other information is omitted
|
||||
func GetAllUsersForTenant(gs graph.Service, user string) (absser.Parsable, error) {
|
||||
func GetAllUsersForTenant(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) {
|
||||
selecting := []string{"userPrincipalName"}
|
||||
|
||||
options, err := optionsForUsers(selecting)
|
||||
@ -85,41 +85,41 @@ func GetAllUsersForTenant(gs graph.Service, user string) (absser.Parsable, error
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return gs.Client().Users().GetWithRequestConfigurationAndResponseHandler(options, nil)
|
||||
return gs.Client().Users().Get(ctx, options)
|
||||
}
|
||||
|
||||
// GetAllEvents for User. Default returns EventResponseCollection for future events.
|
||||
// of the time that the call was made. 'calendar' option must be present to gain
|
||||
// access to additional data map in future calls.
|
||||
func GetAllEventsForUser(gs graph.Service, user string) (absser.Parsable, error) {
|
||||
func GetAllEventsForUser(ctx context.Context, gs graph.Service, user string) (absser.Parsable, error) {
|
||||
options, err := optionsForEvents([]string{"id", "calendar"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return gs.Client().UsersById(user).Events().GetWithRequestConfigurationAndResponseHandler(options, nil)
|
||||
return gs.Client().UsersById(user).Events().Get(ctx, options)
|
||||
}
|
||||
|
||||
// GraphRetrievalFunctions are functions from the Microsoft Graph API that retrieve
|
||||
// the default associated data of a M365 object. This varies by object. Additional
|
||||
// Queries must be run to obtain the omitted fields.
|
||||
type GraphRetrievalFunc func(gs graph.Service, user, m365ID string) (absser.Parsable, error)
|
||||
type GraphRetrievalFunc func(ctx context.Context, gs graph.Service, user, m365ID string) (absser.Parsable, error)
|
||||
|
||||
// RetrieveContactDataForUser is a GraphRetrievalFun that returns all associated fields.
|
||||
func RetrieveContactDataForUser(gs graph.Service, user, m365ID string) (absser.Parsable, error) {
|
||||
return gs.Client().UsersById(user).ContactsById(m365ID).Get()
|
||||
func RetrieveContactDataForUser(ctx context.Context, gs graph.Service, user, m365ID string) (absser.Parsable, error) {
|
||||
return gs.Client().UsersById(user).ContactsById(m365ID).Get(ctx, nil)
|
||||
}
|
||||
|
||||
// RetrieveEventDataForUser is a GraphRetrievalFunc that returns event data.
|
||||
// Calendarable and attachment fields are omitted due to size
|
||||
func RetrieveEventDataForUser(gs graph.Service, user, m365ID string) (absser.Parsable, error) {
|
||||
return gs.Client().UsersById(user).EventsById(m365ID).Get()
|
||||
func RetrieveEventDataForUser(ctx context.Context, gs graph.Service, user, m365ID string) (absser.Parsable, error) {
|
||||
return gs.Client().UsersById(user).EventsById(m365ID).Get(ctx, nil)
|
||||
}
|
||||
|
||||
// RetrieveMessageDataForUser is a GraphRetrievalFunc that returns message data.
|
||||
// Attachment field is omitted due to size.
|
||||
func RetrieveMessageDataForUser(gs graph.Service, user, m365ID string) (absser.Parsable, error) {
|
||||
return gs.Client().UsersById(user).MessagesById(m365ID).Get()
|
||||
func RetrieveMessageDataForUser(ctx context.Context, gs graph.Service, user, m365ID string) (absser.Parsable, error) {
|
||||
return gs.Client().UsersById(user).MessagesById(m365ID).Get(ctx, nil)
|
||||
}
|
||||
|
||||
func CollectFolders(
|
||||
@ -153,7 +153,7 @@ func CollectFolders(
|
||||
return fmt.Errorf("unsupported option %s used in CollectFolders", option)
|
||||
}
|
||||
|
||||
response, err := query(queryService, qp.User)
|
||||
response, err := query(ctx, queryService, qp.User)
|
||||
if err != nil {
|
||||
return fmt.Errorf(
|
||||
"unable to query mail folder for %s: details: %s",
|
||||
@ -184,7 +184,7 @@ func CollectFolders(
|
||||
statusUpdater,
|
||||
)
|
||||
|
||||
iterateFailure := pageIterator.Iterate(callbackFunc)
|
||||
iterateFailure := pageIterator.Iterate(ctx, callbackFunc)
|
||||
if iterateFailure != nil {
|
||||
err = support.WrapAndAppend(qp.User+" iterate failure", iterateFailure, err)
|
||||
}
|
||||
|
||||
@ -39,21 +39,21 @@ func GetRestoreContainer(
|
||||
|
||||
switch option {
|
||||
case messages:
|
||||
fold, err := CreateMailFolder(service, user, name)
|
||||
fold, err := CreateMailFolder(ctx, service, user, name)
|
||||
if err != nil {
|
||||
return "", support.WrapAndAppend(fmt.Sprintf("creating folder %s for user %s", name, user), err, err)
|
||||
}
|
||||
|
||||
return *fold.GetId(), nil
|
||||
case contacts:
|
||||
fold, err := CreateContactFolder(service, user, name)
|
||||
fold, err := CreateContactFolder(ctx, service, user, name)
|
||||
if err != nil {
|
||||
return "", support.WrapAndAppend(user+"failure during CreateContactFolder during restore Contact", err, err)
|
||||
}
|
||||
|
||||
return *fold.GetId(), nil
|
||||
case events:
|
||||
calendar, err := CreateCalendar(service, user, name)
|
||||
calendar, err := CreateCalendar(ctx, service, user, name)
|
||||
if err != nil {
|
||||
return "", support.WrapAndAppend(user+"failure during CreateCalendar during restore Event", err, err)
|
||||
}
|
||||
@ -111,7 +111,7 @@ func RestoreExchangeContact(
|
||||
return errors.Wrap(err, "failure to create contact from bytes: RestoreExchangeContact")
|
||||
}
|
||||
|
||||
response, err := service.Client().UsersById(user).ContactFoldersById(destination).Contacts().Post(contact)
|
||||
response, err := service.Client().UsersById(user).ContactFoldersById(destination).Contacts().Post(ctx, contact, nil)
|
||||
if err != nil {
|
||||
return errors.Wrap(
|
||||
err,
|
||||
@ -145,7 +145,7 @@ func RestoreExchangeEvent(
|
||||
return err
|
||||
}
|
||||
|
||||
response, err := service.Client().UsersById(user).CalendarsById(destination).Events().Post(event)
|
||||
response, err := service.Client().UsersById(user).CalendarsById(destination).Events().Post(ctx, event, nil)
|
||||
if err != nil {
|
||||
return errors.Wrap(err,
|
||||
fmt.Sprintf(
|
||||
@ -215,7 +215,7 @@ func RestoreMailMessage(
|
||||
"policy", cp)
|
||||
fallthrough
|
||||
case control.Copy:
|
||||
return SendMailToBackStore(service, user, destination, clone)
|
||||
return SendMailToBackStore(ctx, service, user, destination, clone)
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,8 +223,13 @@ func RestoreMailMessage(
|
||||
// @param user string represents M365 ID of user within the tenant
|
||||
// @param destination represents M365 ID of a folder within the users's space
|
||||
// @param message is a models.Messageable interface from "github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||
func SendMailToBackStore(service graph.Service, user, destination string, message models.Messageable) error {
|
||||
sentMessage, err := service.Client().UsersById(user).MailFoldersById(destination).Messages().Post(message)
|
||||
func SendMailToBackStore(
|
||||
ctx context.Context,
|
||||
service graph.Service,
|
||||
user, destination string,
|
||||
message models.Messageable,
|
||||
) error {
|
||||
sentMessage, err := service.Client().UsersById(user).MailFoldersById(destination).Messages().Post(ctx, message, nil)
|
||||
if err != nil {
|
||||
return errors.Wrap(err,
|
||||
*message.GetId()+": failure sendMailAPI: "+support.ConnectorStackErrorTrace(err),
|
||||
|
||||
@ -65,7 +65,7 @@ func (gs graphService) ErrPolicy() bool {
|
||||
return gs.failFast
|
||||
}
|
||||
|
||||
func NewGraphConnector(acct account.Account) (*GraphConnector, error) {
|
||||
func NewGraphConnector(ctx context.Context, acct account.Account) (*GraphConnector, error) {
|
||||
m365, err := acct.M365Config()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "retrieving m356 account configuration")
|
||||
@ -85,7 +85,7 @@ func NewGraphConnector(acct account.Account) (*GraphConnector, error) {
|
||||
|
||||
gc.graphService = *aService
|
||||
|
||||
err = gc.setTenantUsers()
|
||||
err = gc.setTenantUsers(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -120,8 +120,8 @@ func (gs *graphService) EnableFailFast() {
|
||||
// setTenantUsers queries the M365 to identify the users in the
|
||||
// workspace. The users field is updated during this method
|
||||
// iff the return value is true
|
||||
func (gc *GraphConnector) setTenantUsers() error {
|
||||
response, err := exchange.GetAllUsersForTenant(gc.graphService, "")
|
||||
func (gc *GraphConnector) setTenantUsers(ctx context.Context) error {
|
||||
response, err := exchange.GetAllUsersForTenant(ctx, gc.graphService, "")
|
||||
if err != nil {
|
||||
return errors.Wrapf(
|
||||
err,
|
||||
@ -168,7 +168,7 @@ func (gc *GraphConnector) setTenantUsers() error {
|
||||
return true
|
||||
}
|
||||
|
||||
iterateError := userIterator.Iterate(callbackFunc)
|
||||
iterateError := userIterator.Iterate(ctx, callbackFunc)
|
||||
if iterateError != nil {
|
||||
err = support.WrapAndAppend(gc.graphService.adapter.GetBaseUrl(), iterateError, err)
|
||||
}
|
||||
@ -380,7 +380,7 @@ func (gc *GraphConnector) createCollections(
|
||||
}
|
||||
collections := make(map[string]*exchange.Collection)
|
||||
|
||||
response, err := query(&gc.graphService, qp.User)
|
||||
response, err := query(ctx, &gc.graphService, qp.User)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(
|
||||
err,
|
||||
@ -401,7 +401,7 @@ func (gc *GraphConnector) createCollections(
|
||||
// with corresponding item M365IDs. New collections are created for each directory.
|
||||
// Each directory used the M365 Identifier. The use of ID stops collisions betweens users
|
||||
callbackFunc := gIter(ctx, qp, errUpdater, collections, gc.UpdateStatus)
|
||||
iterateError := pageIterator.Iterate(callbackFunc)
|
||||
iterateError := pageIterator.Iterate(ctx, callbackFunc)
|
||||
|
||||
if iterateError != nil {
|
||||
errs = support.WrapAndAppend(gc.graphService.adapter.GetBaseUrl(), iterateError, errs)
|
||||
|
||||
@ -29,6 +29,7 @@ func TestDisconnectedGraphSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *DisconnectedGraphConnectorSuite) TestBadConnection() {
|
||||
ctx := context.Background()
|
||||
table := []struct {
|
||||
name string
|
||||
acct func(t *testing.T) account.Account
|
||||
@ -59,9 +60,10 @@ func (suite *DisconnectedGraphConnectorSuite) TestBadConnection() {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range table {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
gc, err := NewGraphConnector(test.acct(t))
|
||||
gc, err := NewGraphConnector(ctx, test.acct(t))
|
||||
assert.Nil(t, gc, test.name+" failed")
|
||||
assert.NotNil(t, err, test.name+"failed")
|
||||
})
|
||||
|
||||
@ -25,9 +25,9 @@ type GraphConnectorIntegrationSuite struct {
|
||||
user string
|
||||
}
|
||||
|
||||
func loadConnector(t *testing.T) *GraphConnector {
|
||||
func loadConnector(ctx context.Context, t *testing.T) *GraphConnector {
|
||||
a := tester.NewM365Account(t)
|
||||
connector, err := NewGraphConnector(a)
|
||||
connector, err := NewGraphConnector(ctx, a)
|
||||
require.NoError(t, err)
|
||||
|
||||
return connector
|
||||
@ -49,9 +49,10 @@ func (suite *GraphConnectorIntegrationSuite) SetupSuite() {
|
||||
suite.T().Skip(err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
|
||||
require.NoError(suite.T(), err)
|
||||
suite.connector = loadConnector(suite.T())
|
||||
suite.connector = loadConnector(ctx, suite.T())
|
||||
suite.user = tester.M365UserID(suite.T())
|
||||
tester.LogTimeOfTest(suite.T())
|
||||
}
|
||||
@ -64,14 +65,14 @@ func (suite *GraphConnectorIntegrationSuite) TestSetTenantUsers() {
|
||||
Users: make(map[string]string, 0),
|
||||
credentials: suite.connector.credentials,
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
service, err := newConnector.createService(false)
|
||||
require.NoError(suite.T(), err)
|
||||
|
||||
newConnector.graphService = *service
|
||||
|
||||
suite.Equal(len(newConnector.Users), 0)
|
||||
err = newConnector.setTenantUsers()
|
||||
err = newConnector.setTenantUsers(ctx)
|
||||
assert.NoError(suite.T(), err)
|
||||
suite.Greater(len(newConnector.Users), 0)
|
||||
}
|
||||
@ -83,8 +84,9 @@ func (suite *GraphConnectorIntegrationSuite) TestSetTenantUsers() {
|
||||
// - contacts
|
||||
// - events
|
||||
func (suite *GraphConnectorIntegrationSuite) TestExchangeDataCollection() {
|
||||
ctx := context.Background()
|
||||
t := suite.T()
|
||||
connector := loadConnector(t)
|
||||
connector := loadConnector(ctx, t)
|
||||
sel := selectors.NewExchangeBackup()
|
||||
sel.Include(sel.Users([]string{suite.user}))
|
||||
collectionList, err := connector.ExchangeDataCollection(context.Background(), sel.Selector)
|
||||
@ -121,8 +123,9 @@ func (suite *GraphConnectorIntegrationSuite) TestExchangeDataCollection() {
|
||||
// test account can be successfully downloaded into bytes and restored into
|
||||
// M365 mail objects
|
||||
func (suite *GraphConnectorIntegrationSuite) TestMailSerializationRegression() {
|
||||
ctx := context.Background()
|
||||
t := suite.T()
|
||||
connector := loadConnector(t)
|
||||
connector := loadConnector(ctx, t)
|
||||
sel := selectors.NewExchangeBackup()
|
||||
sel.Include(sel.MailFolders([]string{suite.user}, []string{"Inbox"}))
|
||||
eb, err := sel.ToExchangeBackup()
|
||||
@ -159,6 +162,7 @@ func (suite *GraphConnectorIntegrationSuite) TestMailSerializationRegression() {
|
||||
// and to store contact within Collection. Downloaded contacts are run through
|
||||
// a regression test to ensure that downloaded items can be uploaded.
|
||||
func (suite *GraphConnectorIntegrationSuite) TestContactSerializationRegression() {
|
||||
ctx := context.Background()
|
||||
t := suite.T()
|
||||
sel := selectors.NewExchangeBackup()
|
||||
sel.Include(sel.ContactFolders([]string{suite.user}, selectors.Any()))
|
||||
@ -166,7 +170,7 @@ func (suite *GraphConnectorIntegrationSuite) TestContactSerializationRegression(
|
||||
require.NoError(t, err)
|
||||
|
||||
scopes := eb.Scopes()
|
||||
connector := loadConnector(t)
|
||||
connector := loadConnector(ctx, t)
|
||||
|
||||
suite.Len(scopes, 1)
|
||||
contactsOnly := scopes[0]
|
||||
@ -201,8 +205,9 @@ func (suite *GraphConnectorIntegrationSuite) TestContactSerializationRegression(
|
||||
// TestEventsSerializationRegression ensures functionality of createCollections
|
||||
// to be able to successfully query, download and restore event objects
|
||||
func (suite *GraphConnectorIntegrationSuite) TestEventsSerializationRegression() {
|
||||
ctx := context.Background()
|
||||
t := suite.T()
|
||||
connector := loadConnector(t)
|
||||
connector := loadConnector(ctx, t)
|
||||
sel := selectors.NewExchangeBackup()
|
||||
sel.Include(sel.EventCalendars([]string{suite.user}, selectors.Any()))
|
||||
scopes := sel.Scopes()
|
||||
@ -240,8 +245,9 @@ func (suite *GraphConnectorIntegrationSuite) TestEventsSerializationRegression()
|
||||
// The final test insures that more than a 75% of the user collections are
|
||||
// returned. If an error was experienced, the test will fail overall
|
||||
func (suite *GraphConnectorIntegrationSuite) TestAccessOfInboxAllUsers() {
|
||||
ctx := context.Background()
|
||||
t := suite.T()
|
||||
connector := loadConnector(t)
|
||||
connector := loadConnector(ctx, t)
|
||||
sel := selectors.NewExchangeBackup()
|
||||
sel.Include(sel.MailFolders(selectors.Any(), []string{"Inbox"}))
|
||||
scopes := sel.DiscreteScopes(connector.GetUsers())
|
||||
@ -262,13 +268,14 @@ func (suite *GraphConnectorIntegrationSuite) TestAccessOfInboxAllUsers() {
|
||||
// TestCreateAndDeleteMailFolder ensures GraphConnector has the ability
|
||||
// to create and remove folders within the tenant
|
||||
func (suite *GraphConnectorIntegrationSuite) TestCreateAndDeleteMailFolder() {
|
||||
ctx := context.Background()
|
||||
now := time.Now()
|
||||
folderName := "TestFolder: " + common.FormatSimpleDateTime(now)
|
||||
aFolder, err := exchange.CreateMailFolder(&suite.connector.graphService, suite.user, folderName)
|
||||
aFolder, err := exchange.CreateMailFolder(ctx, suite.connector.Service(), suite.user, folderName)
|
||||
assert.NoError(suite.T(), err, support.ConnectorStackErrorTrace(err))
|
||||
|
||||
if aFolder != nil {
|
||||
err = exchange.DeleteMailFolder(suite.connector.Service(), suite.user, *aFolder.GetId())
|
||||
err = exchange.DeleteMailFolder(ctx, suite.connector.Service(), suite.user, *aFolder.GetId())
|
||||
assert.NoError(suite.T(), err)
|
||||
|
||||
if err != nil {
|
||||
@ -280,13 +287,14 @@ func (suite *GraphConnectorIntegrationSuite) TestCreateAndDeleteMailFolder() {
|
||||
// TestCreateAndDeleteContactFolder ensures GraphConnector has the ability
|
||||
// to create and remove contact folders within the tenant
|
||||
func (suite *GraphConnectorIntegrationSuite) TestCreateAndDeleteContactFolder() {
|
||||
ctx := context.Background()
|
||||
now := time.Now()
|
||||
folderName := "TestContactFolder: " + common.FormatSimpleDateTime(now)
|
||||
aFolder, err := exchange.CreateContactFolder(suite.connector.Service(), suite.user, folderName)
|
||||
aFolder, err := exchange.CreateContactFolder(ctx, suite.connector.Service(), suite.user, folderName)
|
||||
assert.NoError(suite.T(), err)
|
||||
|
||||
if aFolder != nil {
|
||||
err = exchange.DeleteContactFolder(suite.connector.Service(), suite.user, *aFolder.GetId())
|
||||
err = exchange.DeleteContactFolder(ctx, suite.connector.Service(), suite.user, *aFolder.GetId())
|
||||
assert.NoError(suite.T(), err)
|
||||
|
||||
if err != nil {
|
||||
@ -298,14 +306,15 @@ func (suite *GraphConnectorIntegrationSuite) TestCreateAndDeleteContactFolder()
|
||||
// TestCreateAndDeleteCalendar verifies GraphConnector has the ability to create and remove
|
||||
// exchange.Event.Calendars within the tenant
|
||||
func (suite *GraphConnectorIntegrationSuite) TestCreateAndDeleteCalendar() {
|
||||
ctx := context.Background()
|
||||
now := time.Now()
|
||||
service := suite.connector.Service()
|
||||
calendarName := "TestCalendar: " + common.FormatSimpleDateTime(now)
|
||||
calendar, err := exchange.CreateCalendar(service, suite.user, calendarName)
|
||||
calendar, err := exchange.CreateCalendar(ctx, service, suite.user, calendarName)
|
||||
assert.NoError(suite.T(), err)
|
||||
|
||||
if calendar != nil {
|
||||
err = exchange.DeleteCalendar(service, suite.user, *calendar.GetId())
|
||||
err = exchange.DeleteCalendar(ctx, service, suite.user, *calendar.GetId())
|
||||
assert.NoError(suite.T(), err)
|
||||
|
||||
if err != nil {
|
||||
|
||||
@ -25,7 +25,7 @@ const (
|
||||
|
||||
// Enumerates the drives for the specified user
|
||||
func drives(ctx context.Context, service graph.Service, user string) ([]models.Driveable, error) {
|
||||
r, err := service.Client().UsersById(user).Drives().Get()
|
||||
r, err := service.Client().UsersById(user).Drives().Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to retrieve user drives. user: %s, details: %s",
|
||||
user, support.ConnectorStackErrorTrace(err))
|
||||
@ -53,7 +53,7 @@ func collectItems(
|
||||
builder := service.Client().DrivesById(driveID).Root().Delta()
|
||||
|
||||
for {
|
||||
r, err := builder.Get()
|
||||
r, err := builder.Get(ctx, nil)
|
||||
if err != nil {
|
||||
return errors.Wrapf(
|
||||
err,
|
||||
@ -84,7 +84,7 @@ func collectItems(
|
||||
func getFolder(ctx context.Context, service graph.Service, driveID string, parentFolderID string,
|
||||
folderName string,
|
||||
) (models.DriveItemable, error) {
|
||||
children, err := service.Client().DrivesById(driveID).ItemsById(parentFolderID).Children().Get()
|
||||
children, err := service.Client().DrivesById(driveID).ItemsById(parentFolderID).Children().Get(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(
|
||||
err,
|
||||
@ -114,7 +114,7 @@ func createItem(ctx context.Context, service graph.Service, driveID string, pare
|
||||
|
||||
builder := items.NewItemsRequestBuilder(rawURL, service.Adapter())
|
||||
|
||||
newItem, err := builder.Post(item)
|
||||
newItem, err := builder.Post(ctx, item, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(
|
||||
err,
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
msup "github.com/microsoftgraph/msgraph-sdk-go/drives/item/items/item/createuploadsession"
|
||||
"github.com/pkg/errors"
|
||||
"gopkg.in/resty.v1"
|
||||
|
||||
@ -32,7 +33,7 @@ func driveItemReader(
|
||||
) (string, io.ReadCloser, error) {
|
||||
logger.Ctx(ctx).Debugf("Reading Item %s at %s", itemID, time.Now())
|
||||
|
||||
item, err := service.Client().DrivesById(driveID).ItemsById(itemID).Get()
|
||||
item, err := service.Client().DrivesById(driveID).ItemsById(itemID).Get(ctx, nil)
|
||||
if err != nil {
|
||||
return "", nil, errors.Wrapf(err, "failed to get item %s", itemID)
|
||||
}
|
||||
@ -61,7 +62,10 @@ func driveItemReader(
|
||||
// It does so by creating an upload session and using that URL to initialize an `itemWriter`
|
||||
func driveItemWriter(ctx context.Context, service graph.Service, driveID, itemID string, itemSize int64,
|
||||
) (io.Writer, error) {
|
||||
r, err := service.Client().DrivesById(driveID).ItemsById(itemID).CreateUploadSession().Post(nil)
|
||||
// TODO: @vkamra verify if var session is the desired input
|
||||
session := msup.NewCreateUploadSessionPostRequestBody()
|
||||
|
||||
r, err := service.Client().DrivesById(driveID).ItemsById(itemID).CreateUploadSession().Post(ctx, session, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(
|
||||
err,
|
||||
|
||||
@ -128,7 +128,7 @@ func (suite *ItemIntegrationSuite) TestItemWriter() {
|
||||
// Pick the first drive
|
||||
driveID := *drives[0].GetId()
|
||||
|
||||
root, err := suite.Client().DrivesById(driveID).Root().Get()
|
||||
root, err := suite.Client().DrivesById(driveID).Root().Get(ctx, nil)
|
||||
require.NoError(suite.T(), err)
|
||||
|
||||
// Test Requirement 2: "Test Folder" should exist
|
||||
|
||||
@ -115,7 +115,7 @@ func RestoreCollections(ctx context.Context, service graph.Service, dcs []data.C
|
||||
// of the last folder entry in the hiearchy
|
||||
func createRestoreFolders(ctx context.Context, service graph.Service, driveID string, restoreFolders []string,
|
||||
) (string, error) {
|
||||
driveRoot, err := service.Client().DrivesById(driveID).Root().Get()
|
||||
driveRoot, err := service.Client().DrivesById(driveID).Root().Get(ctx, nil)
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(
|
||||
err,
|
||||
|
||||
@ -114,7 +114,7 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
|
||||
}()
|
||||
|
||||
// retrieve data from the producer
|
||||
gc, err := connector.NewGraphConnector(op.account)
|
||||
gc, err := connector.NewGraphConnector(ctx, op.account)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "connecting to graph api")
|
||||
opStats.readErr = err
|
||||
|
||||
@ -178,7 +178,7 @@ func (op *RestoreOperation) Run(ctx context.Context) (err error) {
|
||||
opStats.resourceCount = len(data.ResourceOwnerSet(dcs))
|
||||
|
||||
// restore those collections using graph
|
||||
gc, err := connector.NewGraphConnector(op.account)
|
||||
gc, err := connector.NewGraphConnector(ctx, op.account)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "connecting to graph api")
|
||||
opStats.writeErr = err
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package m365
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/connector"
|
||||
@ -9,8 +11,8 @@ import (
|
||||
|
||||
// Users returns a list of users in the specified M365 tenant
|
||||
// TODO: Implement paging support
|
||||
func Users(m365Account account.Account) ([]string, error) {
|
||||
gc, err := connector.NewGraphConnector(m365Account)
|
||||
func Users(ctx context.Context, m365Account account.Account) ([]string, error) {
|
||||
gc, err := connector.NewGraphConnector(ctx, m365Account)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not initialize M365 graph connection")
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package m365
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -32,7 +33,7 @@ func (suite *M365IntegrationSuite) SetupSuite() {
|
||||
func (suite *M365IntegrationSuite) TestUsers() {
|
||||
acct := tester.NewM365Account(suite.T())
|
||||
|
||||
users, err := Users(acct)
|
||||
users, err := Users(context.Background(), acct)
|
||||
require.NoError(suite.T(), err)
|
||||
|
||||
require.NotNil(suite.T(), users)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user