add test cases
This commit is contained in:
parent
fadd5ec5df
commit
d92f3446b5
@ -341,7 +341,7 @@ func TeamsCompat(ctx context.Context, acct account.Account) ([]*Team, error) {
|
||||
|
||||
// Teams returns a list of teams in the specified M365 tenant
|
||||
func Teams(ctx context.Context, acct account.Account, errs *fault.Bus) ([]*Team, error) {
|
||||
ac, err := makeAC(ctx, acct, path.TeamsService)
|
||||
ac, err := makeAC(ctx, acct, path.GroupsService)
|
||||
if err != nil {
|
||||
return nil, clues.Stack(err).WithClues(ctx)
|
||||
}
|
||||
@ -365,17 +365,13 @@ func parseTeam(item models.Groupable) (*Team, error) {
|
||||
}
|
||||
|
||||
type getAllGroupers interface {
|
||||
GetAll(ctx context.Context, filterTeams bool, errs *fault.Bus) ([]models.Groupable, error)
|
||||
GetAll(ctx context.Context, errs *fault.Bus) ([]models.Groupable, error)
|
||||
GetTeams(ctx context.Context, errs *fault.Bus) ([]models.Groupable, error)
|
||||
}
|
||||
|
||||
func getAllTeams(ctx context.Context, gas getAllGroupers) ([]*Team, error) {
|
||||
teams, err := gas.GetAll(ctx, true, fault.New(true))
|
||||
// TODO: check this. Label has to be changed
|
||||
teams, err := gas.GetTeams(ctx, fault.New(true))
|
||||
if err != nil {
|
||||
if clues.HasLabel(err, graph.LabelsNoSharePointLicense) {
|
||||
return nil, clues.Stack(graph.ErrServiceNotEnabled, err)
|
||||
}
|
||||
|
||||
return nil, clues.Wrap(err, "retrieving teams")
|
||||
}
|
||||
|
||||
|
||||
@ -145,6 +145,30 @@ func (suite *M365IntegrationSuite) TestSites() {
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *M365IntegrationSuite) TestTeams() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
graph.InitializeConcurrencyLimiter(ctx, true, 4)
|
||||
|
||||
acct := tconfig.NewM365Account(suite.T())
|
||||
|
||||
teams, err := Teams(ctx, acct, fault.New(true))
|
||||
assert.NoError(t, err, clues.ToCore(err))
|
||||
assert.NotEmpty(t, teams)
|
||||
|
||||
for _, team := range teams {
|
||||
suite.Run("team_"+team.ID, func() {
|
||||
t := suite.T()
|
||||
|
||||
assert.NotEmpty(t, team.ID)
|
||||
assert.NotEmpty(t, team.DisplayName)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type m365UnitSuite struct {
|
||||
tester.Suite
|
||||
}
|
||||
@ -473,6 +497,45 @@ func (suite *DiscoveryIntgSuite) TestSites_InvalidCredentials() {
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *DiscoveryIntgSuite) TestTeams_InvalidCredentials() {
|
||||
table := []struct {
|
||||
name string
|
||||
acct func(t *testing.T) account.Account
|
||||
}{
|
||||
{
|
||||
name: "Invalid Credentials",
|
||||
acct: func(t *testing.T) account.Account {
|
||||
a, err := account.NewAccount(
|
||||
account.ProviderM365,
|
||||
account.M365Config{
|
||||
M365: credentials.M365{
|
||||
AzureClientID: "Test",
|
||||
AzureClientSecret: "without",
|
||||
},
|
||||
AzureTenantID: "data",
|
||||
},
|
||||
)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
return a
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range table {
|
||||
suite.Run(test.name, func() {
|
||||
t := suite.T()
|
||||
|
||||
ctx, flush := tester.NewContext(t)
|
||||
defer flush()
|
||||
|
||||
teams, err := Teams(ctx, test.acct(t), fault.New(true))
|
||||
assert.Empty(t, teams, "returned some teams")
|
||||
assert.NotNil(t, err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *DiscoveryIntgSuite) TestGetUserInfo() {
|
||||
table := []struct {
|
||||
name string
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user