mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-09-11 01:55:43 +00:00
992ba235f7
- Added support for various remote control features in the Support Agent, including file transfer, in-session chat, remote audio, and control actions (lock/restart). - Introduced capability flags for incoming session features, allowing for more granular control over permissions. - Updated documentation to reflect the new Support Agent functionalities and connection resilience improvements, including fallback mechanisms for API endpoints. - Enhanced the build process with optional branding sealing and improved error handling for Docker configurations.
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
// Documents the Phase 4 identity contract: managed enrollment responses must
|
|
// not carry a device_token until the operator approves the device.
|
|
func TestManagedEnrollmentResponseOmitsDeviceToken(t *testing.T) {
|
|
resp := EnrollmentResponse{
|
|
Status: "pending",
|
|
DeviceID: "BD-TESTDEVICE0001",
|
|
Message: "Waiting for operator approval",
|
|
}
|
|
raw, err := json.Marshal(resp)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var decoded map[string]any
|
|
if err := json.Unmarshal(raw, &decoded); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, ok := decoded["device_token"]; ok {
|
|
t.Fatalf("pending managed enrollment must omit device_token, got %v", decoded["device_token"])
|
|
}
|
|
if decoded["status"] != "pending" {
|
|
t.Fatalf("status=%v", decoded["status"])
|
|
}
|
|
}
|
|
|
|
func TestApprovedEnrollmentResponseIncludesDeviceTokenField(t *testing.T) {
|
|
resp := EnrollmentResponse{
|
|
Status: "approved",
|
|
DeviceID: "BD-TESTDEVICE0001",
|
|
DeviceToken: "unique-per-device-token",
|
|
}
|
|
raw, err := json.Marshal(resp)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var decoded map[string]any
|
|
if err := json.Unmarshal(raw, &decoded); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if decoded["device_token"] != "unique-per-device-token" {
|
|
t.Fatalf("approved enrollment must include device_token, got %v", decoded["device_token"])
|
|
}
|
|
}
|