<!-- PR description--> --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [x] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
67 lines
1.6 KiB
Go
67 lines
1.6 KiB
Go
package common
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
|
"github.com/alcionai/corso/src/pkg/account"
|
|
"github.com/alcionai/corso/src/pkg/control"
|
|
"github.com/alcionai/corso/src/pkg/credentials"
|
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
|
)
|
|
|
|
type PermissionInfo struct {
|
|
EntityID string
|
|
Roles []string
|
|
}
|
|
|
|
const (
|
|
sanityBackupID = "SANITY_BACKUP_ID"
|
|
sanityTestSourceContainer = "SANITY_TEST_SOURCE_CONTAINER"
|
|
sanityTestRestoreContainer = "SANITY_TEST_RESTORE_CONTAINER"
|
|
sanityTestUser = "SANITY_TEST_USER"
|
|
)
|
|
|
|
type Envs struct {
|
|
BackupID string
|
|
SourceContainer string
|
|
RestoreContainer string
|
|
GroupID string
|
|
SiteID string
|
|
UserID string
|
|
TeamSiteID string
|
|
}
|
|
|
|
func EnvVars(ctx context.Context) Envs {
|
|
folder := strings.TrimSpace(os.Getenv(sanityTestRestoreContainer))
|
|
|
|
e := Envs{
|
|
BackupID: os.Getenv(sanityBackupID),
|
|
SourceContainer: os.Getenv(sanityTestSourceContainer),
|
|
RestoreContainer: folder,
|
|
GroupID: tconfig.GetM365TeamID(ctx),
|
|
SiteID: tconfig.GetM365SiteID(ctx),
|
|
UserID: tconfig.GetM365UserID(ctx),
|
|
TeamSiteID: tconfig.GetM365TeamSiteID(ctx),
|
|
}
|
|
|
|
if len(os.Getenv(sanityTestUser)) > 0 {
|
|
e.UserID = os.Getenv(sanityTestUser)
|
|
}
|
|
|
|
Infof(ctx, "test env vars: %+v", e)
|
|
|
|
return e
|
|
}
|
|
|
|
func GetAC() (api.Client, error) {
|
|
creds := account.M365Config{
|
|
M365: credentials.GetM365(),
|
|
AzureTenantID: os.Getenv(account.AzureTenantID),
|
|
}
|
|
|
|
return api.NewClient(creds, control.DefaultOptions())
|
|
}
|