fix order of lat/long (#38818)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #38777 # Checklist for submitter If some of the following don't apply, delete the relevant line. ## Testing - [x] Added/updated automated tests - [x] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [x] QA'd all new/changed functionality manually For unreleased bug fixes in a release candidate, one of: - [x] Confirmed that the fix is not expected to adversely impact load test results
This commit is contained in:
@@ -33,7 +33,7 @@ describe("LocationModal", () => {
|
||||
expect(link).toBeVisible();
|
||||
expect(link).toHaveAttribute(
|
||||
"href",
|
||||
"https://www.google.com/maps?q=44.9844,-93.2602"
|
||||
"https://www.google.com/maps?q=-93.2602,44.9844"
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ const buildGoogleMapsLinkFromGeo = (loc: IGeoLocation): string | null => {
|
||||
Array.isArray(geometry.coordinates) &&
|
||||
geometry.coordinates.length >= 2
|
||||
) {
|
||||
const [lng, lat] = geometry.coordinates; // GeoJSON is [lng, lat]
|
||||
const [lat, lng] = geometry.coordinates; // GeoJSON is [lat, lng]
|
||||
if (lat != null && lng != null) {
|
||||
return `https://www.google.com/maps?q=${lat},${lng}`;
|
||||
}
|
||||
|
||||
@@ -1002,13 +1002,13 @@ func (c *TestAppleMDMClient) AcknowledgeDeviceInformation(udid, cmdUUID, deviceN
|
||||
return c.sendAndDecodeCommandResponse(payload)
|
||||
}
|
||||
|
||||
func (c *TestAppleMDMClient) AcknowledgeDeviceLocation(udid, cmdUUID string) (*mdm.Command, error) {
|
||||
func (c *TestAppleMDMClient) AcknowledgeDeviceLocation(udid, cmdUUID string, lat, long float64) (*mdm.Command, error) {
|
||||
payload := map[string]any{
|
||||
"Status": "Acknowledged",
|
||||
"UDID": udid,
|
||||
"CommandUUID": cmdUUID,
|
||||
"Latitude": 42.42,
|
||||
"Longitude": -42.42,
|
||||
"Latitude": lat,
|
||||
"Longitude": long,
|
||||
}
|
||||
|
||||
return c.sendAndDecodeCommandResponse(payload)
|
||||
|
||||
@@ -3733,7 +3733,6 @@ func (svc *MDMAppleCheckinAndCommandService) CommandAndReportResults(r *mdm.Requ
|
||||
}
|
||||
|
||||
case fleet.DisableLostModeCmdName:
|
||||
|
||||
if cmdResult.Status == fleet.MDMAppleStatusAcknowledged ||
|
||||
cmdResult.Status == fleet.MDMAppleStatusError ||
|
||||
cmdResult.Status == fleet.MDMAppleStatusCommandFormatError {
|
||||
|
||||
@@ -96,7 +96,7 @@ func (svc *Service) GetHostLocationData(ctx context.Context, hostID uint) (*flee
|
||||
}
|
||||
|
||||
ret.Geometry = &fleet.Geometry{
|
||||
Coordinates: []float64{locData.Longitude, locData.Latitude},
|
||||
Coordinates: []float64{locData.Latitude, locData.Longitude},
|
||||
}
|
||||
|
||||
return &ret, nil
|
||||
|
||||
@@ -196,6 +196,8 @@ func (s *integrationMDMTestSuite) TestLockUnlockWipeIOSIpadOS() {
|
||||
}
|
||||
|
||||
s.enableABM(t.Name())
|
||||
abmTok, err := s.ds.GetABMTokenByOrgName(t.Context(), t.Name())
|
||||
require.NoError(t, err)
|
||||
s.mockDEPResponse(t.Name(), http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
encoder := json.NewEncoder(w)
|
||||
@@ -241,6 +243,7 @@ func (s *integrationMDMTestSuite) TestLockUnlockWipeIOSIpadOS() {
|
||||
// We fake set installed_from_dep to emulate the devices was enrolled with DEP.
|
||||
require.NoError(t, s.ds.SetOrUpdateMDMData(t.Context(), iosHost.ID, false, true, s.server.URL, true, t.Name(), "", false))
|
||||
require.NoError(t, s.ds.SetOrUpdateMDMData(t.Context(), iPadOSHost.ID, false, true, s.server.URL, true, t.Name(), "", false))
|
||||
s.Require().NoError(s.ds.UpsertMDMAppleHostDEPAssignments(t.Context(), []fleet.Host{*iosHost, *iPadOSHost}, abmTok.ID, nil))
|
||||
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
@@ -292,15 +295,22 @@ func (s *integrationMDMTestSuite) TestLockUnlockWipeIOSIpadOS() {
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, cmd)
|
||||
require.Equal(t, "DeviceLocation", cmd.Command.RequestType)
|
||||
_, err = tc.mdmClient.AcknowledgeDeviceLocation(getHostResp.Host.UUID, cmd.CommandUUID)
|
||||
expectedLat, expectedLong := 42.42, 26.26
|
||||
_, err = tc.mdmClient.AcknowledgeDeviceLocation(getHostResp.Host.UUID, cmd.CommandUUID, expectedLat, expectedLong)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Run device location handler
|
||||
s.runWorker()
|
||||
|
||||
// refresh the host's status, it is now locked
|
||||
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/hosts/%d", tc.host.ID), nil, http.StatusOK, &getHostResp)
|
||||
require.NotNil(t, getHostResp.Host.MDM.DeviceStatus)
|
||||
require.Equal(t, string(fleet.DeviceStatusLocked), *getHostResp.Host.MDM.DeviceStatus)
|
||||
require.NotNil(t, getHostResp.Host.MDM.PendingAction)
|
||||
require.Equal(t, "", *getHostResp.Host.MDM.PendingAction)
|
||||
// Fleet should have the device's location data now
|
||||
s.Assert().NotNil(getHostResp.Host.Geolocation)
|
||||
s.Assert().Equal([]float64{expectedLat, expectedLong}, getHostResp.Host.Geolocation.Geometry.Coordinates)
|
||||
|
||||
// try to lock the host again
|
||||
s.Do("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/lock", tc.host.ID), nil, http.StatusConflict)
|
||||
@@ -340,12 +350,16 @@ func (s *integrationMDMTestSuite) TestLockUnlockWipeIOSIpadOS() {
|
||||
require.NoError(t, err)
|
||||
|
||||
// refresh the host's status, it is now unlocked
|
||||
getHostResp = getHostResponse{}
|
||||
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/hosts/%d", tc.host.ID), nil, http.StatusOK, &getHostResp)
|
||||
require.NotNil(t, getHostResp.Host.MDM.DeviceStatus)
|
||||
require.Equal(t, string(fleet.DeviceStatusUnlocked), *getHostResp.Host.MDM.DeviceStatus)
|
||||
require.NotNil(t, getHostResp.Host.MDM.PendingAction)
|
||||
require.Equal(t, "", *getHostResp.Host.MDM.PendingAction)
|
||||
|
||||
// Host location data should have been deleted
|
||||
s.Assert().Nil(getHostResp.Host.Geolocation)
|
||||
|
||||
// wipe the host
|
||||
var wipeResp wipeHostResponse
|
||||
s.DoJSON("POST", fmt.Sprintf("/api/latest/fleet/hosts/%d/wipe", tc.host.ID), nil, http.StatusOK, &wipeResp)
|
||||
|
||||
Reference in New Issue
Block a user