diff --git a/src/internal/tester/config.go b/src/internal/tester/config.go index d46eb50bb..852bbc054 100644 --- a/src/internal/tester/config.go +++ b/src/internal/tester/config.go @@ -22,13 +22,15 @@ const ( // M365 config TestCfgAzureTenantID = "azure_tenantid" TestCfgUserID = "m365userid" + TestCfgSecondaryUserID = "secondarym365userid" TestCfgAccountProvider = "account_provider" ) // test specific env vars const ( - EnvCorsoM365TestUserID = "CORSO_M356_TEST_USER_ID" - EnvCorsoTestConfigFilePath = "CORSO_TEST_CONFIG_FILE" + EnvCorsoM365TestUserID = "CORSO_M356_TEST_USER_ID" + EnvCorsoSecondaryM365TestUserID = "CORSO_SECONDARY_M356_TEST_USER_ID" + EnvCorsoTestConfigFilePath = "CORSO_TEST_CONFIG_FILE" ) // global to hold the test config results. @@ -108,6 +110,13 @@ func readTestConfig() (map[string]string, error) { vpr.GetString(TestCfgUserID), "lidiah@8qzvrj.onmicrosoft.com", ) + fallbackTo( + testEnv, + TestCfgSecondaryUserID, + os.Getenv(EnvCorsoSecondaryM365TestUserID), + vpr.GetString(TestCfgSecondaryUserID), + "lynner@8qzvrj.onmicrosoft.com", + ) testEnv[EnvCorsoTestConfigFilePath] = os.Getenv(EnvCorsoTestConfigFilePath) testConfig = testEnv diff --git a/src/internal/tester/users.go b/src/internal/tester/users.go index eb764e1a1..3fe2850df 100644 --- a/src/internal/tester/users.go +++ b/src/internal/tester/users.go @@ -16,3 +16,15 @@ func M365UserID(t *testing.T) string { return cfg[TestCfgUserID] } + +// SecondaryM365UserID returns an userID string representing the m365UserID +// described by either the env var CORSO_SECONDARY_M356_TEST_USER_ID, the +// corso_test.toml config file or the default value (in that order of priority). +// The default is a last-attempt fallback that will only work on alcion's +// testing org. +func SecondaryM365UserID(t *testing.T) string { + cfg, err := readTestConfig() + require.NoError(t, err, "retrieving secondary m365 user id from test configuration") + + return cfg[TestCfgSecondaryUserID] +}