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:
parent
c82dad6e40
commit
16ad25f3a1
19
src/pkg/services/m365/m365.go
Normal file
19
src/pkg/services/m365/m365.go
Normal 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
|
||||||
|
}
|
||||||
40
src/pkg/services/m365/m365_test.go
Normal file
40
src/pkg/services/m365/m365_test.go
Normal 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)
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user