mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
Update route for hosts encryption key (#9821)
This commit is contained in:
parent
9a8024d5c9
commit
8daead3ef5
@ -3002,7 +3002,7 @@ Requires Fleet's MDM properly [enabled and configured](./Mobile-device-managemen
|
|||||||
|
|
||||||
Retrieves the disk encryption key for a host.
|
Retrieves the disk encryption key for a host.
|
||||||
|
|
||||||
`GET /api/v1/fleet/hosts/:id/encryption_key`
|
`GET /api/v1/fleet/mdm/hosts/:id/encryption_key`
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
@ -3013,7 +3013,7 @@ Retrieves the disk encryption key for a host.
|
|||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
`GET /api/v1/fleet/hosts/8/encryption_key`
|
`GET /api/v1/fleet/mdm/hosts/8/encryption_key`
|
||||||
|
|
||||||
##### Default response
|
##### Default response
|
||||||
|
|
||||||
|
@ -437,10 +437,11 @@ func attachFleetAPIRoutes(r *mux.Router, svc fleet.Service, config config.FleetC
|
|||||||
ue.GET("/api/_version_/fleet/mdm/apple/installers", listMDMAppleInstallersEndpoint, listMDMAppleInstallersRequest{})
|
ue.GET("/api/_version_/fleet/mdm/apple/installers", listMDMAppleInstallersEndpoint, listMDMAppleInstallersRequest{})
|
||||||
ue.GET("/api/_version_/fleet/mdm/apple/devices", listMDMAppleDevicesEndpoint, listMDMAppleDevicesRequest{})
|
ue.GET("/api/_version_/fleet/mdm/apple/devices", listMDMAppleDevicesEndpoint, listMDMAppleDevicesRequest{})
|
||||||
ue.GET("/api/_version_/fleet/mdm/apple/dep/devices", listMDMAppleDEPDevicesEndpoint, listMDMAppleDEPDevicesRequest{})
|
ue.GET("/api/_version_/fleet/mdm/apple/dep/devices", listMDMAppleDEPDevicesEndpoint, listMDMAppleDEPDevicesRequest{})
|
||||||
ue.GET("/api/_version_/fleet/hosts/{id:[0-9]+}/encryption_key", getHostEncryptionKey, getHostEncryptionKeyRequest{})
|
|
||||||
|
|
||||||
// host-specific mdm commands
|
// host-specific mdm routes
|
||||||
ue.PATCH("/api/_version_/fleet/mdm/hosts/{id:[0-9]+}/unenroll", mdmAppleCommandRemoveEnrollmentProfileEndpoint, mdmAppleCommandRemoveEnrollmentProfileRequest{})
|
ue.PATCH("/api/_version_/fleet/mdm/hosts/{id:[0-9]+}/unenroll", mdmAppleCommandRemoveEnrollmentProfileEndpoint, mdmAppleCommandRemoveEnrollmentProfileRequest{})
|
||||||
|
ue.GET("/api/_version_/fleet/mdm/hosts/{id:[0-9]+}/encryption_key", getHostEncryptionKey, getHostEncryptionKeyRequest{})
|
||||||
|
|
||||||
}
|
}
|
||||||
ue.POST("/api/_version_/fleet/mdm/apple/dep/key_pair", newMDMAppleDEPKeyPairEndpoint, nil)
|
ue.POST("/api/_version_/fleet/mdm/apple/dep/key_pair", newMDMAppleDEPKeyPairEndpoint, nil)
|
||||||
ue.GET("/api/_version_/fleet/mdm/apple", getAppleMDMEndpoint, nil)
|
ue.GET("/api/_version_/fleet/mdm/apple", getAppleMDMEndpoint, nil)
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -25,8 +26,6 @@ import (
|
|||||||
"github.com/micromdm/nanomdm/push"
|
"github.com/micromdm/nanomdm/push"
|
||||||
nanomdm_pushsvc "github.com/micromdm/nanomdm/push/service"
|
nanomdm_pushsvc "github.com/micromdm/nanomdm/push/service"
|
||||||
|
|
||||||
"sync/atomic"
|
|
||||||
|
|
||||||
"github.com/fleetdm/fleet/v4/server/config"
|
"github.com/fleetdm/fleet/v4/server/config"
|
||||||
"github.com/fleetdm/fleet/v4/server/datastore/mysql"
|
"github.com/fleetdm/fleet/v4/server/datastore/mysql"
|
||||||
"github.com/fleetdm/fleet/v4/server/fleet"
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
||||||
@ -621,18 +620,18 @@ func (s *integrationMDMTestSuite) TestMDMAppleGetEncryptionKey() {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// request with no token
|
// request with no token
|
||||||
res := s.DoRawNoAuth("GET", fmt.Sprintf("/api/latest/fleet/hosts/%d/encryption_key", host.ID), nil, http.StatusUnauthorized)
|
res := s.DoRawNoAuth("GET", fmt.Sprintf("/api/latest/fleet/mdm/hosts/%d/encryption_key", host.ID), nil, http.StatusUnauthorized)
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
|
|
||||||
// encryption key not processed yet
|
// encryption key not processed yet
|
||||||
resp := getHostEncryptionKeyResponse{}
|
resp := getHostEncryptionKeyResponse{}
|
||||||
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/hosts/%d/encryption_key", host.ID), nil, http.StatusNotFound, &resp)
|
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/mdm/hosts/%d/encryption_key", host.ID), nil, http.StatusNotFound, &resp)
|
||||||
|
|
||||||
// unable to decrypt encryption key
|
// unable to decrypt encryption key
|
||||||
err = s.ds.SetHostsDiskEncryptionKeyStatus(ctx, []uint{host.ID}, false, time.Now())
|
err = s.ds.SetHostsDiskEncryptionKeyStatus(ctx, []uint{host.ID}, false, time.Now())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
resp = getHostEncryptionKeyResponse{}
|
resp = getHostEncryptionKeyResponse{}
|
||||||
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/hosts/%d/encryption_key", host.ID), nil, http.StatusNotFound, &resp)
|
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/mdm/hosts/%d/encryption_key", host.ID), nil, http.StatusNotFound, &resp)
|
||||||
|
|
||||||
// no activities created so far
|
// no activities created so far
|
||||||
activities := listActivitiesResponse{}
|
activities := listActivitiesResponse{}
|
||||||
@ -650,7 +649,7 @@ func (s *integrationMDMTestSuite) TestMDMAppleGetEncryptionKey() {
|
|||||||
err = s.ds.SetHostsDiskEncryptionKeyStatus(ctx, []uint{host.ID}, true, time.Now())
|
err = s.ds.SetHostsDiskEncryptionKeyStatus(ctx, []uint{host.ID}, true, time.Now())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
resp = getHostEncryptionKeyResponse{}
|
resp = getHostEncryptionKeyResponse{}
|
||||||
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/hosts/%d/encryption_key", host.ID), nil, http.StatusOK, &resp)
|
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/mdm/hosts/%d/encryption_key", host.ID), nil, http.StatusOK, &resp)
|
||||||
require.Equal(t, recoveryKey, resp.EncryptionKey.DecryptedValue)
|
require.Equal(t, recoveryKey, resp.EncryptionKey.DecryptedValue)
|
||||||
|
|
||||||
// use the admin token to get the activities
|
// use the admin token to get the activities
|
||||||
@ -753,8 +752,7 @@ func (s *integrationMDMTestSuite) TestMDMAppleGetEncryptionKey() {
|
|||||||
// non-members aren't able to see the token
|
// non-members aren't able to see the token
|
||||||
s.token = s.getTestToken(u.Email, test.GoodPassword)
|
s.token = s.getTestToken(u.Email, test.GoodPassword)
|
||||||
resp = getHostEncryptionKeyResponse{}
|
resp = getHostEncryptionKeyResponse{}
|
||||||
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/hosts/%d/encryption_key", host.ID), nil, http.StatusForbidden, &resp)
|
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/mdm/hosts/%d/encryption_key", host.ID), nil, http.StatusForbidden, &resp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type device struct {
|
type device struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user