mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 00:45:19 +00:00
Calendar config API endpoints bug fixes. (#17640)
Bug fixes for frontend - google_calendar can be nil for global config to indicate that it should not change - `fleet/teams/:id` endpoint now working
This commit is contained in:
parent
c9b917a491
commit
d3e1716572
@ -209,6 +209,15 @@ func (svc *Service) ModifyTeam(ctx context.Context, teamID uint, payload fleet.T
|
||||
|
||||
team.Config.Integrations.Jira = payload.Integrations.Jira
|
||||
team.Config.Integrations.Zendesk = payload.Integrations.Zendesk
|
||||
// Only update the google calendar integration if it's not nil
|
||||
if payload.Integrations.GoogleCalendar != nil {
|
||||
invalid := &fleet.InvalidArgumentError{}
|
||||
_ = svc.validateTeamCalendarIntegrations(ctx, team, payload.Integrations.GoogleCalendar, appCfg, invalid)
|
||||
if invalid.HasErrors() {
|
||||
return nil, ctxerr.Wrap(ctx, invalid)
|
||||
}
|
||||
team.Config.Integrations.GoogleCalendar = payload.Integrations.GoogleCalendar
|
||||
}
|
||||
}
|
||||
|
||||
if payload.WebhookSettings != nil || payload.Integrations != nil {
|
||||
|
@ -478,6 +478,10 @@ func (svc *Service) ModifyAppConfig(ctx context.Context, p []byte, applyOpts fle
|
||||
}
|
||||
}
|
||||
}
|
||||
// If google_calendar is null, we keep the existing setting. If it's not null, we update.
|
||||
if newAppConfig.Integrations.GoogleCalendar == nil {
|
||||
appConfig.Integrations.GoogleCalendar = oldAppConfig.Integrations.GoogleCalendar
|
||||
}
|
||||
|
||||
if !license.IsPremium() {
|
||||
// reset transparency url to empty for downgraded licenses
|
||||
|
@ -1029,6 +1029,21 @@ func (s *integrationEnterpriseTestSuite) TestTeamEndpoints() {
|
||||
modifyExpiry.HostExpirySettings.HostExpiryWindow = 0
|
||||
s.DoJSON("PATCH", fmt.Sprintf("/api/latest/fleet/teams/%d", tm1ID), modifyExpiry, http.StatusUnprocessableEntity, &tmResp)
|
||||
|
||||
// Modify team's calendar config
|
||||
modifyCalendar := fleet.TeamPayload{
|
||||
Integrations: &fleet.TeamIntegrations{
|
||||
GoogleCalendar: &fleet.TeamGoogleCalendarIntegration{
|
||||
Email: "calendar@example.com",
|
||||
},
|
||||
},
|
||||
}
|
||||
s.DoJSON("PATCH", fmt.Sprintf("/api/latest/fleet/teams/%d", tm1ID), modifyCalendar, http.StatusOK, &tmResp)
|
||||
assert.Equal(t, modifyCalendar.Integrations.GoogleCalendar, tmResp.Team.Config.Integrations.GoogleCalendar)
|
||||
|
||||
// Illegal team calendar config
|
||||
modifyCalendar.Integrations.GoogleCalendar.Enable = true
|
||||
s.DoJSON("PATCH", fmt.Sprintf("/api/latest/fleet/teams/%d", tm1ID), modifyCalendar, http.StatusUnprocessableEntity, &tmResp)
|
||||
|
||||
// list team users
|
||||
var usersResp listUsersResponse
|
||||
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/teams/%d/users", tm1ID), nil, http.StatusOK, &usersResp)
|
||||
|
Loading…
Reference in New Issue
Block a user