mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-26 16:49:08 +02:00
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.
71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
package debug
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/netbirdio/netbird/upload-server/types"
|
|
)
|
|
|
|
func TestResolveUploadURL(t *testing.T) {
|
|
const (
|
|
operatorURL = "https://upload.example.com/upload-url"
|
|
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,
|
|
published: operatorURL,
|
|
want: requestedURL,
|
|
},
|
|
{
|
|
name: "requested wins with nothing published",
|
|
requested: requestedURL,
|
|
want: requestedURL,
|
|
},
|
|
{
|
|
name: "published used when nothing requested",
|
|
published: operatorURL,
|
|
want: operatorURL,
|
|
},
|
|
{
|
|
// The default stays the service NetBird runs whatever the
|
|
// deployment: an operator who wants the bundles elsewhere says so,
|
|
// and until then collecting one and sending it to support works.
|
|
name: "nothing configured falls back to the NetBird service",
|
|
want: types.DefaultBundleURL,
|
|
},
|
|
}
|
|
|
|
for _, tc := range tests {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
assert.Equal(t, tc.want, ResolveUploadURL(tc.mdm, tc.requested, tc.published))
|
|
})
|
|
}
|
|
}
|