mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-28 15:29:09 +01:00
* [client] Mark Rosenpass flags as deprecated Rosenpass support is being deprecated. Users enabling it from the CLI should learn that before they depend on it, while the feature itself keeps working. * [client] Show Rosenpass deprecation notice in the UI settings Desktop users enable Rosenpass from the settings toggle, not the CLI, so the deprecation notice needs to reach them there too. A new string key falls back to English until Crowdin translates it, instead of showing a stale translation without the notice. * [client] Keep switchOrCreateProfile doc comment attached The Rosenpass warning helper landed between switchOrCreateProfile and its doc comment, leaving the function undocumented. * [client] Use MarkDeprecated for the Rosenpass flags Follows the convention already used for --enable-lazy-connection, as asked in review. The flags drop out of --help and pflag warns on any use, so the custom helper is no longer needed. * [client] Isolate the Rosenpass flag test from upCmd's flag set Setting the shared upCmd flags left them marked Changed for any later test in the package.
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/spf13/pflag"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestRosenpassFlagsWarnDeprecated(t *testing.T) {
|
|
origEnabled, origPermissive := rosenpassEnabled, rosenpassPermissive
|
|
t.Cleanup(func() {
|
|
rosenpassEnabled, rosenpassPermissive = origEnabled, origPermissive
|
|
})
|
|
|
|
for _, name := range []string{enableRosenpassFlag, rosenpassPermissiveFlag} {
|
|
// Copy the production flag into a private set so Set marks only the copy as
|
|
// Changed, leaving upCmd's shared flag set untouched for other tests.
|
|
prod := upCmd.PersistentFlags().Lookup(name)
|
|
require.NotNil(t, prod, "flag --%s must be registered on up", name)
|
|
flagCopy := *prod
|
|
|
|
var out bytes.Buffer
|
|
flags := pflag.NewFlagSet("rosenpass-test", pflag.ContinueOnError)
|
|
flags.SetOutput(&out)
|
|
flags.AddFlag(&flagCopy)
|
|
|
|
require.NoError(t, flags.Set(name, "true"))
|
|
assert.Contains(t, out.String(), "Flag --"+name+" has been deprecated", "setting --%s should print the deprecation notice", name)
|
|
assert.False(t, prod.Changed, "the shared --%s flag must stay unchanged", name)
|
|
}
|
|
}
|