Implement wrapper around M365 helper methods (#825)

## Description

Exports functionality useful for external services/validators

## Type of change

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

## Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Vaibhav Kamra 2022-09-13 03:32:02 -07:00 committed by GitHub
parent c82dad6e40
commit 16ad25f3a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,19 @@
package m365
import (
"github.com/pkg/errors"
"github.com/alcionai/corso/src/internal/connector"
"github.com/alcionai/corso/src/pkg/account"
)
// 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)
if err != nil {
return nil, errors.Wrap(err, "could not initialize M365 graph connection")
}
return gc.GetUsers(), nil
}

View File

@ -0,0 +1,40 @@
package m365
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/alcionai/corso/src/internal/tester"
)
type M365IntegrationSuite struct {
suite.Suite
}
func TestM365IntegrationSuite(t *testing.T) {
if err := tester.RunOnAny(
tester.CorsoCITests,
); err != nil {
t.Skip(err)
}
suite.Run(t, new(M365IntegrationSuite))
}
func (suite *M365IntegrationSuite) SetupSuite() {
_, err := tester.GetRequiredEnvSls(
tester.M365AcctCredEnvs)
require.NoError(suite.T(), err)
}
func (suite *M365IntegrationSuite) TestUsers() {
acct := tester.NewM365Account(suite.T())
users, err := Users(acct)
require.NoError(suite.T(), err)
require.NotNil(suite.T(), users)
require.Greater(suite.T(), len(users), 0)
}