Add secondary test user (#1186)

## Description

Wire up code to fetch secondary user from config/env and also provide it to tests.

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [x] 💻 CI/Deployment
- [ ] 🐹 Trivial/Minor

## Issue(s)

* closes #1185 

merge after to ensure automatic cleanup:
* #1193 

## Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2022-10-18 11:19:53 -07:00 committed by GitHub
parent b752d1da8d
commit 4800904b04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -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

View File

@ -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]
}