Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

move M365 creds rotation logic to code #5182

Draft
wants to merge 1 commit into
base: 5080-enable-cache
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ jobs:
# run the tests
- name: Integration Tests
env:
AZURE_CLIENT_ID: ${{ secrets[env.AZURE_CLIENT_ID_NAME] }}
AZURE_CLIENT_SECRET: ${{ secrets[env.AZURE_CLIENT_SECRET_NAME] }}
AZURE_CLIENT_ID: ${{ secrets[CLIENT_ID] }},${{ secrets[CLIENT_ID_2] }},${{ secrets[CLIENT_ID_3] }},${{ secrets[CLIENT_ID_4] }}
AZURE_CLIENT_SECRET: ${{ secrets[CLIENT_SECRET] }},${{ secrets[CLIENT_SECRET_2] }},${{ secrets[CLIENT_SECRET_3] }},${{ secrets[CLIENT_SECRET_4] }}
AZURE_TENANT_ID: ${{ secrets.TENANT_ID }}
CORSO_CI_TESTS: true
CORSO_M365_TEST_USER_ID: ${{ vars.CORSO_M365_TEST_USER_ID }}
Expand Down Expand Up @@ -259,8 +259,8 @@ jobs:
# run the tests
- name: Retention Tests
env:
AZURE_CLIENT_ID: ${{ secrets[env.AZURE_CLIENT_ID_NAME] }}
AZURE_CLIENT_SECRET: ${{ secrets[env.AZURE_CLIENT_SECRET_NAME] }}
AZURE_CLIENT_ID: ${{ secrets[CLIENT_ID] }},${{ secrets[CLIENT_ID_2] }},${{ secrets[CLIENT_ID_3] }},${{ secrets[CLIENT_ID_4] }}
AZURE_CLIENT_SECRET: ${{ secrets[CLIENT_SECRET] }},${{ secrets[CLIENT_SECRET_2] }},${{ secrets[CLIENT_SECRET_3] }},${{ secrets[CLIENT_SECRET_4] }}
AZURE_TENANT_ID: ${{ secrets.TENANT_ID }}
CORSO_RETENTION_TESTS: true
CORSO_M365_TEST_USER_ID: ${{ vars.CORSO_M365_TEST_USER_ID }}
Expand Down
14 changes: 14 additions & 0 deletions src/pkg/credentials/m365.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package credentials

import (
"math/rand"
"os"
"strings"

"github.com/alcionai/clues"
)
Expand All @@ -25,6 +27,18 @@ func GetM365() M365 {
AzureClientID := os.Getenv(AzureClientID)
AzureClientSecret := os.Getenv(AzureClientSecret)

randomNumber := rand.Intn(4) + 1

if strings.Contains(AzureClientID, ",") {
AzureClientIDs := strings.Split(AzureClientID, ",")
AzureClientID = AzureClientIDs[randomNumber]
}

if strings.Contains(AzureClientID, ",") {
AzureClientSecrets := strings.Split(AzureClientSecret, ",")
AzureClientSecret = AzureClientSecrets[randomNumber]
}

return M365{
AzureClientID: AzureClientID,
AzureClientSecret: AzureClientSecret,
Expand Down