[client] Move the MDM precedence into ResolveUploadURL

Three of the four bundle paths ordered the destinations themselves, each with
its own copy of "MDM first, then what was asked for". Give the resolver the MDM
value as its first argument so the order lives in one place and a call site
cannot express a different one.

Pure refactor: the daemon passes "" for now, matching what it does today, and
the remote job and both mobile SDKs resolve exactly as before.
This commit is contained in:
riccardom
2026-09-25 13:34:17 +02:00
parent c3993bef73
commit b3ee6c9af2
6 changed files with 52 additions and 24 deletions
+18 -1
View File
@@ -14,12 +14,29 @@ func TestResolveUploadURL(t *testing.T) {
requestedURL = "https://requested.example.com/upload-url"
)
const mdmURL = "https://mdm.example.com/upload-url"
tests := []struct {
name string
mdm string
requested string
published string
want string
}{
{
// Pinning the destination on a managed device is pointless if the
// person at the keyboard can name another one.
name: "MDM outranks a URL the caller named",
mdm: mdmURL,
requested: requestedURL,
published: operatorURL,
want: mdmURL,
},
{
name: "MDM alone wins",
mdm: mdmURL,
want: mdmURL,
},
{
name: "requested wins over published",
requested: requestedURL,
@@ -47,7 +64,7 @@ func TestResolveUploadURL(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.want, ResolveUploadURL(tc.requested, tc.published))
assert.Equal(t, tc.want, ResolveUploadURL(tc.mdm, tc.requested, tc.published))
})
}
}